diff --git a/web/index.html b/web/index.html new file mode 100644 index 0000000000000000000000000000000000000000..7f114f9b11a156c428f7a184c7b8ae5a8a214baf --- /dev/null +++ b/web/index.html @@ -0,0 +1,15 @@ + + + + + + + + + + + +
+ + + diff --git a/web/package.json b/web/package.json index 58bb37659ebb8f01a2ebd8133a9874aa197577b1..7f321af4cab2cbcd1e10229a0c81b733d151f2f3 100644 --- a/web/package.json +++ b/web/package.json @@ -1,44 +1,48 @@ { - "name": "gin-vue-admin", - "version": "2.3.5", - "private": true, - "scripts": { - "serve": "node openDocument.js && vue-cli-service serve", - "build": "vue-cli-service build", - "lint": "vue-cli-service lint" - }, - "dependencies": { - "axios": "^0.19.2", - "core-js": "^3.6.5", - "echarts": "4.9.0", - "element-plus": "^1.1.0-beta.8", - "highlight.js": "^10.6.0", - "marked": "^2.0.0", - "mitt": "^3.0.0", - "path": "^0.12.7", - "qs": "^6.8.0", - "quill": "^1.3.7", - "screenfull": "^5.0.2", - "script-ext-html-webpack-plugin": "^2.1.4", - "spark-md5": "^3.0.1", - "vue": "^3.0.0", - "vue-particle-line": "^0.1.4", - "vue-router": "^4.0.0-0", - "vuex": "^4.0.0-0", - "vuex-persist": "^2.1.0" - }, - "devDependencies": { - "@vue/cli-plugin-babel": "~4.5.0", - "@vue/cli-plugin-eslint": "~4.5.0", - "@vue/cli-plugin-router": "~4.5.0", - "@vue/cli-plugin-vuex": "~4.5.0", - "@vue/cli-service": "~4.5.0", - "@vue/compiler-sfc": "^3.0.0", - "babel-eslint": "^10.1.0", - "babel-plugin-import": "^1.13.3", - "eslint": "^6.7.2", - "eslint-plugin-vue": "^7.0.0", - "sass": "^1.26.5", - "sass-loader": "^8.0.2" - } + "name": "gin-vue-admin", + "version": "2.3.5", + "private": true, + "scripts": { + "serve": "node openDocument.js && vite", + "build": "vite build", + "preview": "vite preview" + }, + "dependencies": { + "axios": "^0.19.2", + "core-js": "^3.6.5", + "echarts": "4.9.0", + "element-plus": "^1.1.0-beta.8", + "highlight.js": "^10.6.0", + "marked": "^2.0.0", + "mitt": "^3.0.0", + "path": "^0.12.7", + "qs": "^6.8.0", + "quill": "^1.3.7", + "screenfull": "^5.0.2", + "script-ext-html-webpack-plugin": "^2.1.4", + "spark-md5": "^3.0.1", + "vue": "^3.0.0", + "vue-particle-line": "^0.1.4", + "vue-router": "^4.0.0-0", + "vuex": "^4.0.0-0", + "vuex-persist": "^2.1.0" + }, + "devDependencies": { + "@vue/cli-plugin-babel": "~4.5.0", + "@vue/cli-plugin-eslint": "~4.5.0", + "@vue/cli-plugin-router": "~4.5.0", + "@vue/cli-plugin-vuex": "~4.5.0", + "@vue/cli-service": "~4.5.0", + "@vue/compiler-sfc": "^3.1.5", + "babel-eslint": "^10.1.0", + "babel-plugin-import": "^1.13.3", + "eslint": "^6.7.2", + "eslint-plugin-vue": "^7.0.0", + "sass": "^1.26.5", + "sass-loader": "^8.0.2", + "vite": "2", + "@vitejs/plugin-legacy": "^1.4.4", + "vite-plugin-importer": "^0.2.5", + "@vitejs/plugin-vue": "latest" + } } diff --git a/web/src/router/index.js b/web/src/router/index.js index 66ccf8c3ceff87f80b90668e8a927b490c724790..290e93133e7a720ac97db594ec94d41cb207aff4 100644 --- a/web/src/router/index.js +++ b/web/src/router/index.js @@ -7,12 +7,12 @@ const routes = [{ { path: '/init', name: 'Init', - component: () => import('@/view/init/index') + component: () => import('@/view/init/index.vue') }, { path: '/login', name: 'Login', - component: () => import('@/view/login/index') + component: () => import('@/view/login/index.vue') } ] diff --git a/web/src/utils/_import.js b/web/src/utils/_import.js deleted file mode 100644 index ccbd6dd795314a31610321c5af1bf0676077fb75..0000000000000000000000000000000000000000 --- a/web/src/utils/_import.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = file => () => { - return import ('@/' + file) -} diff --git a/web/src/utils/asyncRouter.js b/web/src/utils/asyncRouter.js index 7e081c73a564b1c944dcb6087a7c907b021e9281..923aea6575665c4819e20eb18e1854c1f1d4817b 100644 --- a/web/src/utils/asyncRouter.js +++ b/web/src/utils/asyncRouter.js @@ -1,8 +1,10 @@ -const _import = require('./_import') // 获取组件的方法 +const modules = import.meta.glob('../../view/**/*.vue') + export const asyncRouterHandle = (asyncRouter) => { asyncRouter.map(item => { if (item.component) { - item.component = _import(item.component) + item.component = dynamicImport(modules, item.component) + console.log(item.component) } else { delete item['component'] } @@ -11,3 +13,18 @@ export const asyncRouterHandle = (asyncRouter) => { } }) } + +function dynamicImport( + dynamicViewsModules, + component +) { + const keys = Object.keys(dynamicViewsModules) + const matchKeys = keys.filter((key) => { + let k = key.replace('../../view', '') + const lastIndex = k.lastIndexOf('.') + k = k.substring(0, lastIndex) + return k === component + }) + const matchKey = matchKeys[0] + return dynamicViewsModules[matchKey] +} diff --git a/web/vite.config.js b/web/vite.config.js new file mode 100644 index 0000000000000000000000000000000000000000..95631aa457da454e7d9ebd9513d7ee9ca51deccb --- /dev/null +++ b/web/vite.config.js @@ -0,0 +1,73 @@ +/* eslint-disable */ +import legacyPlugin from '@vitejs/plugin-legacy'; +// import usePluginImport from 'vite-plugin-importer'; +import * as path from 'path'; +import vuePlugin from '@vitejs/plugin-vue'; +// @see https://cn.vitejs.dev/config/ +export default ({ + command, + mode +}) => { + let rollupOptions = {}; + + + let optimizeDeps = {}; + + + let alias = { + '@': path.resolve(__dirname, './src'), + 'vue$': 'vue/dist/vue.runtime.esm-bundler.js', + } + + let proxy = { + 'undefined': { + "target": "undefined:undefined/", + "changeOrigin": true, + "pathRewrite": { + "^undefined": "" + } + }, + } + + let define = { + 'process.env.NODE_ENV': '"development"', + } + + let esbuild = {} + + return { + base: './', // index.html文件所在位置 + root: './', // js导入的资源路径,src + resolve: { + alias, + }, + define: define, + server: { + // 代理 + proxy, + }, + build: { + target: 'es2015', + minify: 'terser', // 是否进行压缩,boolean | 'terser' | 'esbuild',默认使用terser + manifest: false, // 是否产出maifest.json + sourcemap: false, // 是否产出soucemap.json + outDir: 'build', // 产出目录 + rollupOptions, + }, + esbuild, + optimizeDeps, + plugins: [ + legacyPlugin({ + targets: ['Android > 39', 'Chrome >= 60', 'Safari >= 10.1', 'iOS >= 10.3', 'Firefox >= 54', 'Edge >= 15'], + }), vuePlugin(), + ], + css: { + preprocessorOptions: { + less: { + // 支持内联 JavaScript + javascriptEnabled: true, + } + } + }, + } +} \ No newline at end of file