@kevairy/template 0.1.0
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/LICENSE +21 -0
- package/README.md +14 -0
- package/package.json +37 -0
- package/template/.env +22 -0
- package/template/.env.development +13 -0
- package/template/.env.production +10 -0
- package/template/.prettierignore +3 -0
- package/template/.prettierrc +20 -0
- package/template/.stylelintignore +9 -0
- package/template/.stylelintrc.cjs +84 -0
- package/template/LICENSE +21 -0
- package/template/README.md +22 -0
- package/template/_gitignore +19 -0
- package/template/eslint-auto-import.json +324 -0
- package/template/eslint.config.mjs +83 -0
- package/template/index.html +25 -0
- package/template/package.json +79 -0
- package/template/playwright.config.ts +25 -0
- package/template/public/favicon.ico +0 -0
- package/template/src/App.vue +39 -0
- package/template/src/adapters/auth/index.ts +9 -0
- package/template/src/adapters/auth/mock.ts +10 -0
- package/template/src/adapters/auth/types.ts +11 -0
- package/template/src/adapters/navigation/index.ts +13 -0
- package/template/src/adapters/navigation/types.ts +6 -0
- package/template/src/api/auth.ts +23 -0
- package/template/src/assets/images/avatar/avatar.webp +0 -0
- package/template/src/assets/images/avatar/avatar1.webp +0 -0
- package/template/src/assets/images/avatar/avatar10.webp +0 -0
- package/template/src/assets/images/avatar/avatar2.webp +0 -0
- package/template/src/assets/images/avatar/avatar3.webp +0 -0
- package/template/src/assets/images/avatar/avatar4.webp +0 -0
- package/template/src/assets/images/avatar/avatar5.webp +0 -0
- package/template/src/assets/images/avatar/avatar6.webp +0 -0
- package/template/src/assets/images/avatar/avatar7.webp +0 -0
- package/template/src/assets/images/avatar/avatar8.webp +0 -0
- package/template/src/assets/images/avatar/avatar9.webp +0 -0
- package/template/src/assets/images/ceremony/hb.png +0 -0
- package/template/src/assets/images/ceremony/sd.png +0 -0
- package/template/src/assets/images/ceremony/xc.png +0 -0
- package/template/src/assets/images/ceremony/yd.png +0 -0
- package/template/src/assets/images/common/logo.webp +0 -0
- package/template/src/assets/images/draw/draw1.png +0 -0
- package/template/src/assets/images/favicon.ico +0 -0
- package/template/src/assets/images/lock/bg_dark.webp +0 -0
- package/template/src/assets/images/lock/bg_light.webp +0 -0
- package/template/src/assets/images/login/kylin-hero-source.png +0 -0
- package/template/src/assets/images/login/lf_icon2.webp +0 -0
- package/template/src/assets/images/settings/menu_layouts/dual_column.png +0 -0
- package/template/src/assets/images/settings/menu_layouts/horizontal.png +0 -0
- package/template/src/assets/images/settings/menu_layouts/mixed.png +0 -0
- package/template/src/assets/images/settings/menu_layouts/vertical.png +0 -0
- package/template/src/assets/images/settings/menu_styles/dark.png +0 -0
- package/template/src/assets/images/settings/menu_styles/design.png +0 -0
- package/template/src/assets/images/settings/menu_styles/light.png +0 -0
- package/template/src/assets/images/settings/theme_styles/dark.png +0 -0
- package/template/src/assets/images/settings/theme_styles/light.png +0 -0
- package/template/src/assets/images/settings/theme_styles/system.png +0 -0
- package/template/src/assets/images/svg/403.svg +1 -0
- package/template/src/assets/images/svg/404.svg +1 -0
- package/template/src/assets/images/svg/500.svg +5 -0
- package/template/src/assets/images/svg/login_icon.svg +1 -0
- package/template/src/assets/images/user/avatar.webp +0 -0
- package/template/src/assets/images/user/bg.webp +0 -0
- package/template/src/assets/styles/core/app.scss +227 -0
- package/template/src/assets/styles/core/dark.scss +93 -0
- package/template/src/assets/styles/core/el-dark.scss +2 -0
- package/template/src/assets/styles/core/el-light.scss +34 -0
- package/template/src/assets/styles/core/el-ui.scss +519 -0
- package/template/src/assets/styles/core/md.scss +1036 -0
- package/template/src/assets/styles/core/mixin.scss +157 -0
- package/template/src/assets/styles/core/reset.scss +41 -0
- package/template/src/assets/styles/core/router-transition.scss +104 -0
- package/template/src/assets/styles/core/tailwind.css +219 -0
- package/template/src/assets/styles/core/theme-animation.scss +63 -0
- package/template/src/assets/styles/core/theme-change.scss +11 -0
- package/template/src/assets/styles/custom/one-dark-pro.scss +98 -0
- package/template/src/assets/styles/index.scss +23 -0
- package/template/src/assets/svg/loading.ts +32 -0
- package/template/src/bootstrap/initializeApp.ts +30 -0
- package/template/src/components/core/banners/art-basic-banner/index.vue +343 -0
- package/template/src/components/core/banners/art-card-banner/index.vue +114 -0
- package/template/src/components/core/base/art-back-to-top/index.vue +40 -0
- package/template/src/components/core/base/art-logo/index.vue +34 -0
- package/template/src/components/core/base/art-svg-icon/index.vue +24 -0
- package/template/src/components/core/cards/art-bar-chart-card/index.vue +103 -0
- package/template/src/components/core/cards/art-data-list-card/index.vue +74 -0
- package/template/src/components/core/cards/art-donut-chart-card/index.vue +124 -0
- package/template/src/components/core/cards/art-image-card/index.vue +89 -0
- package/template/src/components/core/cards/art-line-chart-card/index.vue +126 -0
- package/template/src/components/core/cards/art-progress-card/index.vue +86 -0
- package/template/src/components/core/cards/art-stats-card/index.vue +67 -0
- package/template/src/components/core/cards/art-timeline-list-card/index.vue +69 -0
- package/template/src/components/core/charts/art-bar-chart/index.vue +203 -0
- package/template/src/components/core/charts/art-dual-bar-compare-chart/index.vue +195 -0
- package/template/src/components/core/charts/art-h-bar-chart/index.vue +208 -0
- package/template/src/components/core/charts/art-k-line-chart/index.vue +152 -0
- package/template/src/components/core/charts/art-line-chart/index.vue +371 -0
- package/template/src/components/core/charts/art-radar-chart/index.vue +105 -0
- package/template/src/components/core/charts/art-ring-chart/index.vue +133 -0
- package/template/src/components/core/charts/art-scatter-chart/index.vue +115 -0
- package/template/src/components/core/feedback/art-page-loading/index.vue +281 -0
- package/template/src/components/core/forms/art-button-more/index.vue +71 -0
- package/template/src/components/core/forms/art-button-table/index.vue +59 -0
- package/template/src/components/core/forms/art-drag-verify/index.vue +430 -0
- package/template/src/components/core/forms/art-excel-export/index.vue +390 -0
- package/template/src/components/core/forms/art-excel-import/index.vue +62 -0
- package/template/src/components/core/forms/art-form/index.vue +507 -0
- package/template/src/components/core/forms/art-wang-editor/index.vue +261 -0
- package/template/src/components/core/forms/art-wang-editor/style.scss +273 -0
- package/template/src/components/core/layouts/art-breadcrumb/index.vue +142 -0
- package/template/src/components/core/layouts/art-chat-window/index.vue +262 -0
- package/template/src/components/core/layouts/art-fast-enter/index.vue +113 -0
- package/template/src/components/core/layouts/art-fireworks-effect/index.vue +633 -0
- package/template/src/components/core/layouts/art-global-component/index.vue +14 -0
- package/template/src/components/core/layouts/art-global-search/index.vue +431 -0
- package/template/src/components/core/layouts/art-header-bar/index.vue +485 -0
- package/template/src/components/core/layouts/art-header-bar/widget/ArtUserMenu.vue +118 -0
- package/template/src/components/core/layouts/art-menus/art-horizontal-menu/index.vue +110 -0
- package/template/src/components/core/layouts/art-menus/art-horizontal-menu/widget/HorizontalSubmenu.vue +106 -0
- package/template/src/components/core/layouts/art-menus/art-mixed-menu/index.vue +279 -0
- package/template/src/components/core/layouts/art-menus/art-sidebar-menu/index.vue +354 -0
- package/template/src/components/core/layouts/art-menus/art-sidebar-menu/style.scss +251 -0
- package/template/src/components/core/layouts/art-menus/art-sidebar-menu/theme.scss +258 -0
- package/template/src/components/core/layouts/art-menus/art-sidebar-menu/widget/SidebarSubmenu.vue +190 -0
- package/template/src/components/core/layouts/art-notification/index.vue +456 -0
- package/template/src/components/core/layouts/art-page-content/index.vue +137 -0
- package/template/src/components/core/layouts/art-settings-panel/composables/useSettingsConfig.ts +248 -0
- package/template/src/components/core/layouts/art-settings-panel/composables/useSettingsHandlers.ts +167 -0
- package/template/src/components/core/layouts/art-settings-panel/composables/useSettingsPanel.ts +233 -0
- package/template/src/components/core/layouts/art-settings-panel/composables/useSettingsState.ts +37 -0
- package/template/src/components/core/layouts/art-settings-panel/index.vue +72 -0
- package/template/src/components/core/layouts/art-settings-panel/style.scss +92 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/BasicSettings.vue +77 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/BoxStyleSettings.vue +38 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/ColorSettings.vue +35 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/ContainerSettings.vue +33 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/MenuLayoutSettings.vue +31 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/MenuStyleSettings.vue +44 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/SectionTitle.vue +17 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/SettingActions.vue +236 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/SettingDrawer.vue +51 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/SettingHeader.vue +18 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/SettingItem.vue +101 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/ThemeSettings.vue +28 -0
- package/template/src/components/core/layouts/art-work-tab/index.vue +584 -0
- package/template/src/components/core/media/art-cutter-img/index.vue +350 -0
- package/template/src/components/core/media/art-video-player/index.vue +111 -0
- package/template/src/components/core/others/art-menu-right/index.vue +415 -0
- package/template/src/components/core/others/art-watermark/index.vue +64 -0
- package/template/src/components/core/text-effect/art-count-to/index.vue +310 -0
- package/template/src/components/core/text-effect/art-festival-text-scroll/index.vue +32 -0
- package/template/src/components/core/text-effect/art-text-scroll/index.vue +285 -0
- package/template/src/components/core/theme/theme-svg/index.vue +100 -0
- package/template/src/components/core/views/exception/ArtException.vue +55 -0
- package/template/src/components/core/views/login/AuthTopBar.vue +149 -0
- package/template/src/components/core/views/login/LoginLeftView.vue +602 -0
- package/template/src/components/core/views/result/ArtResultPage.vue +43 -0
- package/template/src/components/core/widget/art-icon-button/index.vue +23 -0
- package/template/src/config/assets/images.ts +61 -0
- package/template/src/config/index.ts +170 -0
- package/template/src/config/modules/component.ts +98 -0
- package/template/src/config/modules/fastEnter.ts +16 -0
- package/template/src/config/modules/festival.ts +51 -0
- package/template/src/config/modules/headerBar.ts +64 -0
- package/template/src/config/setting.ts +109 -0
- package/template/src/directives/core/auth.ts +66 -0
- package/template/src/directives/core/highlight-loader.ts +37 -0
- package/template/src/directives/core/highlight.ts +253 -0
- package/template/src/directives/core/ripple.ts +116 -0
- package/template/src/directives/core/roles.ts +87 -0
- package/template/src/directives/index.ts +14 -0
- package/template/src/enums/appEnum.ts +81 -0
- package/template/src/enums/formEnum.ts +17 -0
- package/template/src/env.d.ts +32 -0
- package/template/src/hooks/core/useAppMode.ts +45 -0
- package/template/src/hooks/core/useAuth.ts +74 -0
- package/template/src/hooks/core/useCeremony.ts +184 -0
- package/template/src/hooks/core/useChart.ts +745 -0
- package/template/src/hooks/core/useCommon.ts +87 -0
- package/template/src/hooks/core/useFastEnter.ts +55 -0
- package/template/src/hooks/core/useHeaderBar.ts +201 -0
- package/template/src/hooks/core/useLayoutHeight.ts +148 -0
- package/template/src/hooks/core/useTableColumns.ts +313 -0
- package/template/src/hooks/core/useTheme.ts +174 -0
- package/template/src/hooks/index.ts +29 -0
- package/template/src/locales/index.ts +123 -0
- package/template/src/locales/langs/en.json +283 -0
- package/template/src/locales/langs/zh.json +283 -0
- package/template/src/main.ts +29 -0
- package/template/src/mock/auth.ts +46 -0
- package/template/src/plugins/echarts.ts +76 -0
- package/template/src/plugins/index.ts +6 -0
- package/template/src/router/core/ComponentLoader.ts +82 -0
- package/template/src/router/core/IframeRouteManager.ts +78 -0
- package/template/src/router/core/MenuProcessor.ts +280 -0
- package/template/src/router/core/RoutePermissionValidator.ts +161 -0
- package/template/src/router/core/RouteRegistry.ts +90 -0
- package/template/src/router/core/RouteTransformer.ts +132 -0
- package/template/src/router/core/RouteValidator.ts +187 -0
- package/template/src/router/core/index.ts +14 -0
- package/template/src/router/guards/afterEach.ts +34 -0
- package/template/src/router/guards/beforeEach.ts +442 -0
- package/template/src/router/index.ts +24 -0
- package/template/src/router/modules/dashboard.ts +23 -0
- package/template/src/router/modules/examples.ts +109 -0
- package/template/src/router/modules/exception.ts +46 -0
- package/template/src/router/modules/index.ts +12 -0
- package/template/src/router/modules/result.ts +32 -0
- package/template/src/router/routes/asyncRoutes.ts +9 -0
- package/template/src/router/routes/staticRoutes.ts +60 -0
- package/template/src/router/routesAlias.ts +8 -0
- package/template/src/services/auth.ts +15 -0
- package/template/src/store/index.ts +52 -0
- package/template/src/store/modules/menu.ts +109 -0
- package/template/src/store/modules/setting.ts +450 -0
- package/template/src/store/modules/user.ts +218 -0
- package/template/src/store/modules/worktab.ts +568 -0
- package/template/src/types/api/api.d.ts +86 -0
- package/template/src/types/common/index.ts +95 -0
- package/template/src/types/common/response.ts +32 -0
- package/template/src/types/component/chart.ts +324 -0
- package/template/src/types/component/index.ts +86 -0
- package/template/src/types/config/index.ts +253 -0
- package/template/src/types/directive/directive.d.ts +15 -0
- package/template/src/types/import/auto-imports.d.ts +319 -0
- package/template/src/types/import/components.d.ts +126 -0
- package/template/src/types/index.ts +22 -0
- package/template/src/types/router/index.ts +80 -0
- package/template/src/types/store/index.ts +157 -0
- package/template/src/utils/form/index.ts +9 -0
- package/template/src/utils/form/validator.ts +316 -0
- package/template/src/utils/http/contract.ts +39 -0
- package/template/src/utils/http/error.ts +182 -0
- package/template/src/utils/http/index.ts +226 -0
- package/template/src/utils/http/status.ts +18 -0
- package/template/src/utils/index.ts +31 -0
- package/template/src/utils/navigation/index.ts +10 -0
- package/template/src/utils/navigation/jump.ts +68 -0
- package/template/src/utils/navigation/route.ts +85 -0
- package/template/src/utils/navigation/worktab.ts +67 -0
- package/template/src/utils/router.ts +63 -0
- package/template/src/utils/socket/index.ts +423 -0
- package/template/src/utils/storage/index.ts +7 -0
- package/template/src/utils/storage/storage-config.ts +127 -0
- package/template/src/utils/storage/storage-key-manager.ts +97 -0
- package/template/src/utils/storage/storage.ts +250 -0
- package/template/src/utils/sys/console.ts +9 -0
- package/template/src/utils/sys/error-handle.ts +143 -0
- package/template/src/utils/sys/index.ts +2 -0
- package/template/src/utils/sys/mittBus.ts +61 -0
- package/template/src/utils/ui/animation.ts +80 -0
- package/template/src/utils/ui/colors.ts +273 -0
- package/template/src/utils/ui/emojo.ts +24 -0
- package/template/src/utils/ui/iconify-loader.ts +31 -0
- package/template/src/utils/ui/index.ts +11 -0
- package/template/src/utils/ui/loading.ts +158 -0
- package/template/src/utils/ui/tabs.ts +60 -0
- package/template/src/views/auth/forget-password/index.vue +62 -0
- package/template/src/views/auth/login/index.vue +166 -0
- package/template/src/views/auth/login/style.css +38 -0
- package/template/src/views/auth/register/index.vue +240 -0
- package/template/src/views/dashboard/console/index.vue +173 -0
- package/template/src/views/examples/analytics/index.vue +389 -0
- package/template/src/views/examples/complex-form/index.vue +395 -0
- package/template/src/views/examples/crud-workspace/index.vue +412 -0
- package/template/src/views/examples/navigation/detail/index.vue +151 -0
- package/template/src/views/examples/navigation/state/index.vue +226 -0
- package/template/src/views/examples/overview/index.vue +309 -0
- package/template/src/views/examples/permissions/index.vue +303 -0
- package/template/src/views/examples/search-table/index.vue +182 -0
- package/template/src/views/examples/search-table/search.config.ts +81 -0
- package/template/src/views/examples/search-table/service.ts +116 -0
- package/template/src/views/examples/search-table/table.config.ts +37 -0
- package/template/src/views/exception/403/index.vue +16 -0
- package/template/src/views/exception/404/index.vue +16 -0
- package/template/src/views/exception/500/index.vue +16 -0
- package/template/src/views/index/index.vue +29 -0
- package/template/src/views/index/style.scss +93 -0
- package/template/src/views/outside/Iframe.vue +42 -0
- package/template/src/views/result/fail/index.vue +28 -0
- package/template/src/views/result/success/index.vue +21 -0
- package/template/tests/e2e/auth.spec.ts +14 -0
- package/template/tests/e2e/search-table.spec.ts +154 -0
- package/template/tests/unit/adapters/auth.spec.ts +38 -0
- package/template/tests/unit/config/app-config.spec.ts +17 -0
- package/template/tests/unit/directives/highlight.spec.ts +20 -0
- package/template/tests/unit/http/contract.spec.ts +47 -0
- package/template/tests/unit/mock/search-table.spec.ts +62 -0
- package/template/tests/unit/router/examples.spec.ts +52 -0
- package/template/tsconfig.json +28 -0
- package/template/vite.config.ts +181 -0
- package/template/vitest.config.ts +27 -0
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<main class="permission-page" aria-labelledby="permission-title">
|
|
3
|
+
<section class="hero art-card">
|
|
4
|
+
<div>
|
|
5
|
+
<span>FOUNDATION / ACCESS CONTROL</span>
|
|
6
|
+
<h1 id="permission-title">权限演练场</h1>
|
|
7
|
+
<p>同时验证路由元数据、操作权限和角色权限。演示身份来自 Mock 认证适配器。</p>
|
|
8
|
+
</div>
|
|
9
|
+
<div class="identity" aria-label="当前演示身份">
|
|
10
|
+
<ArtSvgIcon icon="ri:shield-user-line" aria-hidden="true" />
|
|
11
|
+
<div
|
|
12
|
+
><small>当前身份</small><strong>{{ userName }}</strong></div
|
|
13
|
+
>
|
|
14
|
+
</div>
|
|
15
|
+
</section>
|
|
16
|
+
|
|
17
|
+
<section class="permission-grid" aria-label="权限层级">
|
|
18
|
+
<article v-for="item in permissionLayers" :key="item.title" class="layer-card art-card">
|
|
19
|
+
<span class="layer-card__icon"><ArtSvgIcon :icon="item.icon" aria-hidden="true" /></span>
|
|
20
|
+
<div
|
|
21
|
+
><h2>{{ item.title }}</h2
|
|
22
|
+
><p>{{ item.description }}</p
|
|
23
|
+
><code>{{ item.code }}</code></div
|
|
24
|
+
>
|
|
25
|
+
</article>
|
|
26
|
+
</section>
|
|
27
|
+
|
|
28
|
+
<section class="playground art-card" aria-labelledby="operation-title">
|
|
29
|
+
<div class="section-heading">
|
|
30
|
+
<div
|
|
31
|
+
><h2 id="operation-title">操作权限</h2
|
|
32
|
+
><p>当前路由开放 create、edit 和 export,approve 按钮会被指令从 DOM 移除。</p></div
|
|
33
|
+
>
|
|
34
|
+
<ElTag type="success" effect="light">3 项可用</ElTag>
|
|
35
|
+
</div>
|
|
36
|
+
<div class="button-row">
|
|
37
|
+
<ElButton v-auth="'create'" type="primary" @click="notify('create')">新增资源</ElButton>
|
|
38
|
+
<ElButton v-auth="'edit'" @click="notify('edit')">编辑资源</ElButton>
|
|
39
|
+
<ElButton v-auth="'export'" @click="notify('export')">导出数据</ElButton>
|
|
40
|
+
<ElButton v-auth="'approve'" type="warning">审核资源</ElButton>
|
|
41
|
+
</div>
|
|
42
|
+
<ElAlert title="安全提示" type="info" :closable="false" show-icon>
|
|
43
|
+
<template #default>前端权限只控制界面可见性,真实接口仍必须在服务端执行鉴权。</template>
|
|
44
|
+
</ElAlert>
|
|
45
|
+
</section>
|
|
46
|
+
|
|
47
|
+
<section class="role-section art-card" aria-labelledby="role-title">
|
|
48
|
+
<div class="section-heading"
|
|
49
|
+
><div
|
|
50
|
+
><h2 id="role-title">角色权限</h2
|
|
51
|
+
><p>Mock 管理员拥有 R_SUPER,审计员专属内容不会渲染。</p></div
|
|
52
|
+
></div
|
|
53
|
+
>
|
|
54
|
+
<div class="role-cards">
|
|
55
|
+
<article v-roles="'R_SUPER'" class="role-card is-allowed"
|
|
56
|
+
><ArtSvgIcon icon="ri:checkbox-circle-line" /><div
|
|
57
|
+
><strong>管理员区域</strong><p>角色校验通过,当前内容可见。</p></div
|
|
58
|
+
></article
|
|
59
|
+
>
|
|
60
|
+
<article v-roles="'R_AUDITOR'" class="role-card"><strong>审计员区域</strong></article>
|
|
61
|
+
<article class="role-card is-denied"
|
|
62
|
+
><ArtSvgIcon icon="ri:forbid-line" /><div
|
|
63
|
+
><strong>审计员区域</strong><p>角色不匹配,实际受控节点已从 DOM 移除。</p></div
|
|
64
|
+
></article
|
|
65
|
+
>
|
|
66
|
+
</div>
|
|
67
|
+
</section>
|
|
68
|
+
</main>
|
|
69
|
+
</template>
|
|
70
|
+
|
|
71
|
+
<script setup lang="ts">
|
|
72
|
+
import { ElMessage } from 'element-plus'
|
|
73
|
+
import { useUserStore } from '@/store/modules/user'
|
|
74
|
+
defineOptions({ name: 'PermissionPlaygroundExample' })
|
|
75
|
+
const userStore = useUserStore()
|
|
76
|
+
const userName = computed(() => userStore.getUserInfo.userName || '模板管理员')
|
|
77
|
+
const permissionLayers = [
|
|
78
|
+
{
|
|
79
|
+
title: '路由层',
|
|
80
|
+
description: '通过 roles 决定页面是否可以注册和访问。',
|
|
81
|
+
code: 'meta.roles',
|
|
82
|
+
icon: 'ri:route-line'
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
title: '操作层',
|
|
86
|
+
description: '通过路由 authList 控制页面内具体操作。',
|
|
87
|
+
code: 'v-auth',
|
|
88
|
+
icon: 'ri:cursor-line'
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
title: '角色层',
|
|
92
|
+
description: '针对少量粗粒度区域进行角色判断。',
|
|
93
|
+
code: 'v-roles',
|
|
94
|
+
icon: 'ri:team-line'
|
|
95
|
+
}
|
|
96
|
+
]
|
|
97
|
+
const notify = (permission: string) => ElMessage.success(`权限 ${permission} 校验通过`)
|
|
98
|
+
</script>
|
|
99
|
+
|
|
100
|
+
<style scoped lang="scss">
|
|
101
|
+
.permission-page {
|
|
102
|
+
display: grid;
|
|
103
|
+
gap: 16px;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.hero {
|
|
107
|
+
display: flex;
|
|
108
|
+
gap: 24px;
|
|
109
|
+
align-items: center;
|
|
110
|
+
justify-content: space-between;
|
|
111
|
+
padding: 28px;
|
|
112
|
+
background:
|
|
113
|
+
radial-gradient(
|
|
114
|
+
circle at 90% 10%,
|
|
115
|
+
color-mix(in srgb, var(--el-color-primary) 16%, transparent),
|
|
116
|
+
transparent 36%
|
|
117
|
+
),
|
|
118
|
+
var(--default-box-color);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.hero > div:first-child > span {
|
|
122
|
+
font-size: 12px;
|
|
123
|
+
font-weight: 700;
|
|
124
|
+
color: var(--el-color-primary);
|
|
125
|
+
letter-spacing: 0.12em;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.hero h1 {
|
|
129
|
+
margin-top: 8px;
|
|
130
|
+
font-size: clamp(25px, 3vw, 34px);
|
|
131
|
+
font-weight: 650;
|
|
132
|
+
color: var(--art-gray-900);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.hero p,
|
|
136
|
+
.section-heading p {
|
|
137
|
+
margin-top: 7px;
|
|
138
|
+
line-height: 1.65;
|
|
139
|
+
color: var(--art-gray-600);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.identity {
|
|
143
|
+
display: flex;
|
|
144
|
+
flex: 0 0 auto;
|
|
145
|
+
gap: 12px;
|
|
146
|
+
align-items: center;
|
|
147
|
+
min-width: 190px;
|
|
148
|
+
padding: 16px;
|
|
149
|
+
background: color-mix(in srgb, var(--el-color-primary) 9%, var(--default-box-color));
|
|
150
|
+
border: 1px solid color-mix(in srgb, var(--el-color-primary) 18%, transparent);
|
|
151
|
+
border-radius: 12px;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.identity > svg {
|
|
155
|
+
width: 30px;
|
|
156
|
+
height: 30px;
|
|
157
|
+
color: var(--el-color-primary);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.identity small,
|
|
161
|
+
.identity strong {
|
|
162
|
+
display: block;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.identity small {
|
|
166
|
+
color: var(--art-gray-500);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.identity strong {
|
|
170
|
+
margin-top: 2px;
|
|
171
|
+
color: var(--art-gray-900);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.permission-grid {
|
|
175
|
+
display: grid;
|
|
176
|
+
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
177
|
+
gap: 16px;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.layer-card {
|
|
181
|
+
display: flex;
|
|
182
|
+
gap: 14px;
|
|
183
|
+
padding: 20px;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.layer-card__icon {
|
|
187
|
+
display: grid;
|
|
188
|
+
flex: 0 0 44px;
|
|
189
|
+
place-items: center;
|
|
190
|
+
width: 44px;
|
|
191
|
+
height: 44px;
|
|
192
|
+
color: var(--el-color-primary);
|
|
193
|
+
background: var(--el-color-primary-light-9);
|
|
194
|
+
border-radius: 10px;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.layer-card h2,
|
|
198
|
+
.section-heading h2 {
|
|
199
|
+
font-size: 18px;
|
|
200
|
+
font-weight: 600;
|
|
201
|
+
color: var(--art-gray-900);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.layer-card p {
|
|
205
|
+
min-height: 44px;
|
|
206
|
+
margin: 6px 0 10px;
|
|
207
|
+
line-height: 1.55;
|
|
208
|
+
color: var(--art-gray-600);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.layer-card code {
|
|
212
|
+
color: var(--el-color-primary);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
.playground,
|
|
216
|
+
.role-section {
|
|
217
|
+
padding: 24px;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.section-heading {
|
|
221
|
+
display: flex;
|
|
222
|
+
gap: 16px;
|
|
223
|
+
align-items: flex-start;
|
|
224
|
+
justify-content: space-between;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
.button-row {
|
|
228
|
+
display: flex;
|
|
229
|
+
flex-wrap: wrap;
|
|
230
|
+
gap: 10px;
|
|
231
|
+
margin: 22px 0;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.button-row :deep(.el-button) {
|
|
235
|
+
min-height: 44px;
|
|
236
|
+
margin: 0;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
.role-cards {
|
|
240
|
+
display: grid;
|
|
241
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
242
|
+
gap: 12px;
|
|
243
|
+
margin-top: 20px;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.role-card {
|
|
247
|
+
display: flex;
|
|
248
|
+
gap: 12px;
|
|
249
|
+
align-items: center;
|
|
250
|
+
min-height: 92px;
|
|
251
|
+
padding: 18px;
|
|
252
|
+
border: 1px solid var(--art-gray-200);
|
|
253
|
+
border-radius: 12px;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.role-card > svg {
|
|
257
|
+
width: 26px;
|
|
258
|
+
height: 26px;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
.role-card strong {
|
|
262
|
+
color: var(--art-gray-900);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.role-card p {
|
|
266
|
+
margin-top: 5px;
|
|
267
|
+
color: var(--art-gray-600);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.role-card.is-allowed > svg {
|
|
271
|
+
color: var(--el-color-success);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
.role-card.is-denied {
|
|
275
|
+
border-style: dashed;
|
|
276
|
+
opacity: 0.72;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
.role-card.is-denied > svg {
|
|
280
|
+
color: var(--art-gray-500);
|
|
281
|
+
}
|
|
282
|
+
@media (width <= 760px) {
|
|
283
|
+
.hero {
|
|
284
|
+
flex-direction: column;
|
|
285
|
+
align-items: stretch;
|
|
286
|
+
padding: 20px;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.identity {
|
|
290
|
+
min-width: 0;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
.permission-grid,
|
|
294
|
+
.role-cards {
|
|
295
|
+
grid-template-columns: 1fr;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.playground,
|
|
299
|
+
.role-section {
|
|
300
|
+
padding: 20px;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
</style>
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<main class="search-table-page" aria-labelledby="search-table-title">
|
|
3
|
+
<header class="page-intro art-card">
|
|
4
|
+
<div>
|
|
5
|
+
<span>PAGE PATTERN / SEARCH TABLE</span>
|
|
6
|
+
<h1 id="search-table-title">搜索表格</h1>
|
|
7
|
+
<p>统一演示筛选、重置、分页、排序、批量选择和可配置的表格工具栏。</p>
|
|
8
|
+
</div>
|
|
9
|
+
</header>
|
|
10
|
+
|
|
11
|
+
<section class="table-shell" aria-label="服务目录">
|
|
12
|
+
<KvSearchTablePage
|
|
13
|
+
data-testid="service-search-table"
|
|
14
|
+
title="服务目录"
|
|
15
|
+
row-key="id"
|
|
16
|
+
:search-items="searchItems"
|
|
17
|
+
:columns="serviceTableColumns"
|
|
18
|
+
:request="fetchServicePage"
|
|
19
|
+
:toolbar-options="toolbarOptions"
|
|
20
|
+
>
|
|
21
|
+
<template #bulk-actions="{ selectedRows }">
|
|
22
|
+
<ElButton type="primary" plain @click="handleBulkAction(selectedRows)">
|
|
23
|
+
批量操作
|
|
24
|
+
</ElButton>
|
|
25
|
+
</template>
|
|
26
|
+
|
|
27
|
+
<template #name="{ row }">
|
|
28
|
+
<div class="service-name">
|
|
29
|
+
<span class="service-name__icon" aria-hidden="true">
|
|
30
|
+
<ElIcon><Connection /></ElIcon>
|
|
31
|
+
</span>
|
|
32
|
+
<div class="service-name__content">
|
|
33
|
+
<strong>{{ row.name }}</strong>
|
|
34
|
+
<code>{{ row.code }}</code>
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
</template>
|
|
38
|
+
|
|
39
|
+
<template #status="{ row }">
|
|
40
|
+
<ElTag :type="getStatusMeta(row.status).type" effect="light">
|
|
41
|
+
{{ getStatusMeta(row.status).label }}
|
|
42
|
+
</ElTag>
|
|
43
|
+
</template>
|
|
44
|
+
|
|
45
|
+
<template #operation="{ row }">
|
|
46
|
+
<ElButton link type="primary" @click="showRecord(row)">查看</ElButton>
|
|
47
|
+
</template>
|
|
48
|
+
</KvSearchTablePage>
|
|
49
|
+
</section>
|
|
50
|
+
</main>
|
|
51
|
+
</template>
|
|
52
|
+
|
|
53
|
+
<script setup lang="ts">
|
|
54
|
+
import { Connection } from '@element-plus/icons-vue'
|
|
55
|
+
import { ElButton, ElIcon, ElMessage, ElTag } from 'element-plus'
|
|
56
|
+
import { KvSearchTablePage } from '@kevairy/components'
|
|
57
|
+
import { searchItems, statusMeta } from './search.config'
|
|
58
|
+
import { serviceTableColumns } from './table.config'
|
|
59
|
+
import { fetchServicePage, type ServiceRecord, type ServiceStatus } from './service'
|
|
60
|
+
|
|
61
|
+
defineOptions({ name: 'SearchTableExample' })
|
|
62
|
+
|
|
63
|
+
const toolbarOptions = {
|
|
64
|
+
search: true,
|
|
65
|
+
refresh: true,
|
|
66
|
+
density: true,
|
|
67
|
+
fullscreen: true,
|
|
68
|
+
columns: true,
|
|
69
|
+
settings: true
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const getStatusMeta = (status: ServiceStatus) => statusMeta[status]
|
|
73
|
+
|
|
74
|
+
const handleBulkAction = (rows: ServiceRecord[]) => {
|
|
75
|
+
ElMessage.success(`已选择 ${rows.length} 项,业务项目可在此接入批量操作。`)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const showRecord = (row: ServiceRecord) => {
|
|
79
|
+
ElMessage.info(`${row.name}(${row.code})`)
|
|
80
|
+
}
|
|
81
|
+
</script>
|
|
82
|
+
|
|
83
|
+
<style scoped lang="scss">
|
|
84
|
+
.search-table-page {
|
|
85
|
+
display: flex;
|
|
86
|
+
flex-direction: column;
|
|
87
|
+
gap: 16px;
|
|
88
|
+
height: var(--art-full-height);
|
|
89
|
+
min-height: 0;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.page-intro {
|
|
93
|
+
flex: 0 0 auto;
|
|
94
|
+
padding: 24px;
|
|
95
|
+
|
|
96
|
+
span {
|
|
97
|
+
font-size: 12px;
|
|
98
|
+
font-weight: 700;
|
|
99
|
+
color: var(--el-color-primary);
|
|
100
|
+
letter-spacing: 0.12em;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
h1 {
|
|
104
|
+
margin-top: 6px;
|
|
105
|
+
font-size: 24px;
|
|
106
|
+
font-weight: 650;
|
|
107
|
+
color: var(--art-gray-900);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
p {
|
|
111
|
+
margin-top: 6px;
|
|
112
|
+
line-height: 1.6;
|
|
113
|
+
color: var(--art-gray-600);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.table-shell {
|
|
118
|
+
flex: 1 1 auto;
|
|
119
|
+
min-height: 420px;
|
|
120
|
+
overflow: hidden;
|
|
121
|
+
|
|
122
|
+
:deep(.kv-search-table-page) {
|
|
123
|
+
height: 100%;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.service-name {
|
|
128
|
+
display: flex;
|
|
129
|
+
gap: 10px;
|
|
130
|
+
align-items: center;
|
|
131
|
+
min-width: 0;
|
|
132
|
+
|
|
133
|
+
&__icon {
|
|
134
|
+
display: grid;
|
|
135
|
+
flex: 0 0 36px;
|
|
136
|
+
place-items: center;
|
|
137
|
+
width: 36px;
|
|
138
|
+
height: 36px;
|
|
139
|
+
color: var(--el-color-primary);
|
|
140
|
+
background: var(--el-color-primary-light-9);
|
|
141
|
+
border-radius: var(--el-border-radius-base);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
&__content {
|
|
145
|
+
min-width: 0;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
strong,
|
|
149
|
+
code {
|
|
150
|
+
display: block;
|
|
151
|
+
overflow: hidden;
|
|
152
|
+
text-overflow: ellipsis;
|
|
153
|
+
white-space: nowrap;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
strong {
|
|
157
|
+
font-size: 14px;
|
|
158
|
+
font-weight: 600;
|
|
159
|
+
color: var(--el-text-color-primary);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
code {
|
|
163
|
+
margin-top: 2px;
|
|
164
|
+
font-size: 11px;
|
|
165
|
+
color: var(--el-text-color-secondary);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
@media (width <= 720px) {
|
|
170
|
+
.search-table-page {
|
|
171
|
+
height: auto;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.page-intro {
|
|
175
|
+
padding: 20px;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.table-shell {
|
|
179
|
+
height: 640px;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
</style>
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { SearchFormItem } from '@kevairy/components'
|
|
2
|
+
import type { ServiceStatus } from './service'
|
|
3
|
+
|
|
4
|
+
export const statusMeta: Record<
|
|
5
|
+
ServiceStatus,
|
|
6
|
+
{ label: string; type: 'success' | 'warning' | 'info' }
|
|
7
|
+
> = {
|
|
8
|
+
running: { label: '运行中', type: 'success' },
|
|
9
|
+
warning: { label: '告警', type: 'warning' },
|
|
10
|
+
stopped: { label: '已停止', type: 'info' }
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const searchItems: SearchFormItem[] = [
|
|
14
|
+
{
|
|
15
|
+
key: 'keyword',
|
|
16
|
+
label: '关键词',
|
|
17
|
+
type: 'input',
|
|
18
|
+
props: { placeholder: '服务名称或编码', clearable: true }
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
key: 'category',
|
|
22
|
+
label: '分类',
|
|
23
|
+
type: 'select',
|
|
24
|
+
props: {
|
|
25
|
+
placeholder: '全部分类',
|
|
26
|
+
clearable: true,
|
|
27
|
+
options: ['应用服务', '数据服务', '基础设施'].map((value) => ({ label: value, value }))
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
key: 'status',
|
|
32
|
+
label: '状态',
|
|
33
|
+
type: 'select',
|
|
34
|
+
props: {
|
|
35
|
+
placeholder: '全部状态',
|
|
36
|
+
clearable: true,
|
|
37
|
+
options: Object.entries(statusMeta).map(([value, item]) => ({
|
|
38
|
+
label: item.label,
|
|
39
|
+
value
|
|
40
|
+
}))
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
key: 'owner',
|
|
45
|
+
label: '负责人',
|
|
46
|
+
type: 'select',
|
|
47
|
+
props: {
|
|
48
|
+
placeholder: '全部团队',
|
|
49
|
+
clearable: true,
|
|
50
|
+
options: ['平台团队', '数据团队', '应用团队', '基础架构团队'].map((value) => ({
|
|
51
|
+
label: value,
|
|
52
|
+
value
|
|
53
|
+
}))
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
key: 'region',
|
|
58
|
+
label: '区域',
|
|
59
|
+
type: 'select',
|
|
60
|
+
props: {
|
|
61
|
+
placeholder: '全部区域',
|
|
62
|
+
clearable: true,
|
|
63
|
+
options: ['华东', '华北', '华南'].map((value) => ({ label: value, value }))
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
key: 'updatedRange',
|
|
68
|
+
label: '更新时间',
|
|
69
|
+
type: 'daterange',
|
|
70
|
+
span: 12,
|
|
71
|
+
props: {
|
|
72
|
+
type: 'daterange',
|
|
73
|
+
valueFormat: 'YYYY-MM-DD',
|
|
74
|
+
startPlaceholder: '开始日期',
|
|
75
|
+
endPlaceholder: '结束日期',
|
|
76
|
+
rangeSeparator: '至',
|
|
77
|
+
clearable: true,
|
|
78
|
+
style: { width: '100%' }
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
]
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { PagedTableRequest, PagedTableResponse } from '@kevairy/components'
|
|
2
|
+
|
|
3
|
+
export type ServiceStatus = 'running' | 'warning' | 'stopped'
|
|
4
|
+
|
|
5
|
+
export interface ServiceRecord {
|
|
6
|
+
id: number
|
|
7
|
+
name: string
|
|
8
|
+
code: string
|
|
9
|
+
category: string
|
|
10
|
+
owner: string
|
|
11
|
+
region: string
|
|
12
|
+
status: ServiceStatus
|
|
13
|
+
requestCount: number
|
|
14
|
+
updatedAt: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ServiceQuery extends Record<string, unknown> {
|
|
18
|
+
keyword?: string
|
|
19
|
+
category?: string
|
|
20
|
+
owner?: string
|
|
21
|
+
region?: string
|
|
22
|
+
status?: ServiceStatus
|
|
23
|
+
updatedRange?: string[]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const categories = ['应用服务', '数据服务', '基础设施']
|
|
27
|
+
const owners = ['平台团队', '数据团队', '应用团队', '基础架构团队']
|
|
28
|
+
const regions = ['华东', '华北', '华南']
|
|
29
|
+
const statuses: ServiceStatus[] = ['running', 'warning', 'stopped']
|
|
30
|
+
|
|
31
|
+
const serviceRecords: ServiceRecord[] = Array.from({ length: 68 }, (_, index) => {
|
|
32
|
+
const id = index + 1
|
|
33
|
+
const day = String((index % 28) + 1).padStart(2, '0')
|
|
34
|
+
const hour = String((index * 3) % 24).padStart(2, '0')
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
id,
|
|
38
|
+
name: `模板服务 ${String(id).padStart(2, '0')}`,
|
|
39
|
+
code: `SERVICE_${String(id).padStart(3, '0')}`,
|
|
40
|
+
category: categories[index % categories.length],
|
|
41
|
+
owner: owners[index % owners.length],
|
|
42
|
+
region: regions[index % regions.length],
|
|
43
|
+
status: statuses[index % statuses.length],
|
|
44
|
+
requestCount: 1200 + ((index * 7919) % 88000),
|
|
45
|
+
updatedAt: `2026-08-${day} ${hour}:30`
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
const wait = (delay: number, signal: AbortSignal): Promise<void> =>
|
|
50
|
+
new Promise((resolve, reject) => {
|
|
51
|
+
const timer = globalThis.setTimeout(resolve, delay)
|
|
52
|
+
signal.addEventListener(
|
|
53
|
+
'abort',
|
|
54
|
+
() => {
|
|
55
|
+
globalThis.clearTimeout(timer)
|
|
56
|
+
reject(new DOMException('Request aborted', 'AbortError'))
|
|
57
|
+
},
|
|
58
|
+
{ once: true }
|
|
59
|
+
)
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* 可复制示例默认使用本地数据。接入真实项目时,只需替换此函数,
|
|
64
|
+
* 并继续返回统一的 { records, total } 结构。
|
|
65
|
+
*/
|
|
66
|
+
export async function fetchServicePage(
|
|
67
|
+
params: PagedTableRequest<ServiceQuery>
|
|
68
|
+
): Promise<PagedTableResponse<ServiceRecord>> {
|
|
69
|
+
const keyword = params.query.keyword?.trim().toLowerCase()
|
|
70
|
+
await wait(keyword === 'slow' ? 900 : 320, params.signal)
|
|
71
|
+
|
|
72
|
+
if (keyword === 'error') {
|
|
73
|
+
throw new Error('模拟请求失败。请修改关键词,或点击“重新加载”。')
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
let records = serviceRecords.filter((record) => {
|
|
77
|
+
const matchesKeyword =
|
|
78
|
+
!keyword ||
|
|
79
|
+
record.name.toLowerCase().includes(keyword) ||
|
|
80
|
+
record.code.toLowerCase().includes(keyword)
|
|
81
|
+
const matchesCategory = !params.query.category || record.category === params.query.category
|
|
82
|
+
const matchesOwner = !params.query.owner || record.owner === params.query.owner
|
|
83
|
+
const matchesRegion = !params.query.region || record.region === params.query.region
|
|
84
|
+
const matchesStatus = !params.query.status || record.status === params.query.status
|
|
85
|
+
const range = params.query.updatedRange
|
|
86
|
+
const date = record.updatedAt.slice(0, 10)
|
|
87
|
+
const matchesRange = !range?.length || (date >= range[0] && date <= range[1])
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
matchesKeyword &&
|
|
91
|
+
matchesCategory &&
|
|
92
|
+
matchesOwner &&
|
|
93
|
+
matchesRegion &&
|
|
94
|
+
matchesStatus &&
|
|
95
|
+
matchesRange
|
|
96
|
+
)
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
if (params.sort) {
|
|
100
|
+
const direction = params.sort.order === 'ascending' ? 1 : -1
|
|
101
|
+
const prop = params.sort.prop as keyof ServiceRecord
|
|
102
|
+
records = [...records].sort((left, right) => {
|
|
103
|
+
const leftValue = left[prop]
|
|
104
|
+
const rightValue = right[prop]
|
|
105
|
+
return (
|
|
106
|
+
String(leftValue).localeCompare(String(rightValue), 'zh-CN', { numeric: true }) * direction
|
|
107
|
+
)
|
|
108
|
+
})
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const start = (params.current - 1) * params.size
|
|
112
|
+
return {
|
|
113
|
+
records: records.slice(start, start + params.size),
|
|
114
|
+
total: records.length
|
|
115
|
+
}
|
|
116
|
+
}
|