fix: 1.bug#10597、10533; 2.系统基础配置优化
This commit is contained in:
parent
430a8c7dc8
commit
30e98f69af
|
@ -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<any>(`/system/config/scopes`, data)
|
||||
|
|
|
@ -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<ConfigInfoType>;
|
||||
}
|
||||
|
||||
export const useSystem = defineStore('system', {
|
||||
state: () => ({
|
||||
isCommunity: false,
|
||||
configInfo: [] as any[]
|
||||
}),
|
||||
actions: {
|
||||
getSystemVersion(): Promise<any[]> {
|
||||
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<any[]> {
|
||||
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] : [];
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
|
@ -74,12 +74,13 @@ watch(
|
|||
/**
|
||||
* 推送
|
||||
*/
|
||||
const successCount = ref(0);
|
||||
const failCount = ref(0);
|
||||
const flag = ref(false);
|
||||
const successCount = ref<number>(0);
|
||||
const failCount = ref<number>(0);
|
||||
const flag = ref<boolean>(false);
|
||||
const errMessage = ref<any[]>([]);
|
||||
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)}`;
|
||||
|
|
|
@ -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<formType>({
|
|||
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: () => {
|
||||
|
|
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue