fix(web): 系统设置 CRUD 修复 — version 乐观锁 + 语言字段映射 + JSON 显示
Some checks failed
CI / rust-check (push) Has been cancelled
CI / rust-test (push) Has been cancelled
CI / frontend-build (push) Has been cancelled
CI / security-audit (push) Has been cancelled

- API 层所有 Info/Request 接口添加 version 字段,update 函数传递 version
- delete 函数改为 client.delete(url, { data: { version } }) 发送 JSON body
- LanguageInfo.enabled → is_active,匹配后端 LanguageResp 字段名
- LanguageManager 编辑弹窗简化为只读详情(后端仅支持 is_active 切换)
- SystemSettings 设置值显示改用 JSON.stringify 而非 String()
- SystemSettings updateSetting 发送解析后的 JSON 对象而非字符串
This commit is contained in:
iven
2026-04-26 01:28:13 +08:00
parent b4735213c5
commit 2539e5fc44
10 changed files with 79 additions and 101 deletions

View File

@@ -66,7 +66,7 @@ export default function DictionaryManager() {
const handleDictSubmit = async (values: CreateDictionaryRequest) => {
try {
if (editDict) {
await updateDictionary(editDict.id, values);
await updateDictionary(editDict.id, { ...values, version: editDict.version });
message.success('字典更新成功');
} else {
await createDictionary(values);
@@ -82,9 +82,9 @@ export default function DictionaryManager() {
}
};
const handleDeleteDict = async (id: string) => {
const handleDeleteDict = async (id: string, version: number) => {
try {
await deleteDictionary(id);
await deleteDictionary(id, version);
message.success('字典已删除');
fetchDictionaries();
} catch {
@@ -139,7 +139,7 @@ export default function DictionaryManager() {
if (!activeDictId) return;
try {
if (editItem) {
await updateDictionaryItem(activeDictId, editItem.id, values as UpdateDictionaryItemRequest);
await updateDictionaryItem(activeDictId, editItem.id, { ...values, version: editItem.version } as UpdateDictionaryItemRequest);
message.success('字典项更新成功');
} else {
await createDictionaryItem(activeDictId, values);
@@ -155,9 +155,9 @@ export default function DictionaryManager() {
}
};
const handleDeleteItem = async (dictId: string, itemId: string) => {
const handleDeleteItem = async (dictId: string, itemId: string, version: number) => {
try {
await deleteDictionaryItem(dictId, itemId);
await deleteDictionaryItem(dictId, itemId, version);
message.success('字典项已删除');
fetchDictionaries();
} catch {
@@ -196,7 +196,7 @@ export default function DictionaryManager() {
</Button>
<Popconfirm
title="确定删除此字典?"
onConfirm={() => handleDeleteDict(record.id)}
onConfirm={() => handleDeleteDict(record.id, record.version)}
>
<Button size="small" danger>
@@ -232,7 +232,7 @@ export default function DictionaryManager() {
</Button>
<Popconfirm
title="确定删除此字典项?"
onConfirm={() => handleDeleteItem(dictId, record.id)}
onConfirm={() => handleDeleteItem(dictId, record.id, record.version)}
>
<Button size="small" danger>