mirror of
https://github.com/certd/certd.git
synced 2026-05-15 04:27:31 +08:00
feat: 升级前端框架,适配手机端
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { Modal, notification, theme } from "ant-design-vue";
|
||||
import { Modal, notification } from "ant-design-vue";
|
||||
import * as _ from "lodash-es";
|
||||
// @ts-ignore
|
||||
import { LocalStorage } from "/src/utils/util.storage";
|
||||
@@ -9,20 +9,9 @@ import { HeaderMenus, PlusInfo, SiteEnv, SiteInfo, SuiteSetting, SysInstallInfo,
|
||||
import { useUserStore } from "/@/store/modules/user";
|
||||
import { mitter } from "/@/utils/util.mitt";
|
||||
import { env } from "/@/utils/util.env";
|
||||
import { preferences } from "/@/vben/preferences";
|
||||
|
||||
export type ThemeToken = {
|
||||
token: {
|
||||
colorPrimary?: string;
|
||||
};
|
||||
algorithm: any;
|
||||
};
|
||||
export type ThemeConfig = {
|
||||
colorPrimary: string;
|
||||
mode: string;
|
||||
};
|
||||
export interface SettingState {
|
||||
themeConfig?: ThemeConfig;
|
||||
themeToken: ThemeToken;
|
||||
sysPublic?: SysPublicSetting;
|
||||
installInfo?: {
|
||||
siteId: string;
|
||||
@@ -40,11 +29,6 @@ export interface SettingState {
|
||||
suiteSetting?: SuiteSetting;
|
||||
}
|
||||
|
||||
const defaultThemeConfig = {
|
||||
colorPrimary: "#1890ff",
|
||||
mode: "light"
|
||||
};
|
||||
const SETTING_THEME_KEY = "SETTING_THEME";
|
||||
const defaultSiteInfo: SiteInfo = {
|
||||
title: env.TITLE || "Certd",
|
||||
slogan: env.SLOGAN || "让你的证书永不过期",
|
||||
@@ -56,11 +40,6 @@ const defaultSiteInfo: SiteInfo = {
|
||||
export const useSettingStore = defineStore({
|
||||
id: "app.setting",
|
||||
state: (): SettingState => ({
|
||||
themeConfig: null,
|
||||
themeToken: {
|
||||
token: {},
|
||||
algorithm: theme.defaultAlgorithm
|
||||
},
|
||||
plusInfo: {
|
||||
isPlus: false,
|
||||
vipType: "free",
|
||||
@@ -93,9 +72,6 @@ export const useSettingStore = defineStore({
|
||||
inited: false
|
||||
}),
|
||||
getters: {
|
||||
getThemeConfig(): any {
|
||||
return this.themeConfig || _.merge({}, defaultThemeConfig, LocalStorage.get(SETTING_THEME_KEY) || {});
|
||||
},
|
||||
getSysPublic(): SysPublicSetting {
|
||||
return this.sysPublic;
|
||||
},
|
||||
@@ -162,6 +138,10 @@ export const useSettingStore = defineStore({
|
||||
}
|
||||
}
|
||||
this.siteInfo = _.merge({}, defaultSiteInfo, siteInfo);
|
||||
|
||||
if (this.siteInfo.logo) {
|
||||
preferences.logo.source = this.siteInfo.logo;
|
||||
}
|
||||
},
|
||||
async checkUrlBound() {
|
||||
const userStore = useUserStore();
|
||||
@@ -207,44 +187,7 @@ export const useSettingStore = defineStore({
|
||||
}
|
||||
}
|
||||
},
|
||||
persistThemeConfig() {
|
||||
LocalStorage.set(SETTING_THEME_KEY, this.getThemeConfig);
|
||||
},
|
||||
async setThemeConfig(themeConfig?: ThemeConfig) {
|
||||
this.themeConfig = _.merge({}, this.themeConfig, themeConfig);
|
||||
|
||||
this.persistThemeConfig();
|
||||
this.setPrimaryColor(this.themeConfig.colorPrimary);
|
||||
this.setDarkMode(this.themeConfig.mode);
|
||||
},
|
||||
setPrimaryColor(color: any) {
|
||||
this.themeConfig.colorPrimary = color;
|
||||
_.set(this.themeToken, "token.colorPrimary", color);
|
||||
this.persistThemeConfig();
|
||||
},
|
||||
setDarkMode(mode: string) {
|
||||
this.themeConfig.mode = mode;
|
||||
if (mode === "dark") {
|
||||
this.themeToken.algorithm = theme.darkAlgorithm;
|
||||
// const defaultSeed = theme.defaultSeed;
|
||||
// const mapToken = theme.darkAlgorithm(defaultSeed);
|
||||
// less.modifyVars(mapToken);
|
||||
// less.modifyVars({
|
||||
// "@colorPrimaryBg": "#111a2c",
|
||||
// colorPrimaryBg: "#111a2c"
|
||||
// });
|
||||
// less.refreshStyles();
|
||||
} else {
|
||||
this.themeToken.algorithm = theme.defaultAlgorithm;
|
||||
|
||||
// const defaultSeed = theme.defaultSeed;
|
||||
// const mapToken = theme.defaultAlgorithm(defaultSeed);
|
||||
// less.modifyVars(mapToken);
|
||||
}
|
||||
this.persistThemeConfig();
|
||||
},
|
||||
async init() {
|
||||
await this.setThemeConfig(this.getThemeConfig);
|
||||
await this.loadSysSettings();
|
||||
},
|
||||
async initOnce() {
|
||||
|
||||
Reference in New Issue
Block a user