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