diff --git a/src/api/system/basis.ts b/src/api/system/basis.ts index 711a0bcd..ea3677ec 100644 --- a/src/api/system/basis.ts +++ b/src/api/system/basis.ts @@ -3,4 +3,4 @@ import server from '@/utils/request'; // 保存 export const save_api = (data: any) => server.post(`/system/config/scope/_save`, data) // 获取详情 -export const getDetails_api = (data: any) => server.post(`/system/config/scopes`, data) +export const getDetails_api = (data: any) => server.post(`/system/config/scopes`, data) diff --git a/src/store/system.ts b/src/store/system.ts index 4f3e63f7..5b6cf512 100644 --- a/src/store/system.ts +++ b/src/store/system.ts @@ -2,32 +2,42 @@ import { defineStore } from 'pinia'; import { systemVersion } from '@/api/comm' import { useMenuStore } from './menu' import { getDetails_api } from '@/api/system/basis'; +import type { ConfigInfoType } from '@/views/system/Basis/typing'; + +type SystemStateType = { + isCommunity: boolean; + configInfo: Partial; +} export const useSystem = defineStore('system', { - state: () => ({ - isCommunity: false, - configInfo: [] as any[] - }), - actions: { - getSystemVersion(): Promise { - this.getSystemConfig(); - return new Promise(async (res, rej) => { - const resp = await systemVersion() - if (resp.success && resp.result) { - const isCommunity = resp.result.edition === 'community' - this.isCommunity = isCommunity - // 获取菜单 - const menu = useMenuStore() - const menuData: any[] = await menu.queryMenuTree(isCommunity) - res(menuData) + state: (): SystemStateType => ({ + isCommunity: false, + // configInfo: [] as any[] + configInfo: {} + }), + actions: { + getSystemVersion(): Promise { + this.getSystemConfig(); + return new Promise(async (res, rej) => { + const resp = await systemVersion() + if (resp.success && resp.result) { + const isCommunity = resp.result.edition === 'community' + this.isCommunity = isCommunity + // 获取菜单 + const menu = useMenuStore() + const menuData: any[] = await menu.queryMenuTree(isCommunity) + res(menuData) + } + }) + }, + async getSystemConfig() { + const params = ['front', 'amap', 'paths']; + const { status, result } = await getDetails_api(params); + if (status === 200) { + params.forEach((key: string) => { + this.configInfo[key] = { ...result.find((item: any) => item.scope === key)?.properties } + }) + } } - }) - }, - getSystemConfig() { - const params = ['front', 'amap', 'paths']; - getDetails_api(params).then(({ status, result }: any) => { - this.configInfo = status === 200 ? [...result] : []; - }) } - } }) \ No newline at end of file diff --git a/src/views/media/Cascade/Publish/index.vue b/src/views/media/Cascade/Publish/index.vue index 92d3c4e4..ff579a0c 100644 --- a/src/views/media/Cascade/Publish/index.vue +++ b/src/views/media/Cascade/Publish/index.vue @@ -74,12 +74,13 @@ watch( /** * 推送 */ -const successCount = ref(0); -const failCount = ref(0); -const flag = ref(false); +const successCount = ref(0); +const failCount = ref(0); +const flag = ref(false); const errMessage = ref([]); const errStr = computed(() => JSON.stringify(errMessage.value)); const publish = () => { + successCount.value = 0; const activeAPI = `${BASE_API_PATH}/media/gb28181-cascade/${ props.data.id }/bindings/publish?:X_Access_Token=${LocalStore.get(TOKEN_KEY)}`; diff --git a/src/views/system/Basis/index.vue b/src/views/system/Basis/index.vue index 590f7498..d1f8be37 100644 --- a/src/views/system/Basis/index.vue +++ b/src/views/system/Basis/index.vue @@ -293,6 +293,7 @@ import { LocalStore } from '@/utils/comm'; import { save_api } from '@/api/system/basis'; import { usePermissionStore } from '@/store/permission'; import { useSystem } from '@/store/system'; +import { settingDetail } from '@/api/login'; const action = `${BASE_API_PATH}/file/static`; const headers = { [TOKEN_KEY]: LocalStore.get(TOKEN_KEY) }; @@ -337,18 +338,19 @@ const form = reactive({ backLoading: false, // 背景图加载状态 iconLoading: false, // 页签加载状态 saveLoading: false, - getDetails: () => { - const configInfo = useSystem().$state.configInfo; - const basis = configInfo.find((item: any) => item.scope === 'front'); - const api = configInfo.find((item: any) => item.scope === 'amap'); - const basePath = configInfo.find((item: any) => item.scope === 'paths'); + getDetails: async () => { + const system = useSystem(); + await system.getSystemConfig(); + await settingDetail('front'); + const configInfo = system.$state.configInfo; form.formValue = { - ...basis.properties, - apiKey: api.properties.apiKey, - 'base-path': basePath.properties['base-path'], - logo: basis.properties.logo || '/public/logo.png', - ico: basis.properties.ico || '/public/favicon.ico', - backgroud: basis.properties.backgroud || '/public/images/login.png', + title: configInfo.front?.title, + headerTheme: configInfo.front?.headerTheme, + logo: configInfo.front?.logo || '/public/logo.png', + ico: configInfo.front?.ico || '/public/favicon.ico', + backgroud: configInfo.front?.backgroud || '/public/images/login.png', + apiKey: configInfo.amap?.apiKey, + "base-path": configInfo.paths?.['base-path'] }; }, clickSave: () => { diff --git a/src/views/system/Basis/typing.d.ts b/src/views/system/Basis/typing.d.ts index 1cfadcea..0c3a7644 100644 --- a/src/views/system/Basis/typing.d.ts +++ b/src/views/system/Basis/typing.d.ts @@ -2,13 +2,13 @@ import type { Rule } from 'ant-design-vue/es/form'; /**基本信息表单 */ export interface formValueType { - title: string; // 系统名称 - headerTheme: string; // 主题色 - apiKey: string; // 高德 API key - 'base-path': string; // 系统后台访问的URL - logo:string, - ico:string, - backgroud:string + title: string | undefined; // 系统名称 + headerTheme: string | undefined; // 主题色 + apiKey: string | undefined; // 高德 API key + 'base-path': string | undefined; // 系统后台访问的URL + logo: string | undefined; + ico: string | undefined; + backgroud: string | undefined; } export interface formType { @@ -35,3 +35,20 @@ export interface uploaderType { beforeIconUpload: (file: UploadProps['beforeUpload']) => void changeIconUpload: (info: UploadChangeParam) => void } + +export type PathType = { + 'base-path': string; + 'sso-bind': string; + 'sso-redirect': string; + 'sso-token-set': string; +} + +export type AMapKey = { + apiKey: string; +} + +export type ConfigInfoType = { + paths: PathType; + amap: AMapKey; + front: formValueType; +} \ No newline at end of file