@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,37 @@
|
|
|
1
|
+
import type { ColumnOption } from '@kevairy/components'
|
|
2
|
+
import type { ServiceRecord } from './service'
|
|
3
|
+
|
|
4
|
+
const numberFormatter = new Intl.NumberFormat('zh-CN')
|
|
5
|
+
|
|
6
|
+
export const serviceTableColumns: ColumnOption<ServiceRecord>[] = [
|
|
7
|
+
{ type: 'selection', width: 52, fixed: 'left', disabled: true },
|
|
8
|
+
{ type: 'globalIndex', label: '序号', width: 72, fixed: 'left', disabled: true },
|
|
9
|
+
{ prop: 'name', label: '服务', minWidth: 220, useSlot: true },
|
|
10
|
+
{ prop: 'category', label: '分类', minWidth: 110 },
|
|
11
|
+
{ prop: 'owner', label: '负责人', minWidth: 130 },
|
|
12
|
+
{ prop: 'region', label: '区域', width: 90 },
|
|
13
|
+
{ prop: 'status', label: '状态', width: 100, useSlot: true },
|
|
14
|
+
{
|
|
15
|
+
prop: 'requestCount',
|
|
16
|
+
label: '请求量',
|
|
17
|
+
minWidth: 110,
|
|
18
|
+
align: 'right',
|
|
19
|
+
sortable: 'custom',
|
|
20
|
+
formatter: (row) => numberFormatter.format(row.requestCount)
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
prop: 'updatedAt',
|
|
24
|
+
label: '更新时间',
|
|
25
|
+
minWidth: 170,
|
|
26
|
+
sortable: 'custom'
|
|
27
|
+
},
|
|
28
|
+
{ prop: 'code', label: '服务编码', minWidth: 150, visible: false },
|
|
29
|
+
{
|
|
30
|
+
prop: 'operation',
|
|
31
|
+
label: '操作',
|
|
32
|
+
width: 80,
|
|
33
|
+
fixed: 'right',
|
|
34
|
+
disabled: true,
|
|
35
|
+
useSlot: true
|
|
36
|
+
}
|
|
37
|
+
]
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<!-- 403页面 -->
|
|
2
|
+
<template>
|
|
3
|
+
<ArtException
|
|
4
|
+
:data="{
|
|
5
|
+
title: '403',
|
|
6
|
+
desc: $t('exceptionPage.403'),
|
|
7
|
+
btnText: $t('exceptionPage.gohome'),
|
|
8
|
+
imgUrl
|
|
9
|
+
}"
|
|
10
|
+
/>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script setup lang="ts">
|
|
14
|
+
import imgUrl from '@imgs/svg/403.svg'
|
|
15
|
+
defineOptions({ name: 'Exception403' })
|
|
16
|
+
</script>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<!-- 404页面 -->
|
|
2
|
+
<template>
|
|
3
|
+
<ArtException
|
|
4
|
+
:data="{
|
|
5
|
+
title: '404',
|
|
6
|
+
desc: $t('exceptionPage.404'),
|
|
7
|
+
btnText: $t('exceptionPage.gohome'),
|
|
8
|
+
imgUrl
|
|
9
|
+
}"
|
|
10
|
+
/>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script setup lang="ts">
|
|
14
|
+
import imgUrl from '@imgs/svg/404.svg'
|
|
15
|
+
defineOptions({ name: 'Exception404' })
|
|
16
|
+
</script>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<!-- 500页面 -->
|
|
2
|
+
<template>
|
|
3
|
+
<ArtException
|
|
4
|
+
:data="{
|
|
5
|
+
title: '500',
|
|
6
|
+
desc: $t('exceptionPage.500'),
|
|
7
|
+
btnText: $t('exceptionPage.gohome'),
|
|
8
|
+
imgUrl
|
|
9
|
+
}"
|
|
10
|
+
/>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script setup lang="ts">
|
|
14
|
+
import imgUrl from '@imgs/svg/500.svg'
|
|
15
|
+
defineOptions({ name: 'Exception500' })
|
|
16
|
+
</script>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<!-- 布局容器 -->
|
|
2
|
+
<template>
|
|
3
|
+
<div class="app-layout">
|
|
4
|
+
<aside id="app-sidebar">
|
|
5
|
+
<ArtSidebarMenu />
|
|
6
|
+
</aside>
|
|
7
|
+
|
|
8
|
+
<main id="app-main">
|
|
9
|
+
<div id="app-header">
|
|
10
|
+
<ArtHeaderBar />
|
|
11
|
+
</div>
|
|
12
|
+
<div id="app-content">
|
|
13
|
+
<ArtPageContent />
|
|
14
|
+
</div>
|
|
15
|
+
</main>
|
|
16
|
+
|
|
17
|
+
<div id="app-global">
|
|
18
|
+
<ArtGlobalComponent />
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
</template>
|
|
22
|
+
|
|
23
|
+
<script setup lang="ts">
|
|
24
|
+
defineOptions({ name: 'AppLayout' })
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<style lang="scss" scoped>
|
|
28
|
+
@use './style';
|
|
29
|
+
</style>
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
.app-layout {
|
|
2
|
+
display: flex;
|
|
3
|
+
width: 100%;
|
|
4
|
+
min-height: 100vh;
|
|
5
|
+
background: var(--default-bg-color);
|
|
6
|
+
|
|
7
|
+
#app-sidebar {
|
|
8
|
+
flex-shrink: 0;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
#app-main {
|
|
12
|
+
display: flex;
|
|
13
|
+
flex: 1;
|
|
14
|
+
flex-direction: column;
|
|
15
|
+
min-width: 0;
|
|
16
|
+
height: 100vh;
|
|
17
|
+
overflow: auto;
|
|
18
|
+
|
|
19
|
+
#app-header {
|
|
20
|
+
position: sticky;
|
|
21
|
+
top: 0;
|
|
22
|
+
z-index: 50;
|
|
23
|
+
flex-shrink: 0;
|
|
24
|
+
width: 100%;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
#app-content {
|
|
28
|
+
flex: 1;
|
|
29
|
+
|
|
30
|
+
:deep(.layout-content) {
|
|
31
|
+
box-sizing: border-box;
|
|
32
|
+
width: calc(100% - 40px);
|
|
33
|
+
margin: auto;
|
|
34
|
+
|
|
35
|
+
// 子页面默认 style
|
|
36
|
+
.page-content {
|
|
37
|
+
position: relative;
|
|
38
|
+
box-sizing: border-box;
|
|
39
|
+
padding: 20px;
|
|
40
|
+
overflow: hidden;
|
|
41
|
+
background: var(--default-box-color);
|
|
42
|
+
border-radius: calc(var(--custom-radius) / 2 + 2px) !important;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@media only screen and (width <= 1180px) {
|
|
50
|
+
.app-layout {
|
|
51
|
+
#app-main {
|
|
52
|
+
height: 100dvh;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@media only screen and (width <= 800px) {
|
|
58
|
+
.app-layout {
|
|
59
|
+
position: relative;
|
|
60
|
+
|
|
61
|
+
#app-sidebar {
|
|
62
|
+
position: fixed;
|
|
63
|
+
top: 0;
|
|
64
|
+
left: 0;
|
|
65
|
+
z-index: 300;
|
|
66
|
+
height: 100vh;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
#app-main {
|
|
70
|
+
width: 100%;
|
|
71
|
+
height: auto;
|
|
72
|
+
overflow: visible;
|
|
73
|
+
|
|
74
|
+
#app-content {
|
|
75
|
+
:deep(.layout-content) {
|
|
76
|
+
width: calc(100% - 40px);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@media only screen and (width <= 640px) {
|
|
84
|
+
.app-layout {
|
|
85
|
+
#app-main {
|
|
86
|
+
#app-content {
|
|
87
|
+
:deep(.layout-content) {
|
|
88
|
+
width: calc(100% - 30px);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="box-border w-full h-full" v-loading="isLoading">
|
|
3
|
+
<iframe
|
|
4
|
+
ref="iframeRef"
|
|
5
|
+
:src="iframeUrl"
|
|
6
|
+
frameborder="0"
|
|
7
|
+
class="w-full h-full min-h-[calc(100vh-120px)] border-none"
|
|
8
|
+
@load="handleIframeLoad"
|
|
9
|
+
></iframe>
|
|
10
|
+
</div>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script setup lang="ts">
|
|
14
|
+
import { IframeRouteManager } from '@/router/core'
|
|
15
|
+
|
|
16
|
+
defineOptions({ name: 'IframeView' })
|
|
17
|
+
|
|
18
|
+
const route = useRoute()
|
|
19
|
+
const isLoading = ref(true)
|
|
20
|
+
const iframeUrl = ref('')
|
|
21
|
+
const iframeRef = ref<HTMLIFrameElement | null>(null)
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 初始化 iframe URL
|
|
25
|
+
* 从路由配置中获取对应的外部链接地址
|
|
26
|
+
*/
|
|
27
|
+
onMounted(() => {
|
|
28
|
+
const iframeRoute = IframeRouteManager.getInstance().findByPath(route.path)
|
|
29
|
+
|
|
30
|
+
if (iframeRoute?.meta) {
|
|
31
|
+
iframeUrl.value = iframeRoute.meta.link || ''
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 处理 iframe 加载完成事件
|
|
37
|
+
* 隐藏加载状态
|
|
38
|
+
*/
|
|
39
|
+
const handleIframeLoad = (): void => {
|
|
40
|
+
isLoading.value = false
|
|
41
|
+
}
|
|
42
|
+
</script>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<ArtResultPage
|
|
3
|
+
type="fail"
|
|
4
|
+
title="提交失败"
|
|
5
|
+
message="请核对并修改以下信息后,再重新提交。"
|
|
6
|
+
iconCode="ri:close-fill"
|
|
7
|
+
>
|
|
8
|
+
<template #content>
|
|
9
|
+
<p>您提交的内容有如下错误:</p>
|
|
10
|
+
<p>
|
|
11
|
+
<ArtSvgIcon icon="ri:close-circle-line" class="text-red-500 mr-1" />
|
|
12
|
+
<span>您的账户已被冻结</span>
|
|
13
|
+
</p>
|
|
14
|
+
<p>
|
|
15
|
+
<ArtSvgIcon icon="ri:close-circle-line" class="text-red-500 mr-1" />
|
|
16
|
+
<span>您的账户还不具备申请资格</span>
|
|
17
|
+
</p>
|
|
18
|
+
</template>
|
|
19
|
+
<template #buttons>
|
|
20
|
+
<ElButton type="primary" v-ripple>返回修改</ElButton>
|
|
21
|
+
<ElButton v-ripple>查看</ElButton>
|
|
22
|
+
</template>
|
|
23
|
+
</ArtResultPage>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<script setup lang="ts">
|
|
27
|
+
defineOptions({ name: 'ResultFail' })
|
|
28
|
+
</script>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<ArtResultPage
|
|
3
|
+
type="success"
|
|
4
|
+
title="提交成功"
|
|
5
|
+
message="提交结果页用于反馈一系列操作任务的处理结果,如果仅是简单操作,使用 Message 全局提示反馈即可。灰色区域可以显示一些补充的信息。"
|
|
6
|
+
iconCode="ri:check-fill"
|
|
7
|
+
>
|
|
8
|
+
<template #content>
|
|
9
|
+
<p>已提交申请,等待部门审核。</p>
|
|
10
|
+
</template>
|
|
11
|
+
<template #buttons>
|
|
12
|
+
<ElButton type="primary" v-ripple>返回修改</ElButton>
|
|
13
|
+
<ElButton v-ripple>查看</ElButton>
|
|
14
|
+
<ElButton v-ripple>打印</ElButton>
|
|
15
|
+
</template>
|
|
16
|
+
</ArtResultPage>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script setup lang="ts">
|
|
20
|
+
defineOptions({ name: 'ResultSuccess' })
|
|
21
|
+
</script>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { expect, test } from '@playwright/test'
|
|
2
|
+
|
|
3
|
+
test('redirects anonymous users and signs in to the configured home page', async ({ page }) => {
|
|
4
|
+
await page.goto('/#/dashboard/console')
|
|
5
|
+
|
|
6
|
+
await expect(page).toHaveURL(/#\/auth\/login\?redirect=/)
|
|
7
|
+
await expect(page.getByRole('alert')).toContainText('模板 Mock 模式')
|
|
8
|
+
|
|
9
|
+
await page.getByRole('button', { name: '进入系统(Mock)' }).click()
|
|
10
|
+
|
|
11
|
+
await expect(page).toHaveURL(/#\/dashboard\/console/)
|
|
12
|
+
await expect(page.getByRole('heading', { name: __DISPLAY_NAME_LITERAL__ })).toBeVisible()
|
|
13
|
+
await expect(page).toHaveTitle(/__DISPLAY_NAME_REGEX__/)
|
|
14
|
+
})
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { expect, test, type Page } from '@playwright/test'
|
|
2
|
+
|
|
3
|
+
const openSearchTable = async (page: Page) => {
|
|
4
|
+
await page.goto('/#/examples/search-table')
|
|
5
|
+
const loginButton = page.getByRole('button', { name: '进入系统(Mock)' })
|
|
6
|
+
await expect(loginButton).toBeVisible()
|
|
7
|
+
await loginButton.click()
|
|
8
|
+
|
|
9
|
+
await expect(page).toHaveURL(/#\/examples\/search-table/)
|
|
10
|
+
await expect(page.getByText('服务目录', { exact: true })).toBeVisible()
|
|
11
|
+
await expect(page.getByText('共 68 项')).toBeVisible()
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
test('supports search, reset, pagination, errors, selection and keyboard toolbar actions', async ({
|
|
15
|
+
page
|
|
16
|
+
}) => {
|
|
17
|
+
await openSearchTable(page)
|
|
18
|
+
|
|
19
|
+
const layout = await page.evaluate(() => {
|
|
20
|
+
const appMain = document.querySelector<HTMLElement>('#app-main')
|
|
21
|
+
const header = document.querySelector<HTMLElement>('#app-header')
|
|
22
|
+
const searchTablePage = document.querySelector<HTMLElement>('.search-table-page')
|
|
23
|
+
const pagination = document.querySelector<HTMLElement>('.kv-table .pagination')
|
|
24
|
+
const toolbarButton = document.querySelector<HTMLElement>('.toolbar-button')
|
|
25
|
+
const toolbarButtonRect = toolbarButton?.getBoundingClientRect()
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
availableHeight:
|
|
29
|
+
(appMain?.getBoundingClientRect().height ?? 0) -
|
|
30
|
+
(header?.getBoundingClientRect().height ?? 0) -
|
|
31
|
+
15,
|
|
32
|
+
pageHeight: searchTablePage?.getBoundingClientRect().height ?? 0,
|
|
33
|
+
paginationBottom: pagination?.getBoundingClientRect().bottom ?? Number.POSITIVE_INFINITY,
|
|
34
|
+
viewportHeight: document.documentElement.clientHeight,
|
|
35
|
+
paginationRight: pagination?.classList.contains('right') ?? false,
|
|
36
|
+
paginationOverflowX: pagination ? getComputedStyle(pagination).overflowX : null,
|
|
37
|
+
paginationClientWidth: pagination?.clientWidth ?? 0,
|
|
38
|
+
paginationScrollWidth: pagination?.scrollWidth ?? 0,
|
|
39
|
+
toolbarButtonWidth: toolbarButtonRect?.width ?? 0,
|
|
40
|
+
toolbarButtonHeight: toolbarButtonRect?.height ?? 0
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
expect(Math.abs(layout.pageHeight - layout.availableHeight)).toBeLessThanOrEqual(1)
|
|
45
|
+
expect(layout.paginationBottom).toBeLessThanOrEqual(layout.viewportHeight)
|
|
46
|
+
expect(layout.paginationRight).toBe(true)
|
|
47
|
+
expect(layout.paginationOverflowX).toBe('hidden')
|
|
48
|
+
expect(layout.paginationScrollWidth).toBeLessThanOrEqual(layout.paginationClientWidth)
|
|
49
|
+
expect(layout.toolbarButtonWidth).toBe(32)
|
|
50
|
+
expect(layout.toolbarButtonHeight).toBe(32)
|
|
51
|
+
|
|
52
|
+
const keyword = page.getByPlaceholder('服务名称或编码')
|
|
53
|
+
await keyword.fill('SERVICE_001')
|
|
54
|
+
await page.getByRole('button', { name: '查询', exact: true }).click()
|
|
55
|
+
await expect(page.getByText('共 1 项')).toBeVisible()
|
|
56
|
+
await expect(page.getByText('模板服务 01')).toBeVisible()
|
|
57
|
+
|
|
58
|
+
await page.getByRole('button', { name: '重置', exact: true }).click()
|
|
59
|
+
await expect(page.getByText('共 68 项')).toBeVisible()
|
|
60
|
+
|
|
61
|
+
const nextPage = page.getByRole('button', { name: '下一页' })
|
|
62
|
+
await nextPage.focus()
|
|
63
|
+
await page.keyboard.press('Enter')
|
|
64
|
+
await expect(page.getByText('模板服务 11')).toBeVisible()
|
|
65
|
+
|
|
66
|
+
const firstRowCheckbox = page.locator('.el-table__body-wrapper .el-checkbox').first()
|
|
67
|
+
await firstRowCheckbox.click()
|
|
68
|
+
await expect(page.getByText('已选择 1 项')).toBeVisible()
|
|
69
|
+
|
|
70
|
+
await keyword.fill('error')
|
|
71
|
+
await page.getByRole('button', { name: '查询', exact: true }).click()
|
|
72
|
+
const alert = page.getByRole('alert')
|
|
73
|
+
await expect(alert).toContainText('模拟请求失败')
|
|
74
|
+
await alert.getByRole('button', { name: '重试' }).focus()
|
|
75
|
+
await page.keyboard.press('Enter')
|
|
76
|
+
await expect(alert).toBeVisible()
|
|
77
|
+
|
|
78
|
+
await keyword.fill('SERVICE_002')
|
|
79
|
+
await page.getByRole('button', { name: '查询', exact: true }).click()
|
|
80
|
+
await expect(alert).toBeHidden()
|
|
81
|
+
await expect(page.getByText('模板服务 02')).toBeVisible()
|
|
82
|
+
|
|
83
|
+
const searchToggle = page.getByRole('button', { name: '显示或隐藏搜索条件' })
|
|
84
|
+
await searchToggle.focus()
|
|
85
|
+
await page.keyboard.press('Enter')
|
|
86
|
+
await expect(searchToggle).toHaveAttribute('aria-pressed', 'false')
|
|
87
|
+
await page.keyboard.press('Enter')
|
|
88
|
+
await expect(searchToggle).toHaveAttribute('aria-pressed', 'true')
|
|
89
|
+
|
|
90
|
+
const refresh = page.getByRole('button', { name: '刷新' })
|
|
91
|
+
await refresh.focus()
|
|
92
|
+
await page.keyboard.press('Enter')
|
|
93
|
+
await expect(refresh).toBeEnabled()
|
|
94
|
+
|
|
95
|
+
const density = page.getByRole('button', { name: '表格密度' })
|
|
96
|
+
await density.focus()
|
|
97
|
+
await page.keyboard.press('Enter')
|
|
98
|
+
await expect(page.getByText('紧凑', { exact: true })).toBeVisible()
|
|
99
|
+
|
|
100
|
+
const columns = page.getByRole('button', { name: '列设置' })
|
|
101
|
+
await columns.focus()
|
|
102
|
+
await page.keyboard.press('Enter')
|
|
103
|
+
await expect(page.getByRole('button', { name: '下移一列' }).first()).toBeVisible()
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
test('contains wide tables on mobile and supports dark and reduced-motion modes', async ({
|
|
107
|
+
page
|
|
108
|
+
}) => {
|
|
109
|
+
await page.setViewportSize({ width: 375, height: 812 })
|
|
110
|
+
await page.emulateMedia({ reducedMotion: 'reduce', colorScheme: 'dark' })
|
|
111
|
+
await page.addInitScript(() => localStorage.setItem('admin-template-theme', 'dark'))
|
|
112
|
+
await openSearchTable(page)
|
|
113
|
+
|
|
114
|
+
const metrics = await page.evaluate(() => {
|
|
115
|
+
const tableScroller = document.querySelector<HTMLElement>(
|
|
116
|
+
'.kv-table__viewport .el-table__body-wrapper .el-scrollbar__wrap'
|
|
117
|
+
)
|
|
118
|
+
const toolbarButton = document.querySelector<HTMLElement>('.toolbar-button')
|
|
119
|
+
const pagination = document.querySelector<HTMLElement>('.kv-table .pagination')
|
|
120
|
+
const toolbarButtonRect = toolbarButton?.getBoundingClientRect()
|
|
121
|
+
|
|
122
|
+
return {
|
|
123
|
+
pageClientWidth: document.documentElement.clientWidth,
|
|
124
|
+
pageScrollWidth: document.documentElement.scrollWidth,
|
|
125
|
+
tableClientWidth: tableScroller?.clientWidth ?? 0,
|
|
126
|
+
tableScrollWidth: tableScroller?.scrollWidth ?? 0,
|
|
127
|
+
transitionDuration: toolbarButton ? getComputedStyle(toolbarButton).transitionDuration : null,
|
|
128
|
+
reducedMotion: matchMedia('(prefers-reduced-motion: reduce)').matches,
|
|
129
|
+
dark: document.documentElement.classList.contains('dark'),
|
|
130
|
+
pageHeight:
|
|
131
|
+
document.querySelector<HTMLElement>('.search-table-page')?.getBoundingClientRect().height ??
|
|
132
|
+
0,
|
|
133
|
+
paginationRight: pagination?.classList.contains('right'),
|
|
134
|
+
paginationOverflowX: pagination ? getComputedStyle(pagination).overflowX : null,
|
|
135
|
+
paginationClientWidth: pagination?.clientWidth ?? 0,
|
|
136
|
+
paginationScrollWidth: pagination?.scrollWidth ?? 0,
|
|
137
|
+
toolbarButtonWidth: toolbarButtonRect?.width ?? 0,
|
|
138
|
+
toolbarButtonHeight: toolbarButtonRect?.height ?? 0
|
|
139
|
+
}
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
expect(metrics.dark).toBe(true)
|
|
143
|
+
expect(metrics.pageHeight).toBeGreaterThan(600)
|
|
144
|
+
expect(metrics.paginationRight).toBe(true)
|
|
145
|
+
expect(metrics.paginationOverflowX).toBe('hidden')
|
|
146
|
+
expect(metrics.paginationScrollWidth).toBeLessThanOrEqual(metrics.paginationClientWidth)
|
|
147
|
+
expect(metrics.toolbarButtonWidth).toBe(32)
|
|
148
|
+
expect(metrics.toolbarButtonHeight).toBe(32)
|
|
149
|
+
expect(metrics.pageScrollWidth).toBeLessThanOrEqual(metrics.pageClientWidth)
|
|
150
|
+
expect(metrics.tableScrollWidth).toBeGreaterThan(metrics.tableClientWidth)
|
|
151
|
+
expect(metrics.reducedMotion).toBe(true)
|
|
152
|
+
expect(Number.parseFloat(metrics.transitionDuration ?? '1')).toBeLessThan(0.001)
|
|
153
|
+
await expect(page.getByTestId('service-search-table')).toBeVisible()
|
|
154
|
+
})
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
2
|
+
import { authAdapter } from '@/adapters/auth'
|
|
3
|
+
import { ApiStatus } from '@/utils/http/status'
|
|
4
|
+
|
|
5
|
+
describe('authAdapter', () => {
|
|
6
|
+
beforeEach(() => vi.useFakeTimers())
|
|
7
|
+
afterEach(() => vi.useRealTimers())
|
|
8
|
+
|
|
9
|
+
it('keeps Mock as the template default and maps the stable login contract', async () => {
|
|
10
|
+
const request = authAdapter.login({ username: 'admin', password: '123456' })
|
|
11
|
+
await vi.advanceTimersByTimeAsync(250)
|
|
12
|
+
|
|
13
|
+
await expect(request).resolves.toMatchObject({
|
|
14
|
+
accessToken: expect.any(String),
|
|
15
|
+
refreshToken: expect.any(String)
|
|
16
|
+
})
|
|
17
|
+
expect(authAdapter.name).toBe('mock')
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
it('preserves authentication errors behind the adapter boundary', async () => {
|
|
21
|
+
const request = authAdapter.login({ username: 'invalid', password: 'invalid' })
|
|
22
|
+
const rejection = expect(request).rejects.toMatchObject({ code: ApiStatus.unauthorized })
|
|
23
|
+
|
|
24
|
+
await vi.advanceTimersByTimeAsync(250)
|
|
25
|
+
await rejection
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('returns normalized user information', async () => {
|
|
29
|
+
const request = authAdapter.getUserInfo()
|
|
30
|
+
await vi.advanceTimersByTimeAsync(250)
|
|
31
|
+
|
|
32
|
+
await expect(request).resolves.toMatchObject({
|
|
33
|
+
userId: 'admin',
|
|
34
|
+
roles: ['R_SUPER'],
|
|
35
|
+
buttons: ['*:*:*']
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
})
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import AppConfig from '@/config'
|
|
3
|
+
import { routeModules } from '@/router/modules'
|
|
4
|
+
|
|
5
|
+
describe('app config', () => {
|
|
6
|
+
it('provides the global brand and storage namespace', () => {
|
|
7
|
+
expect(AppConfig.systemInfo.name).toBeTruthy()
|
|
8
|
+
expect(AppConfig.systemInfo.logo).toBeTruthy()
|
|
9
|
+
expect(AppConfig.systemInfo.favicon).toBeTruthy()
|
|
10
|
+
expect(AppConfig.storage.namespace).toMatch(/^[a-z0-9-]+$/)
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
it('registers the examples used by the template documentation', () => {
|
|
14
|
+
expect(AppConfig.features.examples).toBe(true)
|
|
15
|
+
expect(routeModules.some((route) => route.name === 'Examples')).toBe(true)
|
|
16
|
+
})
|
|
17
|
+
})
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { processAllCodeBlocks } from '@/directives/core/highlight'
|
|
3
|
+
|
|
4
|
+
describe('highlight directive', () => {
|
|
5
|
+
it('loads the configured languages on demand and decorates code blocks', async () => {
|
|
6
|
+
const container = document.createElement('div')
|
|
7
|
+
container.innerHTML = `
|
|
8
|
+
<pre><code class="language-typescript">const message: string = 'hello'</code></pre>
|
|
9
|
+
`
|
|
10
|
+
|
|
11
|
+
await processAllCodeBlocks(container)
|
|
12
|
+
|
|
13
|
+
const code = container.querySelector('code')
|
|
14
|
+
expect(code).not.toBeNull()
|
|
15
|
+
expect(code?.classList.contains('hljs')).toBe(true)
|
|
16
|
+
expect(code?.getAttribute('data-highlighted')).toBe('true')
|
|
17
|
+
expect(code?.querySelector('.line-number')).not.toBeNull()
|
|
18
|
+
expect(container.querySelector('.copy-button')).not.toBeNull()
|
|
19
|
+
})
|
|
20
|
+
})
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import {
|
|
3
|
+
createRequestKey,
|
|
4
|
+
isApiSuccessCode,
|
|
5
|
+
normalizeApiCode,
|
|
6
|
+
stableSerialize
|
|
7
|
+
} from '@/utils/http/contract'
|
|
8
|
+
import { ApiStatus } from '@/utils/http/status'
|
|
9
|
+
|
|
10
|
+
describe('HTTP contract helpers', () => {
|
|
11
|
+
it('normalizes numeric response codes and rejects invalid values', () => {
|
|
12
|
+
expect(normalizeApiCode('0')).toBe(0)
|
|
13
|
+
expect(normalizeApiCode('200')).toBe(200)
|
|
14
|
+
expect(normalizeApiCode(200)).toBe(200)
|
|
15
|
+
expect(normalizeApiCode('invalid')).toBe(ApiStatus.error)
|
|
16
|
+
expect(normalizeApiCode(undefined)).toBe(ApiStatus.error)
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it('supports both common success code conventions', () => {
|
|
20
|
+
expect(isApiSuccessCode(0)).toBe(true)
|
|
21
|
+
expect(isApiSuccessCode(200)).toBe(true)
|
|
22
|
+
expect(isApiSuccessCode(201)).toBe(false)
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
it('serializes object keys deterministically', () => {
|
|
26
|
+
expect(stableSerialize({ status: 'running', page: 1 })).toBe(
|
|
27
|
+
stableSerialize({ page: 1, status: 'running' })
|
|
28
|
+
)
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it('creates the same duplicate-request key for equivalent payloads', () => {
|
|
32
|
+
const left = createRequestKey({
|
|
33
|
+
method: 'post',
|
|
34
|
+
url: '/services',
|
|
35
|
+
params: { page: 1, size: 10 },
|
|
36
|
+
data: { owner: 'platform', enabled: false }
|
|
37
|
+
})
|
|
38
|
+
const right = createRequestKey({
|
|
39
|
+
method: 'POST',
|
|
40
|
+
url: '/services',
|
|
41
|
+
params: { size: 10, page: 1 },
|
|
42
|
+
data: { enabled: false, owner: 'platform' }
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
expect(left).toBe(right)
|
|
46
|
+
})
|
|
47
|
+
})
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
2
|
+
import { fetchServicePage, type ServiceQuery } from '@/views/examples/search-table/service'
|
|
3
|
+
import type { PagedTableRequest } from '@kevairy/components'
|
|
4
|
+
|
|
5
|
+
function requestParams(
|
|
6
|
+
query: ServiceQuery = {},
|
|
7
|
+
overrides: Partial<PagedTableRequest<ServiceQuery>> = {}
|
|
8
|
+
): PagedTableRequest<ServiceQuery> {
|
|
9
|
+
return {
|
|
10
|
+
query,
|
|
11
|
+
current: 1,
|
|
12
|
+
size: 10,
|
|
13
|
+
signal: new AbortController().signal,
|
|
14
|
+
...overrides
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async function settle<T>(promise: Promise<T>, delay = 320): Promise<T> {
|
|
19
|
+
await vi.advanceTimersByTimeAsync(delay)
|
|
20
|
+
return promise
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
describe('fetchServicePage', () => {
|
|
24
|
+
beforeEach(() => vi.useFakeTimers())
|
|
25
|
+
afterEach(() => vi.useRealTimers())
|
|
26
|
+
|
|
27
|
+
it('filters and paginates deterministic records', async () => {
|
|
28
|
+
const response = await settle(fetchServicePage(requestParams({ category: '应用服务' })))
|
|
29
|
+
|
|
30
|
+
expect(response.total).toBeGreaterThan(10)
|
|
31
|
+
expect(response.records).toHaveLength(10)
|
|
32
|
+
expect(response.records.every((record) => record.category === '应用服务')).toBe(true)
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it('applies custom sorting before pagination', async () => {
|
|
36
|
+
const response = await settle(
|
|
37
|
+
fetchServicePage(requestParams({}, { sort: { prop: 'requestCount', order: 'descending' } }))
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
expect(response.records[0].requestCount).toBeGreaterThanOrEqual(
|
|
41
|
+
response.records[1].requestCount
|
|
42
|
+
)
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('exposes the documented error state', async () => {
|
|
46
|
+
const request = fetchServicePage(requestParams({ keyword: 'error' }))
|
|
47
|
+
const rejection = expect(request).rejects.toThrow('模拟请求失败')
|
|
48
|
+
|
|
49
|
+
await vi.advanceTimersByTimeAsync(320)
|
|
50
|
+
await rejection
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it('rejects promptly when the request is aborted', async () => {
|
|
54
|
+
const controller = new AbortController()
|
|
55
|
+
const request = fetchServicePage(
|
|
56
|
+
requestParams({ keyword: 'slow' }, { signal: controller.signal })
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
controller.abort()
|
|
60
|
+
await expect(request).rejects.toMatchObject({ name: 'AbortError' })
|
|
61
|
+
})
|
|
62
|
+
})
|