mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-06-07 23:19:35 +08:00
✨ feat(security): 完成配置密文存储前后端闭环
- 补齐连接与代理密文字段的保留替换清空语义 - 接通保存复制删除导入接口并返回 secretless 视图 - 刷新 Wails 绑定并补充实现留痕文档
This commit is contained in:
63
frontend/src/utils/connectionSecretDraft.ts
Normal file
63
frontend/src/utils/connectionSecretDraft.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
export interface ConnectionSecretDraftInput {
|
||||
valueInput?: string;
|
||||
hasSecret?: boolean;
|
||||
clearSecret?: boolean;
|
||||
forceClear?: boolean;
|
||||
trimInput?: boolean;
|
||||
}
|
||||
|
||||
export interface ConnectionSecretDraftResult {
|
||||
value: string;
|
||||
clearStoredSecret: boolean;
|
||||
keepsStoredSecret: boolean;
|
||||
hasSecretAfterSave: boolean;
|
||||
}
|
||||
|
||||
export function resolveConnectionSecretDraft(input: ConnectionSecretDraftInput): ConnectionSecretDraftResult {
|
||||
const rawValue = input.valueInput ?? '';
|
||||
const value = input.trimInput ? String(rawValue).trim() : String(rawValue);
|
||||
|
||||
if (input.forceClear) {
|
||||
return {
|
||||
value: '',
|
||||
clearStoredSecret: true,
|
||||
keepsStoredSecret: false,
|
||||
hasSecretAfterSave: false,
|
||||
};
|
||||
}
|
||||
|
||||
if (value !== '') {
|
||||
return {
|
||||
value,
|
||||
clearStoredSecret: false,
|
||||
keepsStoredSecret: false,
|
||||
hasSecretAfterSave: true,
|
||||
};
|
||||
}
|
||||
|
||||
if (input.clearSecret) {
|
||||
return {
|
||||
value: '',
|
||||
clearStoredSecret: true,
|
||||
keepsStoredSecret: false,
|
||||
hasSecretAfterSave: false,
|
||||
};
|
||||
}
|
||||
|
||||
if (input.hasSecret) {
|
||||
return {
|
||||
value: '',
|
||||
clearStoredSecret: false,
|
||||
keepsStoredSecret: true,
|
||||
hasSecretAfterSave: true,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
value: '',
|
||||
clearStoredSecret: false,
|
||||
keepsStoredSecret: false,
|
||||
hasSecretAfterSave: false,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user