@ditari/bsui 1.0.0 → 1.0.2
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/dist/cjs/components/components.cjs.js +1 -1
- package/dist/cjs/components/components.d.ts +2 -1
- package/dist/cjs/components/form/grid-form/GridForm.cjs.js +1 -0
- package/dist/cjs/components/form/grid-form/GridForm.d.ts +2 -0
- package/dist/cjs/components/form/index.cjs.js +1 -1
- package/dist/cjs/components/form/index.d.ts +8 -1
- package/dist/cjs/components/grid/Grid.cjs.js +1 -0
- package/dist/cjs/components/grid/Grid.d.ts +23 -0
- package/dist/cjs/components/grid/GridItem.cjs.js +1 -0
- package/dist/cjs/components/grid/GridItem.d.ts +2 -0
- package/dist/cjs/components/grid/index.cjs.js +1 -0
- package/dist/cjs/components/grid/index.d.ts +23 -0
- package/dist/cjs/components/index.cjs.js +1 -1
- package/dist/cjs/components/layout/Breadcrumb.vue.cjs.js +1 -1
- package/dist/cjs/components/layout/List.vue.cjs.js +1 -1
- package/dist/cjs/components/layout/Main.vue.cjs.js +1 -1
- package/dist/cjs/components/layout/Menu.cjs.js +1 -1
- package/dist/cjs/components/layout/NavTabs.vue.cjs.js +1 -1
- package/dist/cjs/components/layout/Show.vue.cjs.js +1 -1
- package/dist/cjs/components/layout/Show.vue.d.ts +11 -0
- package/dist/cjs/components/layout/index.d.ts +11 -25
- package/dist/cjs/components/table/Table.vue.cjs.js +1 -1
- package/dist/cjs/components/table/Table.vue.d.ts +1 -1
- package/dist/cjs/components/table/index.d.ts +1 -1
- package/dist/cjs/components/theme/index.cjs.js +1 -0
- package/dist/cjs/components/theme/index.d.ts +1 -0
- package/dist/cjs/hooks/http/index.cjs.js +1 -0
- package/dist/cjs/hooks/http/index.d.ts +29 -0
- package/dist/cjs/hooks/index.cjs.js +1 -0
- package/dist/cjs/hooks/index.d.ts +2 -0
- package/dist/cjs/hooks/route/index.cjs.js +1 -0
- package/dist/cjs/hooks/route/index.d.ts +9 -0
- package/dist/cjs/store/index.cjs.js +1 -0
- package/dist/cjs/store/index.d.ts +7 -7
- package/dist/cjs/store/modules/Breadcrumb.cjs.js +1 -1
- package/dist/cjs/store/modules/Breadcrumb.d.ts +6 -16
- package/dist/cjs/store/modules/DataDictionary.cjs.js +1 -1
- package/dist/cjs/store/modules/DataDictionary.d.ts +28 -3
- package/dist/cjs/store/modules/KeepAlive.cjs.js +1 -1
- package/dist/cjs/store/modules/KeepAlive.d.ts +3 -4
- package/dist/cjs/store/modules/Menu.cjs.js +1 -1
- package/dist/cjs/store/modules/Menu.d.ts +1 -2
- package/dist/cjs/store/modules/NavTab.cjs.js +1 -1
- package/dist/cjs/store/modules/NavTab.d.ts +3 -4
- package/dist/cjs/store/modules/Settings.cjs.js +1 -1
- package/dist/cjs/store/modules/Settings.d.ts +23 -9
- package/dist/cjs/store/modules/User.cjs.js +1 -1
- package/dist/cjs/store/modules/User.d.ts +1 -2
- package/dist/cjs/store/types.cjs.js +1 -1
- package/dist/cjs/utils/get.cjs.js +1 -0
- package/dist/css/grid/style/index.css +1 -0
- package/dist/css/index.css +1 -0
- package/dist/css/menu/style/index.css +1 -0
- package/dist/esm/components/components.d.ts +2 -1
- package/dist/esm/components/components.esm.js +10 -7
- package/dist/esm/components/form/grid-form/GridForm.d.ts +2 -0
- package/dist/esm/components/form/grid-form/GridForm.esm.js +9 -0
- package/dist/esm/components/form/index.d.ts +8 -1
- package/dist/esm/components/form/index.esm.js +5 -3
- package/dist/esm/components/grid/Grid.d.ts +23 -0
- package/dist/esm/components/grid/Grid.esm.js +55 -0
- package/dist/esm/components/grid/GridItem.d.ts +2 -0
- package/dist/esm/components/grid/GridItem.esm.js +15 -0
- package/dist/esm/components/grid/index.d.ts +23 -0
- package/dist/esm/components/grid/index.esm.js +8 -0
- package/dist/esm/components/index.esm.js +16 -13
- package/dist/esm/components/layout/Breadcrumb.vue.esm.js +13 -19
- package/dist/esm/components/layout/List.vue.esm.js +29 -35
- package/dist/esm/components/layout/Main.vue.esm.js +53 -50
- package/dist/esm/components/layout/Menu.esm.js +45 -19
- package/dist/esm/components/layout/NavTabs.vue.esm.js +27 -27
- package/dist/esm/components/layout/Show.vue.d.ts +11 -0
- package/dist/esm/components/layout/Show.vue.esm.js +70 -48
- package/dist/esm/components/layout/index.d.ts +11 -25
- package/dist/esm/components/table/Table.vue.d.ts +1 -1
- package/dist/esm/components/table/Table.vue.esm.js +2 -2
- package/dist/esm/components/table/index.d.ts +1 -1
- package/dist/esm/components/theme/index.d.ts +1 -0
- package/dist/esm/components/theme/index.esm.js +4 -0
- package/dist/esm/hooks/http/index.d.ts +29 -0
- package/dist/esm/hooks/http/index.esm.js +52 -0
- package/dist/esm/hooks/index.d.ts +2 -0
- package/dist/esm/hooks/index.esm.js +6 -0
- package/dist/esm/hooks/route/index.d.ts +9 -0
- package/dist/esm/hooks/route/index.esm.js +42 -0
- package/dist/esm/store/index.d.ts +7 -7
- package/dist/esm/store/index.esm.js +16 -0
- package/dist/esm/store/modules/Breadcrumb.d.ts +6 -16
- package/dist/esm/store/modules/Breadcrumb.esm.js +4 -12
- package/dist/esm/store/modules/DataDictionary.d.ts +28 -3
- package/dist/esm/store/modules/DataDictionary.esm.js +30 -6
- package/dist/esm/store/modules/KeepAlive.d.ts +3 -4
- package/dist/esm/store/modules/KeepAlive.esm.js +4 -4
- package/dist/esm/store/modules/Menu.d.ts +1 -2
- package/dist/esm/store/modules/Menu.esm.js +1 -1
- package/dist/esm/store/modules/NavTab.d.ts +3 -4
- package/dist/esm/store/modules/NavTab.esm.js +2 -2
- package/dist/esm/store/modules/Settings.d.ts +23 -9
- package/dist/esm/store/modules/Settings.esm.js +81 -6
- package/dist/esm/store/modules/User.d.ts +1 -2
- package/dist/esm/store/modules/User.esm.js +4 -1
- package/dist/esm/store/types.esm.js +4 -4
- package/dist/esm/style.css +1 -274
- package/dist/esm/utils/get.esm.js +11 -0
- package/dist/style/grid/style/index.scss +61 -0
- package/dist/style/index.scss +15 -0
- package/dist/style/menu/style/index.scss +18 -0
- package/dist/style/theme/theme.scss +1 -0
- package/dist/style/theme/variable.scss +21 -0
- package/package.json +10 -7
- package/src/components/components.ts +4 -0
- package/src/components/config/Config.vue +8 -0
- package/src/components/form/Form.vue +10 -0
- package/src/components/form/grid-form/GridForm.jsx +10 -0
- package/src/components/form/index.ts +8 -0
- package/src/components/form/style/index.less +0 -0
- package/src/components/grid/Grid.tsx +73 -0
- package/src/components/grid/GridItem.tsx +15 -0
- package/src/components/grid/index.md +4 -0
- package/src/components/grid/index.ts +7 -0
- package/src/components/grid/style/index.scss +61 -0
- package/src/components/index.scss +15 -0
- package/src/components/index.ts +31 -0
- package/src/components/layout/Breadcrumb.vue +119 -0
- package/src/components/layout/Header.vue +0 -0
- package/src/components/layout/Layout.jsx +24 -0
- package/src/components/layout/List.vue +159 -0
- package/src/components/layout/Main.vue +187 -0
- package/src/components/layout/Menu.jsx +96 -0
- package/src/components/layout/NavTabs.vue +192 -0
- package/src/components/layout/Show.vue +157 -0
- package/src/components/layout/index.ts +19 -0
- package/src/components/menu/Menu.jsx +94 -0
- package/src/components/menu/style/index.scss +18 -0
- package/src/components/select/Select.vue +85 -0
- package/src/components/table/Field.vue +49 -0
- package/src/components/table/Table.vue +391 -0
- package/src/components/table/index.md +1 -0
- package/src/components/table/index.ts +5 -0
- package/src/components/theme/index.ts +1 -0
- package/src/components/theme/theme.scss +1 -0
- package/src/components/theme/variable.scss +21 -0
- package/src/hooks/http/index.ts +107 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/route/index.ts +84 -0
- package/src/store/index.ts +7 -0
- package/src/store/modules/Breadcrumb.ts +25 -0
- package/src/store/modules/DataDictionary.ts +49 -0
- package/src/store/modules/KeepAlive.ts +47 -0
- package/src/store/modules/Menu.ts +24 -0
- package/src/store/modules/NavTab.ts +81 -0
- package/src/store/modules/Settings.ts +120 -0
- package/src/store/modules/User.ts +23 -0
- package/src/store/types.ts +15 -0
- package/src/tsconfig.json +16 -0
- package/src/utils/get.ts +15 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/install.ts +12 -0
|
@@ -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,24 @@
|
|
|
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
|
+
list: []
|
|
11
|
+
};
|
|
12
|
+
},
|
|
13
|
+
getters: {
|
|
14
|
+
getMenu: (state) => {
|
|
15
|
+
return state.list;
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
actions: {
|
|
19
|
+
save(data: any) {
|
|
20
|
+
this.list = data;
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
persist: true
|
|
24
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
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 INavTab {
|
|
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 INavTab[],
|
|
28
|
+
// 当前激活的地址
|
|
29
|
+
activeKey: "" as string
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
getters: {
|
|
33
|
+
getList: (state): INavTab[] => {
|
|
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
|
+
const flag = this.list.some(
|
|
54
|
+
(item: INavTab) => item.fullPath === route.fullPath
|
|
55
|
+
);
|
|
56
|
+
if (flag) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const data: INavTab = {
|
|
60
|
+
path: route.path,
|
|
61
|
+
fullPath: route.fullPath,
|
|
62
|
+
query: route.query,
|
|
63
|
+
params: route.params,
|
|
64
|
+
meta: route.meta,
|
|
65
|
+
name: <string>route.name || ""
|
|
66
|
+
};
|
|
67
|
+
this.list.push(data);
|
|
68
|
+
},
|
|
69
|
+
/**
|
|
70
|
+
* 删除标签
|
|
71
|
+
* @param key url路径
|
|
72
|
+
*/
|
|
73
|
+
deleteTabs(key: string) {
|
|
74
|
+
this.list.splice(
|
|
75
|
+
this.list.findIndex((v) => v.fullPath === key),
|
|
76
|
+
1
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
persist: true
|
|
81
|
+
});
|
|
@@ -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 State {
|
|
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: (): State => ({
|
|
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,23 @@
|
|
|
1
|
+
import { defineStore } from "pinia";
|
|
2
|
+
import { USER_ID } from "../types";
|
|
3
|
+
|
|
4
|
+
export const useUserStore = defineStore(USER_ID, {
|
|
5
|
+
state: () => {
|
|
6
|
+
return {
|
|
7
|
+
// token
|
|
8
|
+
token: undefined
|
|
9
|
+
};
|
|
10
|
+
},
|
|
11
|
+
getters: {
|
|
12
|
+
getToken: (state) => state.token
|
|
13
|
+
},
|
|
14
|
+
actions: {
|
|
15
|
+
/**
|
|
16
|
+
* 保存token
|
|
17
|
+
* @param token
|
|
18
|
+
*/
|
|
19
|
+
saveToken(token: any) {
|
|
20
|
+
this.token = token;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
});
|
|
@@ -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`;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"baseUrl": "..",
|
|
4
|
+
"jsx": "preserve",
|
|
5
|
+
"strict": true,
|
|
6
|
+
"target": "ES2015",
|
|
7
|
+
"module": "ESNext",
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"moduleResolution": "Node",
|
|
11
|
+
"allowJs": true,
|
|
12
|
+
"lib": ["esnext", "dom"],
|
|
13
|
+
"types": ["pinia-plugin-persistedstate"],
|
|
14
|
+
"paths": {}
|
|
15
|
+
}
|
|
16
|
+
}
|
package/src/utils/get.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const get = (
|
|
2
|
+
source: Record<string, any>,
|
|
3
|
+
path: string,
|
|
4
|
+
defaultValue: any = undefined
|
|
5
|
+
) => {
|
|
6
|
+
const paths = path.replace(/\[(\d+)\]/g, ".$1").split(".");
|
|
7
|
+
let result = source;
|
|
8
|
+
for (const p of paths) {
|
|
9
|
+
result = Object(result)[p];
|
|
10
|
+
if (result === undefined) {
|
|
11
|
+
return defaultValue;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return result;
|
|
15
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { App, Plugin } from "vue";
|
|
2
|
+
export type SFCWithInstall<T> = T & Plugin;
|
|
3
|
+
export default <T>(comp: T) => {
|
|
4
|
+
(comp as SFCWithInstall<T>).install = (app: App) => {
|
|
5
|
+
// 当组件是 script setup 的形式时,会自动以为文件名注册,会挂载到组件的__name 属性上
|
|
6
|
+
// 所以要加上这个条件
|
|
7
|
+
const name = (comp as any).name || (comp as any).__name;
|
|
8
|
+
//注册组件
|
|
9
|
+
app.component(name, comp as SFCWithInstall<T>);
|
|
10
|
+
};
|
|
11
|
+
return comp as SFCWithInstall<T>;
|
|
12
|
+
};
|