feat: 优化链接获取逻辑

This commit is contained in:
kuaifan 2025-11-06 14:53:16 +00:00
parent 80d1e6469e
commit 4c2425c758
2 changed files with 29 additions and 8 deletions

View File

@ -482,6 +482,8 @@ export default {
linkGet(refresh) {
this.linkLoad++;
const {id, name} = this.linkData;
const previousGuestAccess = this.linkData.guest_access;
this.$store.dispatch("call", {
url: 'file/link',
data: {
@ -490,10 +492,17 @@ export default {
guest_access: this.linkData.guest_access ? 'yes' : 'no'
},
}).then(({data}) => {
this.linkData = Object.assign(data, {
id: this.linkData.id,
name: this.linkData.name,
guest_access: Boolean(data.guest_access || this.linkData.guest_access) //
const guestAccess = data.guest_access !== undefined
? Boolean(data.guest_access)
: previousGuestAccess;
this.linkData = Object.assign({}, data, {
id,
name,
guest_access: guestAccess //
});
this.$store.dispatch("saveFile", {
id,
guest_access: guestAccess ? 1 : 0
});
//
if (refresh === true) {

View File

@ -1753,6 +1753,8 @@ export default {
linkGet(refresh) {
this.linkLoad++;
const {id, name} = this.linkData;
const previousGuestAccess = this.linkData.guest_access;
this.$store.dispatch("call", {
url: 'file/link',
data: {
@ -1761,11 +1763,21 @@ export default {
guest_access: this.linkData.guest_access ? 'yes' : 'no'
},
}).then(({data}) => {
this.linkData = Object.assign(data, {
id: this.linkData.id,
name: this.linkData.name,
guest_access: Boolean(data.guest_access || this.linkData.guest_access) //
const guestAccess = data.guest_access !== undefined
? Boolean(data.guest_access)
: previousGuestAccess;
this.linkData = Object.assign({}, data, {
id,
name,
guest_access: guestAccess //
});
this.$store.dispatch("saveFile", {
id,
guest_access: guestAccess ? 1 : 0
});
if (this.fileInfo && this.fileInfo.id === id) {
this.$set(this.fileInfo, 'guest_access', guestAccess ? 1 : 0);
}
//
if (refresh === true) {
//