diff --git a/.eslintrc.json b/.eslintrc similarity index 100% rename from .eslintrc.json rename to .eslintrc diff --git a/.prettierrc.json b/.prettierrc similarity index 100% rename from .prettierrc.json rename to .prettierrc diff --git a/index.html b/index.html index 205d54a..ddc4df4 100644 --- a/index.html +++ b/index.html @@ -47,10 +47,11 @@ .loading-tip { margin-top: 12px; line-height: 1; + color: #888; }
- loading + loading

欢迎访问%VITE_TITLE%

正在加载中, 请稍后...
diff --git a/package.json b/package.json index 4933c6f..a428560 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "unocss": "^0.49.8", "unplugin-auto-import": "^0.13.0", "unplugin-vue-components": "^0.23.0", + "unplugin-vue-router": "^0.7.0", "vite": "^4.4.9", "vite-plugin-mock": "^3.0.0", "vite-plugin-pages": "^0.28.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 64d323b..3ae0673 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -82,6 +82,9 @@ devDependencies: unplugin-vue-components: specifier: ^0.23.0 version: 0.23.0(vue@3.3.4) + unplugin-vue-router: + specifier: ^0.7.0 + version: 0.7.0(vue-router@4.2.4)(vue@3.3.4) vite: specifier: ^4.4.9 version: 4.4.9(less@4.2.0) @@ -208,7 +211,7 @@ packages: '@babel/parser': 7.22.16 '@babel/template': 7.22.15 '@babel/traverse': 7.22.17 - '@babel/types': 7.22.17 + '@babel/types': 7.23.0 convert-source-map: 1.9.0 debug: 4.3.4 gensync: 1.0.0-beta.2 @@ -222,7 +225,7 @@ packages: resolution: {integrity: sha512-Zu9oWARBqeVOW0dZOjXc3JObrzuqothQ3y/n1kUtrjCoCPLkXUwMvOo/F/TCfoHMbWIFlWwpZtkZVb9ga4U2pA==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.22.17 + '@babel/types': 7.23.0 '@jridgewell/gen-mapping': 0.3.3 '@jridgewell/trace-mapping': 0.3.19 jsesc: 2.5.2 @@ -232,7 +235,7 @@ packages: resolution: {integrity: sha512-LvBTxu8bQSQkcyKOU+a1btnNFQ1dMAd0R6PyW3arXes06F6QLWLIrd681bxRPIXlrMGR3XYnW9JyML7dP3qgxg==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.22.17 + '@babel/types': 7.23.0 dev: true /@babel/helper-compilation-targets@7.22.15: @@ -274,28 +277,28 @@ packages: engines: {node: '>=6.9.0'} dependencies: '@babel/template': 7.22.15 - '@babel/types': 7.22.17 + '@babel/types': 7.23.0 dev: true /@babel/helper-hoist-variables@7.22.5: resolution: {integrity: sha512-wGjk9QZVzvknA6yKIUURb8zY3grXCcOZt+/7Wcy8O2uctxhplmUPkOdlgoNhmdVee2c92JXbf1xpMtVNbfoxRw==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.22.17 + '@babel/types': 7.23.0 dev: true /@babel/helper-member-expression-to-functions@7.22.15: resolution: {integrity: sha512-qLNsZbgrNh0fDQBCPocSL8guki1hcPvltGDv/NxvUoABwFq7GkKSu1nRXeJkVZc+wJvne2E0RKQz+2SQrz6eAA==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.22.17 + '@babel/types': 7.23.0 dev: true /@babel/helper-module-imports@7.22.15: resolution: {integrity: sha512-0pYVBnDKZO2fnSPCrgM/6WMc7eS20Fbok+0r88fp+YtWVLZrp4CkafFGIp+W0VKw4a22sgebPT99y+FDNMdP4w==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.22.17 + '@babel/types': 7.23.0 dev: true /@babel/helper-module-transforms@7.22.17(@babel/core@7.22.17): @@ -309,14 +312,14 @@ packages: '@babel/helper-module-imports': 7.22.15 '@babel/helper-simple-access': 7.22.5 '@babel/helper-split-export-declaration': 7.22.6 - '@babel/helper-validator-identifier': 7.22.15 + '@babel/helper-validator-identifier': 7.22.20 dev: true /@babel/helper-optimise-call-expression@7.22.5: resolution: {integrity: sha512-HBwaojN0xFRx4yIvpwGqxiV2tUfl7401jlok564NgB9EHS1y6QT17FmKWm4ztqjeVdXLuC4fSvHc5ePpQjoTbw==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.22.17 + '@babel/types': 7.23.0 dev: true /@babel/helper-plugin-utils@7.22.5: @@ -340,21 +343,21 @@ packages: resolution: {integrity: sha512-n0H99E/K+Bika3++WNL17POvo4rKWZ7lZEp1Q+fStVbUi8nxPQEBOlTmCOxW/0JsS56SKKQ+ojAe2pHKJHN35w==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.22.17 + '@babel/types': 7.23.0 dev: true /@babel/helper-skip-transparent-expression-wrappers@7.22.5: resolution: {integrity: sha512-tK14r66JZKiC43p8Ki33yLBVJKlQDFoA8GYN67lWCDCqoL6EMMSuM9b+Iff2jHaM/RRFYl7K+iiru7hbRqNx8Q==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.22.17 + '@babel/types': 7.23.0 dev: true /@babel/helper-split-export-declaration@7.22.6: resolution: {integrity: sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.22.17 + '@babel/types': 7.23.0 dev: true /@babel/helper-string-parser@7.22.5: @@ -362,8 +365,8 @@ packages: engines: {node: '>=6.9.0'} dev: true - /@babel/helper-validator-identifier@7.22.15: - resolution: {integrity: sha512-4E/F9IIEi8WR94324mbDUMo074YTheJmd7eZF5vITTeYchqAi6sYXRLHUVsmkdmY4QjfKTcB2jB7dVP3NaBElQ==} + /@babel/helper-validator-identifier@7.22.20: + resolution: {integrity: sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==} engines: {node: '>=6.9.0'} dev: true @@ -378,7 +381,7 @@ packages: dependencies: '@babel/template': 7.22.15 '@babel/traverse': 7.22.17 - '@babel/types': 7.22.17 + '@babel/types': 7.23.0 transitivePeerDependencies: - supports-color dev: true @@ -387,7 +390,7 @@ packages: resolution: {integrity: sha512-C/BaXcnnvBCmHTpz/VGZ8jgtE2aYlW4hxDhseJAWZb7gqGM/qtCK6iZUb0TyKFf7BOUsBH7Q7fkRsDRhg1XklQ==} engines: {node: '>=6.9.0'} dependencies: - '@babel/helper-validator-identifier': 7.22.15 + '@babel/helper-validator-identifier': 7.22.20 chalk: 2.4.2 js-tokens: 4.0.0 dev: true @@ -397,7 +400,7 @@ packages: engines: {node: '>=6.0.0'} hasBin: true dependencies: - '@babel/types': 7.22.17 + '@babel/types': 7.23.0 dev: true /@babel/plugin-syntax-jsx@7.22.5(@babel/core@7.22.17): @@ -444,7 +447,7 @@ packages: dependencies: '@babel/code-frame': 7.22.13 '@babel/parser': 7.22.16 - '@babel/types': 7.22.17 + '@babel/types': 7.23.0 dev: true /@babel/traverse@7.22.17: @@ -458,19 +461,19 @@ packages: '@babel/helper-hoist-variables': 7.22.5 '@babel/helper-split-export-declaration': 7.22.6 '@babel/parser': 7.22.16 - '@babel/types': 7.22.17 + '@babel/types': 7.23.0 debug: 4.3.4 globals: 11.12.0 transitivePeerDependencies: - supports-color dev: true - /@babel/types@7.22.17: - resolution: {integrity: sha512-YSQPHLFtQNE5xN9tHuZnzu8vPr61wVTBZdfv1meex1NBosa4iT05k/Jw06ddJugi4bk7The/oSwQGFcksmEJQg==} + /@babel/types@7.23.0: + resolution: {integrity: sha512-0oIyUfKoI3mSqMvsxBdclDwxXKXAUA8v/apZbc+iSyARYou1o8ZGDxbUYyLFoW2arqS2jDGqJuZvv1d/io1axg==} engines: {node: '>=6.9.0'} dependencies: '@babel/helper-string-parser': 7.22.5 - '@babel/helper-validator-identifier': 7.22.15 + '@babel/helper-validator-identifier': 7.22.20 to-fast-properties: 2.0.0 dev: true @@ -1522,6 +1525,26 @@ packages: '@volar/language-core': 1.10.1 dev: true + /@vue-macros/common@1.8.0(vue@3.3.4): + resolution: {integrity: sha512-auDJJzE0z3uRe3867e0DsqcseKImktNf5ojCZgUKqiVxb2yTlwlgOVAYCgoep9oITqxkXQymSvFeKhedi8PhaA==} + engines: {node: '>=16.14.0'} + peerDependencies: + vue: ^2.7.0 || ^3.2.25 + peerDependenciesMeta: + vue: + optional: true + dependencies: + '@babel/types': 7.23.0 + '@rollup/pluginutils': 5.0.4 + '@vue/compiler-sfc': 3.3.4 + ast-kit: 0.11.2 + local-pkg: 0.4.3 + magic-string-ast: 0.3.0 + vue: 3.3.4 + transitivePeerDependencies: + - rollup + dev: true + /@vue/babel-helper-vue-transform-on@1.1.5: resolution: {integrity: sha512-SgUymFpMoAyWeYWLAY+MkCK3QEROsiUnfaw5zxOVD/M64KQs8D/4oK6Q5omVA2hnvEOE0SCkH2TZxs/jnnUj7w==} dev: true @@ -1536,7 +1559,7 @@ packages: '@babel/plugin-syntax-jsx': 7.22.5(@babel/core@7.22.17) '@babel/template': 7.22.15 '@babel/traverse': 7.22.17 - '@babel/types': 7.22.17 + '@babel/types': 7.23.0 '@vue/babel-helper-vue-transform-on': 1.1.5 camelcase: 6.3.0 html-tags: 3.3.1 @@ -1869,6 +1892,28 @@ packages: engines: {node: '>=0.10.0'} dev: true + /ast-kit@0.11.2: + resolution: {integrity: sha512-Q0DjXK4ApbVoIf9GLyCo252tUH44iTnD/hiJ2TQaJeydYWSpKk0sI34+WMel8S9Wt5pbLgG02oJ+gkgX5DV3sQ==} + engines: {node: '>=16.14.0'} + dependencies: + '@babel/parser': 7.22.16 + '@rollup/pluginutils': 5.0.4 + pathe: 1.1.1 + transitivePeerDependencies: + - rollup + dev: true + + /ast-kit@0.9.5: + resolution: {integrity: sha512-kbL7ERlqjXubdDd+szuwdlQ1xUxEz9mCz1+m07ftNVStgwRb2RWw+U6oKo08PAvOishMxiqz1mlJyLl8yQx2Qg==} + engines: {node: '>=16.14.0'} + dependencies: + '@babel/parser': 7.22.16 + '@rollup/pluginutils': 5.0.4 + pathe: 1.1.1 + transitivePeerDependencies: + - rollup + dev: true + /ast-types@0.13.4: resolution: {integrity: sha512-x1FCFnFifvYDDzTaLII71vG5uvDwgtmDTEVWAxrgeiR8VjMONcCXJx7E+USjDtHlwFmt9MysbqgF9b9Vjr6w+w==} engines: {node: '>=4'} @@ -1876,6 +1921,16 @@ packages: tslib: 2.6.2 dev: true + /ast-walker-scope@0.5.0: + resolution: {integrity: sha512-NsyHMxBh4dmdEHjBo1/TBZvCKxffmZxRYhmclfu0PP6Aftre47jOHYaYaNqJcV0bxihxFXhDkzLHUwHc0ocd0Q==} + engines: {node: '>=16.14.0'} + dependencies: + '@babel/parser': 7.22.16 + ast-kit: 0.9.5 + transitivePeerDependencies: + - rollup + dev: true + /async-retry@1.3.3: resolution: {integrity: sha512-wfr/jstw9xNi/0teMHrRW7dsz3Lt5ARhYNZ2ewpadnhaIp5mbALhOAP+EAdsC7t4Z6wqsDVv9+W6gm1Dk9mEyw==} dependencies: @@ -4655,6 +4710,13 @@ packages: engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} dev: true + /magic-string-ast@0.3.0: + resolution: {integrity: sha512-0shqecEPgdFpnI3AP90epXyxZy9g6CRZ+SZ7BcqFwYmtFEnZ1jpevcV5HoyVnlDS9gCnc1UIg3Rsvp3Ci7r8OA==} + engines: {node: '>=16.14.0'} + dependencies: + magic-string: 0.30.3 + dev: true + /magic-string@0.25.9: resolution: {integrity: sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==} dependencies: @@ -6759,7 +6821,7 @@ packages: acorn: 8.10.0 estree-walker: 3.0.3 magic-string: 0.30.3 - unplugin: 1.4.0 + unplugin: 1.5.0 dev: true /unimport@2.2.4: @@ -6775,7 +6837,7 @@ packages: pkg-types: 1.0.3 scule: 1.0.0 strip-literal: 1.3.0 - unplugin: 1.4.0 + unplugin: 1.5.0 transitivePeerDependencies: - rollup dev: true @@ -6793,7 +6855,7 @@ packages: pkg-types: 1.0.3 scule: 1.0.0 strip-literal: 1.3.0 - unplugin: 1.4.0 + unplugin: 1.5.0 transitivePeerDependencies: - rollup dev: true @@ -6903,6 +6965,33 @@ packages: - supports-color dev: true + /unplugin-vue-router@0.7.0(vue-router@4.2.4)(vue@3.3.4): + resolution: {integrity: sha512-ddRreGq0t5vlSB7OMy4e4cfU1w2AwBQCwmvW3oP/0IHQiokzbx4hd3TpwBu3eIAFVuhX2cwNQwp1U32UybTVCw==} + peerDependencies: + vue-router: ^4.1.0 + peerDependenciesMeta: + vue-router: + optional: true + dependencies: + '@babel/types': 7.23.0 + '@rollup/pluginutils': 5.0.4 + '@vue-macros/common': 1.8.0(vue@3.3.4) + ast-walker-scope: 0.5.0 + chokidar: 3.5.3 + fast-glob: 3.3.1 + json5: 2.2.3 + local-pkg: 0.4.3 + mlly: 1.4.2 + pathe: 1.1.1 + scule: 1.0.0 + unplugin: 1.5.0 + vue-router: 4.2.4(vue@3.3.4) + yaml: 2.3.2 + transitivePeerDependencies: + - rollup + - vue + dev: true + /unplugin@1.4.0: resolution: {integrity: sha512-5x4eIEL6WgbzqGtF9UV8VEC/ehKptPXDS6L2b0mv4FRMkJxRtjaJfOWDd6a8+kYbqsjklix7yWP0N3SUepjXcg==} dependencies: @@ -6912,6 +7001,15 @@ packages: webpack-virtual-modules: 0.5.0 dev: true + /unplugin@1.5.0: + resolution: {integrity: sha512-9ZdRwbh/4gcm1JTOkp9lAkIDrtOyOxgHmY7cjuwI8L/2RTikMcVG25GsZwNAgRuap3iDw2jeq7eoqtAsz5rW3A==} + dependencies: + acorn: 8.10.0 + chokidar: 3.5.3 + webpack-sources: 3.2.3 + webpack-virtual-modules: 0.5.0 + dev: true + /untildify@4.0.0: resolution: {integrity: sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw==} engines: {node: '>=8'} @@ -6923,7 +7021,7 @@ packages: dependencies: '@babel/core': 7.22.17 '@babel/standalone': 7.22.17 - '@babel/types': 7.22.17 + '@babel/types': 7.23.0 defu: 6.1.2 jiti: 1.20.0 mri: 1.2.0 diff --git a/src/pages/post/media/index.vue b/src/pages/post/media/index.vue index f5c34fe..7527c0e 100644 --- a/src/pages/post/media/index.vue +++ b/src/pages/post/media/index.vue @@ -2,15 +2,6 @@
- -
@@ -58,7 +49,7 @@ import { api } from "@/api"; import { Table, useTable } from "@/components"; import { dayjs } from "@/libs/dayjs"; -import numeral from 'numeral'; +import numeral from "numeral"; const getIcon = (mimetype: string) => { if (mimetype.startsWith("image")) { @@ -97,7 +88,7 @@ const table = useTable({ title: "大小", dataIndex: "description", width: 120, - render: ({ record }) => numeral(record.size).format('0 b') + render: ({ record }) => numeral(record.size).format("0 b"), }, { title: "上传时间", @@ -112,7 +103,7 @@ const table = useTable({ buttons: [ { type: "modify", - text: '修改' + text: "修改", }, { type: "delete", @@ -136,8 +127,8 @@ const table = useTable({ hideLabel: true, }, nodeProps: { - placeholder: '素材名称...' - } as any + placeholder: "素材名称...", + }, }, ], }, diff --git a/src/types/auto-router.d.ts b/src/types/auto-router.d.ts new file mode 100644 index 0000000..d40790c --- /dev/null +++ b/src/types/auto-router.d.ts @@ -0,0 +1,159 @@ +/* eslint-disable */ +/* prettier-ignore */ +// @ts-nocheck +// Generated by unplugin-vue-router. ‼️ DO NOT MODIFY THIS FILE ‼️ +// It's recommended to commit this file. +// Make sure to add this file to your tsconfig.json file as an "includes" or "files" entry. + +/// + +import type { + // type safe route locations + RouteLocationTypedList, + RouteLocationResolvedTypedList, + RouteLocationNormalizedTypedList, + RouteLocationNormalizedLoadedTypedList, + RouteLocationAsString, + RouteLocationAsRelativeTypedList, + RouteLocationAsPathTypedList, + + // helper types + // route definitions + RouteRecordInfo, + ParamValue, + ParamValueOneOrMore, + ParamValueZeroOrMore, + ParamValueZeroOrOne, + + // vue-router extensions + _RouterTyped, + RouterLinkTyped, + RouterLinkPropsTyped, + NavigationGuard, + UseLinkFnTyped, + + // data fetching + _DataLoader, + _DefineLoaderOptions, +} from 'unplugin-vue-router/types' + +declare module 'vue-router/auto/routes' { + export interface RouteNamedMap { + '/_layout/': RouteRecordInfo<'/_layout/', '/_layout', Record, Record>, + '/_login/': RouteRecordInfo<'/_login/', '/_login', Record, Record>, + '/[..._all]/': RouteRecordInfo<'/[..._all]/', '/:_all(.*)', { _all: ParamValue }, { _all: ParamValue }>, + '/demo/': RouteRecordInfo<'/demo/', '/demo', Record, Record>, + '/demo/test': RouteRecordInfo<'/demo/test', '/demo/test', Record, Record>, + '/home/': RouteRecordInfo<'/home/', '/home', Record, Record>, + '/my/': RouteRecordInfo<'/my/', '/my', Record, Record>, + '/post/': RouteRecordInfo<'/post/', '/post', Record, Record>, + '/post/category/': RouteRecordInfo<'/post/category/', '/post/category', Record, Record>, + '/post/comment/': RouteRecordInfo<'/post/comment/', '/post/comment', Record, Record>, + '/post/media/': RouteRecordInfo<'/post/media/', '/post/media', Record, Record>, + '/post/post/': RouteRecordInfo<'/post/post/', '/post/post', Record, Record>, + '/system/': RouteRecordInfo<'/system/', '/system', Record, Record>, + '/system/login-log/': RouteRecordInfo<'/system/login-log/', '/system/login-log', Record, Record>, + '/system/menu/': RouteRecordInfo<'/system/menu/', '/system/menu', Record, Record>, + '/system/operation-log/': RouteRecordInfo<'/system/operation-log/', '/system/operation-log', Record, Record>, + '/system/permission/': RouteRecordInfo<'/system/permission/', '/system/permission', Record, Record>, + '/system/role/': RouteRecordInfo<'/system/role/', '/system/role', Record, Record>, + '/system/user/': RouteRecordInfo<'/system/user/', '/system/user', Record, Record>, + } +} + +declare module 'vue-router/auto' { + import type { RouteNamedMap } from 'vue-router/auto/routes' + + export type RouterTyped = _RouterTyped + + /** + * Type safe version of `RouteLocationNormalized` (the type of `to` and `from` in navigation guards). + * Allows passing the name of the route to be passed as a generic. + */ + export type RouteLocationNormalized = RouteLocationNormalizedTypedList[Name] + + /** + * Type safe version of `RouteLocationNormalizedLoaded` (the return type of `useRoute()`). + * Allows passing the name of the route to be passed as a generic. + */ + export type RouteLocationNormalizedLoaded = RouteLocationNormalizedLoadedTypedList[Name] + + /** + * Type safe version of `RouteLocationResolved` (the returned route of `router.resolve()`). + * Allows passing the name of the route to be passed as a generic. + */ + export type RouteLocationResolved = RouteLocationResolvedTypedList[Name] + + /** + * Type safe version of `RouteLocation` . Allows passing the name of the route to be passed as a generic. + */ + export type RouteLocation = RouteLocationTypedList[Name] + + /** + * Type safe version of `RouteLocationRaw` . Allows passing the name of the route to be passed as a generic. + */ + export type RouteLocationRaw = + | RouteLocationAsString + | RouteLocationAsRelativeTypedList[Name] + | RouteLocationAsPathTypedList[Name] + + /** + * Generate a type safe params for a route location. Requires the name of the route to be passed as a generic. + */ + export type RouteParams = RouteNamedMap[Name]['params'] + /** + * Generate a type safe raw params for a route location. Requires the name of the route to be passed as a generic. + */ + export type RouteParamsRaw = RouteNamedMap[Name]['paramsRaw'] + + export function useRouter(): RouterTyped + export function useRoute(name?: Name): RouteLocationNormalizedLoadedTypedList[Name] + + export const useLink: UseLinkFnTyped + + export function onBeforeRouteLeave(guard: NavigationGuard): void + export function onBeforeRouteUpdate(guard: NavigationGuard): void + + export const RouterLink: RouterLinkTyped + export const RouterLinkProps: RouterLinkPropsTyped + + // Experimental Data Fetching + + export function defineLoader< + P extends Promise, + Name extends keyof RouteNamedMap = keyof RouteNamedMap, + isLazy extends boolean = false, + >( + name: Name, + loader: (route: RouteLocationNormalizedLoaded) => P, + options?: _DefineLoaderOptions, + ): _DataLoader, isLazy> + export function defineLoader< + P extends Promise, + isLazy extends boolean = false, + >( + loader: (route: RouteLocationNormalizedLoaded) => P, + options?: _DefineLoaderOptions, + ): _DataLoader, isLazy> + + export { + _definePage as definePage, + _HasDataLoaderMeta as HasDataLoaderMeta, + _setupDataFetchingGuard as setupDataFetchingGuard, + _stopDataFetchingScope as stopDataFetchingScope, + } from 'unplugin-vue-router/runtime' +} + +declare module 'vue-router' { + import type { RouteNamedMap } from 'vue-router/auto/routes' + + export interface TypesConfig { + beforeRouteUpdate: NavigationGuard + beforeRouteLeave: NavigationGuard + + $route: RouteLocationNormalizedLoadedTypedList[keyof RouteNamedMap] + $router: _RouterTyped + + RouterLink: RouterLinkTyped + } +} diff --git a/vite.config.ts b/vite.config.ts index 66d6d61..8a3a945 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -6,6 +6,7 @@ import Unocss from "unocss/vite"; import AutoImport from "unplugin-auto-import/vite"; import { ArcoResolver } from "unplugin-vue-components/resolvers"; import AutoComponent from "unplugin-vue-components/vite"; +import AutoRouter from "unplugin-vue-router/vite"; import { defineConfig, loadEnv } from "vite"; import Page from "vite-plugin-pages"; import { arcoToUnoColor } from "./scripts/vite/color"; @@ -20,41 +21,26 @@ export default defineConfig(({ mode }) => { const env = loadEnv(mode, process.cwd()); const host = env.VITE_HOST ?? "0.0.0.0"; const port = Number(env.VITE_PORT ?? 3020); - return { base: "./", - resolve: { - alias: [ - { - find: "@", - replacement: "/src", - }, - ], - }, - server: { - host, - port, - }, - css: { - preprocessorOptions: { - less: { - javascriptEnabled: true, - modifyVars: { - hack: `true; @import (reference) "${resolve("src/styles/css-arco.less")}";`, - arcoblue: "#66f", - }, - }, - }, - }, plugins: [ + /** + * 自动路由生成(须在vue插件前) + * @see https://github.com/posva/unplugin-vue-router + */ + AutoRouter({ + exclude: ["**/components/*.vue", "**/*.*.vue"], + dts: "src/types/auto-router.d.ts", + }), + /** * 提供 Vue 3 单文件组件支持 * @see https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue */ Vue({ script: { - defineModel: true - } + defineModel: true, + }, }), /** @@ -106,10 +92,10 @@ export default defineConfig(({ mode }) => { presetIcons({ prefix: "", collections: { - 'icon-file': (() => { + "icon-file": (() => { const icons = {}; for (const item of fileIcon) { - icons[item.font_class] = item.show_svg + icons[item.font_class] = item.show_svg; } return icons; })(), @@ -124,5 +110,28 @@ export default defineConfig(({ mode }) => { */ plugin(), ], + resolve: { + alias: [ + { + find: "@", + replacement: "/src", + }, + ], + }, + server: { + host, + port, + }, + css: { + preprocessorOptions: { + less: { + javascriptEnabled: true, + modifyVars: { + hack: `true; @import (reference) "${resolve("src/styles/css-arco.less")}";`, + arcoblue: "#66f", + }, + }, + }, + }, }; });