Skip to content

Commit

Permalink
fix(version): 更新软件包版本至 1.0.4
Browse files Browse the repository at this point in the history
- 在 README-zh.md 和 README.md 中将当前版本从 1.0.3 修改为 1.0.4
- 在 package.json 中更新版本号至 1.0.4
- 优化了 getDefaultApiKey 函数,增加了对响应数据的校验
  • Loading branch information
h7ml committed Dec 10, 2024
1 parent 10727aa commit 4969cf0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ npx ai-markdown-translator -i input.md -o output.md -l "Italian"

## 版本信息

- **当前版本**:1.0.3
- **当前版本**:1.0.4
- **NPM 包**[ai-markdown-translator](https://www.npmjs.com/package/ai-markdown-translator)

## CI 信息
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ npx ai-markdown-translator -i input.md -o output.md -l "Italian"

## Version Information

- **Current Version**: 1.0.3
- **Current Version**: 1.0.4
- **NPM Package**: [ai-markdown-translator](https://www.npmjs.com/package/ai-markdown-translator)

## CI Information
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ai-markdown-translator",
"version": "1.0.3",
"version": "1.0.4",
"description": "CLI tool to translate Markdown files using OpenAI's language models while preserving the original formatting.",
"main": "dist/index.js",
"type": "module",
Expand Down
21 changes: 7 additions & 14 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,24 @@ function writeMarkdownFile(filePath: string, content: string): void {

async function getDefaultApiKey(): Promise<string> {
try {
const response = await axios.get('https://dash-api.302.ai/bot/v1/302aitool11-prompter', {
const response = await axios({
method: 'get',
url: 'https://dash-api.302.ai/bot/v1/302aitool11-prompter',
headers: {
accept:
'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
accept: 'application/json',
'accept-language': 'zh-CN,zh;q=0.9',
'cache-control': 'no-cache',
pragma: 'no-cache',
priority: 'u=0, i',
'sec-ch-ua': '"Google Chrome";v="131", "Chromium";v="131", "Not_A Brand";v="24"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-fetch-dest': 'document',
'sec-fetch-mode': 'navigate',
'sec-fetch-site': 'none',
'sec-fetch-user': '?1',
'upgrade-insecure-requests': '1',
},
});

if (response.status === 200) {
if (response.status === 200 && response.data) {
const data = response.data;
if (data.code === 0) {
if (data.code === 0 && data.data && data.data.api_key) {
return data.data.api_key;
}
}
console.error('获取默认API Key失败: 接口返回数据格式错误');
return '';
} catch (error) {
console.error('获取默认API Key失败:', error);
Expand Down

0 comments on commit 4969cf0

Please sign in to comment.