From 094ae8aeec7b9cc3096d0872bdb8a637aa1464f2 Mon Sep 17 00:00:00 2001 From: jmal Date: Tue, 12 Jan 2021 18:01:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9D=83=E9=99=90=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/file-api.js | 8 +++++ src/components/ShowFile/ShowFile.vue | 12 ++++++- .../SimpleUploader/globalUploader.vue | 9 ++++++ src/components/preview/SimTextPreview.vue | 5 +-- src/components/select/tree.vue | 3 +- src/components/table/TableList.vue | 20 ++++++++++-- src/permission.js | 11 +++++-- src/store/modules/user.js | 4 ++- src/styles/setting.scss | 6 +++- src/utils/file-config.js | 12 +++++-- src/views/setting/articles/articleManager.vue | 5 +-- src/views/setting/articles/blogManager.vue | 2 +- src/views/setting/cloudManager.vue | 4 +++ src/views/setting/sys/menuManager.vue | 25 ++++++++++++++- src/views/setting/sys/roleManager.vue | 32 ++++++++++++------- 15 files changed, 125 insertions(+), 33 deletions(-) diff --git a/src/api/file-api.js b/src/api/file-api.js index 43a92a5..ee99827 100644 --- a/src/api/file-api.js +++ b/src/api/file-api.js @@ -247,4 +247,12 @@ export default { params }) }, + // 是否允许下载 + isAllowDownload: function(params) { + return request({ + url: '/isAllowDownload', + method: 'get', + params + }) + }, } diff --git a/src/components/ShowFile/ShowFile.vue b/src/components/ShowFile/ShowFile.vue index f5b3fc8..d53ab91 100644 --- a/src/components/ShowFile/ShowFile.vue +++ b/src/components/ShowFile/ShowFile.vue @@ -1622,6 +1622,8 @@ export default { this.getFileList() } } + }).catch(() => { + this.newFolderLoading = false }) } else { this.newFolderLoading = false @@ -2221,6 +2223,9 @@ export default { } }).then(() => { this.$refs.fileListTable.clearSelection() + }).catch(() => { + this.renameLoading = false + this.editingIndex = -1 }) }, // 更多操作(多选) @@ -2652,17 +2657,20 @@ export default { row = this.$refs.fileListTable.tableSelectData[0] } } - this.shareDialog = true this.shareFileName = row.name api.generate({ userId: row.userId, fileId: row.id, isFolder: row.isFolder }).then(res => { + this.shareDialog = true if (res.data) { this.shareLink = window.location.origin + '/s?s=' + res.data this.generateShareLinkLoading = false } + }).catch(() => { + this.shareDialog = false + this.generateShareLinkLoading = false }) }, // 复制分享链接 @@ -2733,6 +2741,8 @@ export default { // 移除列表 this.removeSelectItme() } + }).catch(()=>{ + this.rowContextData.isFavorite = !isFavorite }) }, // 删除 diff --git a/src/components/SimpleUploader/globalUploader.vue b/src/components/SimpleUploader/globalUploader.vue index 29e1784..01ad14a 100755 --- a/src/components/SimpleUploader/globalUploader.vue +++ b/src/components/SimpleUploader/globalUploader.vue @@ -319,6 +319,15 @@ }, onFileSuccess(rootFile, file, response) { const res = JSON.parse(response) + if(!res.data){ + this.$message({ + message: res.message, + type: 'error' + }) + this.uploader.cancel() + this.close() + return; + } const data = res.data // 服务器自定义的错误(即虽返回200,但是是错误的情况),这种错误是Uploader无法拦截的 if (!data.upload) { diff --git a/src/components/preview/SimTextPreview.vue b/src/components/preview/SimTextPreview.vue index c097993..881a6c0 100644 --- a/src/components/preview/SimTextPreview.vue +++ b/src/components/preview/SimTextPreview.vue @@ -36,7 +36,6 @@ class="simtext-dialog" v-dialogDrag="{ dialogWidthPercent: dialogWidthPercent}">
-
保存所有 @@ -681,7 +680,9 @@ that.modifyMsg = undefined },1000) } - }) + }).catch(() => { + this.updating = false + }) }, // 全屏 fullScreen() { diff --git a/src/components/select/tree.vue b/src/components/select/tree.vue index be2f715..0f49417 100644 --- a/src/components/select/tree.vue +++ b/src/components/select/tree.vue @@ -100,7 +100,6 @@ export default { handleNodeClick(node){ this.valueTitle = node[this.props.label] this.valueId = node[this.props.value] - this.$emit('getValue',this.valueId) this.defaultExpandedKey = [] this.$refs.treeSelect.blur() this.$emit('input', this.valueId) @@ -111,7 +110,7 @@ export default { this.valueId = null this.defaultExpandedKey = [] this.clearSelected() - this.$emit('getValue',null) + this.$emit('input', '') }, /* 清空选中样式 */ clearSelected(){ diff --git a/src/components/table/TableList.vue b/src/components/table/TableList.vue index 634b559..c7d46dd 100644 --- a/src/components/table/TableList.vue +++ b/src/components/table/TableList.vue @@ -3,6 +3,7 @@
diff --git a/src/permission.js b/src/permission.js index 078b9f5..b923acf 100644 --- a/src/permission.js +++ b/src/permission.js @@ -64,7 +64,7 @@ function setMenuList(next, to){ store.dispatch('user/setMenuList').then((res) => { const to = window.location.pathname if(findPath(res.data, to)){ - next({path: to}) + next(window.location.pathname + window.location.search) } else { next({path: store.getters.menuList[0].path}) } @@ -82,10 +82,15 @@ function setMenuList(next, to){ * @returns {boolean} */ function findPath(menuList, to, parentPath){ - for( let i = 0; i < menuList.length - 1; i++) { + for( let i = 0; i < menuList.length; i++) { const menu = menuList[i] + if(menu.menuType > 0){ + continue + } if(menu.children && menu.children.length > 0){ - return findPath(menu.children, to, menu.path) + if(findPath(menu.children, to, menu.path)){ + return true + } } if(parentPath){ menu.path = parentPath + '/' + menu.path diff --git a/src/store/modules/user.js b/src/store/modules/user.js index d013e8e..57d41b3 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -49,7 +49,7 @@ const actions = { return new Promise( (resolve,reject) => { menuApi.menuTree({userId: state.userId}).then((res) => { state.menuList = getMenuTree(res.data); - commit('SET_MENU_LIST',state.menuList); + commit('SET_MENU_LIST', state.menuList); resetRouter(state.menuList) router.options.routes = router.options.routes.concat(state.menuList); resolve(res) @@ -134,6 +134,7 @@ const actions = { } function getMenuTree(menuList) { + menuList = menuList.filter(menu => menu.menuType === 0) return menuList.map(menu => { let router = {} if(menu.children && menu.children.length){ @@ -158,6 +159,7 @@ function getMenuTree(menuList) { function findChildren(childrenMenu){ let children = [] + childrenMenu = childrenMenu.filter(menu => menu.menuType === 0) childrenMenu.forEach(menu => { let router = { path: menu.path, diff --git a/src/styles/setting.scss b/src/styles/setting.scss index 2a393ae..badfb73 100644 --- a/src/styles/setting.scss +++ b/src/styles/setting.scss @@ -1,3 +1,4 @@ +@import "src/styles/index"; a { color: #1890ff; text-decoration: none; @@ -16,7 +17,7 @@ a:hover { } /deep/.box-card { margin: 0 auto; - max-width: 1140px; + max-width: 1240px; min-width: 640px; .clearfix { font-size: 16px; @@ -30,6 +31,9 @@ a:hover { } } } +/deep/.el-card__body { + padding: 15px; +} .table-search-header{ /deep/.el-card__header { padding: 18px 20px 0; diff --git a/src/utils/file-config.js b/src/utils/file-config.js index 1ba0caf..75512d9 100644 --- a/src/utils/file-config.js +++ b/src/utils/file-config.js @@ -1,3 +1,5 @@ +import fileApi from '@/api/file-api' + export default { baseUrl: '/api', @@ -20,15 +22,19 @@ export default { window.open(url, '_blank') }, download: function(username, file) { - let url = `${this.baseUrl}/file/${username}${file.path}${file.name}?o=download` - window.open(url, '_self') + fileApi.isAllowDownload().then(() => { + let url = `${this.baseUrl}/file/${username}${file.path}${file.name}?o=download` + window.open(url, '_self') + }) }, publicDownload: function(shareId, file) { let url = `${this.baseUrl}/public/s/download/${file.id}/${shareId}` window.open(url, '_self') }, packageDownload: function(fileIds, token) { - window.open(`${this.baseUrl}/packageDownload?fileIds=${fileIds}&jmal-token=${token}`, '_self') + fileApi.isAllowDownload().then(() => { + window.open(`${this.baseUrl}/packageDownload?fileIds=${fileIds}&jmal-token=${token}`, '_self') + }) }, publicPackageDownload: function(shareId, fileIds) { window.open(`${this.baseUrl}/public/s/packageDownload?shareId=${shareId}&fileIds=${fileIds}`, '_self') diff --git a/src/views/setting/articles/articleManager.vue b/src/views/setting/articles/articleManager.vue index 9c93640..527ef81 100644 --- a/src/views/setting/articles/articleManager.vue +++ b/src/views/setting/articles/articleManager.vue @@ -439,11 +439,8 @@ export default { .wailian { margin-left: 8px; } -/deep/.el-card__body { - min-width: 1080px; -} /deep/ .el-dialog__body { - padding: 0 20px; + padding: 0 15px; } /deep/ .el-table-alone-page { tbody .el-table__row:hover { diff --git a/src/views/setting/articles/blogManager.vue b/src/views/setting/articles/blogManager.vue index e8d38a1..ed41946 100644 --- a/src/views/setting/articles/blogManager.vue +++ b/src/views/setting/articles/blogManager.vue @@ -149,7 +149,7 @@ export default { updateSetting(this.form).then((res)=> { this.$message.success("保存成功!") }).catch(()=> { - this.$message.error("保存失败!") + }) } } diff --git a/src/views/setting/cloudManager.vue b/src/views/setting/cloudManager.vue index d1c6c7f..79bad1a 100644 --- a/src/views/setting/cloudManager.vue +++ b/src/views/setting/cloudManager.vue @@ -55,11 +55,15 @@ export default { this.syncLoading = true settingApi.sync({username: this.$store.state.user.name}).then(() => { this.syncLoading = false + }).catch(() => { + this.syncLoading = false }) }, webpChange(webpEnabled) { settingApi.disabledWebp({userId: this.$store.state.user.userId, disabled: !webpEnabled}).then(() => { webpEnabled ? this.$message.success('webp 以启用') : this.$message.warning('webp 以禁用') + }).catch(() => { + this.webpEnabled = !this.webpEnabled }) } } diff --git a/src/views/setting/sys/menuManager.vue b/src/views/setting/sys/menuManager.vue index d294c9c..85cf95a 100644 --- a/src/views/setting/sys/menuManager.vue +++ b/src/views/setting/sys/menuManager.vue @@ -29,7 +29,19 @@ - + + + + @@ -78,6 +90,7 @@ { + this.authorityList = res.data + }) + }, getMenuTree(){ this.loading = true menuApi.menuTree({ @@ -353,4 +373,7 @@ export default { /deep/ .el-select { width: 100%; } +/deep/.box-card { + max-width: 1440px; +} diff --git a/src/views/setting/sys/roleManager.vue b/src/views/setting/sys/roleManager.vue index 1c8a556..93aacbc 100644 --- a/src/views/setting/sys/roleManager.vue +++ b/src/views/setting/sys/roleManager.vue @@ -18,15 +18,19 @@
- - + + + +
data.id === roleId) const role = this.dataList[findIndex] - this.form.id = role.id - this.menuCheckedList = role.menuIds + this.form = role + if(this.$refs.authTree){ + this.$refs.authTree.setCheckedKeys(role.menuIds) + } else { + this.menuCheckedList = role.menuIds + } }, handleEdit(id) { this.editMove = 2 @@ -322,7 +331,6 @@ export default { }, onError() { this.updateLoading = false - this.dialogAuthVisible = false } } }