@zzclub/z-cli 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/package.json +1 -1
- package/src/command/set.js +4 -14
- package/src/command/translate.js +4 -0
- package/src/translate-api/index.js +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
## v0.5.2
|
|
5
|
+
|
|
6
|
+
[compare changes](https://github.com/aatrooox/z-cli/compare/v0.5.1...v0.5.2)
|
|
7
|
+
|
|
8
|
+
### 🩹 Fixes
|
|
9
|
+
|
|
10
|
+
- 翻译功能bug ([603625c](https://github.com/aatrooox/z-cli/commit/603625c))
|
|
11
|
+
|
|
12
|
+
### ❤️ Contributors
|
|
13
|
+
|
|
14
|
+
- Aatrox <gnakzz@qq.com>
|
|
15
|
+
|
|
16
|
+
## v0.5.1
|
|
17
|
+
|
|
18
|
+
[compare changes](https://github.com/aatrooox/z-cli/compare/v0.5.0...v0.5.1)
|
|
19
|
+
|
|
20
|
+
### 🩹 Fixes
|
|
21
|
+
|
|
22
|
+
- 修复config设置 ([94318e3](https://github.com/aatrooox/z-cli/commit/94318e3))
|
|
23
|
+
|
|
24
|
+
### ❤️ Contributors
|
|
25
|
+
|
|
26
|
+
- Aatrox <gnakzz@qq.com>
|
|
27
|
+
|
|
4
28
|
## v0.5.0
|
|
5
29
|
|
|
6
30
|
[compare changes](https://github.com/aatrooox/z-cli/compare/v0.4.5...v0.5.0)
|
package/package.json
CHANGED
package/src/command/set.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { writeFileContent, getLocalConfig } from "../utils/common.js";
|
|
1
|
+
import { writeFileContent, getLocalConfig, setLocalConfig } from "../utils/common.js";
|
|
2
2
|
import chalk from "chalk";
|
|
3
3
|
import ora from "ora";
|
|
4
4
|
import path from "node:path";
|
|
@@ -23,24 +23,14 @@ export const setCmd = {
|
|
|
23
23
|
if (payload.length === 2) {
|
|
24
24
|
let key = payload[0];
|
|
25
25
|
if (!["account.key", "account.appId"].includes(key)) {
|
|
26
|
-
set_spinner.warn(`设置appId: zz set translate appId <value>`);
|
|
27
|
-
set_spinner.warn(`设置key: zz set translate key <value>`);
|
|
26
|
+
set_spinner.warn(`设置appId: zz set translate account.appId <value>`);
|
|
27
|
+
set_spinner.warn(`设置key: zz set translate account.key <value>`);
|
|
28
28
|
process.exit(1);
|
|
29
29
|
}
|
|
30
30
|
let value = payload[1];
|
|
31
31
|
eval(`configItem.${key} = "${value}"`);
|
|
32
32
|
// configItem[key] = value
|
|
33
|
-
|
|
34
|
-
writeFileContent(
|
|
35
|
-
path.resolve(__dirname, "../config.json"),
|
|
36
|
-
configContent,
|
|
37
|
-
(spinner, isOk) => {
|
|
38
|
-
if (isOk) {
|
|
39
|
-
} else {
|
|
40
|
-
spinner.fail("配置失败");
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
);
|
|
33
|
+
setLocalConfig(config, set_spinner)
|
|
44
34
|
} else {
|
|
45
35
|
set_spinner.warn(`设置appId: zz set translate account.appId <value>`);
|
|
46
36
|
set_spinner.warn(`设置key: zz set translate account.key <value>`);
|
package/src/command/translate.js
CHANGED
|
@@ -172,6 +172,10 @@ function startTranslate(limitedWords, cb) {
|
|
|
172
172
|
let translate_result = res.trans_result
|
|
173
173
|
? res.trans_result[0].dst
|
|
174
174
|
: word.value;
|
|
175
|
+
if (res.error_code) {
|
|
176
|
+
const spinner = ora();
|
|
177
|
+
spinner.warn('翻译出错:' + JSON.stringify(res))
|
|
178
|
+
}
|
|
175
179
|
word.value = translate_result;
|
|
176
180
|
});
|
|
177
181
|
curIndex++;
|
|
@@ -4,13 +4,14 @@ import { readJsonFile } from "../utils/file.js";
|
|
|
4
4
|
import axios from "axios";
|
|
5
5
|
import { dirname } from "node:path"
|
|
6
6
|
import { fileURLToPath } from "node:url"
|
|
7
|
+
import { getLocalConfig } from "../utils/common.js";
|
|
7
8
|
|
|
8
9
|
const __filename = fileURLToPath(import.meta.url);
|
|
9
10
|
const __dirname = dirname(__filename);
|
|
10
11
|
let salt = new Date().getTime();
|
|
11
12
|
let appid, key;
|
|
12
13
|
async function genUser() {
|
|
13
|
-
let config = await
|
|
14
|
+
let config = await getLocalConfig();
|
|
14
15
|
let translateConfig = config.translate;
|
|
15
16
|
appid = translateConfig.account.appId; // appid
|
|
16
17
|
key = translateConfig.account.key; // 密钥
|