From 42a3117e2ac087f5c2c28ca07a1c4443e2c38ca3 Mon Sep 17 00:00:00 2001 From: 疯狂的狮子Li <15040126243@163.com> Date: 星期一, 25 十月 2021 18:24:55 +0800 Subject: [PATCH] Merge branch 'master' of https://gitee.com/y_project/RuoYi-Vue into dev --- ruoyi-ui/src/plugins/auth.js | 60 +++++++++++++++ ry.sh | 10 - ruoyi-ui/src/store/modules/permission.js | 11 ++ ruoyi-ui/src/views/monitor/cache/index.vue | 2 ruoyi-ui/src/views/index.vue | 1 ruoyi-ui/src/views/system/role/index.vue | 4 ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java | 5 ry.bat | 46 +++++----- ruoyi-ui/src/layout/components/Settings/index.vue | 4 ruoyi-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java | 2 ruoyi-common/src/main/java/com/ruoyi/common/annotation/RepeatSubmit.java | 2 ruoyi-ui/src/plugins/index.js | 3 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java | 2 ruoyi-ui/src/plugins/download.js | 45 ++++++++-- ruoyi-common/src/main/java/com/ruoyi/common/utils/Threads.java | 2 ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java | 2 16 files changed, 144 insertions(+), 57 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/RepeatSubmit.java b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/RepeatSubmit.java index 4a15b7c..a874667 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/RepeatSubmit.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/RepeatSubmit.java @@ -24,6 +24,6 @@ /** * 鎻愮ず娑堟伅 */ - String message() default "涓嶅厑璁搁噸澶嶆彁浜わ紝璇风◢鍚庡啀璇�"; + String message() default "涓嶅厑璁搁噸澶嶆彁浜わ紝璇风◢鍊欏啀璇�"; } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/Threads.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/Threads.java index 9474a95..5be9582 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/Threads.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/Threads.java @@ -28,7 +28,7 @@ * 鍋滄绾跨▼姹� * 鍏堜娇鐢╯hutdown, 鍋滄鎺ユ敹鏂颁换鍔″苟灏濊瘯瀹屾垚鎵�鏈夊凡瀛樺湪浠诲姟. * 濡傛灉瓒呮椂, 鍒欒皟鐢╯hutdownNow, 鍙栨秷鍦╳orkQueue涓璓ending鐨勪换鍔�,骞朵腑鏂墍鏈夐樆濉炲嚱鏁�. - * 濡傛灉浠嶄汉瓒呮檪锛屽墖寮峰埗閫�鍑�. + * 濡傛灉浠嶇劧瓒呮檪锛屽墖寮峰埗閫�鍑�. * 鍙﹀鍦╯hutdown鏃剁嚎绋嬫湰韬璋冪敤涓柇鍋氫簡澶勭悊. */ public static void shutdownAndAwaitTermination(ExecutorService pool) { diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java index 5df2923..ff56a2a 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java @@ -22,9 +22,6 @@ * @return */ public static void setAttachmentResponseHeader(HttpServletResponse response, String realFileName) throws UnsupportedEncodingException { - response.addHeader("Access-Control-Allow-Origin", "*"); - response.addHeader("Access-Control-Expose-Headers", "Content-Disposition,download-filename"); - String percentEncodedFileName = percentEncode(realFileName); StringBuilder contentDispositionValue = new StringBuilder(); @@ -35,6 +32,8 @@ .append("utf-8''") .append(percentEncodedFileName); + response.addHeader("Access-Control-Allow-Origin", "*"); + response.addHeader("Access-Control-Expose-Headers", "Content-Disposition,download-filename"); response.setHeader("Content-disposition", contentDispositionValue.toString()); response.setHeader("download-filename", percentEncodedFileName); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java index 164a697..eb44006 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java @@ -39,7 +39,7 @@ * @param userId 鐢ㄦ埛ID * @return 閫変腑瑙掕壊ID鍒楄〃 */ - List<Integer> selectRoleListByUserId(Long userId); + List<Long> selectRoleListByUserId(Long userId); /** * 鏍规嵁鐢ㄦ埛ID鏌ヨ瑙掕壊 diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java index c97d2a6..d5838a8 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java @@ -55,7 +55,7 @@ * @param userId 鐢ㄦ埛ID * @return 閫変腑瑙掕壊ID鍒楄〃 */ - List<Integer> selectRoleListByUserId(Long userId); + List<Long> selectRoleListByUserId(Long userId); /** * 閫氳繃瑙掕壊ID鏌ヨ瑙掕壊 diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java index 6e0ed78..7dd14af 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java @@ -117,7 +117,7 @@ * @return 閫変腑瑙掕壊ID鍒楄〃 */ @Override - public List<Integer> selectRoleListByUserId(Long userId) { + public List<Long> selectRoleListByUserId(Long userId) { return baseMapper.selectRoleListByUserId(userId); } diff --git a/ruoyi-ui/src/layout/components/Settings/index.vue b/ruoyi-ui/src/layout/components/Settings/index.vue index ffdedb4..31db9bb 100644 --- a/ruoyi-ui/src/layout/components/Settings/index.vue +++ b/ruoyi-ui/src/layout/components/Settings/index.vue @@ -162,7 +162,7 @@ this.sideTheme = val; }, saveSetting() { - this.$modal.loading("姝e湪淇濆瓨鍒版湰鍦帮紝璇风◢鍚�..."); + this.$modal.loading("姝e湪淇濆瓨鍒版湰鍦帮紝璇风◢鍊�..."); this.$cache.local.set( "layout-setting", `{ @@ -178,7 +178,7 @@ setTimeout(this.$modal.closeLoading(), 1000) }, resetSetting() { - this.$modal.loading("姝e湪娓呴櫎璁剧疆缂撳瓨骞跺埛鏂帮紝璇风◢鍚�..."); + this.$modal.loading("姝e湪娓呴櫎璁剧疆缂撳瓨骞跺埛鏂帮紝璇风◢鍊�..."); this.$cache.local.remove("layout-setting") setTimeout("window.location.reload()", 1000) } diff --git a/ruoyi-ui/src/plugins/auth.js b/ruoyi-ui/src/plugins/auth.js new file mode 100644 index 0000000..af740aa --- /dev/null +++ b/ruoyi-ui/src/plugins/auth.js @@ -0,0 +1,60 @@ +import store from '@/store' + +function authPermission(permission) { + const all_permission = "*:*:*"; + const permissions = store.getters && store.getters.permissions + if (permission && permission.length > 0) { + return permissions.some(v => { + return all_permission === v || v === permission + }) + } else { + return false + } +} + +function authRole(role) { + const super_admin = "admin"; + const roles = store.getters && store.getters.roles + if (role && role.length > 0) { + return roles.some(v => { + return super_admin === v || v === role + }) + } else { + return false + } +} + +export default { + // 楠岃瘉鐢ㄦ埛鏄惁鍏峰鏌愭潈闄� + hasPermi(permission) { + return authPermission(permission); + }, + // 楠岃瘉鐢ㄦ埛鏄惁鍚湁鎸囧畾鏉冮檺锛屽彧闇�鍖呭惈鍏朵腑涓�涓� + hasPermiOr(permissions) { + return permissions.some(item => { + return authPermission(item) + }) + }, + // 楠岃瘉鐢ㄦ埛鏄惁鍚湁鎸囧畾鏉冮檺锛屽繀椤诲叏閮ㄦ嫢鏈� + hasPermiAnd(permissions) { + return permissions.every(item => { + return authPermission(item) + }) + }, + // 楠岃瘉鐢ㄦ埛鏄惁鍏峰鏌愯鑹� + hasRole(role) { + return authRole(role); + }, + // 楠岃瘉鐢ㄦ埛鏄惁鍚湁鎸囧畾瑙掕壊锛屽彧闇�鍖呭惈鍏朵腑涓�涓� + hasRoleOr(roles) { + return roles.some(item => { + return authRole(item) + }) + }, + // 楠岃瘉鐢ㄦ埛鏄惁鍚湁鎸囧畾瑙掕壊锛屽繀椤诲叏閮ㄦ嫢鏈� + hasRoleAnd(roles) { + return roles.every(item => { + return authRole(item) + }) + } +} diff --git a/ruoyi-ui/src/plugins/download.js b/ruoyi-ui/src/plugins/download.js index 50f664a..ec7bdd4 100644 --- a/ruoyi-ui/src/plugins/download.js +++ b/ruoyi-ui/src/plugins/download.js @@ -1,6 +1,7 @@ import { saveAs } from 'file-saver' import axios from 'axios' import { getToken } from '@/utils/auth' +import { Message } from 'element-ui' const baseURL = process.env.VUE_APP_BASE_API @@ -35,9 +36,14 @@ url: url, responseType: 'blob', headers: { 'Authorization': 'Bearer ' + getToken() } - }).then(res => { - const blob = new Blob([res.data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }) - this.saveAs(blob, decodeURI(res.headers['download-filename'])) + }).then(async (res) => { + const isLogin = await this.blobValidate(res.data); + if (isLogin) { + const blob = new Blob([res.data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }) + this.saveAs(blob, decodeURI(res.headers['download-filename'])) + } else { + Message.error('鏃犳晥鐨勪細璇濓紝鎴栬�呬細璇濆凡杩囨湡锛岃閲嶆柊鐧诲綍銆�'); + } }) }, oss(ossId) { @@ -47,9 +53,14 @@ url: url, responseType: 'blob', headers: { 'Authorization': 'Bearer ' + getToken() } - }).then(res => { - const blob = new Blob([res.data], { type: 'application/octet-stream' }) - this.saveAs(blob, decodeURI(res.headers['download-filename'])) + }).then(async (res) => { + const isLogin = await this.blobValidate(res.data); + if (isLogin) { + const blob = new Blob([res.data], { type: 'application/octet-stream' }) + this.saveAs(blob, decodeURI(res.headers['download-filename'])) + } else { + Message.error('鏃犳晥鐨勪細璇濓紝鎴栬�呬細璇濆凡杩囨湡锛岃閲嶆柊鐧诲綍銆�'); + } }) }, zip(url, name) { @@ -59,13 +70,27 @@ url: url, responseType: 'blob', headers: { 'Authorization': 'Bearer ' + getToken() } - }).then(res => { - const blob = new Blob([res.data], { type: 'application/zip' }) - this.saveAs(blob, name) + }).then(async (res) => { + const isLogin = await this.blobValidate(res.data); + if (isLogin) { + const blob = new Blob([res.data], { type: 'application/zip' }) + this.saveAs(blob, name) + } else { + Message.error('鏃犳晥鐨勪細璇濓紝鎴栬�呬細璇濆凡杩囨湡锛岃閲嶆柊鐧诲綍銆�'); + } }) }, saveAs(text, name, opts) { saveAs(text, name, opts); - } + }, + async blobValidate(data) { + try { + const text = await data.text(); + JSON.parse(text); + return false; + } catch (error) { + return true; + } + }, } diff --git a/ruoyi-ui/src/plugins/index.js b/ruoyi-ui/src/plugins/index.js index a138e6d..7cc83a4 100644 --- a/ruoyi-ui/src/plugins/index.js +++ b/ruoyi-ui/src/plugins/index.js @@ -1,9 +1,12 @@ +import auth from './auth' import cache from './cache' import modal from './modal' import download from './download' export default { install(Vue) { + // 璁よ瘉瀵硅薄 + Vue.prototype.$auth = auth // 缂撳瓨瀵硅薄 Vue.prototype.$cache = cache // 妯℃�佹瀵硅薄 diff --git a/ruoyi-ui/src/store/modules/permission.js b/ruoyi-ui/src/store/modules/permission.js index 81026f3..dba9252 100644 --- a/ruoyi-ui/src/store/modules/permission.js +++ b/ruoyi-ui/src/store/modules/permission.js @@ -86,7 +86,7 @@ var children = [] childrenMap.forEach((el, index) => { if (el.children && el.children.length) { - if (el.component === 'ParentView') { + if (el.component === 'ParentView' && !lastRouter) { el.children.forEach(c => { c.path = el.path + '/' + c.path if (c.children && c.children.length) { @@ -106,8 +106,13 @@ return children } -export const loadView = (view) => { // 璺敱鎳掑姞杞� - return (resolve) => require([`@/views/${view}`], resolve) +export const loadView = (view) => { + if (process.env.NODE_ENV === 'development') { + return (resolve) => require([`@/views/${view}`], resolve) + } else { + // 浣跨敤 import 瀹炵幇鐢熶骇鐜鐨勮矾鐢辨噿鍔犺浇 + return () => import(`@/views/${view}`) + } } export default permission diff --git a/ruoyi-ui/src/views/index.vue b/ruoyi-ui/src/views/index.vue index 3d1ab20..8ecc659 100644 --- a/ruoyi-ui/src/views/index.vue +++ b/ruoyi-ui/src/views/index.vue @@ -478,7 +478,6 @@ </template> <script> - export default { name: "Index", data() { diff --git a/ruoyi-ui/src/views/monitor/cache/index.vue b/ruoyi-ui/src/views/monitor/cache/index.vue index 22501dc..cafa28c 100644 --- a/ruoyi-ui/src/views/monitor/cache/index.vue +++ b/ruoyi-ui/src/views/monitor/cache/index.vue @@ -139,7 +139,7 @@ }, // 鎵撳紑鍔犺浇灞� openLoading() { - this.$modal.loading("姝e湪鍔犺浇缂撳瓨鐩戞帶鏁版嵁锛岃绋嶅悗锛�"); + this.$modal.loading("姝e湪鍔犺浇缂撳瓨鐩戞帶鏁版嵁锛岃绋嶅�欙紒"); }, }, }; diff --git a/ruoyi-ui/src/views/system/role/index.vue b/ruoyi-ui/src/views/system/role/index.vue index 4fcc398..9ca11c0 100644 --- a/ruoyi-ui/src/views/system/role/index.vue +++ b/ruoyi-ui/src/views/system/role/index.vue @@ -200,7 +200,7 @@ ref="menu" node-key="id" :check-strictly="!form.menuCheckStrictly" - empty-text="鍔犺浇涓紝璇风◢鍚�" + empty-text="鍔犺浇涓紝璇风◢鍊�" :props="defaultProps" ></el-tree> </el-form-item> @@ -245,7 +245,7 @@ ref="dept" node-key="id" :check-strictly="!form.deptCheckStrictly" - empty-text="鍔犺浇涓紝璇风◢鍚�" + empty-text="鍔犺浇涓紝璇风◢鍊�" :props="defaultProps" ></el-tree> </el-form-item> diff --git a/ry.bat b/ry.bat index a6ba5a5..fd33a72 100644 --- a/ry.bat +++ b/ry.bat @@ -1,45 +1,45 @@ @echo off -rem jar平级目录 +rem jar平锟斤拷目录 set AppName=ruoyi-admin.jar -rem JVM参数 -set JVM_OPTS="-Dname=%AppName% -Duser.timezone=Asia/Shanghai -Xms512M -Xmx512M -XX:PermSize=256M -XX:MaxPermSize=512M -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:NewRatio=1 -XX:SurvivorRatio=30 -XX:+UseParallelGC -XX:+UseParallelOldGC" +rem JVM锟斤拷锟斤拷 +set JVM_OPTS="-Dname=%AppName% -Duser.timezone=Asia/Shanghai -Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:NewRatio=1 -XX:SurvivorRatio=30 -XX:+UseParallelGC -XX:+UseParallelOldGC" -ECHO. - ECHO. [1] 启动%AppName% - ECHO. [2] 关闭%AppName% - ECHO. [3] 重启%AppName% - ECHO. [4] 启动状态 %AppName% - ECHO. [5] 退 出 -ECHO. +ECHO. + ECHO. [1] 锟斤拷锟斤拷%AppName% + ECHO. [2] 锟截憋拷%AppName% + ECHO. [3] 锟斤拷锟斤拷%AppName% + ECHO. [4] 锟斤拷锟斤拷状态 %AppName% + ECHO. [5] 锟斤拷 锟斤拷 +ECHO. -ECHO.请输入选择项目的序号: +ECHO.锟斤拷锟斤拷锟斤拷选锟斤拷锟斤拷目锟斤拷锟斤拷锟�: set /p ID= - IF "%id%"=="1" GOTO start - IF "%id%"=="2" GOTO stop - IF "%id%"=="3" GOTO restart + IF "%id%"=="1" GOTO start + IF "%id%"=="2" GOTO stop + IF "%id%"=="3" GOTO restart IF "%id%"=="4" GOTO status IF "%id%"=="5" EXIT -PAUSE +PAUSE :start for /f "usebackq tokens=1-2" %%a in (`jps -l ^| findstr %AppName%`) do ( set pid=%%a set image_name=%%b ) if defined pid ( - echo %%is running - PAUSE - ) + echo %%is running + PAUSE + ) -start javaw -jar %JAVA_OPTS% ruoyi-admin.jar +start javaw %JAVA_OPTS% -jar %AppName% -echo starting…… +echo starting锟斤拷锟斤拷 echo Start %AppName% success... goto:eof -rem 函数stop通过jps命令查找pid并结束进程 +rem 锟斤拷锟斤拷stop通锟斤拷jps锟斤拷锟斤拷锟斤拷锟絧id锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷 :stop for /f "usebackq tokens=1-2" %%a in (`jps -l ^| findstr %AppName%`) do ( set pid=%%a @@ -48,7 +48,7 @@ if not defined pid (echo process %AppName% does not exists) else ( echo prepare to kill %image_name% echo start kill %pid% ... - rem 根据进程ID,kill进程 + rem 锟斤拷锟捷斤拷锟斤拷ID锟斤拷kill锟斤拷锟斤拷 taskkill /f /pid %pid% ) goto:eof @@ -64,4 +64,4 @@ if not defined pid (echo process %AppName% is dead ) else ( echo %image_name% is running ) -goto:eof \ No newline at end of file +goto:eof diff --git a/ry.sh b/ry.sh index d8e1a78..d6a9cf3 100644 --- a/ry.sh +++ b/ry.sh @@ -1,13 +1,9 @@ #!/bin/sh -# author ruoyi -# ./ry.sh start 鍚姩 -# ./ry.sh stop 鍋滄 -# ./ry.sh restart 閲嶅惎 -# ./ry.sh status 鐘舵�� +# ./ry.sh start 鍚姩 stop 鍋滄 restart 閲嶅惎 status 鐘舵�� AppName=ruoyi-admin.jar # JVM鍙傛暟 -JVM_OPTS="-Dname=$AppName -Duser.timezone=Asia/Shanghai -Xms512M -Xmx512M -XX:PermSize=256M -XX:MaxPermSize=512M -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:NewRatio=1 -XX:SurvivorRatio=30 -XX:+UseParallelGC -XX:+UseParallelOldGC" +JVM_OPTS="-Dname=$AppName -Duser.timezone=Asia/Shanghai -Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:NewRatio=1 -XX:SurvivorRatio=30 -XX:+UseParallelGC -XX:+UseParallelOldGC" APP_HOME=`pwd` LOG_PATH=$APP_HOME/logs/$AppName.log @@ -30,7 +26,7 @@ if [ x"$PID" != x"" ]; then echo "$AppName is running..." else - nohup java -jar $JVM_OPTS target/$AppName > /dev/null 2>&1 & + nohup java $JVM_OPTS -jar $AppName > /dev/null 2>&1 & echo "Start $AppName success..." fi } -- Gitblit v1.9.3