@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,412 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<main class="crud-page" aria-labelledby="crud-title">
|
|
3
|
+
<header class="page-intro art-card">
|
|
4
|
+
<div>
|
|
5
|
+
<span>PAGE PATTERN / CRUD</span>
|
|
6
|
+
<h1 id="crud-title">资源管理工作台</h1>
|
|
7
|
+
<p>演示从查询、新增、编辑到删除确认的完整管理闭环,数据仅保存在当前页面。</p>
|
|
8
|
+
</div>
|
|
9
|
+
<ElButton type="primary" size="large" @click="openCreate">
|
|
10
|
+
<ArtSvgIcon icon="ri:add-line" aria-hidden="true" />
|
|
11
|
+
新增资源
|
|
12
|
+
</ElButton>
|
|
13
|
+
</header>
|
|
14
|
+
|
|
15
|
+
<section class="table-shell" aria-label="资源列表">
|
|
16
|
+
<KvSearchTablePage
|
|
17
|
+
ref="tableRef"
|
|
18
|
+
title="资源目录"
|
|
19
|
+
row-key="id"
|
|
20
|
+
:search-items="searchItems"
|
|
21
|
+
:columns="columns"
|
|
22
|
+
:request="fetchPage"
|
|
23
|
+
>
|
|
24
|
+
<template #bulk-actions="{ selectedRows }">
|
|
25
|
+
<ElButton type="danger" plain @click="removeSelected(selectedRows)">
|
|
26
|
+
删除所选 {{ selectedRows.length }} 项
|
|
27
|
+
</ElButton>
|
|
28
|
+
</template>
|
|
29
|
+
<template #name="{ row }">
|
|
30
|
+
<button class="resource-link" type="button" @click="openEdit(row)">
|
|
31
|
+
<strong>{{ row.name }}</strong>
|
|
32
|
+
<code>{{ row.code }}</code>
|
|
33
|
+
</button>
|
|
34
|
+
</template>
|
|
35
|
+
<template #status="{ row }">
|
|
36
|
+
<ElTag :type="getStatusMeta(row.status).type" effect="light">
|
|
37
|
+
{{ getStatusMeta(row.status).label }}
|
|
38
|
+
</ElTag>
|
|
39
|
+
</template>
|
|
40
|
+
<template #operation="{ row }">
|
|
41
|
+
<div class="row-actions">
|
|
42
|
+
<ElButton link type="primary" @click="openEdit(row)">编辑</ElButton>
|
|
43
|
+
<ElButton link type="danger" @click="removeOne(row)">删除</ElButton>
|
|
44
|
+
</div>
|
|
45
|
+
</template>
|
|
46
|
+
</KvSearchTablePage>
|
|
47
|
+
</section>
|
|
48
|
+
|
|
49
|
+
<KvDialog
|
|
50
|
+
v-model="dialogVisible"
|
|
51
|
+
:title="editingId ? '编辑资源' : '新增资源'"
|
|
52
|
+
width="min(560px, calc(100vw - 24px))"
|
|
53
|
+
draggable
|
|
54
|
+
resizable
|
|
55
|
+
destroy-on-close
|
|
56
|
+
@closed="resetForm"
|
|
57
|
+
>
|
|
58
|
+
<ElForm ref="formRef" :model="form" :rules="rules" label-position="top">
|
|
59
|
+
<div class="form-grid">
|
|
60
|
+
<ElFormItem label="资源名称" prop="name">
|
|
61
|
+
<ElInput v-model.trim="form.name" placeholder="例如:事件中心" autocomplete="off" />
|
|
62
|
+
</ElFormItem>
|
|
63
|
+
<ElFormItem label="资源编码" prop="code">
|
|
64
|
+
<ElInput v-model.trim="form.code" placeholder="例如:event-center" autocomplete="off" />
|
|
65
|
+
</ElFormItem>
|
|
66
|
+
<ElFormItem label="负责人" prop="owner">
|
|
67
|
+
<ElInput v-model.trim="form.owner" placeholder="请输入负责人" />
|
|
68
|
+
</ElFormItem>
|
|
69
|
+
<ElFormItem label="状态" prop="status">
|
|
70
|
+
<ElSelect v-model="form.status" style="width: 100%">
|
|
71
|
+
<ElOption
|
|
72
|
+
v-for="(item, value) in statusMeta"
|
|
73
|
+
:key="value"
|
|
74
|
+
:label="item.label"
|
|
75
|
+
:value="value"
|
|
76
|
+
/>
|
|
77
|
+
</ElSelect>
|
|
78
|
+
</ElFormItem>
|
|
79
|
+
</div>
|
|
80
|
+
</ElForm>
|
|
81
|
+
<template #footer>
|
|
82
|
+
<ElButton @click="dialogVisible = false">取消</ElButton>
|
|
83
|
+
<ElButton type="primary" :loading="saving" @click="saveResource">保存</ElButton>
|
|
84
|
+
</template>
|
|
85
|
+
</KvDialog>
|
|
86
|
+
</main>
|
|
87
|
+
</template>
|
|
88
|
+
|
|
89
|
+
<script setup lang="ts">
|
|
90
|
+
import { KvDialog, KvSearchTablePage } from '@kevairy/components'
|
|
91
|
+
import type { ColumnOption, PagedTableRequest, SearchFormItem } from '@kevairy/components'
|
|
92
|
+
import { ElMessage, ElMessageBox, type FormInstance, type FormRules } from 'element-plus'
|
|
93
|
+
|
|
94
|
+
defineOptions({ name: 'CrudWorkspaceExample' })
|
|
95
|
+
|
|
96
|
+
type ResourceStatus = 'active' | 'draft' | 'offline'
|
|
97
|
+
interface ResourceRecord {
|
|
98
|
+
id: number
|
|
99
|
+
name: string
|
|
100
|
+
code: string
|
|
101
|
+
owner: string
|
|
102
|
+
status: ResourceStatus
|
|
103
|
+
updatedAt: string
|
|
104
|
+
}
|
|
105
|
+
interface ResourceQuery extends Record<string, unknown> {
|
|
106
|
+
keyword?: string
|
|
107
|
+
status?: ResourceStatus
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const statusMeta: Record<
|
|
111
|
+
ResourceStatus,
|
|
112
|
+
{ label: string; type: 'success' | 'warning' | 'info' }
|
|
113
|
+
> = {
|
|
114
|
+
active: { label: '运行中', type: 'success' },
|
|
115
|
+
draft: { label: '草稿', type: 'warning' },
|
|
116
|
+
offline: { label: '已下线', type: 'info' }
|
|
117
|
+
}
|
|
118
|
+
const getStatusMeta = (status: ResourceStatus) => statusMeta[status]
|
|
119
|
+
const records = ref<ResourceRecord[]>([
|
|
120
|
+
{
|
|
121
|
+
id: 1,
|
|
122
|
+
name: '事件中心',
|
|
123
|
+
code: 'event-center',
|
|
124
|
+
owner: '平台团队',
|
|
125
|
+
status: 'active',
|
|
126
|
+
updatedAt: '2026-08-18 09:42'
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
id: 2,
|
|
130
|
+
name: '指标服务',
|
|
131
|
+
code: 'metrics-api',
|
|
132
|
+
owner: '数据团队',
|
|
133
|
+
status: 'active',
|
|
134
|
+
updatedAt: '2026-08-17 16:20'
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
id: 3,
|
|
138
|
+
name: '通知网关',
|
|
139
|
+
code: 'notify-gateway',
|
|
140
|
+
owner: '应用团队',
|
|
141
|
+
status: 'draft',
|
|
142
|
+
updatedAt: '2026-08-16 11:08'
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
id: 4,
|
|
146
|
+
name: '归档任务',
|
|
147
|
+
code: 'archive-worker',
|
|
148
|
+
owner: '平台团队',
|
|
149
|
+
status: 'offline',
|
|
150
|
+
updatedAt: '2026-08-15 18:31'
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
id: 5,
|
|
154
|
+
name: '文件服务',
|
|
155
|
+
code: 'file-service',
|
|
156
|
+
owner: '基础架构团队',
|
|
157
|
+
status: 'active',
|
|
158
|
+
updatedAt: '2026-08-14 14:06'
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
id: 6,
|
|
162
|
+
name: '规则引擎',
|
|
163
|
+
code: 'rule-engine',
|
|
164
|
+
owner: '应用团队',
|
|
165
|
+
status: 'draft',
|
|
166
|
+
updatedAt: '2026-08-13 10:15'
|
|
167
|
+
}
|
|
168
|
+
])
|
|
169
|
+
|
|
170
|
+
const searchItems: SearchFormItem[] = [
|
|
171
|
+
{
|
|
172
|
+
key: 'keyword',
|
|
173
|
+
label: '关键词',
|
|
174
|
+
type: 'input',
|
|
175
|
+
props: { clearable: true, placeholder: '名称或编码' }
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
key: 'status',
|
|
179
|
+
label: '状态',
|
|
180
|
+
type: 'select',
|
|
181
|
+
props: {
|
|
182
|
+
clearable: true,
|
|
183
|
+
placeholder: '全部状态',
|
|
184
|
+
options: Object.entries(statusMeta).map(([value, item]) => ({ value, label: item.label }))
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
]
|
|
188
|
+
const columns: ColumnOption<ResourceRecord>[] = [
|
|
189
|
+
{ type: 'selection', width: 52, fixed: 'left', disabled: true },
|
|
190
|
+
{ type: 'globalIndex', label: '序号', width: 72, disabled: true },
|
|
191
|
+
{ prop: 'name', label: '资源', minWidth: 210, useSlot: true },
|
|
192
|
+
{ prop: 'owner', label: '负责人', minWidth: 130 },
|
|
193
|
+
{ prop: 'status', label: '状态', width: 100, useSlot: true },
|
|
194
|
+
{ prop: 'updatedAt', label: '更新时间', minWidth: 170 },
|
|
195
|
+
{ prop: 'operation', label: '操作', width: 130, fixed: 'right', disabled: true, useSlot: true }
|
|
196
|
+
]
|
|
197
|
+
|
|
198
|
+
const fetchPage = async ({ query, current, size, signal }: PagedTableRequest<ResourceQuery>) => {
|
|
199
|
+
await new Promise<void>((resolve, reject) => {
|
|
200
|
+
const timer = window.setTimeout(resolve, 260)
|
|
201
|
+
signal.addEventListener(
|
|
202
|
+
'abort',
|
|
203
|
+
() => {
|
|
204
|
+
window.clearTimeout(timer)
|
|
205
|
+
reject(new DOMException('请求已取消', 'AbortError'))
|
|
206
|
+
},
|
|
207
|
+
{ once: true }
|
|
208
|
+
)
|
|
209
|
+
})
|
|
210
|
+
const keyword = query.keyword?.trim().toLowerCase()
|
|
211
|
+
const filtered = records.value.filter((item) => {
|
|
212
|
+
const matchesKeyword = !keyword || `${item.name} ${item.code}`.toLowerCase().includes(keyword)
|
|
213
|
+
return matchesKeyword && (!query.status || item.status === query.status)
|
|
214
|
+
})
|
|
215
|
+
const start = (current - 1) * size
|
|
216
|
+
return { records: filtered.slice(start, start + size), total: filtered.length }
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const tableRef = ref<{ refresh: () => Promise<void> | void }>()
|
|
220
|
+
const formRef = ref<FormInstance>()
|
|
221
|
+
const dialogVisible = ref(false)
|
|
222
|
+
const saving = ref(false)
|
|
223
|
+
const editingId = ref<number>()
|
|
224
|
+
const createForm = () => ({ name: '', code: '', owner: '', status: 'draft' as ResourceStatus })
|
|
225
|
+
const form = reactive(createForm())
|
|
226
|
+
const rules: FormRules = {
|
|
227
|
+
name: [{ required: true, message: '请输入资源名称', trigger: 'blur' }],
|
|
228
|
+
code: [
|
|
229
|
+
{ required: true, message: '请输入资源编码', trigger: 'blur' },
|
|
230
|
+
{
|
|
231
|
+
pattern: /^[a-z][a-z0-9-]*$/,
|
|
232
|
+
message: '使用小写字母、数字和短横线,并以字母开头',
|
|
233
|
+
trigger: 'blur'
|
|
234
|
+
}
|
|
235
|
+
],
|
|
236
|
+
owner: [{ required: true, message: '请输入负责人', trigger: 'blur' }]
|
|
237
|
+
}
|
|
238
|
+
const resetForm = () => {
|
|
239
|
+
editingId.value = undefined
|
|
240
|
+
Object.assign(form, createForm())
|
|
241
|
+
formRef.value?.clearValidate()
|
|
242
|
+
}
|
|
243
|
+
const openCreate = () => {
|
|
244
|
+
resetForm()
|
|
245
|
+
dialogVisible.value = true
|
|
246
|
+
}
|
|
247
|
+
const openEdit = (row: ResourceRecord) => {
|
|
248
|
+
editingId.value = row.id
|
|
249
|
+
Object.assign(form, row)
|
|
250
|
+
dialogVisible.value = true
|
|
251
|
+
}
|
|
252
|
+
const saveResource = async () => {
|
|
253
|
+
if (!(await formRef.value?.validate().catch(() => false))) return
|
|
254
|
+
saving.value = true
|
|
255
|
+
await new Promise((resolve) => window.setTimeout(resolve, 420))
|
|
256
|
+
if (editingId.value) {
|
|
257
|
+
const index = records.value.findIndex((item) => item.id === editingId.value)
|
|
258
|
+
if (index >= 0) records.value[index] = { ...records.value[index], ...form, updatedAt: '刚刚' }
|
|
259
|
+
} else {
|
|
260
|
+
records.value.unshift({ id: Date.now(), ...form, updatedAt: '刚刚' })
|
|
261
|
+
}
|
|
262
|
+
saving.value = false
|
|
263
|
+
dialogVisible.value = false
|
|
264
|
+
ElMessage.success(editingId.value ? '资源已更新' : '资源已创建')
|
|
265
|
+
await tableRef.value?.refresh()
|
|
266
|
+
}
|
|
267
|
+
const confirmRemove = (count: number) =>
|
|
268
|
+
ElMessageBox.confirm(`将删除 ${count} 项资源,此操作仅影响当前演示数据。`, '确认删除', {
|
|
269
|
+
type: 'warning',
|
|
270
|
+
confirmButtonText: '删除',
|
|
271
|
+
cancelButtonText: '取消',
|
|
272
|
+
confirmButtonClass: 'el-button--danger'
|
|
273
|
+
})
|
|
274
|
+
const removeOne = async (row: ResourceRecord) => {
|
|
275
|
+
try {
|
|
276
|
+
await confirmRemove(1)
|
|
277
|
+
records.value = records.value.filter((item) => item.id !== row.id)
|
|
278
|
+
ElMessage.success('已删除')
|
|
279
|
+
await tableRef.value?.refresh()
|
|
280
|
+
} catch {
|
|
281
|
+
/* cancelled */
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
const removeSelected = async (selected: ResourceRecord[]) => {
|
|
285
|
+
try {
|
|
286
|
+
await confirmRemove(selected.length)
|
|
287
|
+
const ids = new Set(selected.map((item) => item.id))
|
|
288
|
+
records.value = records.value.filter((item) => !ids.has(item.id))
|
|
289
|
+
ElMessage.success(`已删除 ${selected.length} 项`)
|
|
290
|
+
await tableRef.value?.refresh()
|
|
291
|
+
} catch {
|
|
292
|
+
/* cancelled */
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
</script>
|
|
296
|
+
|
|
297
|
+
<style scoped lang="scss">
|
|
298
|
+
.crud-page {
|
|
299
|
+
display: flex;
|
|
300
|
+
flex-direction: column;
|
|
301
|
+
gap: 16px;
|
|
302
|
+
height: var(--art-full-height);
|
|
303
|
+
min-height: 0;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
.page-intro {
|
|
307
|
+
display: flex;
|
|
308
|
+
flex: 0 0 auto;
|
|
309
|
+
gap: 24px;
|
|
310
|
+
align-items: center;
|
|
311
|
+
justify-content: space-between;
|
|
312
|
+
padding: 24px;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
.page-intro span {
|
|
316
|
+
font-size: 12px;
|
|
317
|
+
font-weight: 700;
|
|
318
|
+
color: var(--el-color-primary);
|
|
319
|
+
letter-spacing: 0.12em;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.page-intro h1 {
|
|
323
|
+
margin-top: 6px;
|
|
324
|
+
font-size: 24px;
|
|
325
|
+
font-weight: 650;
|
|
326
|
+
color: var(--art-gray-900);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
.page-intro p {
|
|
330
|
+
margin-top: 6px;
|
|
331
|
+
line-height: 1.6;
|
|
332
|
+
color: var(--art-gray-600);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
.page-intro :deep(.el-button) {
|
|
336
|
+
min-height: 44px;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
.table-shell {
|
|
340
|
+
flex: 1 1 auto;
|
|
341
|
+
min-height: 420px;
|
|
342
|
+
overflow: hidden;
|
|
343
|
+
|
|
344
|
+
:deep(.kv-search-table-page) {
|
|
345
|
+
height: 100%;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
.resource-link {
|
|
350
|
+
padding: 4px 0;
|
|
351
|
+
color: inherit;
|
|
352
|
+
text-align: left;
|
|
353
|
+
cursor: pointer;
|
|
354
|
+
background: none;
|
|
355
|
+
border: 0;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
.resource-link strong,
|
|
359
|
+
.resource-link code {
|
|
360
|
+
display: block;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
.resource-link strong {
|
|
364
|
+
color: var(--el-color-primary);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
.resource-link code {
|
|
368
|
+
margin-top: 3px;
|
|
369
|
+
font-size: 11px;
|
|
370
|
+
color: var(--el-text-color-secondary);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
.resource-link:focus-visible {
|
|
374
|
+
outline: 2px solid var(--el-color-primary);
|
|
375
|
+
outline-offset: 3px;
|
|
376
|
+
border-radius: 4px;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
.row-actions {
|
|
380
|
+
display: flex;
|
|
381
|
+
white-space: nowrap;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
.form-grid {
|
|
385
|
+
display: grid;
|
|
386
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
387
|
+
gap: 0 16px;
|
|
388
|
+
}
|
|
389
|
+
@media (width <= 720px) {
|
|
390
|
+
.crud-page {
|
|
391
|
+
height: auto;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
.page-intro {
|
|
395
|
+
flex-direction: column;
|
|
396
|
+
align-items: stretch;
|
|
397
|
+
padding: 20px;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
.page-intro :deep(.el-button) {
|
|
401
|
+
width: 100%;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
.form-grid {
|
|
405
|
+
grid-template-columns: 1fr;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
.table-shell {
|
|
409
|
+
height: 640px;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
</style>
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<main class="detail-page" aria-labelledby="detail-page-title">
|
|
3
|
+
<section class="detail-card art-card">
|
|
4
|
+
<div class="detail-card__icon" aria-hidden="true">
|
|
5
|
+
<ArtSvgIcon icon="ri:file-search-line" />
|
|
6
|
+
</div>
|
|
7
|
+
<ElTag effect="plain">菜单隐藏路由</ElTag>
|
|
8
|
+
<h1 id="detail-page-title">详情 {{ detailId }}</h1>
|
|
9
|
+
<p>
|
|
10
|
+
当前页面通过动态路径直接注册,但使用 <code>isHide</code> 从菜单隐藏,并通过
|
|
11
|
+
<code>activePath</code> 保持“页面状态保留演示”菜单项高亮。
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
<dl>
|
|
15
|
+
<div>
|
|
16
|
+
<dt>当前路径</dt>
|
|
17
|
+
<dd
|
|
18
|
+
><code>{{ route.path }}</code></dd
|
|
19
|
+
>
|
|
20
|
+
</div>
|
|
21
|
+
<div>
|
|
22
|
+
<dt>详情标识</dt>
|
|
23
|
+
<dd
|
|
24
|
+
><code>{{ detailId }}</code></dd
|
|
25
|
+
>
|
|
26
|
+
</div>
|
|
27
|
+
<div>
|
|
28
|
+
<dt>父级高亮</dt>
|
|
29
|
+
<dd
|
|
30
|
+
><code>{{ route.meta.activePath }}</code></dd
|
|
31
|
+
>
|
|
32
|
+
</div>
|
|
33
|
+
</dl>
|
|
34
|
+
|
|
35
|
+
<ElButton type="primary" size="large" @click="backToStateDemo">
|
|
36
|
+
<ArtSvgIcon icon="ri:arrow-left-line" aria-hidden="true" />
|
|
37
|
+
返回缓存演示
|
|
38
|
+
</ElButton>
|
|
39
|
+
</section>
|
|
40
|
+
</main>
|
|
41
|
+
</template>
|
|
42
|
+
|
|
43
|
+
<script setup lang="ts">
|
|
44
|
+
defineOptions({ name: 'NavigationDetail' })
|
|
45
|
+
|
|
46
|
+
const router = useRouter()
|
|
47
|
+
const route = useRoute()
|
|
48
|
+
const detailId = computed(() => String(route.params.id || 'unknown'))
|
|
49
|
+
|
|
50
|
+
const backToStateDemo = () => router.push({ name: 'NavigationState' })
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<style scoped lang="scss">
|
|
54
|
+
.detail-page {
|
|
55
|
+
display: grid;
|
|
56
|
+
place-items: center;
|
|
57
|
+
min-height: min(620px, calc(100vh - 220px));
|
|
58
|
+
padding: 24px;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.detail-card {
|
|
62
|
+
width: min(100%, 680px);
|
|
63
|
+
padding: 36px;
|
|
64
|
+
text-align: center;
|
|
65
|
+
|
|
66
|
+
&__icon {
|
|
67
|
+
display: grid;
|
|
68
|
+
place-items: center;
|
|
69
|
+
width: 72px;
|
|
70
|
+
height: 72px;
|
|
71
|
+
margin: 0 auto 20px;
|
|
72
|
+
color: var(--el-color-primary);
|
|
73
|
+
background: color-mix(in srgb, var(--el-color-primary) 12%, transparent);
|
|
74
|
+
border-radius: 18px;
|
|
75
|
+
|
|
76
|
+
svg {
|
|
77
|
+
width: 34px;
|
|
78
|
+
height: 34px;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
h1 {
|
|
83
|
+
margin-top: 14px;
|
|
84
|
+
font-size: clamp(24px, 3vw, 34px);
|
|
85
|
+
font-weight: 650;
|
|
86
|
+
color: var(--art-gray-900);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
> p {
|
|
90
|
+
max-width: 560px;
|
|
91
|
+
margin: 12px auto 0;
|
|
92
|
+
font-size: 15px;
|
|
93
|
+
line-height: 1.75;
|
|
94
|
+
color: var(--art-gray-700);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
code {
|
|
98
|
+
font-size: 13px;
|
|
99
|
+
font-weight: 600;
|
|
100
|
+
color: var(--el-color-primary);
|
|
101
|
+
overflow-wrap: anywhere;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
dl {
|
|
105
|
+
margin: 28px 0;
|
|
106
|
+
text-align: left;
|
|
107
|
+
border-top: 1px solid var(--art-gray-200);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
dl > div {
|
|
111
|
+
display: grid;
|
|
112
|
+
grid-template-columns: 110px minmax(0, 1fr);
|
|
113
|
+
gap: 16px;
|
|
114
|
+
padding: 14px 0;
|
|
115
|
+
border-bottom: 1px solid var(--art-gray-200);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
dt {
|
|
119
|
+
font-size: 13px;
|
|
120
|
+
color: var(--art-gray-600);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
dd {
|
|
124
|
+
min-width: 0;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
:deep(.el-button) {
|
|
128
|
+
min-height: 44px;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
@media (width <= 720px) {
|
|
133
|
+
.detail-page {
|
|
134
|
+
min-height: auto;
|
|
135
|
+
padding: 0;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.detail-card {
|
|
139
|
+
padding: 28px 20px;
|
|
140
|
+
|
|
141
|
+
dl > div {
|
|
142
|
+
grid-template-columns: 1fr;
|
|
143
|
+
gap: 6px;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
:deep(.el-button) {
|
|
147
|
+
width: 100%;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
</style>
|