smart-admin/smart-app/src/store/modules/system/app-config.js

56 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* 项目的配置信息
*
* @Author: 1024创新实验室-主任:卓大
* @Date: 2022-09-06 20:53:47
* @Wechat: zhuda1024
* @Email: lab1024@163.com
* @Copyright 1024创新实验室 https://1024lab.net Since 2012
*/
import { defineStore } from 'pinia';
import { appDefaultConfig } from '@/config/app-config';
import localStorageKeyConst from '@/constants/local-storage-key-const';
import { smartSentry } from '@/lib/smart-sentry';
import { localRead } from '@/utils/local-util';
let state = { ...appDefaultConfig };
let appConfigStr = localRead(localStorageKeyConst.APP_CONFIG);
let language = appDefaultConfig.language;
if (appConfigStr) {
try {
state = JSON.parse(appConfigStr);
language = state.language;
} catch (e) {
smartSentry.captureError(e);
}
}
/**
* 获取初始化的语言
*/
export const getInitializedLanguage = function () {
return language;
};
export const useAppConfigStore = defineStore({
id: 'appConfig',
state: () => ({
// 读取config下的默认配置
...state,
}),
actions: {
reset() {
for (const k in appDefaultConfig) {
this[k] = appDefaultConfig[k];
}
},
showHelpDoc() {
this.helpDocFlag = true;
},
hideHelpDoc() {
this.helpDocFlag = false;
},
},
});