perf: 美化分享链接URL
This commit is contained in:
parent
023c2ece1a
commit
eb8f647c5e
@ -6,7 +6,7 @@
|
||||
|
||||
<script>
|
||||
const pcList = ['/', '/s']
|
||||
const mobileList = ['/_m', '/_m/', '/s_m', '/s_m/']
|
||||
const mobileList = ['/_m', '/_m/']
|
||||
export default {
|
||||
name: 'App',
|
||||
components: {},
|
||||
|
||||
@ -264,7 +264,7 @@ export default {
|
||||
showSharedPage(shareObject) {
|
||||
this.shareOptionConfig.shared = true
|
||||
this.shareOptionConfig.linkLabel = '分享链接'
|
||||
this.setShareLink(this.getShareLink(shareObject.shareId))
|
||||
this.setShareLink(this.getShareLink(shareObject.shareId, shareObject.shortId))
|
||||
this.shareOption.isPrivacy = shareObject.isPrivacy
|
||||
this.shareOption.operationPermissionList = shareObject.operationPermissionList || []
|
||||
if (shareObject.expireDate) {
|
||||
@ -339,8 +339,11 @@ export default {
|
||||
timeFormat(time) {
|
||||
return moment(time).format("yyyy-MM-DD HH:mm")
|
||||
},
|
||||
getShareLink(shareId) {
|
||||
return window.location.origin + '/s?s=' + shareId
|
||||
getShareLink(shareId, shortId) {
|
||||
if (!shortId) {
|
||||
shortId = shareId
|
||||
}
|
||||
return `${window.location.origin}/s/${shortId}`
|
||||
},
|
||||
createShare(update) {
|
||||
this.generateShareLinkLoading = true
|
||||
@ -368,8 +371,8 @@ export default {
|
||||
operationPermissionList: this.shareOption.operationPermissionList
|
||||
}).then(res => {
|
||||
if (res.data) {
|
||||
let {shareId, extractionCode, operationPermissionList} = res.data
|
||||
this.setShareLink(this.getShareLink(shareId))
|
||||
let {shareId, shortId, extractionCode, operationPermissionList} = res.data
|
||||
this.setShareLink(this.getShareLink(shareId, shortId))
|
||||
this.shareId = shareId
|
||||
this.generateShareLinkLoading = false
|
||||
this.shareOptionConfig.shared = true
|
||||
|
||||
@ -7,7 +7,7 @@ import getPageTitle from '@/utils/get-page-title'
|
||||
|
||||
NProgress.configure({ showSpinner: false }) // NProgress配置
|
||||
|
||||
const whiteList = ['/login','/s','/s/','/s_m','/s_m/'] // 白名单
|
||||
const whiteList = ['/login','/s','/s/'] // 白名单
|
||||
|
||||
router.beforeEach(async(to, from, next) => {
|
||||
// 开始进度条
|
||||
@ -51,7 +51,7 @@ router.beforeEach(async(to, from, next) => {
|
||||
}
|
||||
} else {
|
||||
// 没有登录的情况
|
||||
if (whiteList.indexOf(to.path) !== -1) {
|
||||
if (hasWhiteList(to.path)) {
|
||||
// 没有token但是在白名单中,直接进入
|
||||
next()
|
||||
} else {
|
||||
@ -65,6 +65,15 @@ router.beforeEach(async(to, from, next) => {
|
||||
}
|
||||
})
|
||||
|
||||
function hasWhiteList(path) {
|
||||
for (let i = 0; i < whiteList.length; i++) {
|
||||
if (path.indexOf(whiteList[i]) !== -1) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
function setMenuList(next, to){
|
||||
if(store.getters.menuList.length === 0){
|
||||
store.dispatch('user/setMenuList').then((res) => {
|
||||
|
||||
@ -47,12 +47,12 @@ export const constantRoutes = [
|
||||
hidden: true
|
||||
},
|
||||
{
|
||||
path: '/s',
|
||||
path: '/s/:id',
|
||||
component: Layout,
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
name: 's',
|
||||
name: 'share',
|
||||
component: () => import('@/views/public/share/shareList'),
|
||||
}
|
||||
]
|
||||
@ -85,17 +85,6 @@ export const dynamicRouters = [
|
||||
meta: { title: '文件传输' }
|
||||
}]
|
||||
},
|
||||
{
|
||||
path: '/s_m',
|
||||
component: Layout,
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
name: 's_m',
|
||||
component: () => import('@/views/public/share/shareList'),
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/tag',
|
||||
component: Layout,
|
||||
|
||||
@ -223,7 +223,7 @@
|
||||
</van-grid>
|
||||
</van-checkbox-group>
|
||||
</div>
|
||||
<div v-if="linkFailed && !showShareCode" class="share-header">
|
||||
<div v-if="linkFailed && !showShareCode" class="share-header-prompt">
|
||||
<p v-if="prompt !== ''">温馨提示:</p>
|
||||
<p>{{ prompt }}</p>
|
||||
</div>
|
||||
@ -401,7 +401,8 @@ export default {
|
||||
shareLink: '',
|
||||
shareFileName: '',
|
||||
generateShareLinkLoading: true,
|
||||
shareId: this.$route.query.s,
|
||||
shareId: '',
|
||||
shortId: this.$route.params.id,
|
||||
currentDirName: '',
|
||||
linkFailed: true,
|
||||
textPreviewVisible: false,
|
||||
@ -584,7 +585,7 @@ export default {
|
||||
if (index === 0) {
|
||||
this.pathList.splice(this.pathList.findIndex((v, i) => i === index + 1), this.pathList.length - (index + 1))
|
||||
this.getFileList(null, true);
|
||||
this.$router.push(`/s?s=${this.shareId}&vmode=${this.vmode}`)
|
||||
this.pushRouter()
|
||||
}
|
||||
if (item && item.fileId) {
|
||||
this.accessShareOpenDir(item.fileId)
|
||||
@ -598,8 +599,7 @@ export default {
|
||||
if (this.grid) {
|
||||
this.vmode = 'grid'
|
||||
}
|
||||
let f = ''
|
||||
this.$router.push(`/s?s=${this.shareId}&vmode=${this.vmode}`)
|
||||
this.pushRouter()
|
||||
},
|
||||
accessShareOpenDir(fileId) {
|
||||
this.tableLoading = true
|
||||
@ -627,7 +627,7 @@ export default {
|
||||
getFileList(pagination, overload) {
|
||||
this.tableLoading = true
|
||||
api.accessShare({
|
||||
share: this.shareId,
|
||||
share: this.shortId,
|
||||
pageIndex: this.pagination.pageIndex,
|
||||
pageSize: this.pagination.pageSize,
|
||||
showFolderSize: true
|
||||
@ -689,10 +689,11 @@ export default {
|
||||
})
|
||||
},
|
||||
getSharer() {
|
||||
api.getSharer({shareId: this.shareId}).then(res => {
|
||||
api.getSharer({shareId: this.shortId}).then(res => {
|
||||
this.sharer = res.data
|
||||
this.setLoginTitle()
|
||||
if (res.data) {
|
||||
this.shareId = res.data.shareId
|
||||
this.sharerAvatarUrl = window.location.origin + this.imageUrl + res.data.avatar
|
||||
if (this.sharer.netdiskName) {
|
||||
this.netdiskName = this.sharer.netdiskName
|
||||
@ -1046,6 +1047,9 @@ export default {
|
||||
clipboard.destroy()
|
||||
})
|
||||
},
|
||||
pushRouter() {
|
||||
this.$router.push(`/s/${this.shortId}/?vmode=${this.vmode}`)
|
||||
},
|
||||
// 点击文件或文件夹
|
||||
fileClick(row) {
|
||||
window.shareId = this.shareId
|
||||
@ -1057,7 +1061,7 @@ export default {
|
||||
item['index'] = this.pathList.length
|
||||
this.pathList.push(item)
|
||||
this.pagination.pageIndex = 1
|
||||
this.$router.push(`?s=${this.shareId}&vmode=${this.vmode}`)
|
||||
this.pushRouter()
|
||||
this.accessShareOpenDir(row.id)
|
||||
} else {
|
||||
if (row.contentType.startsWith('image')) {
|
||||
@ -1133,6 +1137,13 @@ export default {
|
||||
padding: 0 15px;
|
||||
}
|
||||
|
||||
.share-header-prompt {
|
||||
text-align: center;
|
||||
font-size: 18px;
|
||||
font-weight: 500;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.share-header {
|
||||
text-align: center;
|
||||
font-size: 18px;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user