@ditari/store 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/cjs/index.cjs +20 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.ts +12 -0
- package/dist/cjs/modules/Breadcrumb.cjs +22 -0
- package/dist/cjs/modules/Breadcrumb.cjs.map +1 -0
- package/dist/cjs/modules/Breadcrumb.d.ts +10 -0
- package/dist/cjs/modules/DataDictionary.cjs +50 -0
- package/dist/cjs/modules/DataDictionary.cjs.map +1 -0
- package/dist/cjs/modules/DataDictionary.d.ts +28 -0
- package/dist/cjs/modules/Fuck.d.ts +1 -0
- package/dist/cjs/modules/KeepAlive.cjs +47 -0
- package/dist/cjs/modules/KeepAlive.cjs.map +1 -0
- package/dist/cjs/modules/KeepAlive.d.ts +21 -0
- package/dist/cjs/modules/Menu.cjs +31 -0
- package/dist/cjs/modules/Menu.cjs.map +1 -0
- package/dist/cjs/modules/Menu.d.ts +17 -0
- package/dist/cjs/modules/NavTab.cjs +91 -0
- package/dist/cjs/modules/NavTab.cjs.map +1 -0
- package/dist/cjs/modules/NavTab.d.ts +64 -0
- package/dist/cjs/modules/Settings.cjs +115 -0
- package/dist/cjs/modules/Settings.cjs.map +1 -0
- package/dist/cjs/modules/Settings.d.ts +43 -0
- package/dist/cjs/modules/User.cjs +31 -0
- package/dist/cjs/modules/User.cjs.map +1 -0
- package/dist/cjs/modules/User.d.ts +21 -0
- package/dist/cjs/types.cjs +19 -0
- package/dist/cjs/types.cjs.map +1 -0
- package/dist/cjs/types.d.ts +7 -0
- package/dist/esm/index.d.ts +12 -0
- package/dist/esm/index.mjs +8 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/modules/Breadcrumb.d.ts +10 -0
- package/dist/esm/modules/Breadcrumb.mjs +20 -0
- package/dist/esm/modules/Breadcrumb.mjs.map +1 -0
- package/dist/esm/modules/DataDictionary.d.ts +28 -0
- package/dist/esm/modules/DataDictionary.mjs +48 -0
- package/dist/esm/modules/DataDictionary.mjs.map +1 -0
- package/dist/esm/modules/Fuck.d.ts +1 -0
- package/dist/esm/modules/KeepAlive.d.ts +21 -0
- package/dist/esm/modules/KeepAlive.mjs +45 -0
- package/dist/esm/modules/KeepAlive.mjs.map +1 -0
- package/dist/esm/modules/Menu.d.ts +17 -0
- package/dist/esm/modules/Menu.mjs +29 -0
- package/dist/esm/modules/Menu.mjs.map +1 -0
- package/dist/esm/modules/NavTab.d.ts +64 -0
- package/dist/esm/modules/NavTab.mjs +89 -0
- package/dist/esm/modules/NavTab.mjs.map +1 -0
- package/dist/esm/modules/Settings.d.ts +43 -0
- package/dist/esm/modules/Settings.mjs +113 -0
- package/dist/esm/modules/Settings.mjs.map +1 -0
- package/dist/esm/modules/User.d.ts +21 -0
- package/dist/esm/modules/User.mjs +29 -0
- package/dist/esm/modules/User.mjs.map +1 -0
- package/dist/esm/types.d.ts +7 -0
- package/dist/esm/types.mjs +11 -0
- package/dist/esm/types.mjs.map +1 -0
- package/package.json +36 -0
- package/src/index.ts +12 -0
- package/src/modules/Breadcrumb.ts +25 -0
- package/src/modules/DataDictionary.ts +55 -0
- package/src/modules/KeepAlive.ts +47 -0
- package/src/modules/Menu.ts +29 -0
- package/src/modules/NavTab.ts +106 -0
- package/src/modules/Settings.ts +120 -0
- package/src/modules/User.ts +30 -0
- package/src/types.ts +15 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { defineStore } from 'pinia';
|
|
2
|
+
import { useMediaQuery } from '@vueuse/core';
|
|
3
|
+
import { SETTINGS_ID } from '../types.mjs';
|
|
4
|
+
|
|
5
|
+
const mediaMap = [
|
|
6
|
+
{
|
|
7
|
+
key: "700",
|
|
8
|
+
value: "(max-width: 700px)",
|
|
9
|
+
description: "\u5C0F\u4E8E700\u8BBE\u5907"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
key: "700-960",
|
|
13
|
+
value: "(min-width:700px) and (max-width: 960px)",
|
|
14
|
+
description: "\u5927\u4E8E700\u5C0F\u4E8E960\u8BBE\u5907"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
key: "960-1200",
|
|
18
|
+
value: "(min-width:960px) and (max-width: 1200px)",
|
|
19
|
+
description: "\u5927\u4E8E960\u5C0F\u4E8E1024\u8BBE\u5907"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
key: "1200-1680",
|
|
23
|
+
value: "(min-width:1200px) and (max-width: 1680px)",
|
|
24
|
+
description: " \u5927\u4E8E1200\u5C0F\u4E8E1680\u8BBE\u5907"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
key: "1680",
|
|
28
|
+
value: "(min-width:1680px)",
|
|
29
|
+
description: " \u5927\u4E8E1680\u8BBE\u5907"
|
|
30
|
+
}
|
|
31
|
+
];
|
|
32
|
+
const gridConfig = [
|
|
33
|
+
{
|
|
34
|
+
key: "700",
|
|
35
|
+
value: "repeat(1, 100%)",
|
|
36
|
+
col: 1,
|
|
37
|
+
description: "\u663E\u793A\u4E00\u5217\u5360100%"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
key: "700-960",
|
|
41
|
+
value: "repeat(2, 50%)",
|
|
42
|
+
col: 2,
|
|
43
|
+
description: "\u663E\u793A\u4E24\u5217\u6BCF\u5217\u536050%\u5BBD"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
key: "960-1200",
|
|
47
|
+
value: "repeat(3, 33.33%)",
|
|
48
|
+
col: 3,
|
|
49
|
+
description: "\u663E\u793A\u4E09\u5217\u6BCF\u5217\u536033.33%\u5BBD"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
key: "1200-1680",
|
|
53
|
+
value: "repeat(4, 25%)",
|
|
54
|
+
col: 4,
|
|
55
|
+
description: "\u663E\u793A4\u5217\u6BCF\u5217\u536025%\u5BBD"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
key: "1680",
|
|
59
|
+
value: "repeat(5, 20%)",
|
|
60
|
+
col: 5,
|
|
61
|
+
description: " \u663E\u793A5\u5217\u6BCF\u5217\u536020%\u5BBD"
|
|
62
|
+
}
|
|
63
|
+
];
|
|
64
|
+
const useSettingsStore = defineStore(SETTINGS_ID, {
|
|
65
|
+
state: () => ({
|
|
66
|
+
// 刷新状态
|
|
67
|
+
refresh: false,
|
|
68
|
+
// 菜单收缩
|
|
69
|
+
collapsed: false,
|
|
70
|
+
// 屏幕设备匹配规则
|
|
71
|
+
mediaRuleMap: mediaMap,
|
|
72
|
+
// 网格配置 根据匹配匹配规则
|
|
73
|
+
gridConfig,
|
|
74
|
+
gridValue: {}
|
|
75
|
+
}),
|
|
76
|
+
getters: {
|
|
77
|
+
getRefresh: (state) => state.refresh,
|
|
78
|
+
getCollapsed: (state) => state.collapsed,
|
|
79
|
+
getGrid: (state) => {
|
|
80
|
+
return state.gridValue;
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
actions: {
|
|
84
|
+
/**
|
|
85
|
+
* 切换刷新
|
|
86
|
+
*/
|
|
87
|
+
switchRefreshStatus() {
|
|
88
|
+
this.refresh = !this.refresh;
|
|
89
|
+
},
|
|
90
|
+
/**
|
|
91
|
+
* 切换菜单收缩状态
|
|
92
|
+
*/
|
|
93
|
+
switchCollapsed() {
|
|
94
|
+
this.collapsed = !this.collapsed;
|
|
95
|
+
},
|
|
96
|
+
/**
|
|
97
|
+
* 网格匹配
|
|
98
|
+
*/
|
|
99
|
+
gridMatching() {
|
|
100
|
+
const mediaResult = this.mediaRuleMap.filter(
|
|
101
|
+
(item) => useMediaQuery(item.value).value
|
|
102
|
+
)[0];
|
|
103
|
+
const gridRs = this.gridConfig.filter(
|
|
104
|
+
(item) => item.key === mediaResult.key
|
|
105
|
+
)[0];
|
|
106
|
+
this.gridValue = gridRs;
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
persist: true
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
export { useSettingsStore };
|
|
113
|
+
//# sourceMappingURL=Settings.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Settings.mjs","sources":["../../../src/modules/Settings.ts"],"sourcesContent":["import { defineStore } from \"pinia\";\nimport { useMediaQuery } from \"@vueuse/core\";\nimport { SETTINGS_ID } from \"../types\";\n\nconst mediaMap = [\n {\n key: \"700\",\n value: \"(max-width: 700px)\",\n description: \"小于700设备\"\n },\n {\n key: \"700-960\",\n value: \"(min-width:700px) and (max-width: 960px)\",\n description: \"大于700小于960设备\"\n },\n {\n key: \"960-1200\",\n value: \"(min-width:960px) and (max-width: 1200px)\",\n description: \"大于960小于1024设备\"\n },\n {\n key: \"1200-1680\",\n value: \"(min-width:1200px) and (max-width: 1680px)\",\n description: \" 大于1200小于1680设备\"\n },\n {\n key: \"1680\",\n value: \"(min-width:1680px)\",\n description: \" 大于1680设备\"\n }\n];\n\nconst gridConfig = [\n {\n key: \"700\",\n value: \"repeat(1, 100%)\",\n col: 1,\n description: \"显示一列占100%\"\n },\n {\n key: \"700-960\",\n value: \"repeat(2, 50%)\",\n col: 2,\n description: \"显示两列每列占50%宽\"\n },\n {\n key: \"960-1200\",\n value: \"repeat(3, 33.33%)\",\n col: 3,\n description: \"显示三列每列占33.33%宽\"\n },\n {\n key: \"1200-1680\",\n value: \"repeat(4, 25%)\",\n col: 4,\n description: \"显示4列每列占25%宽\"\n },\n {\n key: \"1680\",\n value: \"repeat(5, 20%)\",\n col: 5,\n description: \" 显示5列每列占20%宽\"\n }\n];\n\nexport interface SettingState {\n refresh: boolean;\n collapsed: boolean;\n mediaRuleMap: any;\n gridConfig: any;\n gridValue: any;\n}\n\nexport const useSettingsStore = defineStore(SETTINGS_ID, {\n state: (): SettingState => ({\n // 刷新状态\n refresh: false as boolean,\n // 菜单收缩\n collapsed: false as boolean,\n // 屏幕设备匹配规则\n mediaRuleMap: mediaMap,\n // 网格配置 根据匹配匹配规则\n gridConfig: gridConfig,\n gridValue: {} as any\n }),\n getters: {\n getRefresh: (state) => state.refresh,\n getCollapsed: (state) => state.collapsed,\n getGrid: (state) => {\n return state.gridValue;\n }\n },\n actions: {\n /**\n * 切换刷新\n */\n switchRefreshStatus() {\n this.refresh = !this.refresh;\n },\n /**\n * 切换菜单收缩状态\n */\n switchCollapsed() {\n this.collapsed = !this.collapsed;\n },\n /**\n * 网格匹配\n */\n gridMatching() {\n const mediaResult = this.mediaRuleMap.filter(\n (item: any) => useMediaQuery(item.value).value\n )[0];\n const gridRs = this.gridConfig.filter(\n (item: any) => item.key === mediaResult.key\n )[0];\n this.gridValue = gridRs;\n }\n },\n persist: true\n});\n"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface UserState {
|
|
2
|
+
token: string | undefined;
|
|
3
|
+
userInfo: any;
|
|
4
|
+
}
|
|
5
|
+
export declare const useUserStore: import("pinia").StoreDefinition<string, UserState, {
|
|
6
|
+
getToken: (state: {
|
|
7
|
+
token: string | undefined;
|
|
8
|
+
userInfo: any;
|
|
9
|
+
} & import("pinia").PiniaCustomStateProperties<UserState>) => string | undefined;
|
|
10
|
+
getUserInfo: (state: {
|
|
11
|
+
token: string | undefined;
|
|
12
|
+
userInfo: any;
|
|
13
|
+
} & import("pinia").PiniaCustomStateProperties<UserState>) => any;
|
|
14
|
+
}, {
|
|
15
|
+
/**
|
|
16
|
+
* 保存token
|
|
17
|
+
* @param token
|
|
18
|
+
*/
|
|
19
|
+
saveToken(token: string): void;
|
|
20
|
+
saveUserInfo(data: any): void;
|
|
21
|
+
}>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { defineStore } from 'pinia';
|
|
2
|
+
import { USER_ID } from '../types.mjs';
|
|
3
|
+
|
|
4
|
+
const useUserStore = defineStore(USER_ID, {
|
|
5
|
+
state: () => ({
|
|
6
|
+
token: void 0,
|
|
7
|
+
userInfo: void 0
|
|
8
|
+
}),
|
|
9
|
+
getters: {
|
|
10
|
+
getToken: (state) => state.token,
|
|
11
|
+
getUserInfo: (state) => state.userInfo
|
|
12
|
+
},
|
|
13
|
+
actions: {
|
|
14
|
+
/**
|
|
15
|
+
* 保存token
|
|
16
|
+
* @param token
|
|
17
|
+
*/
|
|
18
|
+
saveToken(token) {
|
|
19
|
+
this.token = token;
|
|
20
|
+
},
|
|
21
|
+
saveUserInfo(data) {
|
|
22
|
+
this.userInfo = data;
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
persist: true
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export { useUserStore };
|
|
29
|
+
//# sourceMappingURL=User.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"User.mjs","sources":["../../../src/modules/User.ts"],"sourcesContent":["import { defineStore } from \"pinia\";\nimport { USER_ID } from \"../types\";\n\nexport interface UserState {\n token: string | undefined;\n userInfo: any;\n}\nexport const useUserStore = defineStore(USER_ID, {\n state: (): UserState => ({\n token: undefined,\n userInfo: undefined\n }),\n getters: {\n getToken: (state) => state.token,\n getUserInfo: (state) => state.userInfo\n },\n actions: {\n /**\n * 保存token\n * @param token\n */\n saveToken(token: string) {\n this.token = token;\n },\n saveUserInfo(data: any) {\n this.userInfo = data;\n }\n },\n persist: true\n});\n"],"names":[],"mappings":";;;AAOa,MAAA,YAAA,GAAe,YAAY,OAAS,EAAA;AAAA,EAC/C,OAAO,OAAkB;AAAA,IACvB,KAAO,EAAA,KAAA,CAAA;AAAA,IACP,QAAU,EAAA,KAAA,CAAA;AAAA,GACZ,CAAA;AAAA,EACA,OAAS,EAAA;AAAA,IACP,QAAA,EAAU,CAAC,KAAA,KAAU,KAAM,CAAA,KAAA;AAAA,IAC3B,WAAA,EAAa,CAAC,KAAA,KAAU,KAAM,CAAA,QAAA;AAAA,GAChC;AAAA,EACA,OAAS,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAKP,UAAU,KAAe,EAAA;AACvB,MAAA,IAAA,CAAK,KAAQ,GAAA,KAAA,CAAA;AAAA,KACf;AAAA,IACA,aAAa,IAAW,EAAA;AACtB,MAAA,IAAA,CAAK,QAAW,GAAA,IAAA,CAAA;AAAA,KAClB;AAAA,GACF;AAAA,EACA,OAAS,EAAA,IAAA;AACX,CAAC;;;;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const BREADCRUMB_ID: string;
|
|
2
|
+
export declare const DATA_DICTIONARY_ID: string;
|
|
3
|
+
export declare const KEEP_ALIVE_ID: string;
|
|
4
|
+
export declare const MENU_ID: string;
|
|
5
|
+
export declare const NAV_TAB_ID: string;
|
|
6
|
+
export declare const SETTINGS_ID: string;
|
|
7
|
+
export declare const USER_ID: string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const id_prefix = "DITARI_STORE_";
|
|
2
|
+
const BREADCRUMB_ID = `${id_prefix}BREADCRUMB_ID`;
|
|
3
|
+
const DATA_DICTIONARY_ID = `${id_prefix}DATA_DICTIONARY_ID`;
|
|
4
|
+
const KEEP_ALIVE_ID = `${id_prefix}KEEP_ALIVE_ID`;
|
|
5
|
+
const MENU_ID = `${id_prefix}MENU_ID`;
|
|
6
|
+
const NAV_TAB_ID = `${id_prefix}NAV_TABS_ID`;
|
|
7
|
+
const SETTINGS_ID = `${id_prefix}SETTINGS_ID`;
|
|
8
|
+
const USER_ID = `${id_prefix}USER_ID`;
|
|
9
|
+
|
|
10
|
+
export { BREADCRUMB_ID, DATA_DICTIONARY_ID, KEEP_ALIVE_ID, MENU_ID, NAV_TAB_ID, SETTINGS_ID, USER_ID };
|
|
11
|
+
//# sourceMappingURL=types.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.mjs","sources":["../../src/types.ts"],"sourcesContent":["const id_prefix = \"DITARI_STORE_\";\n//面包屑\nexport const BREADCRUMB_ID = `${id_prefix}BREADCRUMB_ID`;\n//字典ID\nexport const DATA_DICTIONARY_ID = `${id_prefix}DATA_DICTIONARY_ID`;\n//缓存组件ID\nexport const KEEP_ALIVE_ID = `${id_prefix}KEEP_ALIVE_ID`;\n//菜单ID\nexport const MENU_ID = `${id_prefix}MENU_ID`;\n//多标签ID\nexport const NAV_TAB_ID = `${id_prefix}NAV_TABS_ID`;\n//用户信息ID\nexport const SETTINGS_ID = `${id_prefix}SETTINGS_ID`;\n//用户信息ID\nexport const USER_ID = `${id_prefix}USER_ID`;\n"],"names":[],"mappings":"AAAA,MAAM,SAAY,GAAA,eAAA,CAAA;AAEL,MAAA,aAAA,GAAgB,GAAG,SAAS,CAAA,aAAA,EAAA;AAE5B,MAAA,kBAAA,GAAqB,GAAG,SAAS,CAAA,kBAAA,EAAA;AAEjC,MAAA,aAAA,GAAgB,GAAG,SAAS,CAAA,aAAA,EAAA;AAE5B,MAAA,OAAA,GAAU,GAAG,SAAS,CAAA,OAAA,EAAA;AAEtB,MAAA,UAAA,GAAa,GAAG,SAAS,CAAA,WAAA,EAAA;AAEzB,MAAA,WAAA,GAAc,GAAG,SAAS,CAAA,WAAA,EAAA;AAE1B,MAAA,OAAA,GAAU,GAAG,SAAS,CAAA,OAAA;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ditari/store",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "store",
|
|
5
|
+
"private": false,
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"author": "yulao",
|
|
10
|
+
"license": "ISC",
|
|
11
|
+
"module": "dist/esm/index.mjs",
|
|
12
|
+
"main": "dist/cjs/index.cjs",
|
|
13
|
+
"types": "dist/esm/index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"require": "./dist/cjs/index.cjs",
|
|
17
|
+
"import": "./dist/esm/index.mjs",
|
|
18
|
+
"types": "./dist/esm/index.d.ts"
|
|
19
|
+
},
|
|
20
|
+
"./esm/*": {
|
|
21
|
+
"import": "./dist/esm/*/index.mjs",
|
|
22
|
+
"types": "./dist/esm/*/index.d.ts"
|
|
23
|
+
},
|
|
24
|
+
"./cjs/*": {
|
|
25
|
+
"require": "./dist/cjs/*/index.cjs",
|
|
26
|
+
"types": "./dist/cjs/*/index.d.ts"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"@vueuse/core": "^9.13.0",
|
|
31
|
+
"vue": "^3.3.4",
|
|
32
|
+
"vue-request": "2.0.0-rc.4",
|
|
33
|
+
"pinia": "^2.1.4",
|
|
34
|
+
"pinia-plugin-persistedstate": "^3.1.0"
|
|
35
|
+
}
|
|
36
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { useBreadcrumbStore } from "./modules/Breadcrumb";
|
|
2
|
+
export type { BreadcrumbState } from "./modules/Breadcrumb";
|
|
3
|
+
export { useDataDicStore } from "./modules/DataDictionary";
|
|
4
|
+
export type { DataDictionaryState } from "./modules/DataDictionary";
|
|
5
|
+
export { useKeepAliveStore } from "./modules/KeepAlive";
|
|
6
|
+
export { useMenuStore } from "./modules/Menu";
|
|
7
|
+
export { useNavTabsStore } from "./modules/NavTab";
|
|
8
|
+
export type { NavTabsState } from "./modules/NavTab";
|
|
9
|
+
export { useSettingsStore } from "./modules/Settings";
|
|
10
|
+
export type { SettingState } from "./modules/Settings";
|
|
11
|
+
export { useUserStore } from "./modules/User";
|
|
12
|
+
export type { UserState } from "./modules/User";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 面包屑
|
|
3
|
+
* @author 余春林
|
|
4
|
+
*/
|
|
5
|
+
import { defineStore } from "pinia";
|
|
6
|
+
import { BREADCRUMB_ID } from "../types";
|
|
7
|
+
|
|
8
|
+
export interface BreadcrumbState {
|
|
9
|
+
breadcrumbs: [];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const useBreadcrumbStore = defineStore(BREADCRUMB_ID, {
|
|
13
|
+
state: (): BreadcrumbState => ({
|
|
14
|
+
breadcrumbs: []
|
|
15
|
+
}),
|
|
16
|
+
getters: {
|
|
17
|
+
getBreadcrumb: (state) => state.breadcrumbs
|
|
18
|
+
},
|
|
19
|
+
actions: {
|
|
20
|
+
saveBreadcrumb(data: any) {
|
|
21
|
+
this.breadcrumbs = data;
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
persist: true
|
|
25
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { defineStore } from "pinia";
|
|
2
|
+
import { DATA_DICTIONARY_ID } from "../types";
|
|
3
|
+
|
|
4
|
+
export interface DataDictionaryState {
|
|
5
|
+
list: any;
|
|
6
|
+
}
|
|
7
|
+
export const useDataDicStore = defineStore(DATA_DICTIONARY_ID, {
|
|
8
|
+
state: (): DataDictionaryState => ({
|
|
9
|
+
list: {}
|
|
10
|
+
}),
|
|
11
|
+
getters: {
|
|
12
|
+
/**
|
|
13
|
+
* 根据key获取字典列表
|
|
14
|
+
* @param state
|
|
15
|
+
*/
|
|
16
|
+
getDicByKey: (state) => {
|
|
17
|
+
return (key: string) => {
|
|
18
|
+
return state.list[key] || [];
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
/**
|
|
22
|
+
* 根据字典名称和字典的value 获取对应的中文
|
|
23
|
+
* @param state
|
|
24
|
+
*/
|
|
25
|
+
getDicTextByValue: (state) => {
|
|
26
|
+
return (key: string, value: string) => {
|
|
27
|
+
const rs = state.list[key] || [];
|
|
28
|
+
return rs
|
|
29
|
+
.filter((item: any) => item.value === value)
|
|
30
|
+
.map((item: any) => item.label)
|
|
31
|
+
.join("");
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
getDicValueByText: (state) => {
|
|
35
|
+
// 根据文字匹配对应的value
|
|
36
|
+
return (key: string, text: string) => {
|
|
37
|
+
const rs = state.list[key] || [];
|
|
38
|
+
return rs
|
|
39
|
+
.filter((item: any) => item.label === text)
|
|
40
|
+
.map((item: any) => item.value)
|
|
41
|
+
.join("");
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
actions: {
|
|
46
|
+
/**
|
|
47
|
+
* 保存字典数据
|
|
48
|
+
* @param data 字典数据
|
|
49
|
+
*/
|
|
50
|
+
save(data: any) {
|
|
51
|
+
this.list = data;
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
persist: true
|
|
55
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 缓存组件name数据
|
|
3
|
+
*/
|
|
4
|
+
import { defineStore } from "pinia";
|
|
5
|
+
import { RouteLocationNormalized } from "vue-router";
|
|
6
|
+
|
|
7
|
+
import { KEEP_ALIVE_ID } from "../types";
|
|
8
|
+
|
|
9
|
+
export const useKeepAliveStore = defineStore(KEEP_ALIVE_ID, {
|
|
10
|
+
state: () => {
|
|
11
|
+
return {
|
|
12
|
+
list: [] as string[]
|
|
13
|
+
};
|
|
14
|
+
},
|
|
15
|
+
getters: {
|
|
16
|
+
get: (state): string[] => {
|
|
17
|
+
return state.list;
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
actions: {
|
|
21
|
+
/**
|
|
22
|
+
* 删除已经缓存的组件
|
|
23
|
+
* @param name 组件名称(必须唯一)
|
|
24
|
+
*/
|
|
25
|
+
deleteKeepAlive(name: string) {
|
|
26
|
+
this.list.splice(
|
|
27
|
+
this.list.findIndex((key: string) => key === name),
|
|
28
|
+
1
|
|
29
|
+
);
|
|
30
|
+
},
|
|
31
|
+
/**
|
|
32
|
+
* 保存要缓存的组件名称
|
|
33
|
+
* @param route
|
|
34
|
+
*/
|
|
35
|
+
save(route: RouteLocationNormalized) {
|
|
36
|
+
const name = <string>route.name;
|
|
37
|
+
if (!name) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const flag = this.list.some((key: string) => key === name);
|
|
41
|
+
if (!flag) {
|
|
42
|
+
this.list.push(name);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
persist: true
|
|
47
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 菜单数据
|
|
3
|
+
*/
|
|
4
|
+
import { defineStore } from "pinia";
|
|
5
|
+
import { MENU_ID } from "../types";
|
|
6
|
+
|
|
7
|
+
export const useMenuStore = defineStore(MENU_ID, {
|
|
8
|
+
state: () => {
|
|
9
|
+
return {
|
|
10
|
+
// 菜单数据
|
|
11
|
+
list: [],
|
|
12
|
+
// 展开的菜单数据
|
|
13
|
+
openMenusKeys: [] as any,
|
|
14
|
+
// 当前激活的菜单
|
|
15
|
+
selectedMenuKeys: [] as any
|
|
16
|
+
};
|
|
17
|
+
},
|
|
18
|
+
getters: {
|
|
19
|
+
getMenu: (state) => {
|
|
20
|
+
return state.list;
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
actions: {
|
|
24
|
+
save(data: any) {
|
|
25
|
+
this.list = data;
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
persist: true
|
|
29
|
+
});
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 多标签数据
|
|
3
|
+
*/
|
|
4
|
+
import { defineStore } from "pinia";
|
|
5
|
+
import {
|
|
6
|
+
LocationQuery,
|
|
7
|
+
RouteLocationNormalized,
|
|
8
|
+
RouteMeta,
|
|
9
|
+
RouteParams
|
|
10
|
+
} from "vue-router";
|
|
11
|
+
|
|
12
|
+
import { NAV_TAB_ID } from "../types";
|
|
13
|
+
|
|
14
|
+
export interface NavTabsState {
|
|
15
|
+
path: string;
|
|
16
|
+
fullPath: string;
|
|
17
|
+
query: LocationQuery;
|
|
18
|
+
params: RouteParams;
|
|
19
|
+
meta: RouteMeta | any;
|
|
20
|
+
name: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const useNavTabsStore = defineStore(NAV_TAB_ID, {
|
|
24
|
+
state: () => {
|
|
25
|
+
return {
|
|
26
|
+
// 多标签列表
|
|
27
|
+
list: [] as NavTabsState[],
|
|
28
|
+
// 当前激活的地址
|
|
29
|
+
activeKey: "" as string
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
getters: {
|
|
33
|
+
getList: (state): NavTabsState[] => {
|
|
34
|
+
return state.list;
|
|
35
|
+
},
|
|
36
|
+
getActiveKey: (state): string => {
|
|
37
|
+
return state.activeKey;
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
actions: {
|
|
41
|
+
/**
|
|
42
|
+
* 设置激活的标签
|
|
43
|
+
* @param key
|
|
44
|
+
*/
|
|
45
|
+
setActiveKey(key: string) {
|
|
46
|
+
this.activeKey = key;
|
|
47
|
+
},
|
|
48
|
+
/**
|
|
49
|
+
* 保存标签信息
|
|
50
|
+
* @param route
|
|
51
|
+
*/
|
|
52
|
+
save(route: RouteLocationNormalized) {
|
|
53
|
+
if (!route.meta?.title) {
|
|
54
|
+
// 没有设置title,则不进入缓存
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const flag = this.list.some((item: NavTabsState) => item.path === route.path);
|
|
58
|
+
if (flag) {
|
|
59
|
+
// 如果有相同的路由变化,更新对应的参数信息
|
|
60
|
+
this.list.forEach((item: NavTabsState) => {
|
|
61
|
+
if (item.path === route.path) {
|
|
62
|
+
item.query = route.query;
|
|
63
|
+
item.fullPath = route.fullPath;
|
|
64
|
+
item.params = route.params;
|
|
65
|
+
item.meta = route.meta;
|
|
66
|
+
item.name = <string>route.name || "";
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const data: NavTabsState = {
|
|
72
|
+
path: route.path,
|
|
73
|
+
fullPath: route.fullPath,
|
|
74
|
+
query: route.query,
|
|
75
|
+
params: route.params,
|
|
76
|
+
meta: route.meta,
|
|
77
|
+
name: <string>route.name || ""
|
|
78
|
+
};
|
|
79
|
+
this.list.push(data);
|
|
80
|
+
},
|
|
81
|
+
/**
|
|
82
|
+
* 删除标签
|
|
83
|
+
* @param key url路径
|
|
84
|
+
*/
|
|
85
|
+
deleteTabs(key: string) {
|
|
86
|
+
this.list.splice(
|
|
87
|
+
this.list.findIndex((v) => v.fullPath === key),
|
|
88
|
+
1
|
|
89
|
+
);
|
|
90
|
+
},
|
|
91
|
+
/**
|
|
92
|
+
* 设置标题
|
|
93
|
+
* @param title 标题
|
|
94
|
+
* @param path url
|
|
95
|
+
*/
|
|
96
|
+
setNavTitle(title: string, path: string) {
|
|
97
|
+
for (let i = 0; i < this.list.length; i++) {
|
|
98
|
+
if (this.list[i].fullPath === path) {
|
|
99
|
+
this.list[i].meta.title = title;
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
persist: true
|
|
106
|
+
});
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { defineStore } from "pinia";
|
|
2
|
+
import { useMediaQuery } from "@vueuse/core";
|
|
3
|
+
import { SETTINGS_ID } from "../types";
|
|
4
|
+
|
|
5
|
+
const mediaMap = [
|
|
6
|
+
{
|
|
7
|
+
key: "700",
|
|
8
|
+
value: "(max-width: 700px)",
|
|
9
|
+
description: "小于700设备"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
key: "700-960",
|
|
13
|
+
value: "(min-width:700px) and (max-width: 960px)",
|
|
14
|
+
description: "大于700小于960设备"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
key: "960-1200",
|
|
18
|
+
value: "(min-width:960px) and (max-width: 1200px)",
|
|
19
|
+
description: "大于960小于1024设备"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
key: "1200-1680",
|
|
23
|
+
value: "(min-width:1200px) and (max-width: 1680px)",
|
|
24
|
+
description: " 大于1200小于1680设备"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
key: "1680",
|
|
28
|
+
value: "(min-width:1680px)",
|
|
29
|
+
description: " 大于1680设备"
|
|
30
|
+
}
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
const gridConfig = [
|
|
34
|
+
{
|
|
35
|
+
key: "700",
|
|
36
|
+
value: "repeat(1, 100%)",
|
|
37
|
+
col: 1,
|
|
38
|
+
description: "显示一列占100%"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
key: "700-960",
|
|
42
|
+
value: "repeat(2, 50%)",
|
|
43
|
+
col: 2,
|
|
44
|
+
description: "显示两列每列占50%宽"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
key: "960-1200",
|
|
48
|
+
value: "repeat(3, 33.33%)",
|
|
49
|
+
col: 3,
|
|
50
|
+
description: "显示三列每列占33.33%宽"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
key: "1200-1680",
|
|
54
|
+
value: "repeat(4, 25%)",
|
|
55
|
+
col: 4,
|
|
56
|
+
description: "显示4列每列占25%宽"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
key: "1680",
|
|
60
|
+
value: "repeat(5, 20%)",
|
|
61
|
+
col: 5,
|
|
62
|
+
description: " 显示5列每列占20%宽"
|
|
63
|
+
}
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
export interface SettingState {
|
|
67
|
+
refresh: boolean;
|
|
68
|
+
collapsed: boolean;
|
|
69
|
+
mediaRuleMap: any;
|
|
70
|
+
gridConfig: any;
|
|
71
|
+
gridValue: any;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export const useSettingsStore = defineStore(SETTINGS_ID, {
|
|
75
|
+
state: (): SettingState => ({
|
|
76
|
+
// 刷新状态
|
|
77
|
+
refresh: false as boolean,
|
|
78
|
+
// 菜单收缩
|
|
79
|
+
collapsed: false as boolean,
|
|
80
|
+
// 屏幕设备匹配规则
|
|
81
|
+
mediaRuleMap: mediaMap,
|
|
82
|
+
// 网格配置 根据匹配匹配规则
|
|
83
|
+
gridConfig: gridConfig,
|
|
84
|
+
gridValue: {} as any
|
|
85
|
+
}),
|
|
86
|
+
getters: {
|
|
87
|
+
getRefresh: (state) => state.refresh,
|
|
88
|
+
getCollapsed: (state) => state.collapsed,
|
|
89
|
+
getGrid: (state) => {
|
|
90
|
+
return state.gridValue;
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
actions: {
|
|
94
|
+
/**
|
|
95
|
+
* 切换刷新
|
|
96
|
+
*/
|
|
97
|
+
switchRefreshStatus() {
|
|
98
|
+
this.refresh = !this.refresh;
|
|
99
|
+
},
|
|
100
|
+
/**
|
|
101
|
+
* 切换菜单收缩状态
|
|
102
|
+
*/
|
|
103
|
+
switchCollapsed() {
|
|
104
|
+
this.collapsed = !this.collapsed;
|
|
105
|
+
},
|
|
106
|
+
/**
|
|
107
|
+
* 网格匹配
|
|
108
|
+
*/
|
|
109
|
+
gridMatching() {
|
|
110
|
+
const mediaResult = this.mediaRuleMap.filter(
|
|
111
|
+
(item: any) => useMediaQuery(item.value).value
|
|
112
|
+
)[0];
|
|
113
|
+
const gridRs = this.gridConfig.filter(
|
|
114
|
+
(item: any) => item.key === mediaResult.key
|
|
115
|
+
)[0];
|
|
116
|
+
this.gridValue = gridRs;
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
persist: true
|
|
120
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { defineStore } from "pinia";
|
|
2
|
+
import { USER_ID } from "../types";
|
|
3
|
+
|
|
4
|
+
export interface UserState {
|
|
5
|
+
token: string | undefined;
|
|
6
|
+
userInfo: any;
|
|
7
|
+
}
|
|
8
|
+
export const useUserStore = defineStore(USER_ID, {
|
|
9
|
+
state: (): UserState => ({
|
|
10
|
+
token: undefined,
|
|
11
|
+
userInfo: undefined
|
|
12
|
+
}),
|
|
13
|
+
getters: {
|
|
14
|
+
getToken: (state) => state.token,
|
|
15
|
+
getUserInfo: (state) => state.userInfo
|
|
16
|
+
},
|
|
17
|
+
actions: {
|
|
18
|
+
/**
|
|
19
|
+
* 保存token
|
|
20
|
+
* @param token
|
|
21
|
+
*/
|
|
22
|
+
saveToken(token: string) {
|
|
23
|
+
this.token = token;
|
|
24
|
+
},
|
|
25
|
+
saveUserInfo(data: any) {
|
|
26
|
+
this.userInfo = data;
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
persist: true
|
|
30
|
+
});
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const id_prefix = "DITARI_STORE_";
|
|
2
|
+
//面包屑
|
|
3
|
+
export const BREADCRUMB_ID = `${id_prefix}BREADCRUMB_ID`;
|
|
4
|
+
//字典ID
|
|
5
|
+
export const DATA_DICTIONARY_ID = `${id_prefix}DATA_DICTIONARY_ID`;
|
|
6
|
+
//缓存组件ID
|
|
7
|
+
export const KEEP_ALIVE_ID = `${id_prefix}KEEP_ALIVE_ID`;
|
|
8
|
+
//菜单ID
|
|
9
|
+
export const MENU_ID = `${id_prefix}MENU_ID`;
|
|
10
|
+
//多标签ID
|
|
11
|
+
export const NAV_TAB_ID = `${id_prefix}NAV_TABS_ID`;
|
|
12
|
+
//用户信息ID
|
|
13
|
+
export const SETTINGS_ID = `${id_prefix}SETTINGS_ID`;
|
|
14
|
+
//用户信息ID
|
|
15
|
+
export const USER_ID = `${id_prefix}USER_ID`;
|