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 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 { systemVersion } from '@/api/comm'
|
||||||
import { useMenuStore } from './menu'
|
import { useMenuStore } from './menu'
|
||||||
import { getDetails_api } from '@/api/system/basis';
|
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', {
|
export const useSystem = defineStore('system', {
|
||||||
state: () => ({
|
state: (): SystemStateType => ({
|
||||||
isCommunity: false,
|
isCommunity: false,
|
||||||
configInfo: [] as any[]
|
// configInfo: [] as any[]
|
||||||
}),
|
configInfo: {}
|
||||||
actions: {
|
}),
|
||||||
getSystemVersion(): Promise<any[]> {
|
actions: {
|
||||||
this.getSystemConfig();
|
getSystemVersion(): Promise<any[]> {
|
||||||
return new Promise(async (res, rej) => {
|
this.getSystemConfig();
|
||||||
const resp = await systemVersion()
|
return new Promise(async (res, rej) => {
|
||||||
if (resp.success && resp.result) {
|
const resp = await systemVersion()
|
||||||
const isCommunity = resp.result.edition === 'community'
|
if (resp.success && resp.result) {
|
||||||
this.isCommunity = isCommunity
|
const isCommunity = resp.result.edition === 'community'
|
||||||
// 获取菜单
|
this.isCommunity = isCommunity
|
||||||
const menu = useMenuStore()
|
// 获取菜单
|
||||||
const menuData: any[] = await menu.queryMenuTree(isCommunity)
|
const menu = useMenuStore()
|
||||||
res(menuData)
|
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 successCount = ref<number>(0);
|
||||||
const failCount = ref(0);
|
const failCount = ref<number>(0);
|
||||||
const flag = ref(false);
|
const flag = ref<boolean>(false);
|
||||||
const errMessage = ref<any[]>([]);
|
const errMessage = ref<any[]>([]);
|
||||||
const errStr = computed(() => JSON.stringify(errMessage.value));
|
const errStr = computed(() => JSON.stringify(errMessage.value));
|
||||||
const publish = () => {
|
const publish = () => {
|
||||||
|
successCount.value = 0;
|
||||||
const activeAPI = `${BASE_API_PATH}/media/gb28181-cascade/${
|
const activeAPI = `${BASE_API_PATH}/media/gb28181-cascade/${
|
||||||
props.data.id
|
props.data.id
|
||||||
}/bindings/publish?:X_Access_Token=${LocalStore.get(TOKEN_KEY)}`;
|
}/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 { save_api } from '@/api/system/basis';
|
||||||
import { usePermissionStore } from '@/store/permission';
|
import { usePermissionStore } from '@/store/permission';
|
||||||
import { useSystem } from '@/store/system';
|
import { useSystem } from '@/store/system';
|
||||||
|
import { settingDetail } from '@/api/login';
|
||||||
|
|
||||||
const action = `${BASE_API_PATH}/file/static`;
|
const action = `${BASE_API_PATH}/file/static`;
|
||||||
const headers = { [TOKEN_KEY]: LocalStore.get(TOKEN_KEY) };
|
const headers = { [TOKEN_KEY]: LocalStore.get(TOKEN_KEY) };
|
||||||
|
@ -337,18 +338,19 @@ const form = reactive<formType>({
|
||||||
backLoading: false, // 背景图加载状态
|
backLoading: false, // 背景图加载状态
|
||||||
iconLoading: false, // 页签加载状态
|
iconLoading: false, // 页签加载状态
|
||||||
saveLoading: false,
|
saveLoading: false,
|
||||||
getDetails: () => {
|
getDetails: async () => {
|
||||||
const configInfo = useSystem().$state.configInfo;
|
const system = useSystem();
|
||||||
const basis = configInfo.find((item: any) => item.scope === 'front');
|
await system.getSystemConfig();
|
||||||
const api = configInfo.find((item: any) => item.scope === 'amap');
|
await settingDetail('front');
|
||||||
const basePath = configInfo.find((item: any) => item.scope === 'paths');
|
const configInfo = system.$state.configInfo;
|
||||||
form.formValue = {
|
form.formValue = {
|
||||||
...basis.properties,
|
title: configInfo.front?.title,
|
||||||
apiKey: api.properties.apiKey,
|
headerTheme: configInfo.front?.headerTheme,
|
||||||
'base-path': basePath.properties['base-path'],
|
logo: configInfo.front?.logo || '/public/logo.png',
|
||||||
logo: basis.properties.logo || '/public/logo.png',
|
ico: configInfo.front?.ico || '/public/favicon.ico',
|
||||||
ico: basis.properties.ico || '/public/favicon.ico',
|
backgroud: configInfo.front?.backgroud || '/public/images/login.png',
|
||||||
backgroud: basis.properties.backgroud || '/public/images/login.png',
|
apiKey: configInfo.amap?.apiKey,
|
||||||
|
"base-path": configInfo.paths?.['base-path']
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
clickSave: () => {
|
clickSave: () => {
|
||||||
|
|
|
@ -2,13 +2,13 @@ import type { Rule } from 'ant-design-vue/es/form';
|
||||||
|
|
||||||
/**基本信息表单 */
|
/**基本信息表单 */
|
||||||
export interface formValueType {
|
export interface formValueType {
|
||||||
title: string; // 系统名称
|
title: string | undefined; // 系统名称
|
||||||
headerTheme: string; // 主题色
|
headerTheme: string | undefined; // 主题色
|
||||||
apiKey: string; // 高德 API key
|
apiKey: string | undefined; // 高德 API key
|
||||||
'base-path': string; // 系统后台访问的URL
|
'base-path': string | undefined; // 系统后台访问的URL
|
||||||
logo:string,
|
logo: string | undefined;
|
||||||
ico:string,
|
ico: string | undefined;
|
||||||
backgroud:string
|
backgroud: string | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface formType {
|
export interface formType {
|
||||||
|
@ -35,3 +35,20 @@ export interface uploaderType {
|
||||||
beforeIconUpload: (file: UploadProps['beforeUpload']) => void
|
beforeIconUpload: (file: UploadProps['beforeUpload']) => void
|
||||||
changeIconUpload: (info: UploadChangeParam) => 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