fix: 1.bug#10597、10533; 2.系统基础配置优化

This commit is contained in:
JiangQiming 2023-03-20 14:57:19 +08:00
parent 430a8c7dc8
commit 30e98f69af
5 changed files with 76 additions and 46 deletions

View File

@ -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)

View File

@ -2,11 +2,18 @@ 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: () => ({
state: (): SystemStateType => ({
isCommunity: false,
configInfo: [] as any[]
// configInfo: [] as any[]
configInfo: {}
}),
actions: {
getSystemVersion(): Promise<any[]> {
@ -23,11 +30,14 @@ export const useSystem = defineStore('system', {
}
})
},
getSystemConfig() {
async getSystemConfig() {
const params = ['front', 'amap', 'paths'];
getDetails_api(params).then(({ status, result }: any) => {
this.configInfo = status === 200 ? [...result] : [];
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 }
})
}
}
}
})

View File

@ -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)}`;

View File

@ -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: () => {

View File

@ -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;
}