配置项修改

修复文件上传失败的问题
修复侧边栏菜单错误高亮的问题
master
toesbieya 6 years ago
parent 2e384fccdc
commit a775f6c5dc
  1. 9
      vue/src/api/file/index.js
  2. 9
      vue/src/component/UploadFile/index.vue
  3. 53
      vue/src/config/index.js
  4. 3
      vue/src/layout/component/TagsView/index.vue
  5. 8
      vue/src/layout/mixin/actionOnSelectMenu.js
  6. 10
      vue/src/layout/mixin/decideRouterTransition.js
  7. 4
      vue/src/mixin/docDetailMixin.js
  8. 4
      vue/src/router/index.js
  9. 4
      vue/src/store/module/resource.js
  10. 3
      vue/src/store/module/tagsView.js
  11. 30
      vue/src/util/file.js
  12. 2
      vue/src/util/index.js
  13. 8
      vue/src/util/storage.js
  14. 4
      vue/src/view/userCenter/indexPage.vue

@ -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)}}))

@ -56,11 +56,12 @@
* successremove事件中的file.url均不带七牛云外链前缀 * successremove事件中的file.url均不带七牛云外链前缀
* */ * */
import axios from 'axios' 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 {debounce, isEmpty} from '@/util'
import {elError} from "@/util/message" import {elError} from "@/util/message"
import {isImage, isDoc, isPdf, isPpt, isRar, isXls, isTxt, isZip} from "@/util/validate" 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 = [ const typeMapper = [
{test: isImage}, {test: isDoc, type: 'doc'}, {test: isPdf, type: 'pdf'}, {test: isPpt, type: 'ppt'}, {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) this.$refs.upload.handleRemove(file)
const index = this.data.findIndex(i => i.downloadUrl === file.downloadUrl) const index = this.data.findIndex(i => i.downloadUrl === file.downloadUrl)

@ -14,12 +14,6 @@ module.exports = {
//全局axios的baseUrl、devServer的路由前缀 //全局axios的baseUrl、devServer的路由前缀
apiPrefix: '/api', apiPrefix: '/api',
//路由模式,['hash','history']
routerMode: 'history',
//是否使用由后端返回的数据作为路由
useBackendRoute: false,
//是否在开发时使用mock,为true时不会启动websocket和代理 //是否在开发时使用mock,为true时不会启动websocket和代理
useMock: false, useMock: false,
@ -32,23 +26,36 @@ module.exports = {
//是否使用错误日志捕捉,暂时没啥用 //是否使用错误日志捕捉,暂时没啥用
errorLog: true, errorLog: true,
//storage的相关键名 //路由配置
sessionUserKey: 'GCC-SESS-USER', route: {
localResourceKey: 'GCC-LOCAL-PERM', //路由模式,['hash','history']
localPersonalSettingsKey: 'GCC-LOCAL-PERSONAL-SETTINGS', mode: 'history',
//路由切换时的过渡动画名称,关联transition.css //是否使用由后端返回的数据作为路由
rightSideRouteTransition: 'left-out', useBackendDataAsRoute: false,
leftSideRouteTransition: 'right-out',
//路由过渡动画设置,关联transition.css
//七牛云上传地址 animate: {
attachmentUploadUrl: 'https://upload.qiniup.com', //当未启用多页签时的路由动画
default: 'el-fade-in-linear',
//附件上传后的存储地址前缀 //要访问的tab顺序高于上一个访问的tab时的路由动画
attachmentPrefix: 'https://static.toesbieya.cn/', next: 'left-out',
//要访问的tab顺序不高于上一个访问的tab时的路由动画
//文件预览接口前缀 prev: 'right-out',
filePreviewPrefix: isDev ? 'http://localhost:8012' : 'https://preview.toesbieya.cn', }
},
//文件配置
file: {
//上传地址
uploadUrl:'https://upload.qiniup.com',
//上传后的存储地址前缀
storePrefix: 'https://static.toesbieya.cn/',
//预览地址前缀
previewPrefix: isDev ? 'http://localhost:8012' : 'https://preview.toesbieya.cn',
},
//省市地区json数据请求地址 //省市地区json数据请求地址
regionDataUrl: `${contextPath}static/json/region-pca.json` regionDataUrl: `${contextPath}static/json/region-pca.json`

@ -30,6 +30,7 @@
<script type="text/jsx"> <script type="text/jsx">
import shortcutMixin from '@/layout/mixin/shortcut' import shortcutMixin from '@/layout/mixin/shortcut'
import decideRouterTransitionMixin from '@/layout/mixin/decideRouterTransition' import decideRouterTransitionMixin from '@/layout/mixin/decideRouterTransition'
import {route as routeConfig} from '@/config'
import ContextMenu from "@/component/ContextMenu" import ContextMenu from "@/component/ContextMenu"
import ContextMenuItem from "@/component/ContextMenu/item" import ContextMenuItem from "@/component/ContextMenu/item"
import ScrollPane from './ScrollPane' import ScrollPane from './ScrollPane'
@ -170,7 +171,7 @@ export default {
beforeDestroy() { beforeDestroy() {
//fade //fade
this.$store.commit('tagsView/transitionName', 'el-fade-in-linear') this.$store.commit('tagsView/transitionName', routeConfig.animate.default)
}, },
mounted() { mounted() {

@ -5,7 +5,13 @@ export default {
actionOnSelectMenu(fullPath, refreshWhenSame = true) { actionOnSelectMenu(fullPath, refreshWhenSame = true) {
//外部链接时打开新窗口 //外部链接时打开新窗口
if (isExternal(fullPath)) { if (isExternal(fullPath)) {
return window.open(fullPath) window.open(fullPath)
//当是从侧边栏打开时,重置高亮菜单
const menu = this.$refs.menu
if (menu && menu.updateActiveIndex) {
menu.updateActiveIndex(this.activeMenu)
}
return
} }
//触发的菜单路径是当前路由时,根据参数判断是否进行刷新 //触发的菜单路径是当前路由时,根据参数判断是否进行刷新

@ -1,14 +1,18 @@
import {leftSideRouteTransition as left, rightSideRouteTransition as right} from '@/config' import {route as routeConfig} from '@/config'
const {animate} = routeConfig
export default { export default {
methods: { methods: {
//根据访问的tab页的左右顺序来确定路由动画 //根据访问的tab页的左右顺序来确定路由动画
decideRouteTransition(to, from) { decideRouteTransition(to, from) {
let transitionName = right let transitionName = animate.prev
const fromIndex = this.visitedViews.findIndex(i => i.path === from.path) const fromIndex = this.visitedViews.findIndex(i => i.path === from.path)
const toIndex = this.visitedViews.findIndex(i => i.path === to.path) const toIndex = this.visitedViews.findIndex(i => i.path === to.path)
if (fromIndex < toIndex) transitionName = left
//新开tab也认为顺序高于上一个tab
if (toIndex === -1 || fromIndex < toIndex) transitionName = animate.next
this.$store.commit('tagsView/transitionName', transitionName) this.$store.commit('tagsView/transitionName', transitionName)
}, },

@ -9,7 +9,7 @@ import FormCard from '@/component/AbstractForm/FormCard'
import UploadFile from '@/component/UploadFile' import UploadFile from '@/component/UploadFile'
import {isEmpty, mergeObj} from '@/util' import {isEmpty, mergeObj} from '@/util'
import {auth} from "@/util/auth" import {auth} from "@/util/auth"
import {deleteUpload} from "@/util/file" import {deleteUpload} from "@/api/file"
import {elAlert, elConfirm, elPrompt, elSuccess} from "@/util/message" import {elAlert, elConfirm, elPrompt, elSuccess} from "@/util/message"
import {closeCurrentPage} from "@/util/route" import {closeCurrentPage} from "@/util/route"
@ -245,7 +245,7 @@ export default {
deleteArr.push(...this.form.uploadImageList.map(i => i.url)) deleteArr.push(...this.form.uploadImageList.map(i => i.url))
} }
if (deleteArr.length > 0) { if (deleteArr.length > 0) {
deleteUpload(deleteArr).catch(e => ({})) deleteUpload.request(deleteArr).catch(e => ({}))
} }
return closeCurrentPage(this.getTablePageUrl()) return closeCurrentPage(this.getTablePageUrl())

@ -15,7 +15,7 @@ import Vue from 'vue'
import Router from 'vue-router' import Router from 'vue-router'
import {pathToRegexp} from 'path-to-regexp' import {pathToRegexp} from 'path-to-regexp'
import NProgress from 'nprogress' import NProgress from 'nprogress'
import {contextPath, routerMode, title} from '@/config' import {contextPath, route as routeConfig, title} from '@/config'
import defaultRoutes from '@/router/define' import defaultRoutes from '@/router/define'
import store from "@/store" import store from "@/store"
import {stringifyRoutes, parseRoutes, generateRoutes} from './util' import {stringifyRoutes, parseRoutes, generateRoutes} from './util'
@ -31,7 +31,7 @@ const whiteList = transformWhiteList(['/login', '/register', '/404', '/403'])
const router = new Router({ const router = new Router({
base: contextPath, base: contextPath,
mode: routerMode, mode: routeConfig.mode,
scrollBehavior: () => ({y: 0}), scrollBehavior: () => ({y: 0}),
routes: defaultRoutes routes: defaultRoutes
}) })

@ -1,5 +1,5 @@
import path from 'path' import path from 'path'
import {useBackendRoute} from '@/config' import {route as routeConfig} from '@/config'
import {addDynamicRoutes} from '@/router' import {addDynamicRoutes} from '@/router'
import {getDynamicRoutes} from '@/router/define' import {getDynamicRoutes} from '@/router/define'
import {parseRoutes, metaExtend} from "@/router/util" import {parseRoutes, metaExtend} from "@/router/util"
@ -85,7 +85,7 @@ const actions = {
//将后台返回的数据转换为合法的route数组 //将后台返回的数据转换为合法的route数组
function transformOriginRouteData(data) { function transformOriginRouteData(data) {
if (!Array.isArray(data)) return [] if (!Array.isArray(data)) return []
if (!useBackendRoute) return getDynamicRoutes() if (!routeConfig.useBackendDataAsRoute) return getDynamicRoutes()
data = JSON.parse(JSON.stringify(data)) data = JSON.parse(JSON.stringify(data))
data = data.filter(i => { data = data.filter(i => {
if (i.type === 3 || !i.enable) { if (i.type === 3 || !i.enable) {

@ -1,3 +1,4 @@
import {route as routeConfig} from '@/config'
import {createMutations} from "@/util" import {createMutations} from "@/util"
const state = { const state = {
@ -8,7 +9,7 @@ const state = {
cachedViews: [], cachedViews: [],
//路由过渡动画名称 //路由过渡动画名称
transitionName: 'el-fade-in-linear' transitionName: routeConfig.animate.default
} }
const mutations = { const mutations = {

@ -1,5 +1,6 @@
import request from "@/api/request" import request from "@/api/request"
import {attachmentUploadUrl, attachmentPrefix, filePreviewPrefix} from '@/config' import {getToken} from "@/api/file"
import {file as fileConfig} from '@/config'
import {isEmpty, timeFormat} from "@/util" import {isEmpty, timeFormat} from "@/util"
import {isTxt} from "@/util/validate" import {isTxt} from "@/util/validate"
@ -18,21 +19,16 @@ export function preview(url) {
if (isTxt(url)) return window.open(url) if (isTxt(url)) return window.open(url)
const connectChar = url.includes('?') ? '&' : '?' const connectChar = url.includes('?') ? '&' : '?'
url = url + connectChar + 'fullfilename=' + url.replace(attachmentPrefix, '') url = url + connectChar + 'fullfilename=' + url.replace(fileConfig.storePrefix, '')
const anchor = document.createElement('a') const anchor = document.createElement('a')
anchor.style.opacity = '0' anchor.style.opacity = '0'
anchor.href = `${filePreviewPrefix}/onlinePreview?url=${encodeURIComponent(url)}` anchor.href = `${fileConfig.previewPrefix}/onlinePreview?url=${encodeURIComponent(url)}`
anchor.target = '_blank' anchor.target = '_blank'
document.body.appendChild(anchor) document.body.appendChild(anchor)
anchor.click() anchor.click()
document.body.removeChild(anchor) document.body.removeChild(anchor)
} }
//获取七牛云直传需要的token
export function getToken() {
return request.get('/file/getToken').then(({data}) => data.data)
}
//下载文件 //下载文件
export function download(url, name) { export function download(url, name) {
const href = typeof url === 'object' ? window.URL.createObjectURL(url) : url const href = typeof url === 'object' ? window.URL.createObjectURL(url) : url
@ -48,29 +44,25 @@ export function download(url, name) {
if (typeof url === 'object') window.URL.revokeObjectURL(url) if (typeof url === 'object') window.URL.revokeObjectURL(url)
} }
//删除已上传的文件
export function deleteUpload(url) {
return request.get('/file/delete?url=' + encodeURIComponent(url))
}
//七牛云直传 //七牛云直传
export function upload(blob, filename, options = {}) { export function upload(blob, filename, options = {}) {
return getToken() return getToken
.request()
.then(token => { .then(token => {
if (!options.generateKey) options.generateKey = defaultOptions.generateKey if (!options.generateKey) {
options.generateKey = defaultOptions.generateKey
}
const param = new FormData() const param = new FormData()
param.append('token', token) param.append('token', token)
param.append('key', options.generateKey(filename)) param.append('key', options.generateKey(filename))
param.append('file', blob, filename) param.append('file', blob, filename)
return request.post(attachmentUploadUrl, param, {...defaultOptions, ...options}) return request.post(fileConfig.uploadUrl, param, {...defaultOptions, ...options})
}) })
.then(({data}) => data)
} }
//自动补全附件链接前缀 //自动补全附件链接前缀
export function autoCompleteUrl(url) { export function autoCompleteUrl(url) {
if (isEmpty(url)) return '' if (isEmpty(url)) return ''
if (['http', 'https'].some(i => url.startsWith(i))) return url if (['http', 'https'].some(i => url.startsWith(i))) return url
return attachmentPrefix + url return fileConfig.storePrefix + url
} }

@ -1,5 +1,3 @@
import {timePass} from "@/filter"
export function isEmpty(...str) { export function isEmpty(...str) {
return str.some(i => i === undefined || i === null || i === '') return str.some(i => i === undefined || i === null || i === '')
} }

@ -1,7 +1,9 @@
import {sessionUserKey, localPersonalSettingsKey, localResourceKey} from '@/config'
import {isEmpty} from "@/util" import {isEmpty} from "@/util"
import {unzip, zip} from "@/util/secret" import {unzip, zip} from "@/util/secret"
const sessionUserKey = 'GCC-SESS-USER'
const localPersonalSettingsKey = 'GCC-LOCAL-PERSONAL-SETTINGS'
export function isUserExist() { export function isUserExist() {
return !isEmpty(sessionStorage.getItem(sessionUserKey)) return !isEmpty(sessionStorage.getItem(sessionUserKey))
} }
@ -49,10 +51,6 @@ function removeUser() {
sessionStorage.removeItem(sessionUserKey) sessionStorage.removeItem(sessionUserKey)
} }
function removeLocalResource() {
localStorage.removeItem(localResourceKey)
}
function removeLocalPersonalSettings() { function removeLocalPersonalSettings() {
localStorage.removeItem(localPersonalSettingsKey) localStorage.removeItem(localPersonalSettingsKey)
} }

@ -17,9 +17,7 @@
</el-tab-pane> </el-tab-pane>
<transition mode="out-in" name="el-fade-in-linear"> <transition mode="out-in" name="el-fade-in-linear">
<keep-alive exclude="user-account"> <component :is="activeTab"/>
<component :is="activeTab"/>
</keep-alive>
</transition> </transition>
</el-tabs> </el-tabs>
</el-card> </el-card>

Loading…
Cancel
Save