mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-06-06 00:18:51 +08:00
feat: 抽离默认配置选项
This commit is contained in:
parent
13749c784d
commit
fc5cec54b0
@ -1,16 +1,15 @@
|
||||
{
|
||||
"version": "1.0.0",
|
||||
"keepAlive": true,
|
||||
"Version": "2.0.0",
|
||||
"KeepAlive": true,
|
||||
"Locale": "zh",
|
||||
"Layout": "vertical-dark",
|
||||
"MapConfigure": {
|
||||
"amapKey": "97b3248d1553172e81f168cf94ea667e",
|
||||
"baiduKey": "wTHbkkEweiFqZLKunMIjcrb2RcqNXkhc",
|
||||
"options": {
|
||||
"resizeEnable": true,
|
||||
"center": [
|
||||
113.6401,
|
||||
34.72468
|
||||
],
|
||||
"center": [113.6401, 34.72468],
|
||||
"zoom": 12
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ import { ref, unref, computed, getCurrentInstance } from "vue";
|
||||
import { useSettingStoreHook } from "/@/store/modules/settings";
|
||||
|
||||
const keepAlive: Boolean = ref(
|
||||
getCurrentInstance().appContext.config.globalProperties.$config?.keepAlive
|
||||
getCurrentInstance().appContext.config.globalProperties.$config?.KeepAlive
|
||||
);
|
||||
|
||||
const getCachedPageList = computed((): string[] => {
|
||||
|
40
src/main.ts
40
src/main.ts
@ -6,6 +6,7 @@ import { createApp, Directive } from "vue";
|
||||
import { usI18n } from "../src/plugins/i18n";
|
||||
import { useTable } from "../src/plugins/vxe-table";
|
||||
import { useElementPlus } from "../src/plugins/element-plus";
|
||||
import { injectResponsiveStorage } from "/@/utils/storage/responsive";
|
||||
|
||||
import "animate.css";
|
||||
// 导入公共样式
|
||||
@ -17,49 +18,14 @@ import "v-contextmenu/dist/themes/default.css";
|
||||
|
||||
const app = createApp(App);
|
||||
|
||||
// 响应式storage
|
||||
import Storage from "responsive-storage";
|
||||
// @ts-ignore
|
||||
app.use(Storage, {
|
||||
// 默认显示首页tag
|
||||
routesInStorage: {
|
||||
type: Array,
|
||||
default: Storage.getData(undefined, "routesInStorage") ?? [
|
||||
{
|
||||
path: "/welcome",
|
||||
parentPath: "/",
|
||||
meta: {
|
||||
title: "message.hshome",
|
||||
icon: "el-icon-s-home",
|
||||
showLink: true,
|
||||
savedPosition: false
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
// 国际化 默认中文zh
|
||||
locale: {
|
||||
type: Object,
|
||||
default: Storage.getData(undefined, "locale") ?? {
|
||||
locale: "zh"
|
||||
}
|
||||
},
|
||||
// layout模式以及主题
|
||||
layout: {
|
||||
type: Object,
|
||||
default: Storage.getData(undefined, "layout") ?? {
|
||||
layout: "vertical-dark"
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 自定义指令
|
||||
import * as directives from "/@/directives";
|
||||
Object.keys(directives).forEach(key => {
|
||||
app.directive(key, (directives as { [key: string]: Directive })[key]);
|
||||
});
|
||||
|
||||
getServerConfig(app).then(async () => {
|
||||
getServerConfig(app).then(async config => {
|
||||
injectResponsiveStorage(app, config);
|
||||
setupStore(app);
|
||||
app.use(router).use(useElementPlus).use(useTable).use(usI18n);
|
||||
await router.isReady();
|
||||
|
38
src/utils/storage/responsive.ts
Normal file
38
src/utils/storage/responsive.ts
Normal file
@ -0,0 +1,38 @@
|
||||
// 响应式storage
|
||||
import { App } from "vue";
|
||||
import Storage from "responsive-storage";
|
||||
|
||||
export const injectResponsiveStorage = (app: App, config: ServerConfigs) => {
|
||||
app.use(Storage, {
|
||||
// 默认显示首页tag
|
||||
routesInStorage: {
|
||||
type: Array,
|
||||
default: Storage.getData(undefined, "routesInStorage") ?? [
|
||||
{
|
||||
path: "/welcome",
|
||||
parentPath: "/",
|
||||
meta: {
|
||||
title: "message.hshome",
|
||||
icon: "el-icon-s-home",
|
||||
showLink: true,
|
||||
savedPosition: false
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
// 国际化 默认中文zh
|
||||
locale: {
|
||||
type: Object,
|
||||
default: Storage.getData(undefined, "locale") ?? {
|
||||
locale: config.Locale
|
||||
}
|
||||
},
|
||||
// layout模式以及主题
|
||||
layout: {
|
||||
type: Object,
|
||||
default: Storage.getData(undefined, "layout") ?? {
|
||||
layout: config.Layout
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
8
types/global.d.ts
vendored
8
types/global.d.ts
vendored
@ -82,6 +82,14 @@ declare global {
|
||||
VITE_GENERATE_UI: string;
|
||||
}
|
||||
|
||||
declare interface ServerConfigs {
|
||||
Version?: string;
|
||||
KeepAlive?: boolean;
|
||||
Locale?: string;
|
||||
Layout?: string;
|
||||
MapConfigure?: any;
|
||||
}
|
||||
|
||||
function parseInt(s: string | number, radix?: number): number;
|
||||
|
||||
function parseFloat(string: string | number): number;
|
||||
|
Loading…
x
Reference in New Issue
Block a user