MCPcopy
hub / github.com/Bistutu/FluentRead / checkConfig

Function checkConfig

entrypoints/utils/check.ts:6–48  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4
5// Check configuration before translation
6export function checkConfig(): boolean {
7 // 1. Check if the plugin is enabled
8 if (!config.on) return false;
9
10 // 2. Check if the token is provided for services that require it
11 if (servicesType.isUseToken(config.service) && !config.token[config.service]) {
12 // DeepLX 的令牌是可选的,不需要强制检查
13 if (config.service === services.deeplx) {
14 } else {
15 sendErrorMessage("令牌尚未配置,请前往设置页配置");
16 return false;
17 }
18 }
19 // Special case for YiYan service (requires both AK and SK)
20 if (config.service === services.yiyan && (!config.ak || !config.sk)) {
21 sendErrorMessage("令牌尚未配置,请前往设置页配置");
22 return false;
23 }
24
25 // Special case for Tencent Cloud service (requires both SecretId and SecretKey)
26 if (config.service === services.tencent && (!config.tencentSecretId || !config.tencentSecretKey)) {
27 sendErrorMessage("腾讯云机器翻译密钥尚未配置,请前往设置页配置SecretId和SecretKey");
28 return false;
29 }
30
31 // 3. Check if a model is selected for AI services (except specific services like Coze)
32 if (servicesType.isAI(config.service) && ![services.cozecn, services.cozecom].includes(config.service)) {
33 const model = config.model[config.service];
34 const customModel = config.customModel[config.service];
35 if (!model || (model === customModelString && !customModel)) {
36 sendErrorMessage("模型尚未配置,请前往设置页配置");
37 return false;
38 }
39 }
40
41 // Some translation services require "bilingual mode" to be enabled
42 if (config.display === 0 && config.service === services.google) {
43 sendErrorMessage("「谷歌翻译」仅支持双语模式,请切换翻译服务");
44 return false;
45 }
46
47 return true;
48}
49
50// Check if the node needs to be translated
51export function skipNode(node: Node): boolean {

Callers 1

handleTranslationFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected