@peng_kai/kit 0.3.0-beta.1 → 0.3.0-beta.11
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/.vscode/settings.json +2 -2
- package/admin/components/currency/src/CurrencyIcon.vue +35 -33
- package/admin/components/date/PeriodPicker.vue +122 -0
- package/admin/components/date/TimeFieldSelectForLabel.vue +24 -0
- package/admin/components/date/TtaTimeZone.vue +516 -0
- package/admin/components/date/helpers.ts +223 -0
- package/admin/components/date/index.ts +4 -0
- package/admin/components/filter/src/FilterReset.vue +39 -7
- package/admin/components/filter/src/more/TableSetting.vue +63 -0
- package/admin/components/provider/Admin.vue +17 -0
- package/admin/components/provider/admin-permission.ts +48 -0
- package/admin/components/provider/admin-router.ts +358 -0
- package/admin/components/provider/index.ts +3 -0
- package/admin/components/text/index.ts +2 -0
- package/admin/components/text/src/Amount.v2.vue +127 -0
- package/admin/components/text/src/Datetime.vue +15 -11
- package/admin/components/text/src/Num.vue +192 -0
- package/admin/components/upload/src/customRequests.ts +1 -1
- package/admin/components/upload/src/helpers.ts +1 -0
- package/admin/layout/large/Breadcrumb.vue +10 -23
- package/admin/layout/large/Content.vue +9 -6
- package/admin/layout/large/Layout.vue +129 -0
- package/admin/layout/large/Menu.vue +24 -17
- package/admin/layout/large/Notice.vue +140 -0
- package/admin/layout/large/Tabs.vue +177 -0
- package/admin/layout/large/index.ts +61 -1
- package/admin/layout/large/y682.mp3 +0 -0
- package/admin/permission/routerGuard.ts +15 -8
- package/admin/permission/vuePlugin.ts +5 -10
- package/admin/route-guards/index.ts +0 -1
- package/admin/stores/index.ts +1 -0
- package/admin/styles/classCover.scss +1 -1
- package/admin/styles/globalCover.scss +4 -0
- package/admin/styles/index.scss +2 -2
- package/antd/hooks/useAntdForm.helpers.ts +10 -1
- package/antd/hooks/useAntdModal.ts +20 -8
- package/antd/hooks/useAntdTable.ts +52 -2
- package/antd/hooks/useAntdTheme.ts +7 -0
- package/antd/index.ts +1 -1
- package/libs/bignumber.ts +1 -1
- package/libs/dayjs.ts +11 -1
- package/libs/fingerprintjs.ts +1 -0
- package/package.json +95 -95
- package/request/interceptors/getDeviceInfo.ts +9 -0
- package/utils/LocaleManager.ts +1 -1
- package/utils/locale/LocaleManager.ts +2 -1
- package/utils/number.ts +1 -2
- package/utils/storage.ts +31 -0
- package/utils/string.ts +14 -0
- package/utils/upload/AwsS3.ts +10 -3
- package/admin/layout/large/PageTab.vue +0 -70
- package/admin/route-guards/collapseMenu.ts +0 -11
- package/libs/a-calc.ts +0 -1
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref } from 'vue';
|
|
3
|
+
import { autoResetRef, useEventListener, useMutationObserver, useResizeObserver } from '@vueuse/core';
|
|
4
|
+
import type { TTab } from '../../components/provider/admin-router';
|
|
5
|
+
|
|
6
|
+
const props = defineProps<{
|
|
7
|
+
current: TTab
|
|
8
|
+
tabs: TTab[]
|
|
9
|
+
}>();
|
|
10
|
+
const emits = defineEmits<{
|
|
11
|
+
close: [TTab]
|
|
12
|
+
open: [TTab]
|
|
13
|
+
refresh: [TTab]
|
|
14
|
+
}>();
|
|
15
|
+
|
|
16
|
+
const $tabList = ref<HTMLElement>();
|
|
17
|
+
const refreshAnim = autoResetRef(false, 300);
|
|
18
|
+
const isLeftmost = ref(false);
|
|
19
|
+
const isRightmost = ref(false);
|
|
20
|
+
|
|
21
|
+
useEventListener($tabList, 'wheel', (e) => {
|
|
22
|
+
if ($tabList.value) {
|
|
23
|
+
const deltaY = e.deltaY < 0 ? -100 : 100;
|
|
24
|
+
$tabList.value.scrollLeft += deltaY;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
function isScrollEnd() {
|
|
29
|
+
if ($tabList.value) {
|
|
30
|
+
const { scrollLeft, scrollWidth, clientWidth } = $tabList.value;
|
|
31
|
+
isRightmost.value = scrollLeft === 0;
|
|
32
|
+
isLeftmost.value = Math.ceil(Math.abs(scrollLeft) + clientWidth) >= scrollWidth;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function refresh(tab: TTab) {
|
|
37
|
+
if (!refreshAnim.value) {
|
|
38
|
+
refreshAnim.value = true;
|
|
39
|
+
emits('refresh', tab);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
useEventListener($tabList, 'scroll', isScrollEnd);
|
|
44
|
+
useResizeObserver($tabList, isScrollEnd);
|
|
45
|
+
useMutationObserver($tabList, isScrollEnd, { childList: true });
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<template>
|
|
49
|
+
<div class="flex items-center">
|
|
50
|
+
<div ref="$tabList" class="tab-list relative ml-auto" :class="{ 'is-leftmost': isLeftmost, 'is-rightmost': isRightmost }">
|
|
51
|
+
<div
|
|
52
|
+
v-for="tab of props.tabs" :key="tab.path"
|
|
53
|
+
class="tab" :class="{ opened: tab.path === props.current?.path }"
|
|
54
|
+
@click="emits('open', tab)"
|
|
55
|
+
>
|
|
56
|
+
<span class="title">{{ tab.title }}</span>
|
|
57
|
+
<span v-if="tab.type !== 2 && props.tabs.length > 1" class="close-btn" @click.stop="emits('close', tab)">
|
|
58
|
+
<i class="i-material-symbols:close-rounded" />
|
|
59
|
+
</span>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
<div v-memo="[refreshAnim]" class="operation-btn ml-2" @click="refresh(props.current)">
|
|
63
|
+
<i class="i-material-symbols:refresh-rounded" :class="{ 'refresh-spin': refreshAnim }" />
|
|
64
|
+
</div>
|
|
65
|
+
</div>
|
|
66
|
+
</template>
|
|
67
|
+
|
|
68
|
+
<style lang="scss" scoped>
|
|
69
|
+
.tab-list {
|
|
70
|
+
display: flex;
|
|
71
|
+
gap: 4px;
|
|
72
|
+
align-items: center;
|
|
73
|
+
overflow-x: auto;
|
|
74
|
+
scrollbar-width: none;
|
|
75
|
+
flex: 1;
|
|
76
|
+
mask-image: linear-gradient(to left, #0000 0%, #000 5%, #000 95%, #0000 100%);
|
|
77
|
+
direction: rtl;
|
|
78
|
+
|
|
79
|
+
&.is-leftmost:not(.is-rightmost) {
|
|
80
|
+
mask-image: linear-gradient(to right, #000 0%, #000 5%, #000 95%, #0000 100%);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
&.is-rightmost:not(.is-leftmost) {
|
|
84
|
+
mask-image: linear-gradient(to left, #000 0%, #000 5%, #000 95%, #0000 100%);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
&.is-leftmost.is-rightmost {
|
|
88
|
+
mask-image: none;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.tab {
|
|
93
|
+
position: relative;
|
|
94
|
+
display: flex;
|
|
95
|
+
align-items: center;
|
|
96
|
+
padding: 0 8px;
|
|
97
|
+
height: 28px;
|
|
98
|
+
font-size: 14px;
|
|
99
|
+
cursor: pointer;
|
|
100
|
+
border-radius: 4px;
|
|
101
|
+
transition: all 0.2s;
|
|
102
|
+
white-space: nowrap;
|
|
103
|
+
line-height: 1em;
|
|
104
|
+
color: var(--antd-colorTextTertiary);
|
|
105
|
+
|
|
106
|
+
&:not(.opened):hover {
|
|
107
|
+
color: var(--antd-colorText);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
&.opened {
|
|
111
|
+
color: var(--antd-colorPrimary);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.title {
|
|
115
|
+
transition: transform 0.1s;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
&:has(.close-btn):hover .title {
|
|
119
|
+
transform: translateX(-4px);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.close-btn {
|
|
123
|
+
position: absolute;
|
|
124
|
+
right: -6px;
|
|
125
|
+
display: flex;
|
|
126
|
+
align-items: center;
|
|
127
|
+
width: 1em;
|
|
128
|
+
height: 1em;
|
|
129
|
+
padding: 2px;
|
|
130
|
+
opacity: 0;
|
|
131
|
+
margin-bottom: -1px;
|
|
132
|
+
transition: all 0.2s;
|
|
133
|
+
transform: scale(0);
|
|
134
|
+
color: var(--antd-colorTextTertiary);
|
|
135
|
+
|
|
136
|
+
&:hover {
|
|
137
|
+
color: var(--antd-colorText);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
&:hover .close-btn {
|
|
142
|
+
margin-left: 0;
|
|
143
|
+
opacity: 1;
|
|
144
|
+
transform: scale(1);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.operation-btn {
|
|
149
|
+
flex: none;
|
|
150
|
+
display: flex;
|
|
151
|
+
align-items: center;
|
|
152
|
+
justify-content: center;
|
|
153
|
+
height: 28px;
|
|
154
|
+
font-size: 18px;
|
|
155
|
+
cursor: pointer;
|
|
156
|
+
border-radius: 4px;
|
|
157
|
+
|
|
158
|
+
&:hover {
|
|
159
|
+
color: var(--antd-colorPrimaryText);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.refresh-spin {
|
|
164
|
+
& {
|
|
165
|
+
animation: spin 200ms linear;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
@keyframes spin {
|
|
169
|
+
0% {
|
|
170
|
+
transform: rotate(0deg);
|
|
171
|
+
}
|
|
172
|
+
100% {
|
|
173
|
+
transform: rotate(360deg);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
</style>
|
|
@@ -1,4 +1,64 @@
|
|
|
1
1
|
export { default as Breadcrumb } from './Breadcrumb.vue';
|
|
2
2
|
export { default as Content } from './Content.vue';
|
|
3
3
|
export { default as Menu } from './Menu.vue';
|
|
4
|
-
export { default as
|
|
4
|
+
export { default as Tabs } from './Tabs.vue';
|
|
5
|
+
export { default as Layout } from './Layout.vue';
|
|
6
|
+
export { default as Notice } from './Notice.vue';
|
|
7
|
+
|
|
8
|
+
/* #B 优化表格水平滚动(测试版方案) */
|
|
9
|
+
const antTableHeaders = new WeakSet<HTMLElement>();
|
|
10
|
+
setInterval(() => {
|
|
11
|
+
const $header = document.querySelector('.antd-cover__table-sticky-pagination .ant-table-header') as HTMLElement;
|
|
12
|
+
|
|
13
|
+
if (!$header || antTableHeaders.has($header))
|
|
14
|
+
return;
|
|
15
|
+
|
|
16
|
+
antTableHeaders.add($header);
|
|
17
|
+
$header.addEventListener('wheel', (ev) => {
|
|
18
|
+
ev.preventDefault();
|
|
19
|
+
const $body = (ev.currentTarget as HTMLElement).parentElement?.querySelector(':scope > .ant-table-body');
|
|
20
|
+
|
|
21
|
+
if ($body) {
|
|
22
|
+
const left = $body.scrollLeft + (ev.deltaY < 0 ? -100 : 100);
|
|
23
|
+
$body.scroll({ left });
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
const tipsKey = 'HIDDEN_TABLE_HORIZONTAL_SCROLLING_PROMPT';
|
|
28
|
+
const hiddenTips = localStorage.getItem(tipsKey);
|
|
29
|
+
|
|
30
|
+
if (!hiddenTips) {
|
|
31
|
+
const tips = `将鼠标指针移至表头,通过滚动鼠标滚轮来水平滑动表格(点击可关闭此提示)`;
|
|
32
|
+
const ctn = document.createElement('div');
|
|
33
|
+
ctn.className = `pos-sticky left-0 top-0 w-full h-full bg-$antd-colorPrimary text-center lh-relaxed text-white`;
|
|
34
|
+
ctn.innerHTML = tips;
|
|
35
|
+
ctn.onclick = () => {
|
|
36
|
+
ctn.remove();
|
|
37
|
+
localStorage.setItem(tipsKey, '1');
|
|
38
|
+
};
|
|
39
|
+
$header.appendChild(ctn);
|
|
40
|
+
}
|
|
41
|
+
}, 1000);
|
|
42
|
+
/* #E */
|
|
43
|
+
|
|
44
|
+
/* #B 高亮最后一次操作的表格行 */
|
|
45
|
+
window.addEventListener('click', (ev) => {
|
|
46
|
+
const targetEle = ev.target as HTMLElement;
|
|
47
|
+
const closestRow = targetEle.closest('.ant-table-row');
|
|
48
|
+
|
|
49
|
+
if (closestRow) {
|
|
50
|
+
document.querySelectorAll('.last-clicked-cell').forEach((cell) => {
|
|
51
|
+
cell.classList.remove('ant-table-cell-row-hover');
|
|
52
|
+
cell.classList.remove('last-clicked-cell');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const cells = closestRow.querySelectorAll(':scope > .ant-table-cell');
|
|
56
|
+
setTimeout(() => {
|
|
57
|
+
cells.forEach((cell) => {
|
|
58
|
+
cell.classList.add('ant-table-cell-row-hover');
|
|
59
|
+
cell.classList.add('last-clicked-cell');
|
|
60
|
+
});
|
|
61
|
+
}, 300);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
/* #E */
|
|
Binary file
|
|
@@ -1,24 +1,31 @@
|
|
|
1
1
|
import type { Router } from 'vue-router';
|
|
2
|
-
import { adminPlugin } from '../adminPlugin';
|
|
3
2
|
import { hasToken } from '../../utils';
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
interface TPermission {
|
|
5
|
+
refresh: () => Promise<any>
|
|
6
|
+
has: (code: string) => boolean
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function setupPermissionRouterGuard(
|
|
10
|
+
router: Router,
|
|
11
|
+
permission: TPermission | undefined,
|
|
12
|
+
rouneNames: { index: string, login: string, 403: string },
|
|
13
|
+
) {
|
|
6
14
|
router.beforeEach(async (to, _, next) => {
|
|
7
|
-
const permissionStore = adminPlugin.deps.usePermissionStore();
|
|
8
15
|
const isLogin = hasToken();
|
|
9
16
|
const needLogin = Boolean(to.meta?.requireAuth);
|
|
10
17
|
let hasPermission = false;
|
|
11
18
|
|
|
12
19
|
if (isLogin) {
|
|
13
|
-
await
|
|
20
|
+
await permission?.refresh();
|
|
14
21
|
|
|
15
22
|
const permissionCode = to.meta?.permissionCode;
|
|
16
|
-
hasPermission = permissionCode ?
|
|
23
|
+
hasPermission = permissionCode ? (permission?.has(permissionCode) ?? true) : true;
|
|
17
24
|
}
|
|
18
25
|
|
|
19
26
|
// 已登录状态跳转登录页,跳转至首页
|
|
20
27
|
if (isLogin && to.name === rouneNames.login)
|
|
21
|
-
return next({ name: rouneNames.index, replace: true });
|
|
28
|
+
return next({ name: rouneNames.index, replace: true, state: { tabType: 2 } });
|
|
22
29
|
|
|
23
30
|
// 不需要登录权限的页面直接通行
|
|
24
31
|
else if (!needLogin)
|
|
@@ -26,7 +33,7 @@ export function setupPermissionRouterGuard(router: Router, rouneNames: { index:
|
|
|
26
33
|
|
|
27
34
|
// 未登录状态进入需要登录权限的页面
|
|
28
35
|
else if (!isLogin && needLogin)
|
|
29
|
-
return next({ name: rouneNames.login,
|
|
36
|
+
return next({ name: rouneNames.login, query: { redirect: to.fullPath }, state: { tabType: 0 }, replace: true });
|
|
30
37
|
|
|
31
38
|
// 登录状态进入需要登录权限的页面,有权限直接通行
|
|
32
39
|
else if (isLogin && needLogin && hasPermission)
|
|
@@ -34,7 +41,7 @@ export function setupPermissionRouterGuard(router: Router, rouneNames: { index:
|
|
|
34
41
|
|
|
35
42
|
// 登录状态进入需要登录权限的页面,无权限,重定向到无权限页面
|
|
36
43
|
else if (isLogin && needLogin && !hasPermission)
|
|
37
|
-
return next({ name: rouneNames[403], replace: true });
|
|
44
|
+
return next({ name: rouneNames[403], state: { tabType: 0 }, replace: true });
|
|
38
45
|
|
|
39
46
|
return next(false);
|
|
40
47
|
});
|
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
import type { App } from 'vue';
|
|
2
2
|
import { watch } from 'vue';
|
|
3
|
-
import {
|
|
3
|
+
import type { createAdminPermission } from '../components/provider/admin-permission';
|
|
4
4
|
|
|
5
5
|
type TCodes = string | string[];
|
|
6
6
|
|
|
7
7
|
const PLUGIN_NAME = 'has-permission';
|
|
8
8
|
const UNWATCH_NAME = `v-${PLUGIN_NAME}@unwatch`;
|
|
9
9
|
|
|
10
|
-
export function setupPermissionPlugin(app: App) {
|
|
10
|
+
export function setupPermissionPlugin(app: App, permission: ReturnType<typeof createAdminPermission>) {
|
|
11
11
|
app.directive<HTMLElement, TCodes>(PLUGIN_NAME, {
|
|
12
12
|
mounted(el, binding) {
|
|
13
|
-
console.log('🤡 / el:', el);
|
|
14
|
-
const permissionStore = adminPlugin.deps.usePermissionStore();
|
|
15
|
-
|
|
16
13
|
function updateVisibility() {
|
|
17
14
|
const codes = binding.value;
|
|
18
|
-
el.style.display =
|
|
15
|
+
el.style.display = permission.has(codes) ? '' : 'none';
|
|
19
16
|
}
|
|
20
17
|
|
|
21
18
|
(el as any)[UNWATCH_NAME] = watch(
|
|
22
|
-
() =>
|
|
19
|
+
() => permission.codes,
|
|
23
20
|
updateVisibility,
|
|
24
21
|
{ immediate: true },
|
|
25
22
|
);
|
|
@@ -32,9 +29,7 @@ export function setupPermissionPlugin(app: App) {
|
|
|
32
29
|
app.use({
|
|
33
30
|
install(app) {
|
|
34
31
|
app.config.globalProperties.$hasPermission = (codes: TCodes) => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return permissionStore.hasPermission(codes);
|
|
32
|
+
return permission.has(codes);
|
|
38
33
|
};
|
|
39
34
|
},
|
|
40
35
|
});
|
package/admin/stores/index.ts
CHANGED
package/admin/styles/index.scss
CHANGED
|
@@ -74,9 +74,10 @@ function groupingForm(groupName: string, items: Record<string, FormItemProps>) {
|
|
|
74
74
|
* 格式化表单项组
|
|
75
75
|
* @param name - 组名
|
|
76
76
|
* @param items - 包含表单数据
|
|
77
|
+
* @param removeTempKey - 是否移除临时字段(建议删除前克隆 items)
|
|
77
78
|
* @returns 返回一个数组,其元素为分组后的表单项对象,如果没有找到匹配的组名,则返回 undefined
|
|
78
79
|
*/
|
|
79
|
-
function formatGroup(name: string, items: Record<string, any
|
|
80
|
+
function formatGroup(name: string, items: Record<string, any>, removeTempKey = false) {
|
|
80
81
|
const group: any[] = [];
|
|
81
82
|
|
|
82
83
|
for (const k in items) {
|
|
@@ -89,6 +90,14 @@ function formatGroup(name: string, items: Record<string, any>) {
|
|
|
89
90
|
group[params.index][params.fieldName] = items[k];
|
|
90
91
|
}
|
|
91
92
|
|
|
93
|
+
if (removeTempKey) {
|
|
94
|
+
const keyRE = new RegExp(`^${name}${GROUP_SEP}\\d+${GROUP_SEP}`);
|
|
95
|
+
Object.keys(items).forEach((key) => {
|
|
96
|
+
if (keyRE.test(key))
|
|
97
|
+
delete items[key];
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
92
101
|
return group?.length ? group.filter(g => !!g) : undefined;
|
|
93
102
|
}
|
|
94
103
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Modal as AntModal } from 'ant-design-vue';
|
|
2
|
-
import {
|
|
3
|
-
import { createVNode, defineComponent, isProxy, onMounted, reactive, toRef, toRefs } from 'vue';
|
|
2
|
+
import { tryOnBeforeUnmount } from '@vueuse/core';
|
|
3
|
+
import { createVNode, defineComponent, isProxy, onDeactivated, onMounted, reactive, toRef, toRefs } from 'vue';
|
|
4
4
|
import type { Component } from 'vue';
|
|
5
5
|
import type { ModalProps } from 'ant-design-vue';
|
|
6
6
|
import type { ComponentEmit, ComponentProps } from 'vue-component-type-helpers';
|
|
@@ -72,14 +72,25 @@ export function useAntdModal<Comp extends Component>(
|
|
|
72
72
|
newCompProps?: typeof compProps,
|
|
73
73
|
newAntdModalProps?: Omit<Partial<ModalProps>, 'open'>,
|
|
74
74
|
) => {
|
|
75
|
-
Object.assign(_modalProps, newAntdModalProps);
|
|
76
|
-
Object.assign(compProps, newCompProps);
|
|
77
|
-
|
|
78
75
|
if (_modalProps.open) {
|
|
79
76
|
// return Promise.reject(new Error('Modal is already open'));
|
|
80
77
|
return;
|
|
81
78
|
}
|
|
82
79
|
|
|
80
|
+
Object.assign(_modalProps, newAntdModalProps);
|
|
81
|
+
|
|
82
|
+
// eslint-disable-next-line no-lone-blocks
|
|
83
|
+
{
|
|
84
|
+
if (!(comp as any).props) {
|
|
85
|
+
Object.keys(compProps).forEach((key) => {
|
|
86
|
+
if (!['ref', 'onClose', 'onConfirm'].includes(key))
|
|
87
|
+
delete compProps[key];
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
Object.assign(compProps, newCompProps);
|
|
92
|
+
}
|
|
93
|
+
|
|
83
94
|
promiseResolvers = Promise.withResolvers();
|
|
84
95
|
_modalProps.open = true;
|
|
85
96
|
|
|
@@ -95,11 +106,11 @@ export function useAntdModal<Comp extends Component>(
|
|
|
95
106
|
};
|
|
96
107
|
|
|
97
108
|
const PresetComponent = defineComponent({
|
|
98
|
-
setup() {
|
|
109
|
+
setup(props) {
|
|
99
110
|
onMounted(() => _modalProps.opener?.(open as any));
|
|
100
111
|
|
|
101
112
|
return () => {
|
|
102
|
-
return createVNode(AntModal, _modalProps, {
|
|
113
|
+
return createVNode(AntModal, { ..._modalProps, ...props }, {
|
|
103
114
|
[modalSlotName]: () => createVNode(_comp.is, compProps as any),
|
|
104
115
|
});
|
|
105
116
|
};
|
|
@@ -114,7 +125,8 @@ export function useAntdModal<Comp extends Component>(
|
|
|
114
125
|
(compProps as any).onClose = close;
|
|
115
126
|
(compProps as any).onConfirm = confirm;
|
|
116
127
|
|
|
117
|
-
|
|
128
|
+
tryOnBeforeUnmount(_onClose);
|
|
129
|
+
onDeactivated(_onClose);
|
|
118
130
|
|
|
119
131
|
return {
|
|
120
132
|
PresetComponent,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { computed, reactive, ref } from 'vue';
|
|
1
|
+
import { computed, reactive, ref, toValue } from 'vue';
|
|
2
2
|
import { pick } from 'lodash-es';
|
|
3
3
|
import type { UseQueryReturnType } from '@tanstack/vue-query';
|
|
4
4
|
import type { Table, TableProps } from 'ant-design-vue';
|
|
@@ -54,7 +54,7 @@ export function useAntdTable<
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
|
-
const defineColumns =
|
|
57
|
+
const { defineColumns } = useTableColumns<LocalColumnsType>();
|
|
58
58
|
const defineRowSelection = (rowSelectionGetter: () => LocalTableRowSelection = () => ({})) => {
|
|
59
59
|
const rowSelection = reactive(rowSelectionGetter());
|
|
60
60
|
|
|
@@ -78,8 +78,10 @@ export function useAntdTable<
|
|
|
78
78
|
showSizeChanger: true,
|
|
79
79
|
showQuickJumper: true,
|
|
80
80
|
pageSizeOptions,
|
|
81
|
+
size: 'default',
|
|
81
82
|
showTotal: total => `共 ${total} 条`,
|
|
82
83
|
},
|
|
84
|
+
size: 'small',
|
|
83
85
|
loading: isLoading.value,
|
|
84
86
|
scroll: { x: 'max-content' },
|
|
85
87
|
sticky: true,
|
|
@@ -126,3 +128,51 @@ type GetRecordType<T> = T extends UseQueryReturnType<infer D, any>
|
|
|
126
128
|
? NonNullable<D['list']>[0]
|
|
127
129
|
: never
|
|
128
130
|
: never;
|
|
131
|
+
|
|
132
|
+
function useTableColumns<LCT extends any[]>() {
|
|
133
|
+
type ColumnConfig = {title: string, dataIndex: string, visible: boolean}
|
|
134
|
+
|
|
135
|
+
const columnsConfig = ref<Array<ColumnConfig> | null>(null);
|
|
136
|
+
let originalColumns: LCT | null = null;
|
|
137
|
+
|
|
138
|
+
const defineColumns = (columnsGetter: () => LCT) => {
|
|
139
|
+
originalColumns = toValue(columnsGetter) || [] as unknown as LCT;
|
|
140
|
+
|
|
141
|
+
return computed(() => {
|
|
142
|
+
const config = columnsConfig.value;
|
|
143
|
+
let columns = columnsGetter();
|
|
144
|
+
|
|
145
|
+
if (config?.length) {
|
|
146
|
+
// 过滤掉不可见的列
|
|
147
|
+
columns = columns.filter((col: any) => {
|
|
148
|
+
const x = config.find(c => c.dataIndex === col.dataIndex);
|
|
149
|
+
return x ? x.visible : true;
|
|
150
|
+
}) as LCT;
|
|
151
|
+
// 基于 config 的顺序排序
|
|
152
|
+
columns = config.map(x => {
|
|
153
|
+
const col = columns.find(c => c.dataIndex === x.dataIndex);
|
|
154
|
+
return col ? col : null;
|
|
155
|
+
}).filter(Boolean) as LCT;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return columns;
|
|
159
|
+
})
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const setColumnsConfig = (columns: Array<ColumnConfig>) => {
|
|
163
|
+
columnsConfig.value = columns;
|
|
164
|
+
|
|
165
|
+
// if (!columnsConfig.value) {
|
|
166
|
+
// columnsConfig.value = originalColumns?.map(col => ({
|
|
167
|
+
// title: col.title,
|
|
168
|
+
// dataIndex: col.dataIndex as string,
|
|
169
|
+
// visible: true,
|
|
170
|
+
// })) || [];
|
|
171
|
+
// }
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
return {
|
|
176
|
+
defineColumns,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
@@ -20,6 +20,13 @@ export function useAntdTheme(mode: Ref<string>, config: Ref<Record<string, any>>
|
|
|
20
20
|
const token: ThemeConfig['token'] = {
|
|
21
21
|
...algorithm({ ...theme.defaultSeed, colorPrimary: _config.colors.primary.DEFAULT, colorInfo: '#17B2FF' }),
|
|
22
22
|
borderRadius: 4,
|
|
23
|
+
|
|
24
|
+
motionUnit: 0.05,
|
|
25
|
+
motionBase: 0,
|
|
26
|
+
motionDurationFast: "0.05s",
|
|
27
|
+
motionDurationMid: "0.1s",
|
|
28
|
+
motionDurationSlow: "0.15s",
|
|
29
|
+
|
|
23
30
|
screenXS,
|
|
24
31
|
screenXSMin: screenXS,
|
|
25
32
|
screenXSMax: screenSM - 0.1,
|
package/antd/index.ts
CHANGED
|
@@ -5,4 +5,4 @@ export { useAntdForm } from './hooks/useAntdForm';
|
|
|
5
5
|
export { useAntdTheme } from './hooks/useAntdTheme';
|
|
6
6
|
export { createAntdModal } from './hooks/createAntdModal';
|
|
7
7
|
export { default as InputNumberRange } from './components/InputNumberRange.vue';
|
|
8
|
-
export type { SchemaConfig, ItemSchema } from './hooks/useAntdForm.ts';
|
|
8
|
+
export type { SchemaConfig, ItemSchema } from './hooks/useAntdForm.ts';
|
package/libs/bignumber.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default } from 'bignumber.js';
|
|
2
|
-
export { BigNumber } from 'bignumber.js';
|
|
2
|
+
export { type BigNumber } from 'bignumber.js';
|
package/libs/dayjs.ts
CHANGED
|
@@ -5,15 +5,25 @@ import weekday from 'dayjs/esm/plugin/weekday';
|
|
|
5
5
|
import localeData from 'dayjs/esm/plugin/localeData';
|
|
6
6
|
import utc from 'dayjs/esm/plugin/utc';
|
|
7
7
|
import tz from 'dayjs/esm/plugin/timezone';
|
|
8
|
+
import weekOfYear from 'dayjs/esm/plugin/weekOfYear';
|
|
9
|
+
import weekYear from 'dayjs/esm/plugin/weekYear';
|
|
10
|
+
import quarterOfYear from 'dayjs/esm/plugin/quarterOfYear';
|
|
11
|
+
import advancedFormat from 'dayjs/esm/plugin/advancedFormat';
|
|
12
|
+
import customParseFormat from 'dayjs/esm/plugin/customParseFormat';
|
|
8
13
|
import 'dayjs/esm/locale/zh';
|
|
9
14
|
import 'dayjs/esm/locale/en';
|
|
10
15
|
|
|
11
16
|
export type { Dayjs, PluginFunc, UnitType, UnitTypeLong, UnitTypeLongPlural, UnitTypeShort, QUnitType, ConfigType, ConfigTypeMap, OpUnitType, OptionType, ManipulateType } from 'dayjs';
|
|
12
17
|
export default dayjs;
|
|
13
18
|
|
|
14
|
-
dayjs.locale('zh');
|
|
15
19
|
dayjs.extend(relativeTime);
|
|
16
20
|
dayjs.extend(weekday);
|
|
17
21
|
dayjs.extend(localeData);
|
|
18
22
|
dayjs.extend(utc);
|
|
19
23
|
dayjs.extend(tz);
|
|
24
|
+
dayjs.extend(weekOfYear);
|
|
25
|
+
dayjs.extend(weekYear);
|
|
26
|
+
dayjs.extend(quarterOfYear);
|
|
27
|
+
dayjs.extend(advancedFormat);
|
|
28
|
+
dayjs.extend(customParseFormat);
|
|
29
|
+
dayjs.locale('zh');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@fingerprintjs/fingerprintjs';
|