Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions others/translate/translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,16 +282,19 @@ const TranslateApp = {
TranslateAPI.setService(currentService);
}

// 保存到本地存储(移除敏感字段,避免明文持久化)
const safeApiConfig = JSON.parse(JSON.stringify(apiConfig));
if (safeApiConfig.baidu) {
delete safeApiConfig.baidu.secretKey;
}
if (safeApiConfig.youdao) {
delete safeApiConfig.youdao.secretKey;
// 保存到本地存储(仅持久化非敏感字段,避免明文持久化密钥)
const safeApiConfig = {
service: currentService
};
if (baiduAppId) {
safeApiConfig.baidu = {
appId: baiduAppId
};
}
if (safeApiConfig.google) {
delete safeApiConfig.google.apiKey;
if (youdaoAppId) {
safeApiConfig.youdao = {
appId: youdaoAppId
};
}
localStorage.setItem('translateApiConfig', JSON.stringify(safeApiConfig));

Expand Down