@peng_kai/kit 0.2.0-beta.3 → 0.2.0-beta.30

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.
Files changed (64) hide show
  1. package/admin/adminPlugin.ts +11 -1
  2. package/admin/components/filter/src/FilterDrawer.vue +153 -153
  3. package/admin/components/filter/src/FilterParam.vue +1 -1
  4. package/admin/components/filter/src/FilterReset.vue +12 -9
  5. package/admin/components/rich-text/index.ts +1 -1
  6. package/admin/components/rich-text/src/RichText.new.vue +164 -0
  7. package/admin/components/rich-text/src/RichText.vue +3 -6
  8. package/admin/components/rich-text/src/editorConfig.ts +126 -0
  9. package/admin/components/rich-text/src/imageUploader.ts +20 -18
  10. package/admin/components/scroll-nav/index.ts +1 -1
  11. package/admin/components/scroll-nav/src/ScrollNav.vue +1 -1
  12. package/admin/components/settings/index.ts +1 -0
  13. package/admin/components/settings/src/Settings.vue +333 -0
  14. package/admin/components/text/index.ts +13 -13
  15. package/admin/components/text/src/Amount.vue +121 -121
  16. package/admin/components/text/src/Datetime.vue +1 -1
  17. package/admin/components/text/src/Duration.vue +26 -26
  18. package/admin/components/text/src/Hash.vue +51 -51
  19. package/admin/components/text/src/createTagGetter.ts +13 -13
  20. package/admin/components/upload/index.ts +1 -0
  21. package/admin/components/upload/src/PictureCardUpload.vue +1 -1
  22. package/admin/components/upload/src/helpers.ts +37 -0
  23. package/admin/defines/route/defineRoute.ts +2 -4
  24. package/admin/defines/route/getRoutes.ts +4 -4
  25. package/admin/defines/route/index.ts +1 -1
  26. package/admin/defines/route-guard/defineRouteGuard.ts +1 -4
  27. package/admin/defines/route-guard/getRouteGuards.ts +5 -7
  28. package/admin/defines/startup/defineStartup.ts +1 -3
  29. package/admin/defines/startup/runStartup.ts +4 -6
  30. package/admin/layout/large/Breadcrumb.vue +2 -2
  31. package/admin/layout/large/Content.vue +2 -2
  32. package/admin/layout/large/Menu.vue +2 -2
  33. package/admin/layout/large/PageTab.vue +2 -2
  34. package/admin/permission/routerGuard.ts +1 -1
  35. package/admin/permission/vuePlugin.ts +1 -0
  36. package/admin/route-guards/index.ts +3 -3
  37. package/admin/route-guards/pageProgress.ts +27 -27
  38. package/admin/stores/createUsePageStore.ts +1 -3
  39. package/admin/styles/classCover.scss +107 -0
  40. package/admin/styles/globalCover.scss +54 -54
  41. package/admin/styles/index.scss +14 -12
  42. package/antd/components/InputNumberRange.vue +59 -59
  43. package/antd/directives/formLabelAlign.ts +36 -36
  44. package/antd/hooks/useAntdDrawer.ts +73 -73
  45. package/antd/hooks/useAntdForm.ts +1 -1
  46. package/antd/hooks/useAntdModal.ts +4 -1
  47. package/antd/hooks/useAntdTable.ts +2 -1
  48. package/libs/dayjs.ts +7 -0
  49. package/libs/echarts.ts +1 -1
  50. package/libs/vue-i18n.ts +21 -0
  51. package/package.json +36 -35
  52. package/request/helpers.ts +68 -68
  53. package/request/interceptors/returnResultType.ts +3 -3
  54. package/request/interceptors/toLogin.ts +43 -26
  55. package/request/request.ts +0 -3
  56. package/request/type.d.ts +92 -92
  57. package/stylelint.config.cjs +7 -7
  58. package/tsconfig.json +50 -50
  59. package/utils/LocaleManager.ts +125 -0
  60. package/utils/date.ts +1 -9
  61. package/vite/index.mjs +34 -8
  62. package/vue/components/infinite-query/index.ts +1 -1
  63. package/vue/components/infinite-query/src/InfiniteQuery.vue +199 -199
  64. package/vue/components/infinite-query/src/useCreateTrigger.ts +39 -39
@@ -2,7 +2,7 @@
2
2
  import { computed, ref, watch } from 'vue';
3
3
  import { Menu as AMenu } from 'ant-design-vue';
4
4
  import type { ItemType } from 'ant-design-vue';
5
- import { adminPlugin } from '../../adminPlugin';
5
+ import { injectTTAdmin } from '../../adminPlugin';
6
6
  import type { TMenu } from '../../stores/createUseMenuStore';
7
7
 
8
8
  function formatMenu(menu: TMenu): ItemType {
@@ -21,7 +21,7 @@ function formatMenu(menu: TMenu): ItemType {
21
21
  </script>
22
22
 
23
23
  <script setup lang="ts">
24
- const { router, useMenuStore } = adminPlugin.deps;
24
+ const { router, useMenuStore } = injectTTAdmin()!.deps;
25
25
  const menuStore = useMenuStore();
26
26
  const items = computed(() => menuStore.menus.map(formatMenu));
27
27
  const openKeys = ref<string[]>([]);
@@ -1,8 +1,8 @@
1
1
  <script setup lang="ts">
2
2
  import { TabPane as ATabPane, Tabs as ATabs } from 'ant-design-vue';
3
- import { adminPlugin } from '../../adminPlugin';
3
+ import { injectTTAdmin } from '../../adminPlugin';
4
4
 
5
- const pageTabStore = adminPlugin.deps.usePageTabStore();
5
+ const pageTabStore = injectTTAdmin()!.deps.usePageTabStore();
6
6
  </script>
7
7
 
8
8
  <template>
@@ -26,7 +26,7 @@ export function setupPermissionRouterGuard(router: Router, rouneNames: { index:
26
26
 
27
27
  // 未登录状态进入需要登录权限的页面
28
28
  else if (!isLogin && needLogin)
29
- return next({ name: rouneNames.login, replace: true });
29
+ return next({ name: rouneNames.login, replace: true, query: { redirect: to.fullPath } });
30
30
 
31
31
  // 登录状态进入需要登录权限的页面,有权限直接通行
32
32
  else if (isLogin && needLogin && hasPermission)
@@ -10,6 +10,7 @@ const UNWATCH_NAME = `v-${PLUGIN_NAME}@unwatch`;
10
10
  export function setupPermissionPlugin(app: App) {
11
11
  app.directive<HTMLElement, TCodes>(PLUGIN_NAME, {
12
12
  mounted(el, binding) {
13
+ console.log('🤡 / el:', el);
13
14
  const permissionStore = adminPlugin.deps.usePermissionStore();
14
15
 
15
16
  function updateVisibility() {
@@ -1,3 +1,3 @@
1
- export { setupPageProgress } from './pageProgress';
2
- export { setupPageTitle } from './pageTitle';
3
- export { setupCollapseMenu } from './collapseMenu';
1
+ export { setupPageProgress } from './pageProgress';
2
+ export { setupPageTitle } from './pageTitle';
3
+ export { setupCollapseMenu } from './collapseMenu';
@@ -1,27 +1,27 @@
1
- import type { Router } from 'vue-router';
2
- import { useStyleTag } from '@vueuse/core';
3
- import NProgress from 'nprogress';
4
- import 'nprogress/nprogress.css';
5
-
6
- /**
7
- * 用于显示页面跳转时,页面顶部进度条
8
- */
9
- export function setupPageProgress(router: Router) {
10
- NProgress.configure({ showSpinner: false });
11
- useStyleTag(`
12
- #nprogress .bar {
13
- height: 3px;
14
- background: var(--antd-colorPrimary);
15
- }
16
- #nprogress .peg {
17
- box-shadow: 0 0 10px var(--antd-colorPrimary), 0 0 5px var(--antd-colorPrimary);
18
- }
19
- `);
20
-
21
- router.beforeEach(() => {
22
- NProgress.start();
23
- });
24
- router.afterEach(() => {
25
- setTimeout(() => NProgress.done(), 200);
26
- });
27
- }
1
+ import type { Router } from 'vue-router';
2
+ import { useStyleTag } from '@vueuse/core';
3
+ import NProgress from 'nprogress';
4
+ import 'nprogress/nprogress.css';
5
+
6
+ /**
7
+ * 用于显示页面跳转时,页面顶部进度条
8
+ */
9
+ export function setupPageProgress(router: Router) {
10
+ NProgress.configure({ showSpinner: false });
11
+ useStyleTag(`
12
+ #nprogress .bar {
13
+ height: 3px;
14
+ background: var(--antd-colorPrimary);
15
+ }
16
+ #nprogress .peg {
17
+ box-shadow: 0 0 10px var(--antd-colorPrimary), 0 0 5px var(--antd-colorPrimary);
18
+ }
19
+ `);
20
+
21
+ router.beforeEach(() => {
22
+ NProgress.start();
23
+ });
24
+ router.afterEach(() => {
25
+ setTimeout(() => NProgress.done(), 200);
26
+ });
27
+ }
@@ -21,9 +21,7 @@ interface IBreadcrumb {
21
21
  }
22
22
 
23
23
  function createUsePageStore() {
24
- return defineStore('appPage', () => {
25
- return storeSetup();
26
- });
24
+ return defineStore('appPage', () => storeSetup());
27
25
  }
28
26
 
29
27
  function storeSetup() {
@@ -173,6 +173,23 @@
173
173
  }
174
174
  }
175
175
 
176
+ // ACard 组件的 actions 右对齐
177
+ .ant-card.antd-cover__actions-right-align {
178
+ .ant-card-actions {
179
+ justify-content: flex-end !important;
180
+ padding: 0 24px;
181
+
182
+ > li {
183
+ width: auto !important;
184
+ border-inline-end: none !important;
185
+
186
+ &:not(:last-child) {
187
+ margin-right: 8px;
188
+ }
189
+ }
190
+ }
191
+ }
192
+
176
193
  // 查询器表单基本样式
177
194
  .ant-form.ant-form__filter {
178
195
  display: flex;
@@ -187,3 +204,93 @@
187
204
  flex: 1 1 auto;
188
205
  }
189
206
  }
207
+
208
+ // Modal 组件中的 Card 组件样式(为了和原 Modal 组件一样)
209
+ .ant-card.antd-cover__card-in-modal {
210
+ --padding-size: 22px;
211
+
212
+ pointer-events: all;
213
+
214
+ @media bp-lt-mobilel {
215
+ --padding-size: 16px;
216
+ }
217
+
218
+ .ant-card-head {
219
+ min-height: 56px;
220
+ padding: 0 var(--padding-size);
221
+
222
+ @media bp-lt-mobilel {
223
+ min-height: 51px;
224
+ }
225
+ }
226
+
227
+ .ant-card-body {
228
+ height: var(--body-height, auto);
229
+ min-height: var(--min-body-height, auto);
230
+ max-height: var(--max-body-height, auto);
231
+ padding: var(--padding-size);
232
+ overflow-y: auto;
233
+ }
234
+
235
+ .ant-card-extra .close-btn {
236
+ --icon-color: var(--antd-colorTextTertiary);
237
+ --bg-color: transparent;
238
+
239
+ position: relative;
240
+ display: flex;
241
+ align-items: center;
242
+ justify-content: center;
243
+ width: 22px;
244
+ height: 22px;
245
+ padding: 0;
246
+ font-size: 18px;
247
+ cursor: pointer;
248
+ background-color: var(--bg-color);
249
+ border: 0;
250
+ border-radius: 4px;
251
+ transition: all 100ms;
252
+
253
+ &::before,
254
+ &::after {
255
+ position: absolute;
256
+ top: 50%;
257
+ left: 50%;
258
+ display: block;
259
+ width: 70%;
260
+ height: 1.5px;
261
+ content: '';
262
+ background-color: var(--icon-color);
263
+ }
264
+
265
+ &::before {
266
+ transform: translate(-50%, -50%) rotateZ(45deg);
267
+ }
268
+
269
+ &::after {
270
+ transform: translate(-50%, -50%) rotateZ(-45deg);
271
+ }
272
+
273
+ &:hover {
274
+ --icon-color: var(--antd-colorText);
275
+ --bg-color: var(--antd-colorFillSecondary);
276
+ }
277
+ }
278
+
279
+ .ant-card-actions {
280
+ display: flex;
281
+ align-items: center;
282
+ justify-content: flex-end !important;
283
+ min-height: 56px;
284
+ padding: 0 var(--padding-size);
285
+
286
+ > li {
287
+ width: auto !important;
288
+ margin: 0;
289
+ border-inline-end: none !important;
290
+
291
+ &:not(:last-child) {
292
+ margin-right: 8px;
293
+ }
294
+ }
295
+ }
296
+ }
@@ -1,54 +1,54 @@
1
- :root {
2
- // table 组件头部圆角设为 0
3
- .ant-table-wrapper {
4
- .ant-table .ant-table-header,
5
- table,
6
- .ant-table-container table > thead > tr:first-child > *:first-child,
7
- .ant-table-container table > thead > tr:first-child > *:last-child {
8
- border-radius: 0;
9
- }
10
-
11
- .ant-pagination {
12
- margin-bottom: 0;
13
- }
14
- }
15
-
16
-
17
- // 隐藏在 sticky 模式下的滚动条
18
- .ant-table-sticky-scroll {
19
- display: none;
20
- }
21
-
22
- // 卡片
23
- .ant-card .ant-card-actions > li > span {
24
- cursor: inherit;
25
- }
26
-
27
- // Tab 溢出出现下列框时
28
- .ant-tabs-dropdown-menu-title-content {
29
- display: flex;
30
- align-items: center;
31
- justify-content: space-between;
32
- }
33
-
34
- // 表格
35
- .ant-table-wrapper {
36
- .ant-table-row-expand-icon-collapsed::before {
37
- height: 1.5px;
38
- }
39
- .ant-table-row-expand-icon-collapsed::after {
40
- width: 1.5px;
41
- }
42
- }
43
-
44
- .ant-drawer {
45
- &:focus {
46
- outline: none;
47
- }
48
-
49
- &.ant-drawer-bottom .ant-drawer-content {
50
- border-top-left-radius: 8px;
51
- border-top-right-radius: 8px;
52
- }
53
- }
54
- }
1
+ :root {
2
+ // table 组件头部圆角设为 0
3
+ .ant-table-wrapper {
4
+ .ant-table .ant-table-header,
5
+ table,
6
+ .ant-table-container table > thead > tr:first-child > *:first-child,
7
+ .ant-table-container table > thead > tr:first-child > *:last-child {
8
+ border-radius: 0;
9
+ }
10
+
11
+ .ant-pagination {
12
+ margin-bottom: 0;
13
+ }
14
+ }
15
+
16
+
17
+ // 隐藏在 sticky 模式下的滚动条
18
+ .ant-table-sticky-scroll {
19
+ display: none;
20
+ }
21
+
22
+ // 卡片
23
+ .ant-card .ant-card-actions > li > span {
24
+ cursor: inherit;
25
+ }
26
+
27
+ // Tab 溢出出现下列框时
28
+ .ant-tabs-dropdown-menu-title-content {
29
+ display: flex;
30
+ align-items: center;
31
+ justify-content: space-between;
32
+ }
33
+
34
+ // 表格
35
+ .ant-table-wrapper {
36
+ .ant-table-row-expand-icon-collapsed::before {
37
+ height: 1.5px;
38
+ }
39
+ .ant-table-row-expand-icon-collapsed::after {
40
+ width: 1.5px;
41
+ }
42
+ }
43
+
44
+ .ant-drawer {
45
+ &:focus {
46
+ outline: none;
47
+ }
48
+
49
+ &.ant-drawer-bottom .ant-drawer-content {
50
+ border-top-left-radius: 8px;
51
+ border-top-right-radius: 8px;
52
+ }
53
+ }
54
+ }
@@ -2,26 +2,28 @@
2
2
  @import './globalCover.scss';
3
3
 
4
4
  @media (pointer: fine) {
5
- * {
6
- scrollbar-color: rgb(0 0 0 / 50%) transparent;
7
- scrollbar-width: thin;
8
5
 
9
- /* overflow-y: overlay; */
6
+ *::-webkit-scrollbar-thumb {
7
+ border-radius: 10px;
8
+ background-color: rgb(133 133 133 / 20%);
9
+ }
10
+
11
+ *::-webkit-scrollbar-thumb:hover {
12
+ background-color: rgb(133 133 133 / 60%);
10
13
  }
11
14
 
12
- ::-webkit-scrollbar {
15
+ *::-webkit-scrollbar {
13
16
  width: 6px;
14
17
  height: 6px;
15
18
  background-color: transparent;
16
19
  }
17
20
 
18
- ::-webkit-scrollbar-thumb {
19
- border-radius: 10px;
20
- background-color: rgb(133 133 133 / 20%);
21
- }
22
-
23
- ::-webkit-scrollbar-thumb:hover {
24
- background-color: rgb(133 133 133 / 60%);
21
+ /* 不支持`::-webkit-scrollbar-*`的浏览器 */
22
+ @supports not selector(::-webkit-scrollbar) {
23
+ * {
24
+ scrollbar-color: rgb(0 0 0 / 50%) transparent;
25
+ scrollbar-width: thin;
26
+ }
25
27
  }
26
28
  }
27
29
 
@@ -1,59 +1,59 @@
1
- <script lang="ts">
2
- import { computed } from 'vue';
3
- import { InputNumber as AInputNumber, Form } from 'ant-design-vue';
4
- </script>
5
-
6
- <script setup lang="ts">
7
- const props = withDefaults(
8
- defineProps<{
9
- value: [number | undefined, number | undefined]
10
- placeholder?: [string, string]
11
- min?: number
12
- max?: number
13
- }>(),
14
- {
15
- min: Number.NEGATIVE_INFINITY,
16
- max: Number.POSITIVE_INFINITY,
17
- },
18
- );
19
- const emits = defineEmits<{
20
- (e: 'update:value', value: typeof props.value): void
21
- }>();
22
-
23
- const formItemContext = Form.useInjectFormItemContext();
24
- const minValue = computed({
25
- get() {
26
- return props.value[0];
27
- },
28
- set(value) {
29
- updateValue(value, maxValue.value);
30
- },
31
- });
32
- const maxValue = computed({
33
- get() {
34
- return props.value[1];
35
- },
36
- set(value) {
37
- updateValue(minValue.value, value);
38
- },
39
- });
40
-
41
- function updateValue(...args: typeof props.value) {
42
- emits('update:value', args.sort());
43
- formItemContext.onFieldChange();
44
- }
45
- </script>
46
-
47
- <template>
48
- <div class="flex items-center">
49
- <AInputNumber
50
- v-model:value="minValue" class="w-full" :min="props.min"
51
- :max="props.max" :placeholder="props.placeholder?.[0]"
52
- />
53
- <span>&nbsp;-&nbsp;</span>
54
- <AInputNumber
55
- v-model:value="maxValue" class="w-full" :min="props.min"
56
- :max="props.max" :placeholder="props.placeholder?.[1]"
57
- />
58
- </div>
59
- </template>
1
+ <script lang="ts">
2
+ import { computed } from 'vue';
3
+ import { InputNumber as AInputNumber, Form } from 'ant-design-vue';
4
+ </script>
5
+
6
+ <script setup lang="ts">
7
+ const props = withDefaults(
8
+ defineProps<{
9
+ value: [number | undefined, number | undefined]
10
+ placeholder?: [string, string]
11
+ min?: number
12
+ max?: number
13
+ }>(),
14
+ {
15
+ min: Number.NEGATIVE_INFINITY,
16
+ max: Number.POSITIVE_INFINITY,
17
+ },
18
+ );
19
+ const emits = defineEmits<{
20
+ (e: 'update:value', value: typeof props.value): void
21
+ }>();
22
+
23
+ const formItemContext = Form.useInjectFormItemContext();
24
+ const minValue = computed({
25
+ get() {
26
+ return props.value[0];
27
+ },
28
+ set(value) {
29
+ updateValue(value, maxValue.value);
30
+ },
31
+ });
32
+ const maxValue = computed({
33
+ get() {
34
+ return props.value[1];
35
+ },
36
+ set(value) {
37
+ updateValue(minValue.value, value);
38
+ },
39
+ });
40
+
41
+ function updateValue(...args: typeof props.value) {
42
+ emits('update:value', args.sort());
43
+ formItemContext.onFieldChange();
44
+ }
45
+ </script>
46
+
47
+ <template>
48
+ <div class="flex items-center">
49
+ <AInputNumber
50
+ v-model:value="minValue" class="w-full" :min="props.min"
51
+ :max="props.max" :placeholder="props.placeholder?.[0]"
52
+ />
53
+ <span>&nbsp;-&nbsp;</span>
54
+ <AInputNumber
55
+ v-model:value="maxValue" class="w-full" :min="props.min"
56
+ :max="props.max" :placeholder="props.placeholder?.[1]"
57
+ />
58
+ </div>
59
+ </template>
@@ -1,36 +1,36 @@
1
- import type { App } from 'vue';
2
-
3
- export function formLabelAlign(app: App) {
4
- const directiveName = 'antd-form-label-align';
5
- const resizeObserverKey = `${directiveName}@resizeObserver`;
6
-
7
- function init(el: HTMLElement) {
8
- const labels = el.querySelectorAll('.ant-form-item .ant-form-item-label');
9
- const resizeObserver = new ResizeObserver((entries) => {
10
- const widths = entries.map(e => e.borderBoxSize?.[0]?.inlineSize ?? 0);
11
- const maxWidth = Math.max(...widths);
12
-
13
- if (maxWidth <= 0)
14
- return;
15
-
16
- el.style.setProperty('--max-label-width', `${maxWidth}px`);
17
- entries.forEach((e) => {
18
- const target = e.target as HTMLElement;
19
- target.style.setProperty('width', 'var(--max-label-width)');
20
- });
21
- });
22
-
23
- Array.from(labels).forEach(label => resizeObserver.observe(label));
24
-
25
- return resizeObserver;
26
- }
27
-
28
- app.directive(directiveName, {
29
- mounted(el: HTMLElement) {
30
- (el as any)[resizeObserverKey] = init(el);
31
- },
32
- updated(el) {
33
- (el as any)[resizeObserverKey] = init(el);
34
- },
35
- });
36
- }
1
+ import type { App } from 'vue';
2
+
3
+ export function formLabelAlign(app: App) {
4
+ const directiveName = 'antd-form-label-align';
5
+ const resizeObserverKey = `${directiveName}@resizeObserver`;
6
+
7
+ function init(el: HTMLElement) {
8
+ const labels = el.querySelectorAll('.ant-form-item .ant-form-item-label');
9
+ const resizeObserver = new ResizeObserver((entries) => {
10
+ const widths = entries.map(e => e.borderBoxSize?.[0]?.inlineSize ?? 0);
11
+ const maxWidth = Math.max(...widths);
12
+
13
+ if (maxWidth <= 0)
14
+ return;
15
+
16
+ el.style.setProperty('--max-label-width', `${maxWidth}px`);
17
+ entries.forEach((e) => {
18
+ const target = e.target as HTMLElement;
19
+ target.style.setProperty('width', 'var(--max-label-width)');
20
+ });
21
+ });
22
+
23
+ Array.from(labels).forEach(label => resizeObserver.observe(label));
24
+
25
+ return resizeObserver;
26
+ }
27
+
28
+ app.directive(directiveName, {
29
+ mounted(el: HTMLElement) {
30
+ (el as any)[resizeObserverKey] = init(el);
31
+ },
32
+ updated(el) {
33
+ (el as any)[resizeObserverKey] = init(el);
34
+ },
35
+ });
36
+ }