From a775f6c5dca18326a311d535fa779b318171dd1a Mon Sep 17 00:00:00 2001 From: toesbieya <1647775459@qq.com> Date: Thu, 27 Aug 2020 13:32:42 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E9=A1=B9=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=20=E4=BF=AE=E5=A4=8D=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E4=BE=A7=E8=BE=B9=E6=A0=8F=E8=8F=9C=E5=8D=95=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E9=AB=98=E4=BA=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vue/src/api/file/index.js | 9 ++++ vue/src/component/UploadFile/index.vue | 9 ++-- vue/src/config/index.js | 53 +++++++++++-------- vue/src/layout/component/TagsView/index.vue | 3 +- vue/src/layout/mixin/actionOnSelectMenu.js | 8 ++- .../layout/mixin/decideRouterTransition.js | 10 ++-- vue/src/mixin/docDetailMixin.js | 4 +- vue/src/router/index.js | 4 +- vue/src/store/module/resource.js | 4 +- vue/src/store/module/tagsView.js | 3 +- vue/src/util/file.js | 30 ++++------- vue/src/util/index.js | 2 - vue/src/util/storage.js | 8 ++- vue/src/view/userCenter/indexPage.vue | 4 +- 14 files changed, 83 insertions(+), 68 deletions(-) create mode 100644 vue/src/api/file/index.js diff --git a/vue/src/api/file/index.js b/vue/src/api/file/index.js new file mode 100644 index 0000000..0d46d26 --- /dev/null +++ b/vue/src/api/file/index.js @@ -0,0 +1,9 @@ +import {GetApi} from "@/api/request" + +export const getToken = new GetApi( + '/file/getToken', + null, + promise => promise.then(({data}) => data) +) + +export const deleteUpload = new GetApi('/file/delete', url => ({params: {url: encodeURIComponent(url)}})) diff --git a/vue/src/component/UploadFile/index.vue b/vue/src/component/UploadFile/index.vue index 452a5b7..36b6209 100644 --- a/vue/src/component/UploadFile/index.vue +++ b/vue/src/component/UploadFile/index.vue @@ -56,11 +56,12 @@ * success、remove事件中的file.url均不带七牛云外链前缀 * */ import axios from 'axios' -import {attachmentPrefix} from '@/config' +import {deleteUpload} from '@/api/file' +import {file as fileConfig} from '@/config' import {debounce, isEmpty} from '@/util' import {elError} from "@/util/message" import {isImage, isDoc, isPdf, isPpt, isRar, isXls, isTxt, isZip} from "@/util/validate" -import {preview, deleteUpload, download, upload, autoCompleteUrl} from "@/util/file" +import {preview, download, upload, autoCompleteUrl} from "@/util/file" const typeMapper = [ {test: isImage}, {test: isDoc, type: 'doc'}, {test: isPdf, type: 'pdf'}, {test: isPpt, type: 'ppt'}, @@ -159,9 +160,9 @@ export default { //区分是否为本次新上传,以及是否上传成功 //若不是新上传的 - if (!file.raw) this.$emit('remove', {url: file.downloadUrl.replace(attachmentPrefix, '')}) + if (!file.raw) this.$emit('remove', {url: file.downloadUrl.replace(fileConfig.storePrefix, '')}) //判断是否上传成功(有可能是正在上传) - else if (file.response && !file.response.err) deleteUpload(file.raw.key) + else if (file.response && !file.response.err) deleteUpload.request(file.raw.key) this.$refs.upload.handleRemove(file) const index = this.data.findIndex(i => i.downloadUrl === file.downloadUrl) diff --git a/vue/src/config/index.js b/vue/src/config/index.js index d228f6a..acb3cd4 100644 --- a/vue/src/config/index.js +++ b/vue/src/config/index.js @@ -14,12 +14,6 @@ module.exports = { //全局axios的baseUrl、devServer的路由前缀 apiPrefix: '/api', - //路由模式,['hash','history'] - routerMode: 'history', - - //是否使用由后端返回的数据作为路由 - useBackendRoute: false, - //是否在开发时使用mock,为true时不会启动websocket和代理 useMock: false, @@ -32,23 +26,36 @@ module.exports = { //是否使用错误日志捕捉,暂时没啥用 errorLog: true, - //storage的相关键名 - sessionUserKey: 'GCC-SESS-USER', - localResourceKey: 'GCC-LOCAL-PERM', - localPersonalSettingsKey: 'GCC-LOCAL-PERSONAL-SETTINGS', - - //路由切换时的过渡动画名称,关联transition.css - rightSideRouteTransition: 'left-out', - leftSideRouteTransition: 'right-out', - - //七牛云上传地址 - attachmentUploadUrl: 'https://upload.qiniup.com', - - //附件上传后的存储地址前缀 - attachmentPrefix: 'https://static.toesbieya.cn/', - - //文件预览接口前缀 - filePreviewPrefix: isDev ? 'http://localhost:8012' : 'https://preview.toesbieya.cn', + //路由配置 + route: { + //路由模式,['hash','history'] + mode: 'history', + + //是否使用由后端返回的数据作为路由 + useBackendDataAsRoute: false, + + //路由过渡动画设置,关联transition.css + animate: { + //当未启用多页签时的路由动画 + default: 'el-fade-in-linear', + //要访问的tab顺序高于上一个访问的tab时的路由动画 + next: 'left-out', + //要访问的tab顺序不高于上一个访问的tab时的路由动画 + prev: 'right-out', + } + }, + + //文件配置 + file: { + //上传地址 + uploadUrl:'https://upload.qiniup.com', + + //上传后的存储地址前缀 + storePrefix: 'https://static.toesbieya.cn/', + + //预览地址前缀 + previewPrefix: isDev ? 'http://localhost:8012' : 'https://preview.toesbieya.cn', + }, //省市地区json数据请求地址 regionDataUrl: `${contextPath}static/json/region-pca.json` diff --git a/vue/src/layout/component/TagsView/index.vue b/vue/src/layout/component/TagsView/index.vue index d3d3b2e..1dd6449 100644 --- a/vue/src/layout/component/TagsView/index.vue +++ b/vue/src/layout/component/TagsView/index.vue @@ -30,6 +30,7 @@