fix: add type for importMetaGlob

This commit is contained in:
chenxuehai@alltuu.com
2023-03-10 11:23:06 +08:00
parent dc98b96ce2
commit 3d6465346c
4 changed files with 25 additions and 11 deletions

View File

@@ -1,6 +1,10 @@
import { createProdMockServer } from 'vite-plugin-mock/es/createProdMockServer';
const modules = import.meta.glob('./**/*.ts', { eager: true });
interface IModuleType {
default: any[];
}
const modules = import.meta.glob<IModuleType>('./**/*.ts', { eager: true });
const mockModules: any[] = [];
Object.keys(modules).forEach((key) => {

23
pnpm-lock.yaml generated
View File

@@ -41,7 +41,7 @@ specifiers:
lodash-es: ^4.17.21
mitt: ^3.0.0
mockjs: ^1.1.0
naive-ui: ^2.33.5
naive-ui: ^2.34.2
pinia: ^2.0.23
postcss: ^8.4.19
prettier: ^2.7.1
@@ -84,7 +84,7 @@ dependencies:
lodash-es: 4.17.21
mitt: 3.0.0
mockjs: 1.1.0
naive-ui: 2.33.5_vue@3.2.45
naive-ui: 2.34.3_vue@3.2.45
pinia: 2.0.23_zwu2zepfy3m6u2gunxlolp35gi
qs: 6.11.0
vfonts: 0.0.3
@@ -1273,6 +1273,10 @@ packages:
resolution: {integrity: sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==}
dev: true
/@types/katex/0.14.0:
resolution: {integrity: sha512-+2FW2CcT0K3P+JMR8YG846bmDwplKUTsWgT2ENwdQ1UdVfRk3GQrh6Mi4sTopy30gI8Uau5CEqHTDZ6YvWIUPA==}
dev: false
/@types/lodash-es/4.17.6:
resolution: {integrity: sha512-R+zTeVUKDdfoRxpAryaQNRKk3105Rrgx2CFRClIgRGaqDTdjsm8h6IYA8ir584W3ePzkZfst5xIgDwYrlh9HLg==}
dependencies:
@@ -2820,7 +2824,7 @@ packages:
dev: true
/errno/0.1.8:
resolution: {integrity: sha512-dJ6oBr5SQ1VSd9qkk7ByRgb/1SH4JZjCHSW/mr63/QcXO9zLVxvJ6Oy13nio03rxpSnVDDjFor75SjVeZWPW/A==}
resolution: {integrity: sha1-i7Ppx9Rjvkl2/4iPdrSAnrwugR8=}
hasBin: true
requiresBuild: true
dependencies:
@@ -3597,7 +3601,7 @@ packages:
dev: true
/fsevents/2.3.2:
resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==}
resolution: {integrity: sha1-ilJveLj99GI7cJ4Ll1xSwkwC/Ro=}
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
os: [darwin]
requiresBuild: true
@@ -3934,7 +3938,7 @@ packages:
dev: true
/image-size/0.5.5:
resolution: {integrity: sha512-6TDAlDPZxUFCv+fuOkIoXT/V/f3Qbq8e37p+YOiYrUv3v9cc3/6x78VdfPgFVaB9dZYeLUfKgHRebpkm/oP2VQ==}
resolution: {integrity: sha1-Cd/Uq50g4p6xw+gLiZA3jfnjy5w=}
engines: {node: '>=0.10.0'}
hasBin: true
requiresBuild: true
@@ -4905,7 +4909,7 @@ packages:
dev: true
/make-dir/2.1.0:
resolution: {integrity: sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==}
resolution: {integrity: sha1-XwMQ4YuL6JjMBwCSlaMK5B6R5vU=}
engines: {node: '>=6'}
requiresBuild: true
dependencies:
@@ -5014,7 +5018,7 @@ packages:
dev: false
/mime/1.6.0:
resolution: {integrity: sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==}
resolution: {integrity: sha1-Ms2eXGRVO9WNGaVor0Uqz/BJgbE=}
engines: {node: '>=4'}
hasBin: true
requiresBuild: true
@@ -5109,13 +5113,14 @@ packages:
resolution: {integrity: sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==}
dev: true
/naive-ui/2.33.5_vue@3.2.45:
resolution: {integrity: sha512-O87zwOduut3Xk9NzGIX+LZYr6sW/Y0oGuNJ6T2dka+14CtHD9iidi8gdxg6obhMpzdwa3SnlxO7nzDLqmXVUwA==}
/naive-ui/2.34.3_vue@3.2.45:
resolution: {integrity: sha512-fUMr0dzb/iGsOTWgoblPVobY5X5dihQ1eam5dA+H74oyLYAvgX4pL96xQFPBLIYqvyRFBAsN85kHN5pLqdtpxA==}
peerDependencies:
vue: ^3.0.0
dependencies:
'@css-render/plugin-bem': 0.15.11_css-render@0.15.11
'@css-render/vue3-ssr': 0.15.11_vue@3.2.45
'@types/katex': 0.14.0
'@types/lodash': 4.14.188
'@types/lodash-es': 4.17.6
async-validator: 4.2.5

View File

@@ -3,8 +3,9 @@ import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router';
import { RedirectRoute } from '@/router/base';
import { PageEnum } from '@/enums/pageEnum';
import { createRouterGuards } from './router-guards';
import type { IModuleType } from './types';
const modules = import.meta.glob('./modules/**/*.ts', { eager: true });
const modules = import.meta.glob<IModuleType>('./modules/**/*.ts', { eager: true });
const routeModuleList: RouteRecordRaw[] = [];

View File

@@ -53,3 +53,7 @@ export interface Menu {
redirect?: string;
sort?: number;
}
export interface IModuleType {
default: Array<RouteRecordRaw> | RouteRecordRaw;
}