diff --git a/.editorconfig b/.editorconfig index c587bdde9e00cba284284d07021f32501e1d8897..9a71884a30262edcd757ad75404b6f55a0b549b7 100644 --- a/.editorconfig +++ b/.editorconfig @@ -13,3 +13,6 @@ indent_size = 2 [*.md] trim_trailing_whitespace = false + +[Makefile] +indent_style = tab diff --git a/.env.production b/.env.production index 827fd3b33e26892db7b88ae9106c7731f7e86754..860b994800d27d36bf80ece92abaa61408753250 100644 --- a/.env.production +++ b/.env.production @@ -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 diff --git a/build/script/hackXlsx.ts b/build/script/hackXlsx.ts deleted file mode 100644 index 181d1405d5708cc38f461e416cbc650059df264a..0000000000000000000000000000000000000000 --- a/build/script/hackXlsx.ts +++ /dev/null @@ -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(); diff --git a/build/vite/optimizer.ts b/build/vite/optimizer.ts index ca3425ca393fb061ee24945c73f3318f06cbbfa2..0825be765463f6882f9500dead00314dcb257e74 100644 --- a/build/vite/optimizer.ts +++ b/build/vite/optimizer.ts @@ -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 diff --git a/build/vite/plugin/gzip.ts b/build/vite/plugin/gzip.ts index 3cd2716a066508a7a38ba55bc2b7c75d680140d8..b9cac8915120df37c25f326056b3f42fe8aaee26 100644 --- a/build/vite/plugin/gzip.ts +++ b/build/vite/plugin/gzip.ts @@ -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(); diff --git a/package.json b/package.json index 871154195efd0b9dd005d5e300efd69f89d0a1d4..f219fcac28bb4625d6339539bada87acd700c89b 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", @@ -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" }, diff --git a/src/components/Form/src/BasicForm.vue b/src/components/Form/src/BasicForm.vue index 7329d12e5d45884fd3a8b67302f4a20c8791085a..8dd25ca08cae8ddccd45d9a45de1ce5dc04156ad 100644 --- a/src/components/Form/src/BasicForm.vue +++ b/src/components/Form/src/BasicForm.vue @@ -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'; @@ -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; } diff --git a/src/components/Form/src/hooks/useFormEvents.ts b/src/components/Form/src/hooks/useFormEvents.ts index f53f649f1058a041176e9eb6ee25b29cbcc372dc..8b37ca7aa1b7547a36a34b833c41d5d15006cc00 100644 --- a/src/components/Form/src/hooks/useFormEvents.ts +++ b/src/components/Form/src/hooks/useFormEvents.ts @@ -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'; @@ -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; diff --git a/src/components/Form/src/hooks/useFormValues.ts b/src/components/Form/src/hooks/useFormValues.ts index b7b36cd82f94298dbb355d043aa9a9d4b49c435e..334ab8b247f32f943742388e7595c48cc2063b93 100644 --- a/src/components/Form/src/hooks/useFormValues.ts +++ b/src/components/Form/src/hooks/useFormValues.ts @@ -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'; @@ -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); } diff --git a/src/locales/setupI18n.ts b/src/locales/setupI18n.ts index 810932b7dffff89490d36b5e1c9d50f5e675c6a6..05de7e6afe022a7efad9b062ab1cadc2b69cc609 100644 --- a/src/locales/setupI18n.ts +++ b/src/locales/setupI18n.ts @@ -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'; diff --git a/src/locales/useLocale.ts b/src/locales/useLocale.ts index b9fa1fc4708cdffe6d615b0ef939ea563fa0be2f..1e076034dcba97759cbf418b666242bfc8ea8d43 100644 --- a/src/locales/useLocale.ts +++ b/src/locales/useLocale.ts @@ -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'; @@ -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 diff --git a/src/views/sys/lock/useNow.ts b/src/views/sys/lock/useNow.ts index 0b99feed9ba43718f63b42eb47af892eadb0c2a7..ae8435030da5f01e9a313c97f7255972c9c294b9 100644 --- a/src/views/sys/lock/useNow.ts +++ b/src/views/sys/lock/useNow.ts @@ -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({ @@ -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'); diff --git a/vite.config.ts b/vite.config.ts index ba9895cb9477c15a2b7940fe4dddf12c99d8b5e3..8e2ae96fe345000aa1e8936c0ce17e9df95bb642 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -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'; @@ -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, @@ -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, }, @@ -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', + ], }, }; }; diff --git a/yarn.lock b/yarn.lock index 4578bd64aadbdcda52962484659fc74f0fcfac43..8f395b1d1519cea771621a14644816ab0ce48c7e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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== @@ -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" @@ -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"