@chewel611/naive-ui-plus 0.0.40 → 0.0.42
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/index.js +580 -573
- package/dist/index.umd.cjs +1 -1
- package/dist/style.css +1 -1
- package/es/layout/content/PTabs.css +1 -1
- package/es/layout/content/PTabs.vue.js +2 -2
- package/es/layout/content/PTabs.vue2.js +104 -97
- package/es/layout/sider/PMenus.vue.js +22 -22
- package/es/layout/store.d.ts +18 -18
- package/es/layout/store.js +24 -24
- package/es/layout/typing.d.ts +0 -6
- package/es/table/PTable.vue.js +1 -1
- package/es/table/typing.d.ts +2 -2
- package/lib/layout/content/PTabs.css +1 -1
- package/lib/layout/content/PTabs.vue.cjs +1 -1
- package/lib/layout/content/PTabs.vue2.cjs +1 -1
- package/lib/layout/sider/PMenus.vue.cjs +1 -1
- package/lib/layout/store.cjs +1 -1
- package/lib/layout/store.d.ts +18 -18
- package/lib/layout/typing.d.ts +0 -6
- package/lib/table/PTable.vue.cjs +1 -1
- package/lib/table/typing.d.ts +2 -2
- package/package.json +3 -2
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as k, ref as d, watch as S, onMounted as y, openBlock as C, createBlock as L, unref as g } from "vue";
|
|
2
2
|
import { NMenu as O } from "naive-ui";
|
|
3
3
|
import { useRoute as P, useRouter as U } from "vue-router";
|
|
4
4
|
import { useLayoutStore as b } from "../store.js";
|
|
5
|
-
const j = /* @__PURE__ */
|
|
5
|
+
const j = /* @__PURE__ */ k({
|
|
6
6
|
__name: "PMenus",
|
|
7
7
|
setup(z) {
|
|
8
|
-
const a = P(),
|
|
8
|
+
const m = d([]), a = P(), p = U(), M = b(), h = d(a.name), l = d(
|
|
9
9
|
a.matched && a.matched.length ? a.matched.map((e) => e.name) : []
|
|
10
|
-
),
|
|
11
|
-
/http(s)?:/.test(e) ? window.open(e) :
|
|
10
|
+
), _ = (e) => {
|
|
11
|
+
a.name !== e && (/http(s)?:/.test(e) ? window.open(e) : p.push({ name: e }));
|
|
12
12
|
}, w = (e) => {
|
|
13
13
|
if (!e) return;
|
|
14
|
-
const n = e.find((s) =>
|
|
15
|
-
|
|
14
|
+
const n = e.find((s) => l.value.indexOf(s) === -1);
|
|
15
|
+
l.value = n ? [n] : [];
|
|
16
16
|
}, f = () => {
|
|
17
17
|
const e = a.matched;
|
|
18
|
-
|
|
18
|
+
l.value = e.map((s) => s.name);
|
|
19
19
|
const n = a.meta?.activeMenu || "";
|
|
20
|
-
|
|
20
|
+
h.value = n || a.name;
|
|
21
21
|
}, i = (e, n = [], s = !1) => {
|
|
22
22
|
const u = [], R = [
|
|
23
23
|
"/:path(.*)*",
|
|
@@ -28,18 +28,18 @@ const j = /* @__PURE__ */ B({
|
|
|
28
28
|
];
|
|
29
29
|
if (!e || e.length === 0)
|
|
30
30
|
return u;
|
|
31
|
-
e = e.sort((o,
|
|
32
|
-
let c = (
|
|
33
|
-
return c === 0 && (c = (o.meta?.sort ?? 0) - (
|
|
31
|
+
e = e.sort((o, r) => {
|
|
32
|
+
let c = (r.children?.length ? 1 : 0) - (o.children?.length ? 1 : 0);
|
|
33
|
+
return c === 0 && (c = (o.meta?.sort ?? 0) - (r.meta?.sort ?? 0)), c;
|
|
34
34
|
});
|
|
35
35
|
for (const o of e) {
|
|
36
36
|
if (s || o.meta?.hidden || R.includes(o.path.toLowerCase())) {
|
|
37
37
|
n.push(o.name), i(o.children || [], n, !0);
|
|
38
38
|
continue;
|
|
39
39
|
}
|
|
40
|
-
const
|
|
41
|
-
(
|
|
42
|
-
) || [], c = o.meta?.alwaysShow != !0 &&
|
|
40
|
+
const r = o.children?.filter(
|
|
41
|
+
(B) => !B.meta?.hidden
|
|
42
|
+
) || [], c = o.meta?.alwaysShow != !0 && r.length === 1, t = c ? r[0] : o, v = {
|
|
43
43
|
key: t.name,
|
|
44
44
|
label: t.meta?.title,
|
|
45
45
|
affix: t.meta?.affix,
|
|
@@ -55,27 +55,27 @@ const j = /* @__PURE__ */ B({
|
|
|
55
55
|
}
|
|
56
56
|
return u;
|
|
57
57
|
}, x = () => {
|
|
58
|
-
const e =
|
|
59
|
-
|
|
58
|
+
const e = p.getRoutes();
|
|
59
|
+
m.value = i(e);
|
|
60
60
|
};
|
|
61
|
-
return
|
|
61
|
+
return S(
|
|
62
62
|
() => a.fullPath,
|
|
63
63
|
() => {
|
|
64
64
|
f();
|
|
65
65
|
}
|
|
66
|
-
),
|
|
66
|
+
), y(() => {
|
|
67
67
|
x(), f();
|
|
68
68
|
}), (e, n) => (C(), L(g(O), {
|
|
69
69
|
class: "h-full",
|
|
70
70
|
inverted: "",
|
|
71
71
|
mode: "vertical",
|
|
72
|
-
options:
|
|
72
|
+
options: m.value,
|
|
73
73
|
collapsed: g(M).state.collapsed,
|
|
74
74
|
"collapsed-width": 64,
|
|
75
75
|
"collapsed-icon-size": 20,
|
|
76
76
|
indent: 24,
|
|
77
|
-
"expanded-keys":
|
|
78
|
-
value:
|
|
77
|
+
"expanded-keys": l.value,
|
|
78
|
+
value: h.value,
|
|
79
79
|
"onUpdate:value": _,
|
|
80
80
|
"onUpdate:expandedKeys": w
|
|
81
81
|
}, null, 8, ["options", "collapsed", "expanded-keys", "value"]));
|
package/es/layout/store.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare const useLayoutStore: import('pinia').StoreDefinition<"p-layout",
|
|
|
8
8
|
avatar: string;
|
|
9
9
|
collapsed: boolean;
|
|
10
10
|
tabs: {
|
|
11
|
-
name
|
|
11
|
+
name?: import('vue-router').RouteRecordNameGeneric;
|
|
12
12
|
matched?: {
|
|
13
13
|
path: import('vue-router')._RouteRecordBase["path"];
|
|
14
14
|
redirect: string | ((to: import('vue-router').RouteLocation, from: import('vue-router').RouteLocationNormalizedLoaded) => import('vue-router').RouteLocationRaw) | {
|
|
@@ -3480,9 +3480,9 @@ export declare const useLayoutStore: import('pinia').StoreDefinition<"p-layout",
|
|
|
3480
3480
|
instances: Record<string, import('vue').ComponentPublicInstance | undefined | null>;
|
|
3481
3481
|
aliasOf: any | undefined;
|
|
3482
3482
|
}[] | undefined;
|
|
3483
|
-
fullPath
|
|
3484
|
-
query
|
|
3485
|
-
hash
|
|
3483
|
+
fullPath?: string | undefined;
|
|
3484
|
+
query?: import('vue-router').LocationQuery | undefined;
|
|
3485
|
+
hash?: string | undefined;
|
|
3486
3486
|
redirectedFrom?: {
|
|
3487
3487
|
matched: {
|
|
3488
3488
|
path: import('vue-router')._RouteRecordBase["path"];
|
|
@@ -6968,8 +6968,8 @@ export declare const useLayoutStore: import('pinia').StoreDefinition<"p-layout",
|
|
|
6968
6968
|
state?: import('vue-router').HistoryState | undefined;
|
|
6969
6969
|
} | undefined;
|
|
6970
6970
|
meta: import('vue-router').RouteMeta & object;
|
|
6971
|
-
path
|
|
6972
|
-
params
|
|
6971
|
+
path?: string | undefined;
|
|
6972
|
+
params?: import('vue-router').RouteParamsGeneric | undefined;
|
|
6973
6973
|
}[];
|
|
6974
6974
|
cacheTabs: boolean;
|
|
6975
6975
|
settingPages?: {
|
|
@@ -7005,7 +7005,7 @@ export declare const useLayoutStore: import('pinia').StoreDefinition<"p-layout",
|
|
|
7005
7005
|
avatar: string;
|
|
7006
7006
|
collapsed: boolean;
|
|
7007
7007
|
tabs: {
|
|
7008
|
-
name
|
|
7008
|
+
name?: import('vue-router').RouteRecordNameGeneric;
|
|
7009
7009
|
matched?: {
|
|
7010
7010
|
path: import('vue-router')._RouteRecordBase["path"];
|
|
7011
7011
|
redirect: string | ((to: import('vue-router').RouteLocation, from: import('vue-router').RouteLocationNormalizedLoaded) => import('vue-router').RouteLocationRaw) | {
|
|
@@ -10477,9 +10477,9 @@ export declare const useLayoutStore: import('pinia').StoreDefinition<"p-layout",
|
|
|
10477
10477
|
instances: Record<string, import('vue').ComponentPublicInstance | undefined | null>;
|
|
10478
10478
|
aliasOf: any | undefined;
|
|
10479
10479
|
}[] | undefined;
|
|
10480
|
-
fullPath
|
|
10481
|
-
query
|
|
10482
|
-
hash
|
|
10480
|
+
fullPath?: string | undefined;
|
|
10481
|
+
query?: import('vue-router').LocationQuery | undefined;
|
|
10482
|
+
hash?: string | undefined;
|
|
10483
10483
|
redirectedFrom?: {
|
|
10484
10484
|
matched: {
|
|
10485
10485
|
path: import('vue-router')._RouteRecordBase["path"];
|
|
@@ -13965,8 +13965,8 @@ export declare const useLayoutStore: import('pinia').StoreDefinition<"p-layout",
|
|
|
13965
13965
|
state?: import('vue-router').HistoryState | undefined;
|
|
13966
13966
|
} | undefined;
|
|
13967
13967
|
meta: import('vue-router').RouteMeta & object;
|
|
13968
|
-
path
|
|
13969
|
-
params
|
|
13968
|
+
path?: string | undefined;
|
|
13969
|
+
params?: import('vue-router').RouteParamsGeneric | undefined;
|
|
13970
13970
|
}[];
|
|
13971
13971
|
cacheTabs: boolean;
|
|
13972
13972
|
settingPages?: {
|
|
@@ -14002,7 +14002,7 @@ export declare const useLayoutStore: import('pinia').StoreDefinition<"p-layout",
|
|
|
14002
14002
|
avatar: string;
|
|
14003
14003
|
collapsed: boolean;
|
|
14004
14004
|
tabs: {
|
|
14005
|
-
name
|
|
14005
|
+
name?: import('vue-router').RouteRecordNameGeneric;
|
|
14006
14006
|
matched?: {
|
|
14007
14007
|
path: import('vue-router')._RouteRecordBase["path"];
|
|
14008
14008
|
redirect: string | ((to: import('vue-router').RouteLocation, from: import('vue-router').RouteLocationNormalizedLoaded) => import('vue-router').RouteLocationRaw) | {
|
|
@@ -17474,9 +17474,9 @@ export declare const useLayoutStore: import('pinia').StoreDefinition<"p-layout",
|
|
|
17474
17474
|
instances: Record<string, import('vue').ComponentPublicInstance | undefined | null>;
|
|
17475
17475
|
aliasOf: any | undefined;
|
|
17476
17476
|
}[] | undefined;
|
|
17477
|
-
fullPath
|
|
17478
|
-
query
|
|
17479
|
-
hash
|
|
17477
|
+
fullPath?: string | undefined;
|
|
17478
|
+
query?: import('vue-router').LocationQuery | undefined;
|
|
17479
|
+
hash?: string | undefined;
|
|
17480
17480
|
redirectedFrom?: {
|
|
17481
17481
|
matched: {
|
|
17482
17482
|
path: import('vue-router')._RouteRecordBase["path"];
|
|
@@ -20962,8 +20962,8 @@ export declare const useLayoutStore: import('pinia').StoreDefinition<"p-layout",
|
|
|
20962
20962
|
state?: import('vue-router').HistoryState | undefined;
|
|
20963
20963
|
} | undefined;
|
|
20964
20964
|
meta: import('vue-router').RouteMeta & object;
|
|
20965
|
-
path
|
|
20966
|
-
params
|
|
20965
|
+
path?: string | undefined;
|
|
20966
|
+
params?: import('vue-router').RouteParamsGeneric | undefined;
|
|
20967
20967
|
}[];
|
|
20968
20968
|
cacheTabs: boolean;
|
|
20969
20969
|
settingPages?: {
|
package/es/layout/store.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineStore as o } from "pinia";
|
|
2
2
|
import { reactive as n } from "vue";
|
|
3
3
|
const i = ["Redirect", "RedirectSon", "login"], I = o("p-layout", () => {
|
|
4
|
-
const
|
|
4
|
+
const e = n({
|
|
5
5
|
collapsed: !1,
|
|
6
6
|
title: "输入项目名称",
|
|
7
7
|
logo: "https://picsum.photos/id/1/100/100",
|
|
@@ -13,63 +13,63 @@ const i = ["Redirect", "RedirectSon", "login"], I = o("p-layout", () => {
|
|
|
13
13
|
enableLanguage: !1
|
|
14
14
|
});
|
|
15
15
|
return {
|
|
16
|
-
state:
|
|
16
|
+
state: e,
|
|
17
17
|
initTabs: (t) => {
|
|
18
|
-
t.sort((
|
|
18
|
+
t.sort((s, a) => s.meta.affix && !a.meta.affix ? -1 : !s.meta.affix && a.meta.affix ? 1 : Number(a.meta.sort ?? 0) - Number(s.meta.sort ?? 0)), e.tabs = t;
|
|
19
19
|
},
|
|
20
|
-
addTab: (t) => i.includes(t.name) ? !1 : (
|
|
20
|
+
addTab: (t) => i.includes(t.name) ? !1 : (e.tabs?.some(
|
|
21
21
|
(a) => a.fullPath == t.fullPath
|
|
22
|
-
) ||
|
|
22
|
+
) || e.tabs?.push(t), !0),
|
|
23
23
|
closeCurrentTab: (t) => {
|
|
24
|
-
const
|
|
24
|
+
const s = e.tabs.findIndex(
|
|
25
25
|
(a) => a.fullPath == t.fullPath
|
|
26
26
|
);
|
|
27
|
-
|
|
27
|
+
e.tabs.splice(s, 1);
|
|
28
28
|
},
|
|
29
29
|
closeAllTabs: () => {
|
|
30
|
-
|
|
30
|
+
e.tabs = e.tabs.filter((t) => t?.meta?.affix ?? !1);
|
|
31
31
|
},
|
|
32
32
|
closeOtherTabs: (t) => {
|
|
33
|
-
|
|
34
|
-
(
|
|
33
|
+
e.tabs = e.tabs.filter(
|
|
34
|
+
(s) => s.fullPath == t.fullPath || (s?.meta?.affix ?? !1)
|
|
35
35
|
);
|
|
36
36
|
},
|
|
37
37
|
closeLeftTabs: (t) => {
|
|
38
|
-
const
|
|
38
|
+
const s = e.tabs.findIndex(
|
|
39
39
|
(a) => a.fullPath == t.fullPath
|
|
40
40
|
);
|
|
41
|
-
|
|
42
|
-
(a, l) => l >=
|
|
41
|
+
e.tabs = e.tabs.filter(
|
|
42
|
+
(a, l) => l >= s || (a?.meta?.affix ?? !1)
|
|
43
43
|
);
|
|
44
44
|
},
|
|
45
45
|
closeRightTabs: (t) => {
|
|
46
|
-
const
|
|
46
|
+
const s = e.tabs.findIndex(
|
|
47
47
|
(a) => a.fullPath == t.fullPath
|
|
48
48
|
);
|
|
49
|
-
|
|
50
|
-
(a, l) => l <=
|
|
49
|
+
e.tabs = e.tabs.filter(
|
|
50
|
+
(a, l) => l <= s || (a?.meta?.affix ?? !1)
|
|
51
51
|
);
|
|
52
52
|
},
|
|
53
53
|
collapse: () => {
|
|
54
|
-
|
|
54
|
+
e.collapsed = !e.collapsed;
|
|
55
55
|
},
|
|
56
56
|
setTitle: (t) => {
|
|
57
|
-
|
|
57
|
+
e.title = t;
|
|
58
58
|
},
|
|
59
59
|
setLogo: (t) => {
|
|
60
|
-
|
|
60
|
+
e.logo = t;
|
|
61
61
|
},
|
|
62
|
-
setUser: (t,
|
|
63
|
-
|
|
62
|
+
setUser: (t, s) => {
|
|
63
|
+
e.uid = t, e.uname = s;
|
|
64
64
|
},
|
|
65
65
|
setSettingPages: (t) => {
|
|
66
|
-
|
|
66
|
+
e.settingPages = t;
|
|
67
67
|
},
|
|
68
68
|
setLogout: (t) => {
|
|
69
|
-
|
|
69
|
+
e.logout = t;
|
|
70
70
|
},
|
|
71
71
|
enableLanguage: (t) => {
|
|
72
|
-
|
|
72
|
+
e.enableLanguage = t;
|
|
73
73
|
}
|
|
74
74
|
};
|
|
75
75
|
});
|
package/es/layout/typing.d.ts
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { RouteLocationNormalized } from 'vue-router';
|
|
2
2
|
export type RouteItem = Partial<RouteLocationNormalized> & {
|
|
3
|
-
fullPath: string;
|
|
4
|
-
path: string;
|
|
5
|
-
name: string;
|
|
6
|
-
hash: string;
|
|
7
3
|
meta: object;
|
|
8
|
-
params: object;
|
|
9
|
-
query: object;
|
|
10
4
|
};
|
|
11
5
|
export type LayoutState = {
|
|
12
6
|
title: string;
|
package/es/table/PTable.vue.js
CHANGED
|
@@ -114,7 +114,7 @@ const we = { class: "text-lg font-medium" }, be = { id: "data-content" }, Ce = {
|
|
|
114
114
|
k.value = !0;
|
|
115
115
|
try {
|
|
116
116
|
if (l.onLoad) {
|
|
117
|
-
var {
|
|
117
|
+
var { items: e, totalCount: t } = await l.onLoad(
|
|
118
118
|
u.value.page,
|
|
119
119
|
u.value.pageSize
|
|
120
120
|
);
|
package/es/table/typing.d.ts
CHANGED
|
@@ -19,8 +19,8 @@ export type DataTableProps = {
|
|
|
19
19
|
idField?: string;
|
|
20
20
|
columns: DataTableColumnDefine[];
|
|
21
21
|
onLoad: (page: number, pageSize: number) => Promise<{
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
items: any[];
|
|
23
|
+
totalCount: number;
|
|
24
24
|
}>;
|
|
25
25
|
onDelete?: (rows: any[]) => Promise<boolean>;
|
|
26
26
|
onAdd?: () => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.tabs-view[data-v-
|
|
1
|
+
.tabs-view[data-v-428fe23d]{width:100%;padding:6px 0;display:flex;transition:all .2s ease-in-out}.tabs-view-main[data-v-428fe23d]{height:32px;display:flex;max-width:100%;min-width:100%}.tabs-view-main .tabs-card[data-v-428fe23d]{-webkit-box-flex:1;flex-grow:1;flex-shrink:1;overflow:hidden;position:relative}.tabs-view-main .tabs-card .tabs-card-prev[data-v-428fe23d],.tabs-view-main .tabs-card .tabs-card-next[data-v-428fe23d]{width:32px;text-align:center;position:absolute;line-height:32px;cursor:pointer}.tabs-view-main .tabs-card .tabs-card-prev .n-icon[data-v-428fe23d],.tabs-view-main .tabs-card .tabs-card-next .n-icon[data-v-428fe23d]{display:flex;align-items:center;justify-content:center;height:32px;width:32px}.tabs-view-main .tabs-card .tabs-card-prev[data-v-428fe23d]{left:0}.tabs-view-main .tabs-card .tabs-card-next[data-v-428fe23d]{right:0}.tabs-view-main .tabs-card .tabs-card-next-hide[data-v-428fe23d],.tabs-view-main .tabs-card .tabs-card-prev-hide[data-v-428fe23d]{display:none}.tabs-view-main .tabs-card-scroll[data-v-428fe23d]{white-space:nowrap;overflow:hidden}.tabs-view-main .tabs-card-scroll-item[data-v-428fe23d]{background:var(--d48fbd46);color:var(--v380ec63c);height:32px;padding:6px 16px 4px;border-radius:3px;margin-right:6px;cursor:pointer;display:inline-block;position:relative;flex:0 0 auto}.tabs-view-main .tabs-card-scroll-item span[data-v-428fe23d]{float:left;vertical-align:middle}.tabs-view-main .tabs-card-scroll-item[data-v-428fe23d]:hover{color:#515a6e}.tabs-view-main .tabs-card-scroll-item .n-icon[data-v-428fe23d]{height:22px;width:21px;margin-right:-6px;position:relative;vertical-align:middle;text-align:center;color:#808695}.tabs-view-main .tabs-card-scroll-item .n-icon[data-v-428fe23d]:hover{color:#515a6e!important}.tabs-view-main .tabs-card-scroll-item .n-icon svg[data-v-428fe23d]{height:21px;display:inline-block}.tabs-view-main .tabs-card-scroll .active-item[data-v-428fe23d]{color:#2d8cf0}.tabs-view-main .tabs-card-scrollable[data-v-428fe23d]{padding:0 32px;overflow:hidden}.tabs-view .tabs-close[data-v-428fe23d]{min-width:32px;width:32px;height:32px;line-height:32px;text-align:center;background:var(--color);border-radius:2px;cursor:pointer}.tabs-view .tabs-close-btn[data-v-428fe23d]{color:var(--color);height:100%;display:flex;align-items:center;justify-content:center}.tabs-view-default-background[data-v-428fe23d]{background:#f5f7f9}.tabs-view-dark-background[data-v-428fe23d]{background:#101014}.tabs-view-fix[data-v-428fe23d]{position:fixed;z-index:5;padding:6px 10px;left:200px}.tabs-view-fixed-header[data-v-428fe23d]{top:0}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./PTabs.vue2.cjs");;/* empty css */const t=require("../../_virtual/_plugin-vue_export-helper.cjs"),u=t.default(e.default,[["__scopeId","data-v-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./PTabs.vue2.cjs");;/* empty css */const t=require("../../_virtual/_plugin-vue_export-helper.cjs"),u=t.default(e.default,[["__scopeId","data-v-428fe23d"]]);exports.default=u;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),B=require("element-resize-detector"),j=require("vuedraggable"),u=require("@vicons/antd"),S=require("vue-router"),r=require("naive-ui"),Y=require("../store.cjs"),F={class:"tabs-view-main"},U=["id","onClick","onContextmenu"],X={class:"tabs-close"},H={class:"tabs-close-btn"},J=t.defineComponent({__name:"PTabs",setup(G){t.useCssVars(e=>({d48fbd46:x.value,v380ec63c:T.value}));const b=r.useThemeVars(),x=t.computed(()=>b.value.cardColor),T=t.computed(()=>b.value.textColor1),k=r.useMessage(),c=S.useRoute(),f=S.useRouter(),s=t.ref(null),w=t.ref(null),g=t.ref(!1),i=Y.useLayoutStore(),d=t.computed(()=>i.state.tabs),a=t.reactive({activeKey:c.fullPath,scrollable:!0,dropdownX:0,dropdownY:0,showDropdown:!1,isMultiHeaderFixed:!0,multiTabsSetting:!0}),_=["Login","Redirect","ErrorPage"],v=e=>({meta:e.meta,name:e.name,fullPath:e.fullPath??e.path,path:e.path,hash:e.hash??"",query:e.query??{},params:e.params??{}}),V=t.computed(()=>{const l=i.state.collapsed?"64px":"272px";return{left:l,width:`calc(100% - ${l})`}}),C=t.computed(()=>{const e=d.value.length<=1;return[{label:"刷新当前",key:"1",icon:()=>t.h(r.NIcon,null,{default:()=>t.h(u.ReloadOutlined)})},{label:"关闭当前",key:"2",disabled:g.value||e,icon:()=>t.h(r.NIcon,null,{default:()=>t.h(u.CloseOutlined)})},{label:"关闭其他",key:"3",disabled:e,icon:()=>t.h(r.NIcon,null,{default:()=>t.h(u.ColumnWidthOutlined)})},{label:"关闭全部",key:"4",disabled:e,icon:()=>t.h(r.NIcon,null,{default:()=>t.h(u.MinusOutlined)})}]}),P=()=>{let e=[v(c)];f.getRoutes().filter(o=>o.meta.affix).forEach(o=>{const l=v(o);e.every(n=>n.name!==l.name)&&e.push(l)});try{if(i.state.cacheTabs){const o=localStorage.getItem("TABS_ROUTES");e=o?JSON.parse(o):e}}finally{return e}},E=e=>{const o=f.getRoutes();e.forEach(l=>{const n=o.find(m=>m.path===l.path);n&&(l.meta=n.meta||l.meta,l.name=n.name||l.name)}),i.state.cacheTabs&&localStorage.setItem("TABS_ROUTES",JSON.stringify(e))},O=()=>{const e=P();E(e),i.initTabs(e)},h=async e=>{if(await t.nextTick(),!s.value)return;const o=s.value.offsetWidth,l=s.value.scrollWidth;o<l?(a.scrollable=!0,e&&[...s.value.querySelectorAll(".tabs-card-scroll-item")||[]].forEach(m=>{m.id===`tag${a.activeKey.split("/").join("/")}`&&m.scrollIntoView&&m.scrollIntoView()})):a.scrollable=!1},W=e=>!(e.draggedContext.element.meta.affix||e.relatedContext.element.meta.affix),M=()=>{let e;e=B(),e.listenTo(w.value,()=>h(!0))},R=e=>{if(!e||e.fullPath===c.fullPath)return;if(a.activeKey=e.fullPath,toString.call(e)==="[object String]"){f.replace(e).catch(console.error);return}const o=e;f.replace(o).catch(console.error)},D=(e,o)=>{e.preventDefault(),g.value=o.path==="/home",a.showDropdown=!1,t.nextTick().then(()=>{a.showDropdown=!0,a.dropdownX=e.clientX,a.dropdownY=e.clientY})},I=()=>{if(c.meta.keepAlive){var e=f.currentRoute.value.matched.find(o=>o.name==c.name);e&&e.components?.default?.name}},N=e=>{if(d.value.length===1)return k.warning("这已经是最后一页,不能再关闭了!");if(I(),i.closeCurrentTab(e),a.activeKey===e.fullPath){const o=d.value[Math.max(0,d.value.length-1)];a.activeKey=o.fullPath,f.push(o)}h()},L=e=>{const o=d.value.find(l=>l.fullPath==e.fullPath);o&&N(o)},q=e=>{i.closeOtherTabs(e),a.activeKey=e.fullPath,h()},z=()=>{i.closeAllTabs(),h()},A=t.inject("reloadPage"),y=e=>{switch(e){case"1":A();break;case"2":N(c);break;case"3":q(c);break;case"4":z();break}h(),a.showDropdown=!1},p=(e,o)=>{const l=s.value.scrollLeft,n=o>0&&l+o>=e||o<0&&l+o<=e?e:l+o;if(s.value&&s.value.scrollTo(n,0),n!==e)return window.requestAnimationFrame(()=>p(e,o))},K=()=>{const e=s.value.offsetWidth,o=s.value.scrollLeft;if(!o)return;const l=o>e?o-e:0;p(l,(l-o)/20)},$=()=>{const e=s.value.offsetWidth,o=s.value.scrollWidth,l=s.value.scrollLeft;if(o-l<=e)return;const n=o-l>e*2?l+e:o-e;p(n,(n-l)/20)};return window.addEventListener("beforeunload",()=>{i.state.cacheTabs&&localStorage.setItem("TABS_ROUTES",JSON.stringify(d.value))}),window.addEventListener("scroll",e=>{let o=e.target.scrollTop||document.documentElement.scrollTop||window.pageYOffset||document.body.scrollTop;a.isMultiHeaderFixed=o>=64},!0),t.watch(()=>c.fullPath,e=>{_.includes(c.name)||(a.activeKey=e,i.addTab(v(c)),h(!0))},{immediate:!0}),O(),t.onMounted(()=>M()),(e,o)=>(t.openBlock(),t.createElementBlock("div",{class:"box-border tabs-view tabs-view-fix tabs-view-default-background",style:t.normalizeStyle(V.value)},[t.createElementVNode("div",F,[t.createElementVNode("div",{ref_key:"navWrap",ref:w,class:t.normalizeClass(["tabs-card",{"tabs-card-scrollable":a.scrollable}])},[t.createElementVNode("span",{class:t.normalizeClass(["tabs-card-prev",{"tabs-card-prev-hide":!a.scrollable}]),onClick:K},[t.createVNode(t.unref(r.NIcon),{size:"16",color:"#515a6e"},{default:t.withCtx(()=>[t.createVNode(t.unref(u.LeftOutlined))]),_:1})],2),t.createElementVNode("span",{class:t.normalizeClass(["tabs-card-next",{"tabs-card-next-hide":!a.scrollable}]),onClick:$},[t.createVNode(t.unref(r.NIcon),{size:"16",color:"#515a6e"},{default:t.withCtx(()=>[t.createVNode(t.unref(u.RightOutlined))]),_:1})],2),t.createElementVNode("div",{ref_key:"navScroll",ref:s,class:"tabs-card-scroll"},[t.createVNode(t.unref(j),{animation:"300","item-key":"fullPath",class:"flex",list:d.value,move:W},{item:t.withCtx(({element:l})=>[t.createElementVNode("div",{class:t.normalizeClass(["tabs-card-scroll-item",{"active-item":a.activeKey===l.fullPath}]),id:`tag${l.fullPath.split("/").join("/")}`,onClick:t.withModifiers(n=>R(l),["stop"]),onContextmenu:n=>D(n,l)},[t.createElementVNode("span",null,t.toDisplayString(l.meta.title),1),l.meta.affix?t.createCommentVNode("",!0):(t.openBlock(),t.createBlock(t.unref(r.NIcon),{key:0,size:"14",onClick:t.withModifiers(n=>L(l),["stop"])},{default:t.withCtx(()=>[t.createVNode(t.unref(u.CloseOutlined))]),_:1},8,["onClick"]))],42,U)]),_:1},8,["list"])],512)],2),t.createElementVNode("div",X,[t.createVNode(t.unref(r.NDropdown),{trigger:"hover",placement:"bottom-end",options:C.value,onSelect:y},{default:t.withCtx(()=>[t.createElementVNode("div",H,[t.createVNode(t.unref(r.NIcon),{size:"16",color:"#515a6e"},{default:t.withCtx(()=>[t.createVNode(t.unref(u.DownOutlined))]),_:1})])]),_:1},8,["options"])]),t.createVNode(t.unref(r.NDropdown),{placement:"bottom-start",show:a.showDropdown,x:a.dropdownX,y:a.dropdownY,options:C.value,onClickoutside:o[0]||(o[0]=l=>a.showDropdown=!1),onSelect:y},null,8,["show","x","y","options"])])],4))}});exports.default=J;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("vue"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("vue"),q=require("naive-ui"),g=require("vue-router"),B=require("../store.cjs"),b=a.defineComponent({__name:"PMenus",setup(k){const m=a.ref([]),c=g.useRoute(),h=g.useRouter(),M=B.useLayoutStore(),p=a.ref(c.name),u=a.ref(c.matched&&c.matched.length?c.matched.map(e=>e.name):[]),_=e=>{c.name!==e&&(/http(s)?:/.test(e)?window.open(e):h.push({name:e}))},w=e=>{if(!e)return;const n=e.find(r=>u.value.indexOf(r)===-1);u.value=n?[n]:[]},f=()=>{const e=c.matched;u.value=e.map(r=>r.name);const n=c.meta?.activeMenu||"";p.value=n||c.name},i=(e,n=[],r=!1)=>{const d=[],x=["/:path(.*)*","/redirect","/redirect/:path(.*)","/login","/oidc-callback"];if(!e||e.length===0)return d;e=e.sort((o,l)=>{let s=(l.children?.length?1:0)-(o.children?.length?1:0);return s===0&&(s=(o.meta?.sort??0)-(l.meta?.sort??0)),s});for(const o of e){if(r||o.meta?.hidden||x.includes(o.path.toLowerCase())){n.push(o.name),i(o.children||[],n,!0);continue}const l=o.children?.filter(S=>!S.meta?.hidden)||[],s=o.meta?.alwaysShow!=!0&&l.length===1,t=s?l[0]:o,v={key:t.name,label:t.meta?.title,affix:t.meta?.affix,sort:s?o.meta?.sort??0:t.meta?.sort??0,path:t.path,redirect:t.redirect,icon:s?o.meta?.icon:t.meta?.icon,permissions:t.meta?.permissions,meta:t.meta,children:void 0};n.includes(t.name)||(d.push(v),n.push(t.name)),t.children?.length>0&&(v.children=i(t.children,n,r))}return d},R=()=>{const e=h.getRoutes();m.value=i(e)};return a.watch(()=>c.fullPath,()=>{f()}),a.onMounted(()=>{R(),f()}),(e,n)=>(a.openBlock(),a.createBlock(a.unref(q.NMenu),{class:"h-full",inverted:"",mode:"vertical",options:m.value,collapsed:a.unref(M).state.collapsed,"collapsed-width":64,"collapsed-icon-size":20,indent:24,"expanded-keys":u.value,value:p.value,"onUpdate:value":_,"onUpdate:expandedKeys":w},null,8,["options","collapsed","expanded-keys","value"]))}});exports.default=b;
|
package/lib/layout/store.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("pinia"),n=require("vue"),i=["Redirect","RedirectSon","login"],
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("pinia"),n=require("vue"),i=["Redirect","RedirectSon","login"],f=o.defineStore("p-layout",()=>{const e=n.reactive({collapsed:!1,title:"输入项目名称",logo:"https://picsum.photos/id/1/100/100",avatar:"",uid:"",uname:"",tabs:[],cacheTabs:!1,enableLanguage:!1});return{state:e,initTabs:t=>{t.sort((s,a)=>s.meta.affix&&!a.meta.affix?-1:!s.meta.affix&&a.meta.affix?1:Number(a.meta.sort??0)-Number(s.meta.sort??0)),e.tabs=t},addTab:t=>i.includes(t.name)?!1:(e.tabs?.some(a=>a.fullPath==t.fullPath)||e.tabs?.push(t),!0),closeCurrentTab:t=>{const s=e.tabs.findIndex(a=>a.fullPath==t.fullPath);e.tabs.splice(s,1)},closeAllTabs:()=>{e.tabs=e.tabs.filter(t=>t?.meta?.affix??!1)},closeOtherTabs:t=>{e.tabs=e.tabs.filter(s=>s.fullPath==t.fullPath||(s?.meta?.affix??!1))},closeLeftTabs:t=>{const s=e.tabs.findIndex(a=>a.fullPath==t.fullPath);e.tabs=e.tabs.filter((a,l)=>l>=s||(a?.meta?.affix??!1))},closeRightTabs:t=>{const s=e.tabs.findIndex(a=>a.fullPath==t.fullPath);e.tabs=e.tabs.filter((a,l)=>l<=s||(a?.meta?.affix??!1))},collapse:()=>{e.collapsed=!e.collapsed},setTitle:t=>{e.title=t},setLogo:t=>{e.logo=t},setUser:(t,s)=>{e.uid=t,e.uname=s},setSettingPages:t=>{e.settingPages=t},setLogout:t=>{e.logout=t},enableLanguage:t=>{e.enableLanguage=t}}});exports.useLayoutStore=f;
|
package/lib/layout/store.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare const useLayoutStore: import('pinia').StoreDefinition<"p-layout",
|
|
|
8
8
|
avatar: string;
|
|
9
9
|
collapsed: boolean;
|
|
10
10
|
tabs: {
|
|
11
|
-
name
|
|
11
|
+
name?: import('vue-router').RouteRecordNameGeneric;
|
|
12
12
|
matched?: {
|
|
13
13
|
path: import('vue-router')._RouteRecordBase["path"];
|
|
14
14
|
redirect: string | ((to: import('vue-router').RouteLocation, from: import('vue-router').RouteLocationNormalizedLoaded) => import('vue-router').RouteLocationRaw) | {
|
|
@@ -3480,9 +3480,9 @@ export declare const useLayoutStore: import('pinia').StoreDefinition<"p-layout",
|
|
|
3480
3480
|
instances: Record<string, import('vue').ComponentPublicInstance | undefined | null>;
|
|
3481
3481
|
aliasOf: any | undefined;
|
|
3482
3482
|
}[] | undefined;
|
|
3483
|
-
fullPath
|
|
3484
|
-
query
|
|
3485
|
-
hash
|
|
3483
|
+
fullPath?: string | undefined;
|
|
3484
|
+
query?: import('vue-router').LocationQuery | undefined;
|
|
3485
|
+
hash?: string | undefined;
|
|
3486
3486
|
redirectedFrom?: {
|
|
3487
3487
|
matched: {
|
|
3488
3488
|
path: import('vue-router')._RouteRecordBase["path"];
|
|
@@ -6968,8 +6968,8 @@ export declare const useLayoutStore: import('pinia').StoreDefinition<"p-layout",
|
|
|
6968
6968
|
state?: import('vue-router').HistoryState | undefined;
|
|
6969
6969
|
} | undefined;
|
|
6970
6970
|
meta: import('vue-router').RouteMeta & object;
|
|
6971
|
-
path
|
|
6972
|
-
params
|
|
6971
|
+
path?: string | undefined;
|
|
6972
|
+
params?: import('vue-router').RouteParamsGeneric | undefined;
|
|
6973
6973
|
}[];
|
|
6974
6974
|
cacheTabs: boolean;
|
|
6975
6975
|
settingPages?: {
|
|
@@ -7005,7 +7005,7 @@ export declare const useLayoutStore: import('pinia').StoreDefinition<"p-layout",
|
|
|
7005
7005
|
avatar: string;
|
|
7006
7006
|
collapsed: boolean;
|
|
7007
7007
|
tabs: {
|
|
7008
|
-
name
|
|
7008
|
+
name?: import('vue-router').RouteRecordNameGeneric;
|
|
7009
7009
|
matched?: {
|
|
7010
7010
|
path: import('vue-router')._RouteRecordBase["path"];
|
|
7011
7011
|
redirect: string | ((to: import('vue-router').RouteLocation, from: import('vue-router').RouteLocationNormalizedLoaded) => import('vue-router').RouteLocationRaw) | {
|
|
@@ -10477,9 +10477,9 @@ export declare const useLayoutStore: import('pinia').StoreDefinition<"p-layout",
|
|
|
10477
10477
|
instances: Record<string, import('vue').ComponentPublicInstance | undefined | null>;
|
|
10478
10478
|
aliasOf: any | undefined;
|
|
10479
10479
|
}[] | undefined;
|
|
10480
|
-
fullPath
|
|
10481
|
-
query
|
|
10482
|
-
hash
|
|
10480
|
+
fullPath?: string | undefined;
|
|
10481
|
+
query?: import('vue-router').LocationQuery | undefined;
|
|
10482
|
+
hash?: string | undefined;
|
|
10483
10483
|
redirectedFrom?: {
|
|
10484
10484
|
matched: {
|
|
10485
10485
|
path: import('vue-router')._RouteRecordBase["path"];
|
|
@@ -13965,8 +13965,8 @@ export declare const useLayoutStore: import('pinia').StoreDefinition<"p-layout",
|
|
|
13965
13965
|
state?: import('vue-router').HistoryState | undefined;
|
|
13966
13966
|
} | undefined;
|
|
13967
13967
|
meta: import('vue-router').RouteMeta & object;
|
|
13968
|
-
path
|
|
13969
|
-
params
|
|
13968
|
+
path?: string | undefined;
|
|
13969
|
+
params?: import('vue-router').RouteParamsGeneric | undefined;
|
|
13970
13970
|
}[];
|
|
13971
13971
|
cacheTabs: boolean;
|
|
13972
13972
|
settingPages?: {
|
|
@@ -14002,7 +14002,7 @@ export declare const useLayoutStore: import('pinia').StoreDefinition<"p-layout",
|
|
|
14002
14002
|
avatar: string;
|
|
14003
14003
|
collapsed: boolean;
|
|
14004
14004
|
tabs: {
|
|
14005
|
-
name
|
|
14005
|
+
name?: import('vue-router').RouteRecordNameGeneric;
|
|
14006
14006
|
matched?: {
|
|
14007
14007
|
path: import('vue-router')._RouteRecordBase["path"];
|
|
14008
14008
|
redirect: string | ((to: import('vue-router').RouteLocation, from: import('vue-router').RouteLocationNormalizedLoaded) => import('vue-router').RouteLocationRaw) | {
|
|
@@ -17474,9 +17474,9 @@ export declare const useLayoutStore: import('pinia').StoreDefinition<"p-layout",
|
|
|
17474
17474
|
instances: Record<string, import('vue').ComponentPublicInstance | undefined | null>;
|
|
17475
17475
|
aliasOf: any | undefined;
|
|
17476
17476
|
}[] | undefined;
|
|
17477
|
-
fullPath
|
|
17478
|
-
query
|
|
17479
|
-
hash
|
|
17477
|
+
fullPath?: string | undefined;
|
|
17478
|
+
query?: import('vue-router').LocationQuery | undefined;
|
|
17479
|
+
hash?: string | undefined;
|
|
17480
17480
|
redirectedFrom?: {
|
|
17481
17481
|
matched: {
|
|
17482
17482
|
path: import('vue-router')._RouteRecordBase["path"];
|
|
@@ -20962,8 +20962,8 @@ export declare const useLayoutStore: import('pinia').StoreDefinition<"p-layout",
|
|
|
20962
20962
|
state?: import('vue-router').HistoryState | undefined;
|
|
20963
20963
|
} | undefined;
|
|
20964
20964
|
meta: import('vue-router').RouteMeta & object;
|
|
20965
|
-
path
|
|
20966
|
-
params
|
|
20965
|
+
path?: string | undefined;
|
|
20966
|
+
params?: import('vue-router').RouteParamsGeneric | undefined;
|
|
20967
20967
|
}[];
|
|
20968
20968
|
cacheTabs: boolean;
|
|
20969
20969
|
settingPages?: {
|
package/lib/layout/typing.d.ts
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { RouteLocationNormalized } from 'vue-router';
|
|
2
2
|
export type RouteItem = Partial<RouteLocationNormalized> & {
|
|
3
|
-
fullPath: string;
|
|
4
|
-
path: string;
|
|
5
|
-
name: string;
|
|
6
|
-
hash: string;
|
|
7
3
|
meta: object;
|
|
8
|
-
params: object;
|
|
9
|
-
query: object;
|
|
10
4
|
};
|
|
11
5
|
export type LayoutState = {
|
|
12
6
|
title: string;
|
package/lib/table/PTable.vue.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("naive-ui"),e=require("vue"),u=require("@vicons/antd"),K={class:"text-lg font-medium"},X={id:"data-content"},Y={key:0,class:"rounded-lg bg-gray-50 flex flex-row gap-2 items-center justify-end p-4 mb-4"},G=e.defineComponent({__name:"PTable",props:{title:{},idField:{default:"id"},columns:{},onLoad:{},onDelete:{},onAdd:{},onEdit:{}},setup(y,{expose:S}){const N=e.ref(null),D=a.useDialog(),g=a.useMessage(),p=e.ref(!1),h=e.ref([]),m=e.ref([]),c=e.ref({page:1,itemCount:0,pageSize:10,pageSizes:[10,20,30,50],showSizePicker:!0,onChange:async t=>{c.value.page=t,await d()},onUpdatePageSize:async t=>{c.value.pageSize=t,await d()}}),i=y,B=t=>{const o=n=>{const l=[];return t&&t.forEach(r=>{r.key!=="edit"&&r.key!=="delete"&&l.push({label:r.name,key:r.key,icon:r.icon&&(()=>e.h(a.NIcon,null,{default:()=>e.h(r.icon)})),props:{onClick:()=>r.action(n)}})}),l};return{title:"操作",key:"actions",width:100,fixed:"right",render:n=>{let l=[];if(i.onEdit&&l.push({label:"编辑",key:"edit",icon:()=>e.h(a.NIcon,null,{default:()=>e.h(u.EditOutlined)}),props:{onClick:async()=>await i.onEdit(n)}}),i.onDelete&&l.push({label:"删除",key:"delete",icon:()=>e.h(a.NIcon,null,{default:()=>e.h(u.DeleteOutlined)}),props:{onClick:()=>R(n)}}),l=[...l,...o(n)],!(l.length<=0))return e.h(a.NDropdown,{options:l,placement:"bottom-start"},{default:()=>e.h(a.NButton,{size:"small",type:"primary"},{default:()=>["操作",e.h(a.NIcon,()=>e.h(u.MoreOutlined))]})})}}},O=e.computed(()=>{const t=i.columns.filter(n=>n.key!="action").map(n=>({title:n.title,key:n.key,width:n.width,fixed:n.fixed??!1,render:n.render,ellipsis:n.ellipsis?{tooltip:!0}:!1})),o=i.columns.reduce((n,l)=>l.key==="action"?l:n,void 0)?.action;return o&&o?.length>0||i.onEdit||i.onDelete?[{type:"selection",fixed:"left"},...t,B(o)]:[{type:"selection",fixed:"left"},...t]}),T=async()=>await d(),R=t=>x([t]),I=()=>{const t=k();x(t)},x=t=>{t&&t.length>0&&D.warning({title:"警告",content:"删除数据不可恢复, 确认删除吗?",positiveText:"确定",negativeText:"取消",onPositiveClick:async()=>{if(i.onDelete)try{await i.onDelete(t)?(d(),g.success("删除成功")):g.error("删除失败")}catch(o){g.error(o.message)}}})},k=()=>h.value?m.value.filter(o=>h.value.includes(o.id)).map(o=>e.toRaw(o)):[],z=()=>k()[0],L=()=>e.toRaw(m.value),d=async()=>{if(!p.value){p.value=!0;try{if(i.onLoad){var{
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("naive-ui"),e=require("vue"),u=require("@vicons/antd"),K={class:"text-lg font-medium"},X={id:"data-content"},Y={key:0,class:"rounded-lg bg-gray-50 flex flex-row gap-2 items-center justify-end p-4 mb-4"},G=e.defineComponent({__name:"PTable",props:{title:{},idField:{default:"id"},columns:{},onLoad:{},onDelete:{},onAdd:{},onEdit:{}},setup(y,{expose:S}){const N=e.ref(null),D=a.useDialog(),g=a.useMessage(),p=e.ref(!1),h=e.ref([]),m=e.ref([]),c=e.ref({page:1,itemCount:0,pageSize:10,pageSizes:[10,20,30,50],showSizePicker:!0,onChange:async t=>{c.value.page=t,await d()},onUpdatePageSize:async t=>{c.value.pageSize=t,await d()}}),i=y,B=t=>{const o=n=>{const l=[];return t&&t.forEach(r=>{r.key!=="edit"&&r.key!=="delete"&&l.push({label:r.name,key:r.key,icon:r.icon&&(()=>e.h(a.NIcon,null,{default:()=>e.h(r.icon)})),props:{onClick:()=>r.action(n)}})}),l};return{title:"操作",key:"actions",width:100,fixed:"right",render:n=>{let l=[];if(i.onEdit&&l.push({label:"编辑",key:"edit",icon:()=>e.h(a.NIcon,null,{default:()=>e.h(u.EditOutlined)}),props:{onClick:async()=>await i.onEdit(n)}}),i.onDelete&&l.push({label:"删除",key:"delete",icon:()=>e.h(a.NIcon,null,{default:()=>e.h(u.DeleteOutlined)}),props:{onClick:()=>R(n)}}),l=[...l,...o(n)],!(l.length<=0))return e.h(a.NDropdown,{options:l,placement:"bottom-start"},{default:()=>e.h(a.NButton,{size:"small",type:"primary"},{default:()=>["操作",e.h(a.NIcon,()=>e.h(u.MoreOutlined))]})})}}},O=e.computed(()=>{const t=i.columns.filter(n=>n.key!="action").map(n=>({title:n.title,key:n.key,width:n.width,fixed:n.fixed??!1,render:n.render,ellipsis:n.ellipsis?{tooltip:!0}:!1})),o=i.columns.reduce((n,l)=>l.key==="action"?l:n,void 0)?.action;return o&&o?.length>0||i.onEdit||i.onDelete?[{type:"selection",fixed:"left"},...t,B(o)]:[{type:"selection",fixed:"left"},...t]}),T=async()=>await d(),R=t=>x([t]),I=()=>{const t=k();x(t)},x=t=>{t&&t.length>0&&D.warning({title:"警告",content:"删除数据不可恢复, 确认删除吗?",positiveText:"确定",negativeText:"取消",onPositiveClick:async()=>{if(i.onDelete)try{await i.onDelete(t)?(d(),g.success("删除成功")):g.error("删除失败")}catch(o){g.error(o.message)}}})},k=()=>h.value?m.value.filter(o=>h.value.includes(o.id)).map(o=>e.toRaw(o)):[],z=()=>k()[0],L=()=>e.toRaw(m.value),d=async()=>{if(!p.value){p.value=!0;try{if(i.onLoad){var{items:t,totalCount:o}=await i.onLoad(c.value.page,c.value.pageSize);m.value=t,c.value.itemCount=o}}catch(n){g.error(n.message)}finally{p.value=!1}}},H=e.computed(()=>{const t=e.unref(N);if(!t)return;const o=t?.$el,n=o.querySelector(".n-data-table-thead "),{bottomIncludeBody:l}=$(n),r=48;let s=12,w=25;const f=o.querySelector(".n-data-table__pagination");if(f){const v=f.offsetHeight;s+=v||0}else s+=28;return l-(r+s+w)}),P=t=>!t||!t.getBoundingClientRect?0:t.getBoundingClientRect(),$=t=>{const o=document.documentElement,n=o.scrollLeft,l=o.scrollTop,r=o.clientLeft,s=o.clientTop,w=window.pageXOffset,f=window.pageYOffset,_=P(t),{left:v,top:q,width:M,height:A}=_,j=(w||n)-(r||0),U=(f||l)-(s||0),W=v+w,F=q+f,C=W-j,b=F-U,V=window.document.documentElement.clientWidth,E=window.document.documentElement.clientHeight;return{left:C,top:b,right:V-M-C,bottom:E-A-b,rightIncludeBody:V-C,bottomIncludeBody:E-b}};return e.onMounted(async()=>await d()),S({getData:L,getSelectedRow:z,getSelectedRows:k,refreshData:d,resetPage:()=>{c.value.page=1}}),(t,o)=>{const n=a.NTooltip,l=a.NSpace,r=a.NDataTable;return e.openBlock(),e.createBlock(e.unref(a.NCard),{bordered:!1},{header:e.withCtx(()=>[e.createVNode(l,{justify:"space-between",align:"center",class:"w-full"},{default:e.withCtx(()=>[e.createElementVNode("span",K,e.toDisplayString(y.title),1),e.createVNode(l,null,{default:e.withCtx(()=>[i.onAdd?(e.openBlock(),e.createBlock(n,{key:0,trigger:"hover"},{trigger:e.withCtx(()=>[e.createVNode(e.unref(a.NIcon),{size:"18",class:"mr-1 cursor-pointer hover:text-blue-600",onClick:i.onAdd},{default:e.withCtx(()=>[e.createVNode(e.unref(u.PlusSquareOutlined))]),_:1},8,["onClick"])]),default:e.withCtx(()=>[o[1]||(o[1]=e.createElementVNode("span",null,"新增",-1))]),_:1})):e.createCommentVNode("",!0),i.onDelete?(e.openBlock(),e.createBlock(n,{key:1,trigger:"hover"},{trigger:e.withCtx(()=>[e.createVNode(e.unref(a.NIcon),{size:"18",class:"mr-1 cursor-pointer hover:text-blue-600",onClick:I},{default:e.withCtx(()=>[e.createVNode(e.unref(u.DeleteOutlined))]),_:1})]),default:e.withCtx(()=>[o[2]||(o[2]=e.createElementVNode("span",null,"删除",-1))]),_:1})):e.createCommentVNode("",!0),e.createVNode(n,{trigger:"hover"},{trigger:e.withCtx(()=>[e.createVNode(e.unref(a.NIcon),{size:"18",class:"cursor-pointer hover:text-blue-600",onClick:T},{default:e.withCtx(()=>[e.createVNode(e.unref(u.ReloadOutlined))]),_:1})]),default:e.withCtx(()=>[o[3]||(o[3]=e.createElementVNode("span",null,"刷新",-1))]),_:1})]),_:1})]),_:1})]),default:e.withCtx(()=>[e.createElementVNode("div",X,[t.$slots.toolbar?(e.openBlock(),e.createElementBlock("div",Y,[e.renderSlot(t.$slots,"toolbar")])):e.createCommentVNode("",!0),e.createVNode(r,{remote:"",ref_key:"$table",ref:N,"checked-row-keys":h.value,"onUpdate:checkedRowKeys":o[0]||(o[0]=s=>h.value=s),"max-height":H.value,loading:p.value,bordered:!1,"single-line":!1,columns:O.value,data:m.value,pagination:c.value,"row-key":s=>s[y.idField]},null,8,["checked-row-keys","max-height","loading","columns","data","pagination","row-key"])])]),_:3})}}});exports.default=G;
|
package/lib/table/typing.d.ts
CHANGED
|
@@ -19,8 +19,8 @@ export type DataTableProps = {
|
|
|
19
19
|
idField?: string;
|
|
20
20
|
columns: DataTableColumnDefine[];
|
|
21
21
|
onLoad: (page: number, pageSize: number) => Promise<{
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
items: any[];
|
|
23
|
+
totalCount: number;
|
|
24
24
|
}>;
|
|
25
25
|
onDelete?: (rows: any[]) => Promise<boolean>;
|
|
26
26
|
onAdd?: () => Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chewel611/naive-ui-plus",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.42",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"sideEffects": false,
|
|
@@ -48,10 +48,11 @@
|
|
|
48
48
|
"@tailwindcss/vite": "^4.1.18",
|
|
49
49
|
"@types/element-resize-detector": "^1.1.6",
|
|
50
50
|
"@types/minimist": "^1.2.5",
|
|
51
|
-
"@types/node": "^24.
|
|
51
|
+
"@types/node": "^24.12.0",
|
|
52
52
|
"@vicons/antd": "^0.13.0",
|
|
53
53
|
"@vitejs/plugin-vue": "^6.0.4",
|
|
54
54
|
"@vue/tsconfig": "^0.8.1",
|
|
55
|
+
"alova": "^3.5.1",
|
|
55
56
|
"less": "^4.4.0",
|
|
56
57
|
"less-loader": "^12.3.0",
|
|
57
58
|
"minimist": "^1.2.8",
|