diff --git a/apps/web-antd/src/views/dashboard/serverList/index.vue b/apps/web-antd/src/views/dashboard/serverList/index.vue index eb40f69..9800f8a 100644 --- a/apps/web-antd/src/views/dashboard/serverList/index.vue +++ b/apps/web-antd/src/views/dashboard/serverList/index.vue @@ -12,6 +12,7 @@ import { AccessControl } from '@vben/access'; import dayjs from 'dayjs'; import { $t } from '#/locales' const appId = ref(1); +const refreshCurrentAppLoading = ref(false); const [BaseForm, BaseFormApi] = useVbenForm({ // 所有表单项共用,可单独在表单内覆盖 commonConfig: { @@ -103,28 +104,63 @@ const appList = ref([]); const ServerList = ref([]); const reload = ref(false); const reloadReview = ref(false); + +async function syncCurrentAppInfo(selectedAppId?: number) { + const response = await getAppListApi(); + appList.value = Array.isArray(response) ? response : []; + const targetAppId = selectedAppId ?? appId.value ?? appList.value[0]?.AppId; + const app = appList.value.find((item) => item.AppId === targetAppId) ?? appList.value[0]; + if (!app) { + ServerList.value = []; + return; + } + + appId.value = app.AppId; + BaseFormApi.updateSchema([ + { + component: 'Select', + componentProps: { + options: appList.value.map((item) => ({ + label: $t('page.server.' + item.AppName), + value: item.AppId, + })), + }, + fieldName: 'fieldOptions', + }, + ]); + BaseFormApi.setFieldValue('fieldOptions', app.AppId); + BaseFormApi.setFieldValue( + 'update', + dayjs((app.Update ?? 0) * 1000).format('YYYY-MM-DD HH:mm:ss'), + ); + const serverResponse = await getServerListApi({ AppId: app.AppId }); + ServerList.value = Array.isArray(serverResponse) ? serverResponse : []; +} + +async function refreshCurrentAppInfo(showSuccess = true) { + refreshCurrentAppLoading.value = true; + try { + const value = await BaseFormApi.getValues(); + await syncCurrentAppInfo(value.fieldOptions); + if (showSuccess) { + notification.success({ + duration: 5, + message: '当前APP信息已刷新', + }); + } + } catch (error) { + notification.error({ + duration: 5, + message: '刷新当前APP信息失败', + }); + } finally { + refreshCurrentAppLoading.value = false; + } +} + onMounted(async () => { try { - const response = await getAppListApi(); - appList.value = Array.isArray(response) ? response : []; - const app = appList.value[0]; - if (!app) return; - const updateTime = dayjs((app.Update ?? 0) * 1000).format('YYYY-MM-DD HH:mm:ss') - BaseFormApi.setFieldValue("update", updateTime) - BaseFormApi.updateSchema([ - { - component: 'Select', - componentProps: { - options: appList.value.map((item) => ({ - label: $t('page.server.' + item.AppName), - value: item.AppId, - })), - }, - fieldName: 'fieldOptions', - }, - ]); - const serverResponse = await getServerListApi({ AppId: app.AppId }); - ServerList.value = Array.isArray(serverResponse) ? serverResponse : []; + await syncCurrentAppInfo(); // setInterval(async () => { // const serverResponse = await getServerListApi({ AppId: appId.value }); // ServerList.value = Array.isArray(serverResponse) ? serverResponse : []; @@ -181,12 +217,7 @@ async function update() { duration: 10, message: "服务器更新成功" }) - const response = await getAppListApi(); - appList.value = Array.isArray(response) ? response : []; - const app = appList.value.find((item) => item.AppId === Value.fieldOptions); - if (!app) return; - const updateTime = dayjs((app.Update ?? 0) * 1000).format('YYYY-MM-DD HH:mm:ss') - BaseFormApi.setFieldValue("update", updateTime) + await syncCurrentAppInfo(Value.fieldOptions); } catch (e) { reload.value = false; notification.error({ @@ -206,12 +237,7 @@ async function updateReview() { duration: 10, message: "服务器更新成功" }) - const response = await getAppListApi(); - appList.value = Array.isArray(response) ? response : []; - const app = appList.value.find((item) => item.AppId === Value.fieldOptions); - if (!app) return; - const updateTime = dayjs((app.Update ?? 0) * 1000).format('YYYY-MM-DD HH:mm:ss') - BaseFormApi.setFieldValue("update", updateTime) + await syncCurrentAppInfo(Value.fieldOptions); } catch (e) { reloadReview.value = false; notification.error({ @@ -231,6 +257,9 @@ async function updateReview() { + diff --git a/apps/web-antd/src/views/language/language.vue b/apps/web-antd/src/views/language/language.vue index f9f6c25..11cdabe 100644 --- a/apps/web-antd/src/views/language/language.vue +++ b/apps/web-antd/src/views/language/language.vue @@ -583,6 +583,19 @@ function characterLimitColor(row: languageType, columnName : string) {