Skip to content

Commit

Permalink
fix: mock plugin error #171
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Jan 10, 2021
1 parent 8bd20c6 commit 3509ebe
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 78 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ indent_size = 2

[*.md]
trim_trailing_whitespace = false

[Makefile]
indent_style = tab
4 changes: 2 additions & 2 deletions .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
VITE_USE_MOCK = true

# public path
VITE_PUBLIC_PATH = ./
VITE_PUBLIC_PATH = /

# Delete console
VITE_DROP_CONSOLE = true

# Whether to output gz file for packaging
VITE_BUILD_GZIP = true
VITE_BUILD_GZIP = false

# Basic interface address SPA
VITE_GLOB_API_URL=/api
Expand Down
17 changes: 0 additions & 17 deletions build/script/hackXlsx.ts

This file was deleted.

8 changes: 4 additions & 4 deletions build/vite/optimizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import type { GetManualChunk, GetManualChunkApi } from 'rollup';

//
const vendorLibs: { match: string[]; output: string }[] = [
{
match: ['xlsx'],
output: 'xlsx',
},
// {
// match: ['xlsx'],
// output: 'xlsx',
// },
];

// @ts-ignore
Expand Down
2 changes: 1 addition & 1 deletion build/vite/plugin/gzip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import gzipPlugin from 'rollup-plugin-gzip';
import { isBuildGzip } from '../../utils';
import { Plugin } from 'vite';
export function configGzipPlugin(isBuild: boolean): Plugin | Plugin[] {
const useGzip = isBuild && isBuildGzip;
const useGzip = isBuild && isBuildGzip();

if (useGzip) {
return gzipPlugin();
Expand Down
12 changes: 5 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vben-admin",
"version": "2.0.0-rc.16",
"version": "2.0.0-rc.15",
"scripts": {
"bootstrap": "yarn install",
"serve": "vite",
Expand All @@ -15,9 +15,7 @@
"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: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",
"hack-esm:xlsx": "esno ./build/script/hackXlsx",
"postinstall": "npm run hack-esm:xlsx"
"reinstall": "rimraf yarn.lock && rimraf package.lock.json && rimraf node_modules && npm run bootstrap"
},
"dependencies": {
"@iconify/iconify": "^2.0.0-rc.5",
Expand Down Expand Up @@ -98,11 +96,11 @@
"stylelint-order": "^4.1.0",
"ts-node": "^9.1.0",
"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-mock": "^2.0.0-beta.1",
"vite-plugin-mock": "^2.0.0-beta.3",
"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",
"yargs": "^16.2.0"
},
Expand Down
7 changes: 4 additions & 3 deletions src/components/Form/src/BasicForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
import FormAction from './components/FormAction.vue';
import { dateItemType } from './helper';
import moment from 'moment';
import { dateUtil } from '/@/utils/dateUtil';
// import { cloneDeep } from 'lodash-es';
import { deepMerge } from '/@/utils';
Expand Down Expand Up @@ -108,11 +109,11 @@
// handle date type
if (defaultValue && dateItemType.includes(component)) {
if (!Array.isArray(defaultValue)) {
schema.defaultValue = moment(defaultValue);
schema.defaultValue = dateUtil(defaultValue);
} else {
const def: moment.Moment[] = [];
defaultValue.forEach((item) => {
def.push(moment(item));
def.push(dateUtil(item));
});
schema.defaultValue = def;
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/Form/src/hooks/useFormEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { unref, toRaw } from 'vue';
import { isArray, isFunction, isObject, isString } from '/@/utils/is';
import { deepMerge, unique } from '/@/utils';
import { dateItemType, handleInputNumberValue } from '../helper';
import moment from 'moment';
import { dateUtil } from '/@/utils/dateUtil';
import { cloneDeep } from 'lodash-es';
import { error } from '/@/utils/log';

Expand Down Expand Up @@ -67,11 +67,11 @@ export function useFormEvents({
if (Array.isArray(value)) {
const arr: moment.Moment[] = [];
for (const ele of value) {
arr.push(moment(ele));
arr.push(dateUtil(ele));
}
formModel[key] = arr;
} else {
formModel[key] = moment(value);
formModel[key] = dateUtil(value);
}
} else {
formModel[key] = value;
Expand Down
7 changes: 4 additions & 3 deletions src/components/Form/src/hooks/useFormValues.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { isArray, isFunction, isObject, isString } from '/@/utils/is';
import moment from 'moment';
import { dateUtil } from '/@/utils/dateUtil';

import { unref, nextTick } from 'vue';
import type { Ref, ComputedRef } from 'vue';
import type { FieldMapToTime, FormSchema } from '../types/form';
Expand Down Expand Up @@ -65,8 +66,8 @@ export function useFormValues({

const [startTime, endTime]: string[] = values[field];

values[startTimeKey] = moment(startTime).format(format);
values[endTimeKey] = moment(endTime).format(format);
values[startTimeKey] = dateUtil(startTime).format(format);
values[endTimeKey] = dateUtil(endTime).format(format);
Reflect.deleteProperty(values, field);
}

Expand Down
2 changes: 0 additions & 2 deletions src/locales/setupI18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import type { I18n, I18nOptions } from 'vue-i18n';

import { createI18n } from 'vue-i18n';

import 'moment/dist/locale/zh-cn';

import projectSetting from '/@/settings/projectSetting';

import messages from './getMessage';
Expand Down
8 changes: 3 additions & 5 deletions src/locales/useLocale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import type { Ref } from 'vue';
import { unref, ref } from 'vue';
import { useLocaleSetting } from '/@/hooks/setting/useLocaleSetting';

import moment from 'moment';

import 'moment/dist/locale/zh-cn';
import { dateUtil } from '/@/utils/dateUtil';

import { i18n } from './setupI18n';

Expand All @@ -36,14 +34,14 @@ export function useLocale() {
antConfigLocaleRef.value = locale.default;
});

moment.locale('cn');
dateUtil.locale('cn');
break;
// English
case 'en':
import('ant-design-vue/es/locale/en_US').then((locale) => {
antConfigLocaleRef.value = locale.default;
});
moment.locale('en-us');
dateUtil.locale('en-us');
break;

// other
Expand Down
6 changes: 3 additions & 3 deletions src/views/sys/lock/useNow.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import moment from 'moment';
import { dateUtil } from '/@/utils/dateUtil';
import { reactive, toRefs } from 'vue';
import { tryOnMounted, tryOnUnmounted } from '/@/utils/helper/vueHelper';
import { useLocaleSetting } from '/@/hooks/setting/useLocaleSetting';

export function useNow(immediate = true) {
const { getLang } = useLocaleSetting();
const localData = moment.localeData(getLang.value);
const localData = dateUtil.localeData(getLang.value);
let timer: IntervalHandle;

const state = reactive({
Expand All @@ -20,7 +20,7 @@ export function useNow(immediate = true) {
});

const update = () => {
const now = moment();
const now = dateUtil();

const h = now.format('HH');
const m = now.format('mm');
Expand Down
13 changes: 9 additions & 4 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { loadEnv } from 'vite';

import { modifyVars } from './build/config/lessModifyVars';
import { createProxy } from './build/vite/proxy';
import { configManualChunk } from './build/vite/optimizer';

import { wrapperEnv } from './build/utils';

Expand Down Expand Up @@ -53,9 +52,11 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
rollupOptions: {
output: {
compact: true,
manualChunks: configManualChunk,
},
},
commonjsOptions: {
ignore: ['fs', 'crypto', 'stream'],
},
},
define: {
__VERSION__: pkg.version,
Expand All @@ -69,7 +70,7 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
preprocessorOptions: {
less: {
modifyVars: {
// reference: Avoid repeated references
// reference: Avoid repeated references
hack: `true; @import (reference) "${resolve('src/design/config.less')}";`,
...modifyVars,
},
Expand All @@ -86,7 +87,11 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
],

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 changes: 13 additions & 24 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@
globals "^11.1.0"
lodash "^4.17.19"

"@babel/traverse@^7.0.0", "@babel/traverse@^7.12.12":
"@babel/traverse@^7.0.0":
version "7.12.12"
resolved "https://registry.npmjs.org/@babel/traverse/-/traverse-7.12.12.tgz#d0cd87892704edd8da002d674bc811ce64743376"
integrity sha512-s88i0X0lPy45RrLM8b9mz8RPH5FqO9G9p7ti59cToE44xFm1Q+Pjh5Gq4SXBbtb88X7Uy7pexeqRIQDDMNkL0w==
Expand Down Expand Up @@ -7798,21 +7798,10 @@ vite-plugin-html@^2.0.0-beta.5:
ejs "^3.1.5"
html-minifier-terser "^5.1.1"

vite-plugin-import-context@^1.0.0-rc.1:
version "1.0.0-rc.1"
resolved "https://registry.npmjs.org/vite-plugin-import-context/-/vite-plugin-import-context-1.0.0-rc.1.tgz#ce3faf51b0c8d2e33bb434326b5dbd89ec7e7229"
integrity sha512-ZVhj9npqduN+WFhA59LxvyHnrN4lEJlA5RkpYChqtVev7greyemioUpyzdgKxkXhdDVApYBOlGcRTU7rr1+Fdg==
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==
vite-plugin-mock@^2.0.0-beta.3:
version "2.0.0-beta.3"
resolved "https://registry.npmjs.org/vite-plugin-mock/-/vite-plugin-mock-2.0.0-beta.3.tgz#5276b86734106ccd7aaa299bfb0d16a86c8d2823"
integrity sha512-LfgXV3Mzulz89OfuXysxLpnyu66mDiFAeBjwx24N/OiEyZEHagbVRVOJU8Xz/oTmtH7EP/AyrYjQFRb2elQ0BQ==
dependencies:
"@rollup/plugin-node-resolve" "^11.0.1"
body-parser "^1.19.0"
Expand All @@ -7835,20 +7824,20 @@ vite-plugin-purge-icons@^0.5.0:
"@purge-icons/generated" "^0.5.0"
rollup-plugin-purge-icons "^0.5.0"

vite-plugin-pwa@^0.3.3:
version "0.3.3"
resolved "https://registry.npmjs.org/vite-plugin-pwa/-/vite-plugin-pwa-0.3.3.tgz#00ece9b7b558153a4afa3fbbac2913c5b3ff6fa8"
integrity sha512-aojgEk9u1Aaoo80zT8AdhGlPUrWHmV9fdJhbj/9vvEyj02DJQCvu7rr5gEJJRjtUSS+xtzIWzy2Rc3P+x4gD5A==
vite-plugin-pwa@^0.3.5:
version "0.3.5"
resolved "https://registry.npmjs.org/vite-plugin-pwa/-/vite-plugin-pwa-0.3.5.tgz#a1700e60ab91fa5fa92d0bdf7102ac87187ac00e"
integrity sha512-mabDRu/rk6w/f5eXGlNzD8GJCw8kKeg82UTLmaUYj3M7G5eKvyRYTXVPY2TPe1WWPMTE1c3Ypw9iL4QDV707Ww==
dependencies:
debug "^4.3.2"
fast-glob "^3.2.4"
pretty-bytes "^5.5.0"
workbox-build "^6.0.2"

vite@^2.0.0-beta.19:
version "2.0.0-beta.19"
resolved "https://registry.npmjs.org/vite/-/vite-2.0.0-beta.19.tgz#9e1a3ff4843d8e72fc2b771691c43124ceeacd21"
integrity sha512-6EJAPypH8m9lCK2pB1UfU+qBw65wCHFoMITtFotDAd03m5hz2d9cPXfPgaCk0PhQPgtGcgn5xeAfLIdZ5e6cPA==
vite@^2.0.0-beta.21:
version "2.0.0-beta.21"
resolved "https://registry.npmjs.org/vite/-/vite-2.0.0-beta.21.tgz#9a7233c93ed59c5b5de28c3a74f1e94b815d746e"
integrity sha512-B6OhGHwh4DTkDBxZXtGhxmDkK75M3o0sKFz/cfZ2bdqxRze870sJgH66kPuYWjgSVDdPz0NTIKBaxrbcA8wwmw==
dependencies:
esbuild "^0.8.26"
postcss "^8.2.1"
Expand Down

0 comments on commit 3509ebe

Please sign in to comment.