no message

This commit is contained in:
kuaifan 2024-10-14 16:58:40 +08:00
parent 1702aab538
commit e956a03098
3 changed files with 4 additions and 44 deletions

View File

@ -269,32 +269,12 @@ class Doo
/**
* 翻译
* @param $text
* @param string $type
* @return string
*/
public static function translate($text): string
public static function translate($text, string $type = ""): string
{
// 存在版本号 且 低于0.38.28时 使用原文
$version = Base::headerOrInput('version');
if ($version && !Base::judgeClientVersion('0.38.28', $version)) {
return $text;
}
if (is_string($text)) {
// 等于success、error、warning、info、(为空)时不处理
if (in_array($text, ['success', 'error', 'warning', 'info', ''])) {
return $text;
}
// 以__L(开头,)__结尾的不处理
if (str_starts_with($text, "__L(") && str_ends_with($text, ")__")) {
return $text;
}
$text = "__L(" . $text . ")__";
} elseif (is_array($text)) {
foreach ($text as $key => $val) {
$text[$key] = self::translate($val);
}
}
return $text;
return self::string(self::doo()->translate($text, $type));
}
/**

View File

@ -229,25 +229,6 @@ $A.bindScreenshotKey = (data) => {
$A.Electron.sendMessage('bindScreenshotKey', {key});
};
// 翻译
$A.apiTranslate = (data) => {
if ($A.isJson(data)) {
for (let key in data) {
if (!data.hasOwnProperty(key)) continue;
data[key] = $A.apiTranslate(data[key]);
}
} else if ($A.isArray(data)) {
data.forEach((val, index) => {
data[index] = $A.apiTranslate(val);
});
} else if (typeof data === 'string' && /__L\((.*?)\)__/.test(data)) {
data = data.replace(/__L\((.*?)\)__/g, (match, p1) => {
return $L(p1)
})
}
return data
}
Vue.prototype.$A = $A;
Vue.prototype.$L = $L;
Vue.prototype.$Electron = $A.Electron;

View File

@ -167,7 +167,6 @@ export default {
if (params.encrypt === true && result.encrypted) {
result = await dispatch("pgpDecryptApi", result.encrypted)
}
result = $A.apiTranslate(result)
const {ret, data, msg} = result
if (ret === -1) {
state.userId = 0
@ -3541,7 +3540,7 @@ export default {
if (result.type === "encrypt" && result.encrypted) {
result = await dispatch("pgpDecryptApi", result.encrypted)
}
const msgDetail = $A.apiTranslate($A.formatMsgBasic(result));
const msgDetail = $A.formatMsgBasic(result);
const {type, msgId} = msgDetail;
switch (type) {
case "open":