diff --git a/.env.production b/.env.production index e04e309..3f7a99e 100644 --- a/.env.production +++ b/.env.production @@ -5,5 +5,6 @@ VUE_APP_TITLE = 管理系统 ENV = 'production' # 若依管理系统/生产环境 -# VUE_APP_BASE_API = '/prod-api' -VUE_APP_BASE_API = 'http://48.1.16.91:8080' +# VUE_APP_BASE_API = "http://192.168.142.241:8080" +# VUE_APP_BASE_API = "http://192.168.142.241:8080" +VUE_APP_BASE_URL = https://nicowebgl.cn/macmini/project/kdemo/ \ No newline at end of file diff --git a/.env.production.backup b/.env.production.backup new file mode 100644 index 0000000..e04e309 --- /dev/null +++ b/.env.production.backup @@ -0,0 +1,9 @@ +# 页面标题 +VUE_APP_TITLE = 管理系统 + +# 生产环境配置 +ENV = 'production' + +# 若依管理系统/生产环境 +# VUE_APP_BASE_API = '/prod-api' +VUE_APP_BASE_API = 'http://48.1.16.91:8080' diff --git a/cp.sh b/cp.sh new file mode 100755 index 0000000..522b69d --- /dev/null +++ b/cp.sh @@ -0,0 +1,3 @@ +mv dist kdemo +cp -r kdemo /Users/nicolas/docker/nginx/html/macmini/project +rm -rf kdemo \ No newline at end of file diff --git a/public/index.html b/public/index.html index e4f77b3..74394f5 100644 --- a/public/index.html +++ b/public/index.html @@ -1,14 +1,17 @@ - - - - - - - <%= webpackConfig.name %> - - diff --git a/src/main.js b/src/main.js index d3bbce8..7624fc2 100644 --- a/src/main.js +++ b/src/main.js @@ -27,8 +27,7 @@ Vue.prototype.$px2rem = px2rem; Vue.prototype.$dictLabel = dictLabel; Vue.directive("px", px2remDirective); -import './assets/icons' // icon -import './permission' // permission control +import './assets/icons' // icon/ permission control import { getDicts } from "@/api/system/dict/data" import { getConfigKey } from "@/api/system/config" import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, handleTree } from "@/utils/ruoyi" diff --git a/src/permission.js b/src/permission.js deleted file mode 100644 index 14579ca..0000000 --- a/src/permission.js +++ /dev/null @@ -1,81 +0,0 @@ -import router from './router' -import store from './store' -import { Message } from 'element-ui' -import NProgress from 'nprogress' -import 'nprogress/nprogress.css' -import { getToken } from '@/utils/auth' -import { isPathMatch } from '@/utils/validate' -import { isRelogin } from '@/utils/request' - -NProgress.configure({ showSpinner: false }) - -const whiteList = ['/login', '/register'] - -const isWhiteList = (path) => { - return whiteList.some(pattern => isPathMatch(pattern, path)) -} - -router.beforeEach((to, from, next) => { - NProgress.start() - // if (getToken()) { - // to.meta.title && store.dispatch('settings/setTitle', to.meta.title) - // /* has token*/ - // if (to.path === '/login') { - // next({ path: '/' }) - // NProgress.done() - // } else if (isWhiteList(to.path)) { - // next() - // } else { - // if (store.getters.roles.length === 0) { - // isRelogin.show = true - // // 判断当前用户是否已拉取完user_info信息 - // store.dispatch('GetInfo').then(() => { - // isRelogin.show = false - // store.dispatch('GenerateRoutes').then(accessRoutes => { - // // 根据roles权限生成可访问的路由表 - // router.addRoutes(accessRoutes) // 动态添加可访问路由表 - // next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 - // }) - // }).catch(err => { - // store.dispatch('LogOut').then(() => { - // Message.error(err) - // next({ path: '/' }) - // }) - // }) - // } else { - // next() - // } - // } - // } else { - // 没有token - // if (isWhiteList(to.path)) { - // 在免登录白名单,直接进入 - // if (store.getters.dictList.length === 0) { - // const query = { - // pageNum: 1, - // pageSize: 100, - // dictType: "sys_title", - // }; - // store - // .dispatch("getDict", query) - // .then((res) => { - // next(); - // // let dictList = JSON.stringify(res.rows); - // // this.$cache.session.set("dictList", dictList); - // }) - // .catch(() => {}); - - // } else { - next(); - // } - // next() - // } else { - // next(`/login?redirect=${encodeURIComponent(to.fullPath)}`) // 否则全部重定向到登录页 - // NProgress.done() - // } - // } -}) - -router.afterEach(() => { - NProgress.done() -}) diff --git a/src/router/index.js b/src/router/index.js index d5daf25..b6cd64a 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -66,7 +66,7 @@ export const constantRoutes = [ // component: Layout, name: "Layout_main", component: () => import("@/views/bigScreen/Layout_main/index.vue"), - redirect: "home", + redirect: "/home", children: [ // { // path: 'index', @@ -233,7 +233,7 @@ Router.prototype.replace = function push(location) { } export default new Router({ - mode: 'history', // 去掉url中的# + mode: 'hash', // 加上# scrollBehavior: () => ({ y: 0 }), routes: constantRoutes }) diff --git a/src/utils/three.js b/src/utils/three.js index 70aecca..d92cd88 100644 --- a/src/utils/three.js +++ b/src/utils/three.js @@ -518,7 +518,7 @@ export function drawAxes(element, options = {}, ballCallBack) { composer.addPass(fxaa); /* ========== 环境光照/HDR环境贴图 ========== */ - new RGBELoader().load("/hdr/basic.hdr", (tex) => { + new RGBELoader().load(process.env.VUE_APP_BASE_URL + "/hdr/basic.hdr", (tex) => { tex.mapping = THREE.EquirectangularReflectionMapping; scene.environment = tex; }); @@ -606,7 +606,7 @@ export function drawAxes(element, options = {}, ballCallBack) { const img = document.createElement('img') - img.src = `/icon_xz/${axes}0${i}.png` + img.src = process.env.VUE_APP_BASE_URL + `/icon_xz/${axes}0${i}.png` img.style.width = '10px' diff --git a/vue.config.js b/vue.config.js index 18f5646..d273700 100644 --- a/vue.config.js +++ b/vue.config.js @@ -6,12 +6,11 @@ function resolve(dir) { } const CompressionPlugin = require('compression-webpack-plugin') +const CopyWebpackPlugin = require('copy-webpack-plugin') const name = process.env.VUE_APP_TITLE || '若依管理系统' // 网页标题 -const baseUrl = 'http://localhost:8080' // 后端接口 -const port = process.env.port || process.env.npm_config_port || 80 // 端口 // vue.config.js 配置说明 //官方vue.config.js 参考文档 https://cli.vuejs.org/zh/config/#css-loaderoptions @@ -20,7 +19,7 @@ module.exports = { // 部署生产环境和开发环境下的URL。 // 默认情况下,Vue CLI 会假设你的应用是被部署在一个域名的根路径上 // 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.vip/admin/,则设置 baseUrl 为 /admin/。 - publicPath: process.env.NODE_ENV === "production" ? "/" : "/", + publicPath: process.env.NODE_ENV === "production" ? "https://nicowebgl.cn/macmini/project/kdemo/" : "/", // 在npm run build 或 yarn build 时 ,生成文件的目录名称(要和baseUrl的生产环境路径一致)(默认dist) outputDir: "dist", // 用于放置生成的静态资源 (js、css、img、fonts) 的;(项目打包之后,静态资源会放在这个文件夹下) @@ -31,23 +30,8 @@ module.exports = { // webpack-dev-server 相关配置 devServer: { host: "0.0.0.0", - port: port, + port: 1005, open: true, - proxy: { - // detail: https://cli.vuejs.org/config/#devserver-proxy - [process.env.VUE_APP_BASE_API]: { - target: baseUrl, - changeOrigin: true, - pathRewrite: { - ["^" + process.env.VUE_APP_BASE_API]: "", - }, - }, - // springdoc proxy - "^/v3/api-docs/(.*)": { - target: baseUrl, - changeOrigin: true, - }, - }, disableHostCheck: true, }, css: { @@ -74,87 +58,25 @@ module.exports = { minRatio: 0.8, // 压缩比例,小于 80% 的文件不会被压缩 deleteOriginalAssets: false, // 压缩后删除原文件 }), - ], - // module: { - // rules: [ - // { - // test: /\.mjs$/, - // include: /node_modules/, - // type: "javascript/auto", - // }, - // ], - // }, - // module: { - // rules: [ - // { - // test: /\.js$/, - // include: /node_modules\/quill/, - // use: { - // loader: 'babel-loader', - // options: { - // presets: ['@babel/preset-env'], - // plugins: ['@babel/plugin-proposal-class-properties'] - // } - // } - // } - // ] - // } - }, - // transpileDependencies: ["mermaid", "quill"], - chainWebpack(config) { - config.plugins.delete("preload"); // TODO: need test - config.plugins.delete("prefetch"); // TODO: need test - - // set svg-sprite-loader - config.module.rule("svg").exclude.add(resolve("src/assets/icons")).end(); - config.module - .rule("icons") - .test(/\.svg$/) - .include.add(resolve("src/assets/icons")) - .end() - .use("svg-sprite-loader") - .loader("svg-sprite-loader") - .options({ - symbolId: "icon-[name]", - }) - .end(); - - config.when(process.env.NODE_ENV !== "development", (config) => { - config - .plugin("ScriptExtHtmlWebpackPlugin") - .after("html") - .use("script-ext-html-webpack-plugin", [ - { - // `runtime` must same as runtimeChunk name. default is `runtime` - inline: /runtime\..*\.js$/, - }, - ]) - .end(); - - config.optimization.splitChunks({ - chunks: "all", - cacheGroups: { - libs: { - name: "chunk-libs", - test: /[\\/]node_modules[\\/]/, - priority: 10, - chunks: "initial", // only package third parties that are initially dependent - }, - elementUI: { - name: "chunk-elementUI", // split elementUI into a single package - test: /[\\/]node_modules[\\/]_?element-ui(.*)/, // in order to adapt to cnpm - priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app - }, - commons: { - name: "chunk-commons", - test: resolve("src/components"), // can customize your rules - minChunks: 3, // minimum common number - priority: 5, - reuseExistingChunk: true, - }, + // 复制 mxGraph resources 和 css 文件 + new CopyWebpackPlugin([ + { + from: path.resolve(__dirname, 'node_modules/mxgraph/javascript/src/resources'), + to: path.resolve(__dirname, 'dist/mxgraph/resources') }, - }); - config.optimization.runtimeChunk("single"); - }); - }, + { + from: path.resolve(__dirname, 'node_modules/mxgraph/javascript/src/resources'), + to: path.resolve(__dirname, 'dist/resources') + }, + { + from: path.resolve(__dirname, 'node_modules/mxgraph/javascript/src/css'), + to: path.resolve(__dirname, 'dist/mxgraph/css') + }, + { + from: path.resolve(__dirname, 'node_modules/mxgraph/javascript/src/css'), + to: path.resolve(__dirname, 'dist/css') + } + ]), + ], + } };