fix: version 页改 antd a-table + 初始服务端探测(发布=注册到服务端)
This commit is contained in:
@@ -2,16 +2,15 @@
|
|||||||
/**
|
/**
|
||||||
* 模板版本发布(issue #183 [E2]):发布 = 注册新版本到服务端注册表;
|
* 模板版本发布(issue #183 [E2]):发布 = 注册新版本到服务端注册表;
|
||||||
* 注册表离线时降级本地记录并标注。
|
* 注册表离线时降级本地记录并标注。
|
||||||
|
* 表格:antd a-table(响应式直绑,规避 vxe-grid proxy 时序)。
|
||||||
*/
|
*/
|
||||||
import { ref } from 'vue';
|
import { onMounted, ref } from 'vue';
|
||||||
|
|
||||||
import { Page, VbenButton } from '@vben/common-ui';
|
import { Page, VbenButton } from '@vben/common-ui';
|
||||||
import { MaterialSymbolsAdd } from '@vben/icons';
|
import { MaterialSymbolsAdd } from '@vben/icons';
|
||||||
import { message } from 'antdv-next';
|
import { message } from 'antdv-next';
|
||||||
|
|
||||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
import { fetchRegistryModels, registerModel } from '#/api/iaop/registry';
|
||||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
|
||||||
import { registerModel } from '#/api/iaop/registry';
|
|
||||||
|
|
||||||
interface VersionRow {
|
interface VersionRow {
|
||||||
version: string;
|
version: string;
|
||||||
@@ -28,37 +27,31 @@ const rows = ref<VersionRow[]>([
|
|||||||
{ version: 'v0.8.0', stage: 'dev', time: '2026-08-03 09:00', author: 'bot_dev1', note: '布局资产初版' },
|
{ version: 'v0.8.0', stage: 'dev', time: '2026-08-03 09:00', author: 'bot_dev1', note: '布局资产初版' },
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const gridOptions: VxeTableGridOptions = {
|
const columns = [
|
||||||
rowConfig: { keyField: 'version' },
|
{ title: '版本', dataIndex: 'version', key: 'version', width: 120 },
|
||||||
height: 'auto',
|
{ title: '阶段', dataIndex: 'stage', key: 'stage', width: 110 },
|
||||||
stripe: true,
|
{ title: '时间', dataIndex: 'time', key: 'time', width: 180 },
|
||||||
columns: [
|
{ title: '作者', dataIndex: 'author', key: 'author', width: 120 },
|
||||||
{ title: '版本', field: 'version', width: 110 },
|
{ title: '说明', dataIndex: 'note', key: 'note' },
|
||||||
{ title: '阶段', field: 'stage', width: 100, slots: { default: 'stage' } },
|
];
|
||||||
{ title: '时间', field: 'time', width: 170 },
|
|
||||||
{ title: '作者', field: 'author', width: 110 },
|
|
||||||
{ title: '说明', field: 'note', minWidth: 200 },
|
|
||||||
],
|
|
||||||
proxy: {
|
|
||||||
query: async ({ page } = {}) => {
|
|
||||||
// page 可能缺省(分页未就绪的首次查询),兜底返回全量
|
|
||||||
const cur = page?.currentPage ?? 1;
|
|
||||||
const size = page?.pageSize ?? (rows.value.length || 10);
|
|
||||||
return {
|
|
||||||
items: rows.value.slice((cur - 1) * size, cur * size),
|
|
||||||
total: rows.value.length,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const [Grid, gridApi] = useVbenVxeGrid({ gridOptions });
|
const tagColor = (stage: string) =>
|
||||||
|
stage === 'prod' ? 'green' : stage === 'staging' ? 'orange' : 'blue';
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
// 初始探测服务端在线状态(注册表可达 → 在线)
|
||||||
|
try {
|
||||||
|
await fetchRegistryModels();
|
||||||
|
online.value = true;
|
||||||
|
} catch {
|
||||||
|
online.value = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
async function publish() {
|
async function publish() {
|
||||||
const version = `v${Date.now() % 100000}`;
|
const version = `v${Date.now() % 100000}`;
|
||||||
const name = 'iaop-template';
|
const name = 'iaop-template';
|
||||||
try {
|
try {
|
||||||
// 发布 = 注册新版本到服务端注册表(staging)
|
|
||||||
await registerModel({ name, version, stage: 'staging', description: '手动发布(前端)' });
|
await registerModel({ name, version, stage: 'staging', description: '手动发布(前端)' });
|
||||||
online.value = true;
|
online.value = true;
|
||||||
rows.value.unshift({
|
rows.value.unshift({
|
||||||
@@ -76,7 +69,6 @@ async function publish() {
|
|||||||
});
|
});
|
||||||
message.warning('注册表服务不可达:本次发布仅本地记录');
|
message.warning('注册表服务不可达:本次发布仅本地记录');
|
||||||
}
|
}
|
||||||
gridApi.query();
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -85,10 +77,12 @@ async function publish() {
|
|||||||
<template #extra>
|
<template #extra>
|
||||||
<VbenButton variant="solid" @click="publish"><MaterialSymbolsAdd class="size-4" />发布新版本</VbenButton>
|
<VbenButton variant="solid" @click="publish"><MaterialSymbolsAdd class="size-4" />发布新版本</VbenButton>
|
||||||
</template>
|
</template>
|
||||||
<Grid>
|
<a-table :data-source="rows" :columns="columns" row-key="version" size="small" :pagination="false">
|
||||||
<template #stage="{ row }">
|
<template #bodyCell="{ column, record }">
|
||||||
<a-tag :color="row.stage === 'prod' ? 'green' : row.stage === 'staging' ? 'orange' : 'blue'">{{ row.stage }}</a-tag>
|
<template v-if="column.key === 'stage'">
|
||||||
|
<a-tag :color="tagColor(record.stage)">{{ record.stage }}</a-tag>
|
||||||
</template>
|
</template>
|
||||||
</Grid>
|
</template>
|
||||||
|
</a-table>
|
||||||
</Page>
|
</Page>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user