From 2ce745f780b00954daead923598d12a0fd7a2730 Mon Sep 17 00:00:00 2001
From: blak-kong <546598185@qq.com>
Date: Thu, 14 Dec 2023 09:51:50 +0800
Subject: [PATCH 1/3] .
---
flossom-ui/.env.development | 3 +
flossom-ui/.env.production | 3 +
flossom-ui/src/permission.js | 80 +++---
flossom-ui/src/router/index.js | 178 +++++++-------
flossom-ui/src/utils/request.js | 250 +++++++++++--------
flossom-ui/src/views/login.vue | 418 +++++++++++++++++---------------
flossom-ui/vue.config.js | 151 ++++++------
7 files changed, 585 insertions(+), 498 deletions(-)
diff --git a/flossom-ui/.env.development b/flossom-ui/.env.development
index 5fdbb7b..ec3c05f 100644
--- a/flossom-ui/.env.development
+++ b/flossom-ui/.env.development
@@ -9,3 +9,6 @@ VUE_APP_BASE_API = '/dev-api'
# 路由懒加载
VUE_CLI_BABEL_TRANSPILE_MODULES = true
+
+# 设置端口号
+port=8080
diff --git a/flossom-ui/.env.production b/flossom-ui/.env.production
index eda5aff..4f9dcfb 100644
--- a/flossom-ui/.env.production
+++ b/flossom-ui/.env.production
@@ -6,3 +6,6 @@ ENV = 'production'
# 花至管理系统/生产环境
VUE_APP_BASE_API = '/prod-api'
+
+# 设置端口号
+# port=8080
\ No newline at end of file
diff --git a/flossom-ui/src/permission.js b/flossom-ui/src/permission.js
index e1a14da..8f2d2ee 100644
--- a/flossom-ui/src/permission.js
+++ b/flossom-ui/src/permission.js
@@ -1,56 +1,60 @@
-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 { isRelogin } from '@/utils/request'
+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 { isRelogin } from "@/utils/request";
-NProgress.configure({ showSpinner: false })
+NProgress.configure({ showSpinner: false });
-const whiteList = ['/login', '/register']
+const whiteList = ["/login", "/register"];
router.beforeEach((to, from, next) => {
- NProgress.start()
+ NProgress.start();
if (getToken()) {
- to.meta.title && store.dispatch('settings/setTitle', to.meta.title)
+ to.meta.title && store.dispatch("settings/setTitle", to.meta.title);
/* has token*/
- if (to.path === '/login') {
- next({ path: '/' })
- NProgress.done()
+ if (to.path === "/login") {
+ next({ path: "/" });
+ NProgress.done();
} else {
if (store.getters.roles.length === 0) {
- isRelogin.show = true
+ 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: '/' })
- })
+ 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()
+ next();
}
}
} else {
+ next();
// 没有token
- if (whiteList.indexOf(to.path) !== -1) {
- // 在免登录白名单,直接进入
- next()
- } else {
- next(`/login?redirect=${encodeURIComponent(to.fullPath)}`) // 否则全部重定向到登录页
- NProgress.done()
- }
+ // if (whiteList.indexOf(to.path) !== -1) {
+ // // 在免登录白名单,直接进入
+ // next()
+ // } else {
+ // next(`/login?redirect=${encodeURIComponent(to.fullPath)}`) // 否则全部重定向到登录页
+ // NProgress.done()
+ // }
}
-})
+});
router.afterEach(() => {
- NProgress.done()
-})
+ NProgress.done();
+});
diff --git a/flossom-ui/src/router/index.js b/flossom-ui/src/router/index.js
index 71907b6..47fac3f 100644
--- a/flossom-ui/src/router/index.js
+++ b/flossom-ui/src/router/index.js
@@ -1,10 +1,10 @@
-import Vue from 'vue'
-import Router from 'vue-router'
+import Vue from "vue";
+import Router from "vue-router";
-Vue.use(Router)
+Vue.use(Router);
/* Layout */
-import Layout from '@/layout'
+import Layout from "@/layout";
/**
* Note: 路由配置项
@@ -31,153 +31,153 @@ import Layout from '@/layout'
// 公共路由
export const constantRoutes = [
{
- path: '/redirect',
+ path: "/redirect",
component: Layout,
hidden: true,
children: [
{
- path: '/redirect/:path(.*)',
- component: () => import('@/views/redirect')
- }
- ]
+ path: "/redirect/:path(.*)",
+ component: () => import("@/views/redirect"),
+ },
+ ],
},
{
- path: '/login',
- component: () => import('@/views/login'),
- hidden: true
+ path: "/login",
+ component: () => import("@/views/login"),
+ hidden: true,
},
{
- path: '/register',
- component: () => import('@/views/register'),
- hidden: true
+ path: "/register",
+ component: () => import("@/views/register"),
+ hidden: true,
},
{
- path: '/404',
- component: () => import('@/views/error/404'),
- hidden: true
+ path: "/404",
+ component: () => import("@/views/error/404"),
+ hidden: true,
},
{
- path: '/401',
- component: () => import('@/views/error/401'),
- hidden: true
+ path: "/401",
+ component: () => import("@/views/error/401"),
+ hidden: true,
},
{
- path: '',
+ path: "",
component: Layout,
- redirect: 'index',
+ redirect: "index",
children: [
{
- path: 'index',
- component: () => import('@/views/index'),
- name: 'Index',
- meta: { title: '首页', icon: 'dashboard', affix: true }
- }
- ]
+ path: "index",
+ component: () => import("@/views/index"),
+ name: "Index",
+ meta: { title: "首页", icon: "dashboard", affix: true },
+ },
+ ],
},
{
- path: '/user',
+ path: "/user",
component: Layout,
hidden: true,
- redirect: 'noredirect',
+ redirect: "noredirect",
children: [
{
- path: 'profile',
- component: () => import('@/views/system/user/profile/index'),
- name: 'Profile',
- meta: { title: '个人中心', icon: 'user' }
- }
- ]
- }
-]
+ path: "profile",
+ component: () => import("@/views/system/user/profile/index"),
+ name: "Profile",
+ meta: { title: "个人中心", icon: "user" },
+ },
+ ],
+ },
+];
// 动态路由,基于用户权限动态去加载
export const dynamicRoutes = [
{
- path: '/system/user-auth',
+ path: "/system/user-auth",
component: Layout,
hidden: true,
- permissions: ['system:user:edit'],
+ permissions: ["system:user:edit"],
children: [
{
- path: 'role/:userId(\\d+)',
- component: () => import('@/views/system/user/authRole'),
- name: 'AuthRole',
- meta: { title: '分配角色', activeMenu: '/system/user' }
- }
- ]
+ path: "role/:userId(\\d+)",
+ component: () => import("@/views/system/user/authRole"),
+ name: "AuthRole",
+ meta: { title: "分配角色", activeMenu: "/system/user" },
+ },
+ ],
},
{
- path: '/system/role-auth',
+ path: "/system/role-auth",
component: Layout,
hidden: true,
- permissions: ['system:role:edit'],
+ permissions: ["system:role:edit"],
children: [
{
- path: 'user/:roleId(\\d+)',
- component: () => import('@/views/system/role/authUser'),
- name: 'AuthUser',
- meta: { title: '分配用户', activeMenu: '/system/role' }
- }
- ]
+ path: "user/:roleId(\\d+)",
+ component: () => import("@/views/system/role/authUser"),
+ name: "AuthUser",
+ meta: { title: "分配用户", activeMenu: "/system/role" },
+ },
+ ],
},
{
- path: '/system/dict-data',
+ path: "/system/dict-data",
component: Layout,
- hidden: true,
- permissions: ['system:dict:list'],
+ hidden: false,
+ // permissions: ["system:dict:list"],
children: [
{
- path: 'index/:dictId(\\d+)',
- component: () => import('@/views/system/dict/data'),
- name: 'Data',
- meta: { title: '字典数据', activeMenu: '/system/dict' }
- }
- ]
+ path: "index/:dictId(\\d+)",
+ component: () => import("@/views/system/dict/data"),
+ name: "Data",
+ meta: { title: "字典数据", activeMenu: "/system/dict" },
+ },
+ ],
},
{
- path: '/monitor/job-log',
+ path: "/monitor/job-log",
component: Layout,
hidden: true,
- permissions: ['monitor:job:list'],
+ permissions: ["monitor:job:list"],
children: [
{
- path: 'index/:jobId(\\d+)',
- component: () => import('@/views/monitor/job/log'),
- name: 'JobLog',
- meta: { title: '调度日志', activeMenu: '/monitor/job' }
- }
- ]
+ path: "index/:jobId(\\d+)",
+ component: () => import("@/views/monitor/job/log"),
+ name: "JobLog",
+ meta: { title: "调度日志", activeMenu: "/monitor/job" },
+ },
+ ],
},
{
- path: '/tool/gen-edit',
+ path: "/tool/gen-edit",
component: Layout,
hidden: true,
- permissions: ['tool:gen:edit'],
+ permissions: ["tool:gen:edit"],
children: [
{
- path: 'index/:tableId(\\d+)',
- component: () => import('@/views/tool/gen/editTable'),
- name: 'GenEdit',
- meta: { title: '修改生成配置', activeMenu: '/tool/gen' }
- }
- ]
- }
-]
+ path: "index/:tableId(\\d+)",
+ component: () => import("@/views/tool/gen/editTable"),
+ name: "GenEdit",
+ meta: { title: "修改生成配置", activeMenu: "/tool/gen" },
+ },
+ ],
+ },
+];
// 防止连续点击多次路由报错
let routerPush = Router.prototype.push;
let routerReplace = Router.prototype.replace;
// push
Router.prototype.push = function push(location) {
- return routerPush.call(this, location).catch(err => err)
-}
+ return routerPush.call(this, location).catch((err) => err);
+};
// replace
Router.prototype.replace = function push(location) {
- return routerReplace.call(this, location).catch(err => err)
-}
+ return routerReplace.call(this, location).catch((err) => err);
+};
export default new Router({
- mode: 'history', // 去掉url中的#
+ mode: "history", // 去掉url中的#
scrollBehavior: () => ({ y: 0 }),
- routes: constantRoutes
-})
+ routes: constantRoutes,
+});
diff --git a/flossom-ui/src/utils/request.js b/flossom-ui/src/utils/request.js
index ffb0d21..2ceba58 100644
--- a/flossom-ui/src/utils/request.js
+++ b/flossom-ui/src/utils/request.js
@@ -1,114 +1,148 @@
-import axios from 'axios'
-import { Notification, MessageBox, Message, Loading } from 'element-ui'
-import store from '@/store'
-import { getToken } from '@/utils/auth'
-import errorCode from '@/utils/errorCode'
+import axios from "axios";
+import { Notification, MessageBox, Message, Loading } from "element-ui";
+import store from "@/store";
+import { getToken } from "@/utils/auth";
+import errorCode from "@/utils/errorCode";
import { tansParams, blobValidate } from "@/utils/ruoyi";
-import cache from '@/plugins/cache'
-import { saveAs } from 'file-saver'
+import cache from "@/plugins/cache";
+import { saveAs } from "file-saver";
let downloadLoadingInstance;
// 是否显示重新登录
export let isRelogin = { show: false };
-axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
+axios.defaults.headers["Content-Type"] = "application/json;charset=utf-8";
// 创建axios实例
const service = axios.create({
// axios中请求配置有baseURL选项,表示请求URL公共部分
baseURL: process.env.VUE_APP_BASE_API,
// 超时
- timeout: 10000
-})
+ timeout: 10000,
+});
// request拦截器
-service.interceptors.request.use(config => {
- // 是否需要设置 token
- const isToken = (config.headers || {}).isToken === false
- // 是否需要防止数据重复提交
- const isRepeatSubmit = (config.headers || {}).repeatSubmit === false
- if (getToken() && !isToken) {
- config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
- }
- // get请求映射params参数
- if (config.method === 'get' && config.params) {
- let url = config.url + '?' + tansParams(config.params);
- url = url.slice(0, -1);
- config.params = {};
- config.url = url;
- }
- if (!isRepeatSubmit && (config.method === 'post' || config.method === 'put')) {
- const requestObj = {
- url: config.url,
- data: typeof config.data === 'object' ? JSON.stringify(config.data) : config.data,
- time: new Date().getTime()
+service.interceptors.request.use(
+ (config) => {
+ // 是否需要设置 token
+ const isToken = (config.headers || {}).isToken === false;
+ // 是否需要防止数据重复提交
+ const isRepeatSubmit = (config.headers || {}).repeatSubmit === false;
+ if (getToken() && !isToken) {
+ config.headers["Authorization"] = "Bearer " + getToken(); // 让每个请求携带自定义token 请根据实际情况自行修改
}
- const requestSize = Object.keys(JSON.stringify(requestObj)).length; // 请求数据大小
- const limitSize = 5 * 1024 * 1024; // 限制存放数据5M
- if (requestSize >= limitSize) {
- console.warn(`[${config.url}]: ` + '请求数据大小超出允许的5M限制,无法进行防重复提交验证。')
- return config;
+ // get请求映射params参数
+ if (config.method === "get" && config.params) {
+ let url = config.url + "?" + tansParams(config.params);
+ url = url.slice(0, -1);
+ config.params = {};
+ config.url = url;
}
- const sessionObj = cache.session.getJSON('sessionObj')
- if (sessionObj === undefined || sessionObj === null || sessionObj === '') {
- cache.session.setJSON('sessionObj', requestObj)
- } else {
- const s_url = sessionObj.url; // 请求地址
- const s_data = sessionObj.data; // 请求数据
- const s_time = sessionObj.time; // 请求时间
- const interval = 1000; // 间隔时间(ms),小于此时间视为重复提交
- if (s_data === requestObj.data && requestObj.time - s_time < interval && s_url === requestObj.url) {
- const message = '数据正在处理,请勿重复提交';
- console.warn(`[${s_url}]: ` + message)
- return Promise.reject(new Error(message))
+ if (
+ !isRepeatSubmit &&
+ (config.method === "post" || config.method === "put")
+ ) {
+ const requestObj = {
+ url: config.url,
+ data:
+ typeof config.data === "object"
+ ? JSON.stringify(config.data)
+ : config.data,
+ time: new Date().getTime(),
+ };
+ const requestSize = Object.keys(JSON.stringify(requestObj)).length; // 请求数据大小
+ const limitSize = 5 * 1024 * 1024; // 限制存放数据5M
+ if (requestSize >= limitSize) {
+ console.warn(
+ `[${config.url}]: ` +
+ "请求数据大小超出允许的5M限制,无法进行防重复提交验证。"
+ );
+ return config;
+ }
+ const sessionObj = cache.session.getJSON("sessionObj");
+ if (
+ sessionObj === undefined ||
+ sessionObj === null ||
+ sessionObj === ""
+ ) {
+ cache.session.setJSON("sessionObj", requestObj);
} else {
- cache.session.setJSON('sessionObj', requestObj)
+ const s_url = sessionObj.url; // 请求地址
+ const s_data = sessionObj.data; // 请求数据
+ const s_time = sessionObj.time; // 请求时间
+ const interval = 1000; // 间隔时间(ms),小于此时间视为重复提交
+ if (
+ s_data === requestObj.data &&
+ requestObj.time - s_time < interval &&
+ s_url === requestObj.url
+ ) {
+ const message = "数据正在处理,请勿重复提交";
+ console.warn(`[${s_url}]: ` + message);
+ return Promise.reject(new Error(message));
+ } else {
+ cache.session.setJSON("sessionObj", requestObj);
+ }
}
}
+ return config;
+ },
+ (error) => {
+ console.log(error);
+ Promise.reject(error);
}
- return config
-}, error => {
- console.log(error)
- Promise.reject(error)
-})
+);
// 响应拦截器
-service.interceptors.response.use(res => {
+service.interceptors.response.use(
+ (res) => {
// 未设置状态码则默认成功状态
const code = res.data.code || 200;
// 获取错误信息
- const msg = errorCode[code] || res.data.msg || errorCode['default']
+ const msg = errorCode[code] || res.data.msg || errorCode["default"];
// 二进制数据则直接返回
- if (res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer') {
- return res.data
+ if (
+ res.request.responseType === "blob" ||
+ res.request.responseType === "arraybuffer"
+ ) {
+ return res.data;
}
if (code === 401) {
if (!isRelogin.show) {
isRelogin.show = true;
- MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', { confirmButtonText: '重新登录', cancelButtonText: '取消', type: 'warning' }).then(() => {
- isRelogin.show = false;
- store.dispatch('LogOut').then(() => {
- location.href = '/index';
+ MessageBox.confirm(
+ "登录状态已过期,您可以继续留在该页面,或者重新登录",
+ "系统提示",
+ {
+ confirmButtonText: "重新登录",
+ cancelButtonText: "取消",
+ type: "warning",
+ }
+ )
+ .then(() => {
+ isRelogin.show = false;
+ store.dispatch("LogOut").then(() => {
+ location.href = "/index";
+ });
})
- }).catch(() => {
- isRelogin.show = false;
- });
- }
- return Promise.reject('无效的会话,或者会话已过期,请重新登录。')
+ .catch(() => {
+ isRelogin.show = false;
+ });
+ }
+ return Promise.reject("无效的会话,或者会话已过期,请重新登录。");
} else if (code === 500) {
- Message({ message: msg, type: 'error' })
- return Promise.reject(new Error(msg))
+ Message({ message: msg, type: "error" });
+ return Promise.reject(new Error(msg));
} else if (code === 601) {
- Message({ message: msg, type: 'warning' })
- return Promise.reject('error')
+ Message({ message: msg, type: "warning" });
+ return Promise.reject("error");
} else if (code !== 200) {
- Notification.error({ title: msg })
- return Promise.reject('error')
+ Notification.error({ title: msg });
+ return Promise.reject("error");
} else {
- return res.data
+ return res.data;
}
},
- error => {
- console.log('err' + error)
+ (error) => {
+ console.log("err" + error);
let { message } = error;
if (message == "Network Error") {
message = "后端接口连接异常";
@@ -117,36 +151,48 @@ service.interceptors.response.use(res => {
} else if (message.includes("Request failed with status code")) {
message = "系统接口" + message.substr(message.length - 3) + "异常";
}
- Message({ message: message, type: 'error', duration: 5 * 1000 })
- return Promise.reject(error)
+ Message({ message: message, type: "error", duration: 5 * 1000 });
+ return Promise.reject(error);
}
-)
+);
// 通用下载方法
export function download(url, params, filename, config) {
- downloadLoadingInstance = Loading.service({ text: "正在下载数据,请稍候", spinner: "el-icon-loading", background: "rgba(0, 0, 0, 0.7)", })
- return service.post(url, params, {
- transformRequest: [(params) => { return tansParams(params) }],
- headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
- responseType: 'blob',
- ...config
- }).then(async (data) => {
- const isBlob = blobValidate(data);
- if (isBlob) {
- const blob = new Blob([data])
- saveAs(blob, filename)
- } else {
- const resText = await data.text();
- const rspObj = JSON.parse(resText);
- const errMsg = errorCode[rspObj.code] || rspObj.msg || errorCode['default']
- Message.error(errMsg);
- }
- downloadLoadingInstance.close();
- }).catch((r) => {
- console.error(r)
- Message.error('下载文件出现错误,请联系管理员!')
- downloadLoadingInstance.close();
- })
+ downloadLoadingInstance = Loading.service({
+ text: "正在下载数据,请稍候",
+ spinner: "el-icon-loading",
+ background: "rgba(0, 0, 0, 0.7)",
+ });
+ return service
+ .post(url, params, {
+ transformRequest: [
+ (params) => {
+ return tansParams(params);
+ },
+ ],
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
+ responseType: "blob",
+ ...config,
+ })
+ .then(async (data) => {
+ const isBlob = blobValidate(data);
+ if (isBlob) {
+ const blob = new Blob([data]);
+ saveAs(blob, filename);
+ } else {
+ const resText = await data.text();
+ const rspObj = JSON.parse(resText);
+ const errMsg =
+ errorCode[rspObj.code] || rspObj.msg || errorCode["default"];
+ Message.error(errMsg);
+ }
+ downloadLoadingInstance.close();
+ })
+ .catch((r) => {
+ console.error(r);
+ Message.error("下载文件出现错误,请联系管理员!");
+ downloadLoadingInstance.close();
+ });
}
-export default service
+export default service;
diff --git a/flossom-ui/src/views/login.vue b/flossom-ui/src/views/login.vue
index 3785e24..9056a57 100644
--- a/flossom-ui/src/views/login.vue
+++ b/flossom-ui/src/views/login.vue
@@ -1,219 +1,251 @@
-
-
- 花至后台管理系统
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
![]()
-
-
- 记住密码
-
-
- 登 录
- 登 录 中...
-
-
- 立即注册
-
-
-
-
-
-
+
+
+ 花至后台管理系统
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
![]()
+
+
+ 记住密码
+
+
+ 登 录
+ 登 录 中...
+
+
+ 立即注册
+
+
+
+
+
+
diff --git a/flossom-ui/vue.config.js b/flossom-ui/vue.config.js
index a29c2f6..4858f78 100644
--- a/flossom-ui/vue.config.js
+++ b/flossom-ui/vue.config.js
@@ -1,15 +1,15 @@
-'use strict'
-const path = require('path')
+"use strict";
+const path = require("path");
function resolve(dir) {
- return path.join(__dirname, dir)
+ return path.join(__dirname, dir);
}
-const CompressionPlugin = require('compression-webpack-plugin')
+const CompressionPlugin = require("compression-webpack-plugin");
-const name = process.env.VUE_APP_TITLE || '花至管理系统' // 网页标题
+const name = process.env.VUE_APP_TITLE || "花至管理系统"; // 网页标题
-const port = process.env.port || process.env.npm_config_port || 80 // 端口
+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,16 +20,16 @@ module.exports = {
// 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.vip/admin/,则设置 baseUrl 为 /admin/。
publicPath: process.env.NODE_ENV === "production" ? "/" : "/",
// 在npm run build 或 yarn build 时 ,生成文件的目录名称(要和baseUrl的生产环境路径一致)(默认dist)
- outputDir: 'dist',
+ outputDir: "dist",
// 用于放置生成的静态资源 (js、css、img、fonts) 的;(项目打包之后,静态资源会放在这个文件夹下)
- assetsDir: 'static',
+ assetsDir: "static",
// 是否开启eslint保存检测,有效值:ture | false | 'error'
- lintOnSave: process.env.NODE_ENV === 'development',
+ lintOnSave: process.env.NODE_ENV === "development",
// 如果你不需要生产环境的 source map,可以将其设置为 false 以加速生产环境构建。
productionSourceMap: false,
// webpack-dev-server 相关配置
devServer: {
- host: '0.0.0.0',
+ host: "0.0.0.0",
port: port,
open: true,
proxy: {
@@ -38,97 +38,96 @@ module.exports = {
target: `http://localhost:8080`,
changeOrigin: true,
pathRewrite: {
- ['^' + process.env.VUE_APP_BASE_API]: ''
- }
- }
+ ["^" + process.env.VUE_APP_BASE_API]: "",
+ },
+ },
},
- disableHostCheck: true
+ disableHostCheck: true,
},
css: {
loaderOptions: {
sass: {
- sassOptions: { outputStyle: "expanded" }
- }
- }
+ sassOptions: { outputStyle: "expanded" },
+ },
+ },
},
configureWebpack: {
name: name,
resolve: {
alias: {
- '@': resolve('src')
- }
+ "@": resolve("src"),
+ },
},
plugins: [
// http://doc.ruoyi.vip/ruoyi-vue/other/faq.html#使用gzip解压缩静态文件
new CompressionPlugin({
- cache: false, // 不启用文件缓存
- test: /\.(js|css|html)?$/i, // 压缩文件格式
- filename: '[path].gz[query]', // 压缩后的文件名
- algorithm: 'gzip', // 使用gzip压缩
- minRatio: 0.8 // 压缩率小于1才会压缩
- })
+ cache: false, // 不启用文件缓存
+ test: /\.(js|css|html)?$/i, // 压缩文件格式
+ filename: "[path].gz[query]", // 压缩后的文件名
+ algorithm: "gzip", // 使用gzip压缩
+ minRatio: 0.8, // 压缩率小于1才会压缩
+ }),
],
},
chainWebpack(config) {
- config.plugins.delete('preload') // TODO: need test
- config.plugins.delete('prefetch') // TODO: need test
+ 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('svg')
- .exclude.add(resolve('src/assets/icons'))
- .end()
- config.module
- .rule('icons')
+ .rule("icons")
.test(/\.svg$/)
- .include.add(resolve('src/assets/icons'))
+ .include.add(resolve("src/assets/icons"))
.end()
- .use('svg-sprite-loader')
- .loader('svg-sprite-loader')
+ .use("svg-sprite-loader")
+ .loader("svg-sprite-loader")
.options({
- symbolId: 'icon-[name]'
+ symbolId: "icon-[name]",
})
- .end()
+ .end();
- config.when(process.env.NODE_ENV !== 'development', config => {
- config
- .plugin('ScriptExtHtmlWebpackPlugin')
- .after('html')
- .use('script-ext-html-webpack-plugin', [{
+ 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()
+ 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
- }
- }
- })
+ 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,
+ },
+ },
+ });
- config.optimization.runtimeChunk('single'),
- {
- from: path.resolve(__dirname, './public/robots.txt'), //防爬虫文件
- to: './' //到根目录下
- }
- })
- }
-}
+ config.optimization.runtimeChunk("single"),
+ {
+ from: path.resolve(__dirname, "./public/robots.txt"), //防爬虫文件
+ to: "./", //到根目录下
+ };
+ });
+ },
+};
From b175087114a03b669bcafacdf2cd81e7f20ef471 Mon Sep 17 00:00:00 2001
From: blak-kong <546598185@qq.com>
Date: Thu, 14 Dec 2023 10:12:18 +0800
Subject: [PATCH 2/3] .
---
flossom-ui/package.json | 3 ++-
flossom-ui/src/permission.js | 16 +++++++---------
flossom-ui/vue.config.js | 8 ++++++++
3 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/flossom-ui/package.json b/flossom-ui/package.json
index 2827a72..f7945b0 100644
--- a/flossom-ui/package.json
+++ b/flossom-ui/package.json
@@ -5,7 +5,8 @@
"author": "花至",
"license": "MIT",
"scripts": {
- "dev": "vue-cli-service serve",
+ "local": "vue-cli-service serve --mode local",
+ "dev": "vue-cli-service serve --mode development",
"build:prod": "vue-cli-service build",
"build:stage": "vue-cli-service build --mode staging",
"preview": "node build/index.js --preview",
diff --git a/flossom-ui/src/permission.js b/flossom-ui/src/permission.js
index 8f2d2ee..6ca9cc4 100644
--- a/flossom-ui/src/permission.js
+++ b/flossom-ui/src/permission.js
@@ -43,15 +43,13 @@ router.beforeEach((to, from, next) => {
}
}
} else {
- next();
- // 没有token
- // if (whiteList.indexOf(to.path) !== -1) {
- // // 在免登录白名单,直接进入
- // next()
- // } else {
- // next(`/login?redirect=${encodeURIComponent(to.fullPath)}`) // 否则全部重定向到登录页
- // NProgress.done()
- // }
+ if (whiteList.indexOf(to.path) !== -1) {
+ // 在免登录白名单,直接进入
+ next();
+ } else {
+ next(`/login?redirect=${encodeURIComponent(to.fullPath)}`); // 否则全部重定向到登录页
+ NProgress.done();
+ }
}
});
diff --git a/flossom-ui/vue.config.js b/flossom-ui/vue.config.js
index 4858f78..7a45fff 100644
--- a/flossom-ui/vue.config.js
+++ b/flossom-ui/vue.config.js
@@ -11,6 +11,14 @@ const name = process.env.VUE_APP_TITLE || "花至管理系统"; // 网页标题
const port = process.env.port || process.env.npm_config_port || 80; // 端口
+function getTargetUrl() {
+ if (process.env.NODE_ENV === "local") {
+ return "http://110.41.134.131:8080";
+ } else {
+ return `http://localhost:8080`;
+ }
+}
+
// vue.config.js 配置说明
//官方vue.config.js 参考文档 https://cli.vuejs.org/zh/config/#css-loaderoptions
// 这里只列一部分,具体配置参考文档
From 79f74d6262dcf54d86e1fa99b099be38903705ca Mon Sep 17 00:00:00 2001
From: blak-kong <546598185@qq.com>
Date: Thu, 4 Jan 2024 09:54:10 +0800
Subject: [PATCH 3/3] add quill-better-table
---
flossom-ui/package.json | 1 +
1 file changed, 1 insertion(+)
diff --git a/flossom-ui/package.json b/flossom-ui/package.json
index f7945b0..5a34735 100644
--- a/flossom-ui/package.json
+++ b/flossom-ui/package.json
@@ -51,6 +51,7 @@
"jsencrypt": "3.0.0-rc.1",
"nprogress": "0.2.0",
"quill": "1.3.7",
+ "quill-better-table": "^1.2.10",
"screenfull": "5.0.2",
"sortablejs": "1.10.2",
"vue": "2.6.12",