feat: 新增系统设置帮助文档/官网设置

This commit is contained in:
TsMask
2023-11-23 15:04:46 +08:00
parent 12499e78ea
commit c1c6500df2
13 changed files with 493 additions and 55 deletions

View File

@@ -25,6 +25,10 @@ type AppStore = {
registerUser: boolean;
/**登录界面背景 */
loginBackground: string;
/**系统使用手册 */
helpDoc: string;
/**官方网址 */
officialUrl: string;
};
const useAppStore = defineStore('app', {
@@ -32,12 +36,14 @@ const useAppStore = defineStore('app', {
appName: import.meta.env.VITE_APP_NAME,
appCode: import.meta.env.VITE_APP_CODE,
appVersion: import.meta.env.VITE_APP_VERSION,
copyright: 'Copyright ©2023 For AGrandTech',
copyright: `Copyright ©2023 For ${import.meta.env.VITE_APP_NAME}`,
logoType: 'icon',
filePathIcon: '',
filePathBrand: '',
registerUser: false,
loginBackground: '',
helpDoc: '',
officialUrl: '',
}),
getters: {
/**
@@ -97,6 +103,25 @@ const useAppStore = defineStore('app', {
: import.meta.env.VITE_API_BASE_URL;
return `${baseUrl}${path}`;
},
/**
* 获取正确使用手册地址
* @param state 内部属性不用传入
* @returns 手册地址url
*/
getHelpDoc(state) {
const path = state.helpDoc;
if (!path || path === '#') {
return '#';
}
if (validHttp(path)) {
return path;
}
// 兼容旧前端可改配置文件
const baseUrl = import.meta.env.PROD
? sessionGet('baseUrl') || import.meta.env.VITE_API_BASE_URL
: import.meta.env.VITE_API_BASE_URL;
return `${baseUrl}${path}`;
},
},
actions: {
/**设置网页标题 */
@@ -125,26 +150,22 @@ const useAppStore = defineStore('app', {
async fnSysConf() {
const res = await getSysConf();
if (res.code === RESULT_CODE_SUCCESS && res.data) {
if (res.data.title) {
this.appName = res.data.title;
}
if (res.data.copyright) {
this.copyright = res.data.copyright;
}
this.appName = res.data.title;
this.copyright = res.data.copyright;
this.logoType = res.data.logoType;
this.filePathIcon = res.data.filePathIcon;
this.filePathBrand = res.data.filePathBrand;
if (res.data.logoType) {
this.logoType = res.data.logoType;
// 修改html内容-小图当作favicon.ico
// 修改html内容-小图当作favicon.ico
if (this.logoType) {
const iconDom = document.querySelector("link[rel~='icon']");
if (iconDom) {
iconDom.setAttribute('href', this.getLOGOIcon);
}
}
this.registerUser = res.data.registerUser === 'true';
if (res.data.loginBackground) {
this.loginBackground = res.data.loginBackground;
}
this.loginBackground = res.data.loginBackground;
this.helpDoc = res.data.helpDoc;
this.officialUrl = res.data.officialUrl;
}
return res;
},