mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-02-03 02:54:40 +08:00
fix: mock plugin error #171
This commit is contained in:
parent
8bd20c6cd7
commit
3509ebec16
@ -13,3 +13,6 @@ indent_size = 2
|
|||||||
|
|
||||||
[*.md]
|
[*.md]
|
||||||
trim_trailing_whitespace = false
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
|
[Makefile]
|
||||||
|
indent_style = tab
|
||||||
|
@ -2,13 +2,13 @@
|
|||||||
VITE_USE_MOCK = true
|
VITE_USE_MOCK = true
|
||||||
|
|
||||||
# public path
|
# public path
|
||||||
VITE_PUBLIC_PATH = ./
|
VITE_PUBLIC_PATH = /
|
||||||
|
|
||||||
# Delete console
|
# Delete console
|
||||||
VITE_DROP_CONSOLE = true
|
VITE_DROP_CONSOLE = true
|
||||||
|
|
||||||
# Whether to output gz file for packaging
|
# Whether to output gz file for packaging
|
||||||
VITE_BUILD_GZIP = true
|
VITE_BUILD_GZIP = false
|
||||||
|
|
||||||
# Basic interface address SPA
|
# Basic interface address SPA
|
||||||
VITE_GLOB_API_URL=/api
|
VITE_GLOB_API_URL=/api
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
import fs from 'fs-extra';
|
|
||||||
|
|
||||||
import path from 'path';
|
|
||||||
|
|
||||||
// Because xlsx internally references the node module, the pre-optimization of vite2.0 fails. Since the node module inside xlsx is not used on the web side, all the code that uses the node module is replaced with `{}` to be compatible with'vite2'
|
|
||||||
function replaceCjs() {
|
|
||||||
const xlsx = path.resolve(process.cwd(), 'node_modules/xlsx/xlsx.js');
|
|
||||||
let raw = fs.readFileSync(xlsx, 'utf-8');
|
|
||||||
|
|
||||||
raw = raw
|
|
||||||
.replace(`require('fs')`, '{}')
|
|
||||||
.replace(`require('stream')`, '{}')
|
|
||||||
.replace(`require('crypto')`, '{}');
|
|
||||||
fs.writeFileSync(xlsx, raw);
|
|
||||||
}
|
|
||||||
|
|
||||||
replaceCjs();
|
|
@ -2,10 +2,10 @@ import type { GetManualChunk, GetManualChunkApi } from 'rollup';
|
|||||||
|
|
||||||
//
|
//
|
||||||
const vendorLibs: { match: string[]; output: string }[] = [
|
const vendorLibs: { match: string[]; output: string }[] = [
|
||||||
{
|
// {
|
||||||
match: ['xlsx'],
|
// match: ['xlsx'],
|
||||||
output: 'xlsx',
|
// output: 'xlsx',
|
||||||
},
|
// },
|
||||||
];
|
];
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
@ -2,7 +2,7 @@ import gzipPlugin from 'rollup-plugin-gzip';
|
|||||||
import { isBuildGzip } from '../../utils';
|
import { isBuildGzip } from '../../utils';
|
||||||
import { Plugin } from 'vite';
|
import { Plugin } from 'vite';
|
||||||
export function configGzipPlugin(isBuild: boolean): Plugin | Plugin[] {
|
export function configGzipPlugin(isBuild: boolean): Plugin | Plugin[] {
|
||||||
const useGzip = isBuild && isBuildGzip;
|
const useGzip = isBuild && isBuildGzip();
|
||||||
|
|
||||||
if (useGzip) {
|
if (useGzip) {
|
||||||
return gzipPlugin();
|
return gzipPlugin();
|
||||||
|
12
package.json
12
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "vben-admin",
|
"name": "vben-admin",
|
||||||
"version": "2.0.0-rc.16",
|
"version": "2.0.0-rc.15",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"bootstrap": "yarn install",
|
"bootstrap": "yarn install",
|
||||||
"serve": "vite",
|
"serve": "vite",
|
||||||
@ -15,9 +15,7 @@
|
|||||||
"lint:eslint": "eslint --fix --ext \"src/**/*.{vue,less,css,scss}\"",
|
"lint:eslint": "eslint --fix --ext \"src/**/*.{vue,less,css,scss}\"",
|
||||||
"lint:prettier": "prettier --write --loglevel warn \"src/**/*.{js,json,tsx,css,less,scss,vue,html,md}\"",
|
"lint:prettier": "prettier --write --loglevel warn \"src/**/*.{js,json,tsx,css,less,scss,vue,html,md}\"",
|
||||||
"lint:stylelint": "stylelint --fix \"**/*.{vue,less,postcss,css,scss}\" --cache --cache-location node_modules/.cache/stylelint/",
|
"lint:stylelint": "stylelint --fix \"**/*.{vue,less,postcss,css,scss}\" --cache --cache-location node_modules/.cache/stylelint/",
|
||||||
"reinstall": "rimraf yarn.lock && rimraf package.lock.json && rimraf node_modules && npm run bootstrap",
|
"reinstall": "rimraf yarn.lock && rimraf package.lock.json && rimraf node_modules && npm run bootstrap"
|
||||||
"hack-esm:xlsx": "esno ./build/script/hackXlsx",
|
|
||||||
"postinstall": "npm run hack-esm:xlsx"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@iconify/iconify": "^2.0.0-rc.5",
|
"@iconify/iconify": "^2.0.0-rc.5",
|
||||||
@ -98,11 +96,11 @@
|
|||||||
"stylelint-order": "^4.1.0",
|
"stylelint-order": "^4.1.0",
|
||||||
"ts-node": "^9.1.0",
|
"ts-node": "^9.1.0",
|
||||||
"typescript": "^4.1.3",
|
"typescript": "^4.1.3",
|
||||||
"vite": "^2.0.0-beta.19",
|
"vite": "^2.0.0-beta.21",
|
||||||
"vite-plugin-html": "^2.0.0-beta.5",
|
"vite-plugin-html": "^2.0.0-beta.5",
|
||||||
"vite-plugin-mock": "^2.0.0-beta.1",
|
"vite-plugin-mock": "^2.0.0-beta.3",
|
||||||
"vite-plugin-purge-icons": "^0.5.0",
|
"vite-plugin-purge-icons": "^0.5.0",
|
||||||
"vite-plugin-pwa": "^0.3.3",
|
"vite-plugin-pwa": "^0.3.5",
|
||||||
"vue-eslint-parser": "^7.3.0",
|
"vue-eslint-parser": "^7.3.0",
|
||||||
"yargs": "^16.2.0"
|
"yargs": "^16.2.0"
|
||||||
},
|
},
|
||||||
|
@ -41,7 +41,8 @@
|
|||||||
import FormAction from './components/FormAction.vue';
|
import FormAction from './components/FormAction.vue';
|
||||||
|
|
||||||
import { dateItemType } from './helper';
|
import { dateItemType } from './helper';
|
||||||
import moment from 'moment';
|
import { dateUtil } from '/@/utils/dateUtil';
|
||||||
|
|
||||||
// import { cloneDeep } from 'lodash-es';
|
// import { cloneDeep } from 'lodash-es';
|
||||||
import { deepMerge } from '/@/utils';
|
import { deepMerge } from '/@/utils';
|
||||||
|
|
||||||
@ -108,11 +109,11 @@
|
|||||||
// handle date type
|
// handle date type
|
||||||
if (defaultValue && dateItemType.includes(component)) {
|
if (defaultValue && dateItemType.includes(component)) {
|
||||||
if (!Array.isArray(defaultValue)) {
|
if (!Array.isArray(defaultValue)) {
|
||||||
schema.defaultValue = moment(defaultValue);
|
schema.defaultValue = dateUtil(defaultValue);
|
||||||
} else {
|
} else {
|
||||||
const def: moment.Moment[] = [];
|
const def: moment.Moment[] = [];
|
||||||
defaultValue.forEach((item) => {
|
defaultValue.forEach((item) => {
|
||||||
def.push(moment(item));
|
def.push(dateUtil(item));
|
||||||
});
|
});
|
||||||
schema.defaultValue = def;
|
schema.defaultValue = def;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import { unref, toRaw } from 'vue';
|
|||||||
import { isArray, isFunction, isObject, isString } from '/@/utils/is';
|
import { isArray, isFunction, isObject, isString } from '/@/utils/is';
|
||||||
import { deepMerge, unique } from '/@/utils';
|
import { deepMerge, unique } from '/@/utils';
|
||||||
import { dateItemType, handleInputNumberValue } from '../helper';
|
import { dateItemType, handleInputNumberValue } from '../helper';
|
||||||
import moment from 'moment';
|
import { dateUtil } from '/@/utils/dateUtil';
|
||||||
import { cloneDeep } from 'lodash-es';
|
import { cloneDeep } from 'lodash-es';
|
||||||
import { error } from '/@/utils/log';
|
import { error } from '/@/utils/log';
|
||||||
|
|
||||||
@ -67,11 +67,11 @@ export function useFormEvents({
|
|||||||
if (Array.isArray(value)) {
|
if (Array.isArray(value)) {
|
||||||
const arr: moment.Moment[] = [];
|
const arr: moment.Moment[] = [];
|
||||||
for (const ele of value) {
|
for (const ele of value) {
|
||||||
arr.push(moment(ele));
|
arr.push(dateUtil(ele));
|
||||||
}
|
}
|
||||||
formModel[key] = arr;
|
formModel[key] = arr;
|
||||||
} else {
|
} else {
|
||||||
formModel[key] = moment(value);
|
formModel[key] = dateUtil(value);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
formModel[key] = value;
|
formModel[key] = value;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { isArray, isFunction, isObject, isString } from '/@/utils/is';
|
import { isArray, isFunction, isObject, isString } from '/@/utils/is';
|
||||||
import moment from 'moment';
|
import { dateUtil } from '/@/utils/dateUtil';
|
||||||
|
|
||||||
import { unref, nextTick } from 'vue';
|
import { unref, nextTick } from 'vue';
|
||||||
import type { Ref, ComputedRef } from 'vue';
|
import type { Ref, ComputedRef } from 'vue';
|
||||||
import type { FieldMapToTime, FormSchema } from '../types/form';
|
import type { FieldMapToTime, FormSchema } from '../types/form';
|
||||||
@ -65,8 +66,8 @@ export function useFormValues({
|
|||||||
|
|
||||||
const [startTime, endTime]: string[] = values[field];
|
const [startTime, endTime]: string[] = values[field];
|
||||||
|
|
||||||
values[startTimeKey] = moment(startTime).format(format);
|
values[startTimeKey] = dateUtil(startTime).format(format);
|
||||||
values[endTimeKey] = moment(endTime).format(format);
|
values[endTimeKey] = dateUtil(endTime).format(format);
|
||||||
Reflect.deleteProperty(values, field);
|
Reflect.deleteProperty(values, field);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,8 +3,6 @@ import type { I18n, I18nOptions } from 'vue-i18n';
|
|||||||
|
|
||||||
import { createI18n } from 'vue-i18n';
|
import { createI18n } from 'vue-i18n';
|
||||||
|
|
||||||
import 'moment/dist/locale/zh-cn';
|
|
||||||
|
|
||||||
import projectSetting from '/@/settings/projectSetting';
|
import projectSetting from '/@/settings/projectSetting';
|
||||||
|
|
||||||
import messages from './getMessage';
|
import messages from './getMessage';
|
||||||
|
@ -7,9 +7,7 @@ import type { Ref } from 'vue';
|
|||||||
import { unref, ref } from 'vue';
|
import { unref, ref } from 'vue';
|
||||||
import { useLocaleSetting } from '/@/hooks/setting/useLocaleSetting';
|
import { useLocaleSetting } from '/@/hooks/setting/useLocaleSetting';
|
||||||
|
|
||||||
import moment from 'moment';
|
import { dateUtil } from '/@/utils/dateUtil';
|
||||||
|
|
||||||
import 'moment/dist/locale/zh-cn';
|
|
||||||
|
|
||||||
import { i18n } from './setupI18n';
|
import { i18n } from './setupI18n';
|
||||||
|
|
||||||
@ -36,14 +34,14 @@ export function useLocale() {
|
|||||||
antConfigLocaleRef.value = locale.default;
|
antConfigLocaleRef.value = locale.default;
|
||||||
});
|
});
|
||||||
|
|
||||||
moment.locale('cn');
|
dateUtil.locale('cn');
|
||||||
break;
|
break;
|
||||||
// English
|
// English
|
||||||
case 'en':
|
case 'en':
|
||||||
import('ant-design-vue/es/locale/en_US').then((locale) => {
|
import('ant-design-vue/es/locale/en_US').then((locale) => {
|
||||||
antConfigLocaleRef.value = locale.default;
|
antConfigLocaleRef.value = locale.default;
|
||||||
});
|
});
|
||||||
moment.locale('en-us');
|
dateUtil.locale('en-us');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// other
|
// other
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import moment from 'moment';
|
import { dateUtil } from '/@/utils/dateUtil';
|
||||||
import { reactive, toRefs } from 'vue';
|
import { reactive, toRefs } from 'vue';
|
||||||
import { tryOnMounted, tryOnUnmounted } from '/@/utils/helper/vueHelper';
|
import { tryOnMounted, tryOnUnmounted } from '/@/utils/helper/vueHelper';
|
||||||
import { useLocaleSetting } from '/@/hooks/setting/useLocaleSetting';
|
import { useLocaleSetting } from '/@/hooks/setting/useLocaleSetting';
|
||||||
|
|
||||||
export function useNow(immediate = true) {
|
export function useNow(immediate = true) {
|
||||||
const { getLang } = useLocaleSetting();
|
const { getLang } = useLocaleSetting();
|
||||||
const localData = moment.localeData(getLang.value);
|
const localData = dateUtil.localeData(getLang.value);
|
||||||
let timer: IntervalHandle;
|
let timer: IntervalHandle;
|
||||||
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
@ -20,7 +20,7 @@ export function useNow(immediate = true) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const update = () => {
|
const update = () => {
|
||||||
const now = moment();
|
const now = dateUtil();
|
||||||
|
|
||||||
const h = now.format('HH');
|
const h = now.format('HH');
|
||||||
const m = now.format('mm');
|
const m = now.format('mm');
|
||||||
|
@ -8,7 +8,6 @@ import { loadEnv } from 'vite';
|
|||||||
|
|
||||||
import { modifyVars } from './build/config/lessModifyVars';
|
import { modifyVars } from './build/config/lessModifyVars';
|
||||||
import { createProxy } from './build/vite/proxy';
|
import { createProxy } from './build/vite/proxy';
|
||||||
import { configManualChunk } from './build/vite/optimizer';
|
|
||||||
|
|
||||||
import { wrapperEnv } from './build/utils';
|
import { wrapperEnv } from './build/utils';
|
||||||
|
|
||||||
@ -53,9 +52,11 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
|
|||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
output: {
|
output: {
|
||||||
compact: true,
|
compact: true,
|
||||||
manualChunks: configManualChunk,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
commonjsOptions: {
|
||||||
|
ignore: ['fs', 'crypto', 'stream'],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
define: {
|
define: {
|
||||||
__VERSION__: pkg.version,
|
__VERSION__: pkg.version,
|
||||||
@ -69,7 +70,7 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
|
|||||||
preprocessorOptions: {
|
preprocessorOptions: {
|
||||||
less: {
|
less: {
|
||||||
modifyVars: {
|
modifyVars: {
|
||||||
// reference: Avoid repeated references
|
// reference: Avoid repeated references
|
||||||
hack: `true; @import (reference) "${resolve('src/design/config.less')}";`,
|
hack: `true; @import (reference) "${resolve('src/design/config.less')}";`,
|
||||||
...modifyVars,
|
...modifyVars,
|
||||||
},
|
},
|
||||||
@ -86,7 +87,11 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
|
|||||||
],
|
],
|
||||||
|
|
||||||
optimizeDeps: {
|
optimizeDeps: {
|
||||||
include: ['ant-design-vue/es/locale/zh_CN', 'ant-design-vue/es/locale/en_US'],
|
include: [
|
||||||
|
'ant-design-vue/es/locale/zh_CN',
|
||||||
|
'moment/dist/locale/zh-cn',
|
||||||
|
'ant-design-vue/es/locale/en_US',
|
||||||
|
],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
37
yarn.lock
37
yarn.lock
@ -925,7 +925,7 @@
|
|||||||
globals "^11.1.0"
|
globals "^11.1.0"
|
||||||
lodash "^4.17.19"
|
lodash "^4.17.19"
|
||||||
|
|
||||||
"@babel/traverse@^7.0.0", "@babel/traverse@^7.12.12":
|
"@babel/traverse@^7.0.0":
|
||||||
version "7.12.12"
|
version "7.12.12"
|
||||||
resolved "https://registry.npmjs.org/@babel/traverse/-/traverse-7.12.12.tgz#d0cd87892704edd8da002d674bc811ce64743376"
|
resolved "https://registry.npmjs.org/@babel/traverse/-/traverse-7.12.12.tgz#d0cd87892704edd8da002d674bc811ce64743376"
|
||||||
integrity sha512-s88i0X0lPy45RrLM8b9mz8RPH5FqO9G9p7ti59cToE44xFm1Q+Pjh5Gq4SXBbtb88X7Uy7pexeqRIQDDMNkL0w==
|
integrity sha512-s88i0X0lPy45RrLM8b9mz8RPH5FqO9G9p7ti59cToE44xFm1Q+Pjh5Gq4SXBbtb88X7Uy7pexeqRIQDDMNkL0w==
|
||||||
@ -7798,21 +7798,10 @@ vite-plugin-html@^2.0.0-beta.5:
|
|||||||
ejs "^3.1.5"
|
ejs "^3.1.5"
|
||||||
html-minifier-terser "^5.1.1"
|
html-minifier-terser "^5.1.1"
|
||||||
|
|
||||||
vite-plugin-import-context@^1.0.0-rc.1:
|
vite-plugin-mock@^2.0.0-beta.3:
|
||||||
version "1.0.0-rc.1"
|
version "2.0.0-beta.3"
|
||||||
resolved "https://registry.npmjs.org/vite-plugin-import-context/-/vite-plugin-import-context-1.0.0-rc.1.tgz#ce3faf51b0c8d2e33bb434326b5dbd89ec7e7229"
|
resolved "https://registry.npmjs.org/vite-plugin-mock/-/vite-plugin-mock-2.0.0-beta.3.tgz#5276b86734106ccd7aaa299bfb0d16a86c8d2823"
|
||||||
integrity sha512-ZVhj9npqduN+WFhA59LxvyHnrN4lEJlA5RkpYChqtVev7greyemioUpyzdgKxkXhdDVApYBOlGcRTU7rr1+Fdg==
|
integrity sha512-LfgXV3Mzulz89OfuXysxLpnyu66mDiFAeBjwx24N/OiEyZEHagbVRVOJU8Xz/oTmtH7EP/AyrYjQFRb2elQ0BQ==
|
||||||
dependencies:
|
|
||||||
"@babel/core" "^7.12.10"
|
|
||||||
"@babel/plugin-transform-typescript" "^7.12.1"
|
|
||||||
"@babel/traverse" "^7.12.12"
|
|
||||||
"@rollup/pluginutils" "^4.1.0"
|
|
||||||
debug "^4.3.1"
|
|
||||||
|
|
||||||
vite-plugin-mock@^2.0.0-beta.1:
|
|
||||||
version "2.0.0-beta.1"
|
|
||||||
resolved "https://registry.npmjs.org/vite-plugin-mock/-/vite-plugin-mock-2.0.0-beta.1.tgz#660c3b7867c84d20c82bf2e074e9b8377d2a9427"
|
|
||||||
integrity sha512-wnMAfVGXsYDlSWD4kV0xG9X6ZWir1UGsH4xeGzxbAU0XlkgQgJxxFJ1/j+QjD8bauKmuU9QUW1uAr9TWwzTShg==
|
|
||||||
dependencies:
|
dependencies:
|
||||||
"@rollup/plugin-node-resolve" "^11.0.1"
|
"@rollup/plugin-node-resolve" "^11.0.1"
|
||||||
body-parser "^1.19.0"
|
body-parser "^1.19.0"
|
||||||
@ -7835,20 +7824,20 @@ vite-plugin-purge-icons@^0.5.0:
|
|||||||
"@purge-icons/generated" "^0.5.0"
|
"@purge-icons/generated" "^0.5.0"
|
||||||
rollup-plugin-purge-icons "^0.5.0"
|
rollup-plugin-purge-icons "^0.5.0"
|
||||||
|
|
||||||
vite-plugin-pwa@^0.3.3:
|
vite-plugin-pwa@^0.3.5:
|
||||||
version "0.3.3"
|
version "0.3.5"
|
||||||
resolved "https://registry.npmjs.org/vite-plugin-pwa/-/vite-plugin-pwa-0.3.3.tgz#00ece9b7b558153a4afa3fbbac2913c5b3ff6fa8"
|
resolved "https://registry.npmjs.org/vite-plugin-pwa/-/vite-plugin-pwa-0.3.5.tgz#a1700e60ab91fa5fa92d0bdf7102ac87187ac00e"
|
||||||
integrity sha512-aojgEk9u1Aaoo80zT8AdhGlPUrWHmV9fdJhbj/9vvEyj02DJQCvu7rr5gEJJRjtUSS+xtzIWzy2Rc3P+x4gD5A==
|
integrity sha512-mabDRu/rk6w/f5eXGlNzD8GJCw8kKeg82UTLmaUYj3M7G5eKvyRYTXVPY2TPe1WWPMTE1c3Ypw9iL4QDV707Ww==
|
||||||
dependencies:
|
dependencies:
|
||||||
debug "^4.3.2"
|
debug "^4.3.2"
|
||||||
fast-glob "^3.2.4"
|
fast-glob "^3.2.4"
|
||||||
pretty-bytes "^5.5.0"
|
pretty-bytes "^5.5.0"
|
||||||
workbox-build "^6.0.2"
|
workbox-build "^6.0.2"
|
||||||
|
|
||||||
vite@^2.0.0-beta.19:
|
vite@^2.0.0-beta.21:
|
||||||
version "2.0.0-beta.19"
|
version "2.0.0-beta.21"
|
||||||
resolved "https://registry.npmjs.org/vite/-/vite-2.0.0-beta.19.tgz#9e1a3ff4843d8e72fc2b771691c43124ceeacd21"
|
resolved "https://registry.npmjs.org/vite/-/vite-2.0.0-beta.21.tgz#9a7233c93ed59c5b5de28c3a74f1e94b815d746e"
|
||||||
integrity sha512-6EJAPypH8m9lCK2pB1UfU+qBw65wCHFoMITtFotDAd03m5hz2d9cPXfPgaCk0PhQPgtGcgn5xeAfLIdZ5e6cPA==
|
integrity sha512-B6OhGHwh4DTkDBxZXtGhxmDkK75M3o0sKFz/cfZ2bdqxRze870sJgH66kPuYWjgSVDdPz0NTIKBaxrbcA8wwmw==
|
||||||
dependencies:
|
dependencies:
|
||||||
esbuild "^0.8.26"
|
esbuild "^0.8.26"
|
||||||
postcss "^8.2.1"
|
postcss "^8.2.1"
|
||||||
|
Loading…
Reference in New Issue
Block a user