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

View File

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