Skip to content

Commit 2c367c0

Browse files
committed
Merge branch 'master' of https://github.com/YunaiV/ruoyi-vue-pro into feature/1.6.2
2 parents b419f1d + 932fdda commit 2c367c0

File tree

23 files changed

+359
-170
lines changed

23 files changed

+359
-170
lines changed

.npmrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
phantomjs_cdnurl=http://cnpmjs.org/downloads
2+
chromedriver_cdnurl=http://cdn.npm.taobao.org/dist/chromedriver
3+
sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
4+
registry=https://registry.npmmirror.com

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"build:dev": "vue-cli-service build --mode dev",
1313
"build:demo1024": "vue-cli-service build --mode demo1024",
1414
"preview": "node build/index.js --preview",
15-
"lint": "eslint --ext .js,.vue src"
15+
"lint": "eslint --ext .js,.vue src",
16+
"clean": "rimraf node_modules"
1617
},
1718
"husky": {
1819
"hooks": {
@@ -62,11 +63,11 @@
6263
"vue-router": "3.4.9",
6364
"vuedraggable": "2.24.3",
6465
"vuex": "3.6.0",
65-
"bpmn-js-token-simulation": "^0.10.0",
66-
"min-dash": "^3.5.2",
67-
"xml-js": "^1.6.11",
68-
"@babel/parser": "^7.7.4",
69-
"throttle-debounce": "^2.1.0"
66+
"bpmn-js-token-simulation": "0.10.0",
67+
"min-dash": "3.5.2",
68+
"xml-js": "1.6.11",
69+
"@babel/parser": "7.7.4",
70+
"throttle-debounce": "2.1.0"
7071
},
7172
"devDependencies": {
7273
"@vue/cli-plugin-babel": "4.4.6",

src/components/generator/config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,8 @@ export const selectComponents = [
499499
__slot__: {
500500
'list-type': true
501501
},
502-
action: process.env.VUE_APP_BASE_API + "/admin-api/infra/file/upload", // 请求地址
502+
// action: process.env.VUE_APP_BASE_API + "/admin-api/infra/file/upload", // 请求地址
503+
action: '/infra/file/upload', // 请求地址
503504
disabled: false,
504505
accept: '',
505506
name: 'file',

src/components/parser/Parser.vue

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script>
22
import { deepClone } from '@/utils/index'
33
import render from '@/components/render/render.js'
4+
import {getAccessToken} from "@/utils/auth";
45
56
const ruleTrigger = {
67
'el-input': 'blur',
@@ -79,10 +80,51 @@ function formBtns(h) {
7980
}
8081
8182
function renderFormItem(h, elementList) {
83+
const that = this
84+
const data = this[this.formConf.formModel]
85+
// const formRef = that.$refs[that.formConf.formRef] // 这里直接添加有问题,此时还找不到表单 $refs
8286
return elementList.map(scheme => {
8387
const config = scheme.__config__
8488
const layout = layouts[config.layout]
8589
90+
// edit by 芋道源码,解决 el-upload 上传的问题
91+
// 参考 https://github.com/JakHuang/form-generator/blob/master/src/components/parser/example/Index.vue 实现
92+
const vModel = scheme.__vModel__
93+
const val = data[vModel]
94+
if (scheme.__config__.tag === 'el-upload') {
95+
// 回显图片
96+
scheme['file-list'] = (val || []).map(url => ({ name: url, url }))
97+
// 上传地址 + 请求头
98+
scheme.action = process.env.VUE_APP_BASE_API + "/admin-api/infra/file/upload"
99+
scheme.headers = { Authorization: "Bearer " + getAccessToken() }
100+
// 注意 on-success 不能绑定箭头函数!!!
101+
scheme['on-success'] = function (response, file, fileList) {
102+
if (response.code !== 0) {
103+
return;
104+
}
105+
// 添加到 data 中
106+
const prev = data[vModel] || []
107+
this.$set(data, vModel, [
108+
...prev,
109+
response.data
110+
])
111+
// 发起表单校验
112+
that.$refs[that.formConf.formRef].validateField(vModel)
113+
}
114+
// 注意 on-remove 不能绑定箭头函数!!!
115+
scheme['on-remove'] = function (file, fileList) {
116+
// 移除从 data 中
117+
const prev = data[vModel] || []
118+
const index = prev.indexOf(file.response.data)
119+
if (index === -1) {
120+
return
121+
}
122+
prev.splice(index, 1) // 直接移除即可,无需重复 set,因为 array 是引用
123+
// 发起表单校验
124+
that.$refs[that.formConf.formRef].validateField(vModel)
125+
}
126+
}
127+
86128
if (layout) {
87129
return layout.call(this, h, scheme)
88130
}

src/layout/components/TagsView/index.vue

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -152,44 +152,37 @@ export default {
152152
})
153153
},
154154
refreshSelectedTag(view) {
155-
this.$store.dispatch('tagsView/delCachedView', view).then(() => {
156-
const { fullPath } = view
157-
this.$nextTick(() => {
158-
this.$router.replace({
159-
path: '/redirect' + fullPath
160-
})
161-
})
162-
})
155+
this.$tab.refreshPage(view);
163156
},
164157
closeSelectedTag(view) {
165-
this.$store.dispatch('tagsView/delView', view).then(({ visitedViews }) => {
158+
this.$tab.closePage(view).then(({ visitedViews }) => {
166159
if (this.isActive(view)) {
167160
this.toLastView(visitedViews, view)
168161
}
169162
})
170163
},
171164
closeRightTags() {
172-
this.$store.dispatch('tagsView/delRightTags', this.selectedTag).then(visitedViews => {
165+
this.$tab.closeRightPage(this.selectedTag).then(visitedViews => {
173166
if (!visitedViews.find(i => i.fullPath === this.$route.fullPath)) {
174167
this.toLastView(visitedViews)
175168
}
176169
})
177170
},
178171
closeLeftTags() {
179-
this.$store.dispatch('tagsView/delLeftTags', this.selectedTag).then(visitedViews => {
172+
this.$tab.closeLeftPage(this.selectedTag).then(visitedViews => {
180173
if (!visitedViews.find(i => i.fullPath === this.$route.fullPath)) {
181174
this.toLastView(visitedViews)
182175
}
183176
})
184177
},
185178
closeOthersTags() {
186179
this.$router.push(this.selectedTag).catch(()=>{});
187-
this.$store.dispatch('tagsView/delOthersViews', this.selectedTag).then(() => {
180+
this.$tab.closeOtherPage(this.selectedTag).then(() => {
188181
this.moveToCurrentTag()
189182
})
190183
},
191184
closeAllTags(view) {
192-
this.$store.dispatch('tagsView/delAllViews').then(({ visitedViews }) => {
185+
this.$tab.closeAllPage().then(({ visitedViews }) => {
193186
if (this.affixTags.some(tag => tag.path === this.$route.path)) {
194187
return
195188
}

src/main.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ import "bpmn-js/dist/assets/bpmn-font/css/bpmn-embedded.css";
6969
import Tinymce from '@/components/tinymce/index.vue'
7070
Vue.component('tinymce', Tinymce)
7171
import '@/icons'
72-
import axios from 'axios'
73-
Vue.prototype.$axios = axios
72+
import request from "@/utils/request" // 实现 form generator 使用自己定义的 axios request 对象
73+
console.log(request)
74+
Vue.prototype.$axios = request
7475
import '@/styles/index.scss'
7576

7677
/**

src/store/modules/permission.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { constantRoutes } from '@/router'
22
import { getRouters } from '@/api/menu'
33
import Layout from '@/layout/index'
44
import ParentView from '@/components/ParentView';
5+
import { toCamelCase } from "@/utils";
56

67
const permission = {
78
state: {
@@ -56,6 +57,8 @@ function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) {
5657
icon: route.icon,
5758
noCache: !route.keepAlive,
5859
}
60+
// 路由地址转首字母大写驼峰,作为路由名称,适配keepAlive
61+
route.name = toCamelCase(route.path, true)
5962
route.hidden = !route.visible
6063
// 处理 component 属性
6164
if (route.children) { // 父节点

src/store/modules/tagsView.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const mutations = {
6363
}
6464
}
6565
},
66-
66+
6767
DEL_RIGHT_VIEWS: (state, view) => {
6868
const index = state.visitedViews.findIndex(v => v.path === view.path)
6969
if (index === -1) {
@@ -79,6 +79,23 @@ const mutations = {
7979
}
8080
return false
8181
})
82+
},
83+
84+
DEL_LEFT_VIEWS: (state, view) => {
85+
const index = state.visitedViews.findIndex(v => v.path === view.path)
86+
if (index === -1) {
87+
return
88+
}
89+
state.visitedViews = state.visitedViews.filter((item, idx) => {
90+
if (idx >= index || (item.meta && item.meta.affix)) {
91+
return true
92+
}
93+
const i = state.cachedViews.indexOf(item.name)
94+
if (i > -1) {
95+
state.cachedViews.splice(i, 1)
96+
}
97+
return false
98+
})
8299
}
83100
}
84101

@@ -172,7 +189,14 @@ const actions = {
172189
commit('DEL_RIGHT_VIEWS', view)
173190
resolve([...state.visitedViews])
174191
})
175-
}
192+
},
193+
194+
delLeftTags({ commit }, view) {
195+
return new Promise(resolve => {
196+
commit('DEL_LEFT_VIEWS', view)
197+
resolve([...state.visitedViews])
198+
})
199+
},
176200
}
177201

178202
export default {

src/utils/auth.js

Lines changed: 81 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,96 @@
1-
import Cookies from 'js-cookie'
1+
import {decrypt, encrypt} from "@/utils/jsencrypt";
22

33
const AccessTokenKey = 'ACCESS_TOKEN'
44
const RefreshTokenKey = 'REFRESH_TOKEN'
55

6+
// ========== Token 相关 ==========
7+
68
export function getAccessToken() {
7-
return Cookies.get(AccessTokenKey)
9+
return localStorage.getItem(AccessTokenKey)
810
}
911

1012
export function getRefreshToken() {
11-
return Cookies.get(RefreshTokenKey)
13+
return localStorage.getItem(RefreshTokenKey)
1214
}
1315

1416
export function setToken(token) {
15-
Cookies.set(AccessTokenKey, token.accessToken)
16-
Cookies.set(RefreshTokenKey, token.refreshToken)
17+
localStorage.setItem(AccessTokenKey, token.accessToken)
18+
localStorage.setItem(RefreshTokenKey, token.refreshToken)
1719
}
1820

1921
export function removeToken() {
20-
Cookies.remove(AccessTokenKey)
21-
Cookies.remove(RefreshTokenKey)
22+
localStorage.removeItem(AccessTokenKey)
23+
localStorage.removeItem(RefreshTokenKey)
24+
}
25+
26+
// ========== 账号相关 ==========
27+
28+
const UsernameKey = 'USERNAME'
29+
const PasswordKey = 'PASSWORD'
30+
const RememberMeKey = 'REMEMBER_ME'
31+
32+
export function getUsername() {
33+
return localStorage.getItem(UsernameKey)
34+
}
35+
36+
export function setUsername(username) {
37+
localStorage.setItem(UsernameKey, username)
38+
}
39+
40+
export function removeUsername() {
41+
localStorage.removeItem(UsernameKey)
42+
}
43+
44+
export function getPassword() {
45+
const password = localStorage.getItem(PasswordKey)
46+
return password ? decrypt(password) : undefined
47+
}
48+
49+
export function setPassword(password) {
50+
localStorage.setItem(PasswordKey, encrypt(password))
51+
}
52+
53+
export function removePassword() {
54+
localStorage.removeItem(PasswordKey)
55+
}
56+
57+
export function getRememberMe() {
58+
return localStorage.getItem(RememberMeKey) === 'true'
59+
}
60+
61+
export function setRememberMe(rememberMe) {
62+
localStorage.setItem(RememberMeKey, rememberMe)
63+
}
64+
65+
export function removeRememberMe() {
66+
localStorage.removeItem(RememberMeKey)
67+
}
68+
69+
// ========== 租户相关 ==========
70+
71+
const TenantIdKey = 'TENANT_ID'
72+
const TenantNameKey = 'TENANT_NAME'
73+
74+
export function getTenantName() {
75+
return localStorage.getItem(TenantNameKey)
76+
}
77+
78+
export function setTenantName(username) {
79+
localStorage.setItem(TenantNameKey, username)
80+
}
81+
82+
export function removeTenantName() {
83+
localStorage.removeItem(TenantNameKey)
84+
}
85+
86+
export function getTenantId() {
87+
return localStorage.getItem(TenantIdKey)
88+
}
89+
90+
export function setTenantId(username) {
91+
localStorage.setItem(TenantIdKey, username)
92+
}
93+
94+
export function removeTenantId() {
95+
localStorage.removeItem(TenantIdKey)
2296
}

src/utils/constants.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ export const SystemUserSocialTypeEnum = {
7575
title: "钉钉",
7676
type: 20,
7777
source: "dingtalk",
78-
img: "https://cdn.jsdelivr.net/gh/justauth/[email protected]/dingtalk.png",
78+
img: "https://s1.ax1x.com/2022/05/22/OzMDRs.png",
7979
},
8080
WECHAT_ENTERPRISE: {
8181
title: "企业微信",
8282
type: 30,
8383
source: "wechat_enterprise",
84-
img: "https://cdn.jsdelivr.net/gh/justauth/[email protected]/wechat_enterprise.png",
84+
img: "https://s1.ax1x.com/2022/05/22/OzMrzn.png",
8585
}
8686
}
8787

0 commit comments

Comments
 (0)