diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e5b516..a3773bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Release Notes +## 0.0.11(2024-06-26) + +- Profiles management: You can switch between profiles or add a new one. +- Guide special products to web debugging. +- Fixed some UI issues. +- Update User-Agent. + ## 0.0.10(2024-05-17) - SDK code documentation has been enhanced with the Code Sample link. diff --git a/media/package.json b/media/package.json index b5a12e0..6e5eee9 100644 --- a/media/package.json +++ b/media/package.json @@ -13,6 +13,7 @@ }, "dependencies": { "@alicloud/console-components": "^1.6.2", + "@ant-design/icons": "^5.3.7", "@monaco-editor/react": "^4.6.0", "@vercel/ncc": "^0.38.1", "@vscode-elements/elements": "^1.3.0", diff --git a/media/src/components/ProfileManager/ProfileManagerIndex.tsx b/media/src/components/ProfileManager/ProfileManagerIndex.tsx index cc51d2d..afd45ef 100644 --- a/media/src/components/ProfileManager/ProfileManagerIndex.tsx +++ b/media/src/components/ProfileManager/ProfileManagerIndex.tsx @@ -5,6 +5,8 @@ import { Button, Form, Input, Message } from "@alicloud/console-components"; import React from "react"; import { PontUIService } from "../../service/UIService"; +import { message } from "antd"; +import { LoadingOutlined } from "@ant-design/icons"; export class ProfileManagerIndexProps {} @@ -30,7 +32,10 @@ export const ProfileManagerIndex: React.FC = (props) = {status === "success" ? (
- 新增成功! +
+
+
新增成功!
+
) : ( -
- Profile 名称} required> - 用于区别不同的 profiles。 - - - Access Key} required> - - 获取方式请参见 - - 创建 RAM 用户的 AccessKey - - 。 - - - - Secret Key} required> - - 获取方式请参见 - + {status === "loading" ? ( +
+ +
写入中...
+
+ ) : null} + + Profile 名称
} required> + 用于区别不同的 profiles。 + +
+ Access Key} required> + + 获取方式请参见 + + 创建 RAM 用户的 AccessKey + + 。 + + + + Secret Key} required> + + 获取方式请参见 + + 创建 RAM 用户的 AccessKey + + 。 + + + + 默认 Region Id} required> + + 阿里云支持的 Region Id ,请参见 + + 地域和可用区 + + 。 + + + +
+ { + if (errors) { + return; + } else { + setStatus("loading"); + PontUIService.addNewAKProfile(submitValue).then((res) => { + if (res.success === true) { + setStatus("success"); + } else { + message.error("添加失败,请重试"); + setStatus("edit"); + } + }); + } + }} + className="text-right" > - 创建 RAM 用户的 AccessKey - - 。 - - - - 默认 Region Id} required> - - 阿里云支持的 Region Id ,请参见 - - 地域和可用区 - - 。 - - - -
- { - if (errors) { - return; - } else { - PontUIService.addNewAKProfile(submitValue).then((res) => { - if (res.success === true) { - setStatus("success"); - } - }); - } - }} - className="text-right" - > - 新增 - - 重置 -
- + 新增 +
+ 重置 +
+ + )} diff --git a/media/yarn.lock b/media/yarn.lock index adade6f..fc9bb22 100644 --- a/media/yarn.lock +++ b/media/yarn.lock @@ -92,6 +92,11 @@ resolved "https://registry.npmmirror.com/@ant-design/icons-svg/-/icons-svg-4.3.1.tgz#4b2f65a17d4d32b526baa6414aca2117382bf8da" integrity sha512-4QBZg8ccyC6LPIRii7A0bZUk3+lEDCLnhB+FVsflGdcWPPmV+j3fire4AwwoqHV/BibgvBmR9ZIo4s867smv+g== +"@ant-design/icons-svg@^4.4.0": + version "4.4.2" + resolved "https://registry.npmmirror.com/@ant-design/icons-svg/-/icons-svg-4.4.2.tgz#ed2be7fb4d82ac7e1d45a54a5b06d6cecf8be6f6" + integrity sha512-vHbT+zJEVzllwP+CM+ul7reTEfBR0vgxFe7+lREAsAA7YGsYpboiq2sQNeQeRvh09GfQgs/GyFEvZpJ9cLXpXA== + "@ant-design/icons@^5.2.6": version "5.2.6" resolved "https://registry.npmmirror.com/@ant-design/icons/-/icons-5.2.6.tgz#2d4a9a37f531eb2a20cebec01d6fb69cf593900d" @@ -103,6 +108,17 @@ classnames "^2.2.6" rc-util "^5.31.1" +"@ant-design/icons@^5.3.7": + version "5.3.7" + resolved "https://registry.npmmirror.com/@ant-design/icons/-/icons-5.3.7.tgz#d9f3654bf7934ee5faba43f91b5a187f5309ec68" + integrity sha512-bCPXTAg66f5bdccM4TT21SQBDO1Ek2gho9h3nO9DAKXJP4sq+5VBjrQMSxMVXSB3HyEz+cUbHQ5+6ogxCOpaew== + dependencies: + "@ant-design/colors" "^7.0.0" + "@ant-design/icons-svg" "^4.4.0" + "@babel/runtime" "^7.11.2" + classnames "^2.2.6" + rc-util "^5.31.1" + "@ant-design/react-slick@~1.0.2": version "1.0.2" resolved "https://registry.npmmirror.com/@ant-design/react-slick/-/react-slick-1.0.2.tgz#241bb412aeacf7ff5d50c61fa5db66773fde6b56" @@ -5644,6 +5660,7 @@ string-convert@^0.2.0: integrity sha512-u/1tdPl4yQnPBjnVrmdLo9gtuLvELKsAoRapekWggdiQNvvvum+jYF329d84NAa660KQw7pB2n36KrIKVoXa3A== "string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0: + name string-width-cjs version "4.2.3" resolved "https://registry.npmmirror.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== diff --git a/package.json b/package.json index 5559f8c..6a5ce88 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "displayName": "Alibaba Cloud API Toolkit", "description": "The Alibaba Cloud API Toolkit for VSCode makes it easier to access Alibaba Cloud services.", "author": "Alibaba Cloud SDK Team", - "version": "0.0.10", + "version": "0.0.11", "private": true, "publisher": "alibabacloud-openapi", "license": "Apache-2.0", diff --git a/src/Service.ts b/src/Service.ts index 239ae1c..fda6c4d 100644 --- a/src/Service.ts +++ b/src/Service.ts @@ -353,9 +353,9 @@ export class AlicloudAPIService { response, }; } else { - let result = await vscode.window.showErrorMessage("请完成AK/SK配置后,再发起调用", "查看配置方法", "取消"); - if (result === "查看配置方法") { - vscode.env.openExternal(vscode.Uri.parse("https://github.com/aliyun/aliyun-cli?tab=readme-ov-file#configure")); + let result = await vscode.window.showErrorMessage("请完成AK/SK配置后,再发起调用", "去配置", "取消"); + if (result === "去配置") { + this.openProfileManager(); } } } diff --git a/src/commands.ts b/src/commands.ts index 3c7eef1..a3e05b0 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -18,6 +18,7 @@ import * as fs from "fs-extra"; import { Product } from "./types"; import { codeSampleProvider } from "./plugins/generate"; import { generateImport } from "./common/generateImport"; +import { getProfileInfoInstance } from "./profileManager"; const path = require("path"); @@ -274,6 +275,8 @@ export class AlicloudApiCommands { }); vscode.commands.registerCommand("alicloud.api.restart", async () => { + const profileInfo = await getProfileInfoInstance(); + await profileInfo.refreshProfiles(); await vscode.window.withProgress( { location: vscode.ProgressLocation.Window, diff --git a/src/profileManager.ts b/src/profileManager.ts index 763e268..4b896b2 100644 --- a/src/profileManager.ts +++ b/src/profileManager.ts @@ -71,11 +71,31 @@ export class ProfileManager { await this.saveProfiles(config); } + async checkAliyunDir() { + const filePath = path.join(os.homedir(), ".aliyun"); + const { R_OK, W_OK } = fs.constants; + try { + // 检测写入权限 + await fsx.access(os.homedir(), R_OK | W_OK); + // 检查文件夹是否存在 + fs.stat(filePath, async (err) => { + if (err && err.code === "ENOENT") { + // 不存在,创建它 + await fs.promises.mkdir(filePath); + } + }); + } catch (ex) { + console.error("创建文件夹时出错:", ex); + } + } + async loadProfiles() { const configFilePath = path.join(os.homedir(), ".aliyun/config.json"); const { R_OK, W_OK } = fs.constants; try { + await this.checkAliyunDir(); await fsx.access(configFilePath, R_OK | W_OK); + // 检查 dirTest 文件夹是否存在 const content = await fsx.readFile(configFilePath, "utf-8"); return JSON.parse(content); } catch (ex) {