fix(frontend): replace share delete confirm with in-app modal
This commit is contained in:
@@ -94,6 +94,14 @@ createApp({
|
||||
shares: [],
|
||||
directLinks: [],
|
||||
directLinksLoading: false,
|
||||
showDeleteConfirmModal: false,
|
||||
deleteConfirm: {
|
||||
type: '', // share | direct_link
|
||||
id: null,
|
||||
title: '',
|
||||
message: '',
|
||||
loading: false
|
||||
},
|
||||
showShareFileModal: false,
|
||||
creatingShare: false, // 创建分享中状态
|
||||
shareFileForm: {
|
||||
@@ -2965,9 +2973,29 @@ handleDragLeave(e) {
|
||||
}
|
||||
},
|
||||
|
||||
async deleteDirectLink(id) {
|
||||
if (!window.confirm('确定要删除这个直链吗?')) return;
|
||||
requestDeleteDirectLink(id, event = null) {
|
||||
if (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
const linkId = parseInt(id, 10);
|
||||
if (!Number.isFinite(linkId) || linkId <= 0) {
|
||||
this.showToast('warning', '提示', '无效的直链ID');
|
||||
return;
|
||||
}
|
||||
|
||||
this.deleteConfirm = {
|
||||
type: 'direct_link',
|
||||
id: linkId,
|
||||
title: '删除直链',
|
||||
message: '确定要删除这个直链吗?删除后将无法继续访问。',
|
||||
loading: false
|
||||
};
|
||||
this.showDeleteConfirmModal = true;
|
||||
},
|
||||
|
||||
async deleteDirectLink(id) {
|
||||
try {
|
||||
const response = await axios.delete(`${this.apiBase}/api/direct-link/${id}`);
|
||||
if (response.data?.success) {
|
||||
@@ -3000,9 +3028,29 @@ handleDragLeave(e) {
|
||||
}
|
||||
},
|
||||
|
||||
async deleteShare(id) {
|
||||
if (!window.confirm('确定要删除这个分享吗?')) return;
|
||||
requestDeleteShare(id, event = null) {
|
||||
if (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
const shareId = parseInt(id, 10);
|
||||
if (!Number.isFinite(shareId) || shareId <= 0) {
|
||||
this.showToast('warning', '提示', '无效的分享ID');
|
||||
return;
|
||||
}
|
||||
|
||||
this.deleteConfirm = {
|
||||
type: 'share',
|
||||
id: shareId,
|
||||
title: '删除分享',
|
||||
message: '确定要删除这个分享吗?删除后外链将立即失效。',
|
||||
loading: false
|
||||
};
|
||||
this.showDeleteConfirmModal = true;
|
||||
},
|
||||
|
||||
async deleteShare(id) {
|
||||
try {
|
||||
const response = await axios.delete(`${this.apiBase}/api/share/${id}`);
|
||||
|
||||
@@ -3016,6 +3064,40 @@ handleDragLeave(e) {
|
||||
}
|
||||
},
|
||||
|
||||
closeDeleteConfirmModal(force = false) {
|
||||
if (this.deleteConfirm.loading && !force) return;
|
||||
this.showDeleteConfirmModal = false;
|
||||
this.deleteConfirm = {
|
||||
type: '',
|
||||
id: null,
|
||||
title: '',
|
||||
message: '',
|
||||
loading: false
|
||||
};
|
||||
},
|
||||
|
||||
async confirmDeleteAction() {
|
||||
if (this.deleteConfirm.loading) return;
|
||||
const { type, id } = this.deleteConfirm;
|
||||
if (!type || !id) {
|
||||
this.closeDeleteConfirmModal(true);
|
||||
return;
|
||||
}
|
||||
|
||||
this.deleteConfirm.loading = true;
|
||||
try {
|
||||
if (type === 'share') {
|
||||
await this.deleteShare(id);
|
||||
} else if (type === 'direct_link') {
|
||||
await this.deleteDirectLink(id);
|
||||
}
|
||||
this.closeDeleteConfirmModal(true);
|
||||
} catch (error) {
|
||||
console.error('执行删除操作失败:', error);
|
||||
this.deleteConfirm.loading = false;
|
||||
}
|
||||
},
|
||||
|
||||
// 格式化到期时间显示
|
||||
formatExpireTime(expiresAt) {
|
||||
if (!expiresAt) return '永久有效';
|
||||
|
||||
Reference in New Issue
Block a user