fix(topics): 外键约束导致 delete 400
选题有关联 content_tasks/article/publish_record/metrics 表, 外键约束阻止删除。改为先级联删除关联数据再删选题。 前端同时显示服务端返回的具体错误信息,而不是笼统的 删除失败。
This commit is contained in:
@@ -547,12 +547,16 @@ const TopicsApp = {
|
||||
},
|
||||
async deleteTopic(id) {
|
||||
try {
|
||||
await this.$confirm('确定删除?', '提示', { type: 'warning' });
|
||||
await this.$confirm('确定删除选题 ' + id + '?将同时删除相关文章、发布记录等关联数据。', '提示', { type: 'warning' });
|
||||
await this.api('/api/topics/' + id, { method: 'DELETE' });
|
||||
this.$message.success('删除成功');
|
||||
await this.fetchTopics();
|
||||
await this.fetchTodayCount();
|
||||
} catch (e) { if (e !== 'cancel') this.$message.error('删除失败'); }
|
||||
} catch (e) {
|
||||
if (e === 'cancel') return;
|
||||
const msg = e?.response?.data?.detail || e?.message || '未知错误';
|
||||
this.$message.error('删除失败: ' + msg);
|
||||
}
|
||||
},
|
||||
switchPlatform(platform) {
|
||||
if (this.editing) this.cancelEdit();
|
||||
|
||||
Reference in New Issue
Block a user