From 832eae61a470b86e0bc13cad1f06f3bccee47213 Mon Sep 17 00:00:00 2001 From: yini-chen Date: Fri, 10 May 2024 14:13:48 +0800 Subject: [PATCH 1/4] fix: the reminder for repeat subscriptions --- src/explorer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/explorer.ts b/src/explorer.ts index c944abe..cb5ead1 100644 --- a/src/explorer.ts +++ b/src/explorer.ts @@ -348,7 +348,7 @@ export class AlicloudApiExplorer implements vscode.TreeDataProvider Date: Wed, 15 May 2024 15:12:56 +0800 Subject: [PATCH 2/4] fix:UI --- media/src/components/APIPage/API.tsx | 4 ++-- media/src/components/main.tsx | 2 +- media/src/mocks/routerMeta.ts | 2 +- media/src/pages/_app.tsx | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/media/src/components/APIPage/API.tsx b/media/src/components/APIPage/API.tsx index 82f9edf..e3644cf 100644 --- a/media/src/components/APIPage/API.tsx +++ b/media/src/components/APIPage/API.tsx @@ -141,7 +141,7 @@ export const API: React.FC = (props) => { const renderContent = React.useMemo(() => { const documentComp = (
- {selectedApi?.description ? ( + {selectedApi?.description && selectedApi?.description !== selectedApi?.summary ? (
@@ -262,7 +262,7 @@ export const API: React.FC = (props) => {
{selectedApi?.summary ? ( -
+
{selectedApi?.summary}
) : null} diff --git a/media/src/components/main.tsx b/media/src/components/main.tsx index 3024e70..69b382c 100644 --- a/media/src/components/main.tsx +++ b/media/src/components/main.tsx @@ -37,7 +37,7 @@ export const App: React.FC = (props) => { const [appMeta, setAppMeta] = React.useState(props.routerMeta); const { pageType, schemaType, specName, modName, name, spec: metaSpec, remoteSpec } = appMeta || {}; - const {product:popcode,version} = getSpecInfoFromName(specName || ""); + const { product: popcode, version } = getSpecInfoFromName(specName || ""); const [itemMeta, setItemMeta] = React.useState(metaSpec); const [defs, setDefs] = React.useState({}); diff --git a/media/src/mocks/routerMeta.ts b/media/src/mocks/routerMeta.ts index fc0d26e..4f256b3 100644 --- a/media/src/mocks/routerMeta.ts +++ b/media/src/mocks/routerMeta.ts @@ -3,7 +3,7 @@ export const routerMeta = { modName: "", spec: { consumes: ["application/xml"], - deprecated: true, + deprecated: false, description: '## 接口说明\n\n\n\n- **准备工作**:\n - 通过实名认证。更多信息,请参见[账号实名认证相关文档](~~48263~~)。 \n - 成本估算:了解云服务器ECS的计费方式。更多信息,请参见[计费概述](~~25398~~)。\n - 产品选型:调用[DescribeInstanceTypes](~~25620~~)查看目标实例规格的性能数据,或者参见[选型配置](~~58291~~)了解如何选择实例规格。\n - 查询库存:调用[DescribeAvailableResource](~~66186~~)查看指定地域或者可用区内的资源供给情况。\n - 网络规划:您需要确保您已经有可用的安全组。更多信息,请参见[CreateSecurityGroup](~~25553~~)。创建专有网络VPC类型实例前,您需要预先在相应的阿里云地域[创建VPC](~~65430~~)。\n\n\n\n\n\n\n- **准备工作**:\n - 成本估算:了解云服务器ECS的计费方式。更多信息,请参见[计费概述](~~25398~~)。\n - 产品选型:调用[DescribeInstanceTypes](~~25620~~)查看目标实例规格的性能数据,或者参见[选型配置](~~58291~~)了解如何选择实例规格。\n - 查询库存:调用[DescribeAvailableResource](~~66186~~)查看指定地域或者可用区内的资源供给情况。\n - 网络规划:您需要确保您已经有可用的安全组。更多信息,请参见[CreateSecurityGroup](~~25553~~)。创建专有网络VPC类型实例前,您需要预先在相应的阿里云地域[创建VPC](~~65430~~)。\n\n\n\n- **与CreateInstance对比差异**:\n\n 和CreateInstance接口相比,RunInstances接口有以下优点:\n \n - 单次最多可以创建100台实例,避免重复多次调用CreateInstance。\n - 实例创建之后,实例会自动变成`Starting`状态,然后变成`Running`状态,不需要再调用[StartInstance](~~25500~~)启动实例。\n - 创建实例时可以指定`InternetMaxBandwidthOut`为ECS实例分配公网IP,不需要您再调用[AllocatePublicIpAddress](~~25544~~)分配公网IP。\n - 您可以指定`AutoReleaseTime`参数来设定自动释放时间,不需要再调用[ModifyInstanceAutoReleaseTime](~~47576~~)设置自动释放时间。\n - 您可以指定`LaunchTemplateId`和`LaunchTemplateVersion`使用启动模板,可以免除您每次创建实例时都需要填入大量配置参数。\n - 可以指定`UniqueSuffix`参数批量设置有序的实例名称或主机名称,方便管理与检索。\n - 使用RunInstances创建实例时支持设置Enclave机密计算模式和可信系统模式。\n - 可以指定 `NetworkOptions.EnableJumboFrame`参数为true在创建时开启Jumbo frame特性。 更多信息,请参见 [ECS实例MTU](~~200512~~)。\n\n- **注意事项**:\n\n - 单次最多能创建100台实例。\n - 您可以指定参数`AutoReleaseTime`设置实例自动释放时间。\n - 创建成功后会返回实例ID列表,您可以通过[DescribeInstances](~~25506~~)查询新建实例状态。\n - 创建实例时,默认自动启动实例,直到实例状态变成运行中(`Running`)。\n - 自2020年11月27日起,创建和变配ECS实例时带宽峰值受账户限速策略影响。如需更大带宽峰值,请提交工单。具体限速策略:单个地域下,所有按使用流量计费ECS实例的实际运行带宽峰值总和不大于5 Gbit/s;所有按固定带宽计费ECS实例的实际运行带宽峰值总和不大于50 Gbit/s。\n - 与[CreateInstance](~~25499~~)相比,通过`RunInstances`创建的实例如果参数`InternetMaxBandwidthOut`的值大于0,则自动为实例分配公网IP。\n - RunInstances支持以下任一方式绑定主网卡,但需要注意一次调用只能选用一种方式配置主网卡,同时使用两种方式将会调用失败并返回错误信息。\n - 通过`SecurityGroupId`、`VSwitchId`、`PrivateIpAddress`、`NetworkInterfaceQueueNumber`与`Ipv6AddressCount`等参数直接设置主网卡的相关配置信息。\n - 通过`NetworkInterface.N.*`设置主网卡以及辅助网卡的配置信息。当`NetworkInterface.N.InstanceType`取值为`Primary`时,表示设置主网卡;当`NetworkInterface.N.InstanceType`取值为`Secondary`或空值时,表示设置辅助网卡。\n - 提交创建任务后,参数不合法或者库存不足的情况下会报错,具体的报错原因参见错误码。\n\n - 如果创建实例时返回`QuotaExceed.ElasticQuota`错误,表示您在当前地域选择的实例规格所要创建的台数超出系统限额,或者全实例规格vCPU配额超出系统限额,您可以前往[ECS管理控制台](https://ecs.console.aliyun.com/?spm=a2c8b.12215451.favorites.decs.5e3a336aMGTtzy#/privileges/quota)或[配额中心](https://quotas.console.aliyun.com/products/ecs/quotas)申请提高限额。\n \n - 如果创建实例时返回`QuotaExceed.DiskCapacity`错误,表示您当前选择的磁盘类型所要创建的总容量超出指定可用区的系统限额,您可以前往[配额中心](https://quotas.console.aliyun.com/products/disk/quotas)查询和申请提高磁盘容量配额。\n\n\n\n\n- **最佳实践**:\n\n - 单次大批量创建ECS实例(大于100台)遇到库存不足的场景;对实例规格或可用区等资源配置无指定要求,更关注如何快速创建实例的场景;对ECS实例数量无指定要求,更关注总算力vCPU个数等场景下,阿里云推荐您使用弹性供应组。您可以通过[CreateAutoProvisioningGroup](~~122738~~)创建弹性供应组,一键式地部署跨计费方式、跨可用区、跨实例规格族的实例集群。更多信息,请参见[使用弹性供应组API批量创建ECS实例](~~200772~~)。\n\n - `RunInstances`可以执行批量创建任务,为便于管理与检索,建议您为每批次启动的实例指定标签(`Tag.N.Key`和`Tag.N.Value`),并且为主机名(`HostName`)和实例名称(`InstanceName`)添加有序后缀(`UniqueSuffix`)。\n\n - 实例启动模板能免除您每次创建实例时都需要填入大量配置参数,您可以创建实例启动模板([CreateLaunchTemplate](~~74686~~))后,在`RunInstances`请求中指定`LaunchTemplateId`和`LaunchTemplateVersion`使用启动模板。\n\n\n\n\n\n- **最佳实践**:\n\n - 单次大批量创建ECS实例(大于100台)遇到库存不足的场景;对实例规格或可用区等资源配置无指定要求,更关注如何快速创建实例的场景;对ECS实例数量无指定要求,更关注总算力vCPU个数等场景下,阿里云推荐您使用弹性供应组。您可以通过[CreateAutoProvisioningGroup](~~122738~~)创建弹性供应组,一键式地部署跨计费方式、跨可用区、跨实例规格族的实例集群。更多信息,请参见[使用弹性供应组API批量创建ECS实例](~~200772~~)。\n\n - `RunInstances`可以执行批量创建任务,为便于管理与检索,建议您为每批次启动的实例指定标签(`Tag.N.Key`和`Tag.N.Value`),并且为主机名(`HostName`)和实例名称(`InstanceName`)添加有序后缀(`UniqueSuffix`)。\n\n - 实例启动模板能免除您每次创建实例时都需要填入大量配置参数,您可以创建实例启动模板([CreateLaunchTemplate](~~74686~~))后,在`RunInstances`请求中指定`LaunchTemplateId`和`LaunchTemplateVersion`使用启动模板。\n\n\n\n### 示例1:创建包年包月实例\n\n实例所在地域为华东1(杭州),计费方式为包年包月,购买时长一个月,到期自动续费一个月,镜像ID为:aliyun_3_x64_20G_alibase_20221102.vhd,实例规格为:ecs.g7.large,40 GiB ESSD云盘,挂载100 GiB ESSD云数据盘,公网出带宽为10 Mbit/s,自动分配私网IP和公网IP,实例名称为ECS-test,登录密码为ECS@test1234,数量为1台。\n\n```\nhttp(s)://ecs.aliyuncs.com/?Action=RunInstances\n&RegionId=cn-hangzhou\n&ImageId=aliyun_3_x64_20G_alibase_20221102.vhd\n&InstanceType=ecs.g7.large\n&SecurityGroupId=sg-bp150uqocpf9jj70****\n&VSwitchId=vsw-bp1qo7s91cbch5i4l****\n&InstanceChargeType=PrePaid\n&SystemDisk.Size=40\n&DataDisk.1.Size=100\n&DataDisk.1.Category=cloud_essd\n&SystemDisk.Category=cloud_essd\n&Amount=1\n&Period=1\n&PeriodUnit=Month\n&AutoRenew=true\n&AutoRenewPeriod=1\n&HostName=ECS-test\n&Password=ECS@test1234\n&InternetMaxBandwidthOut=10\n&公共请求参数\n```\n\n### 示例2:创建按量付费实例\n\n实例所在地域为华东1(杭州),计费方式为按量付费,镜像ID为:aliyun_3_x64_20G_alibase_20221102.vhd,实例规格为:ecs.g7.large,40 GiB ESSD云盘,挂载100 GiB ESSD云数据盘,公网出带宽为10 Mbit/s,自动分配私网IP和公网IP,实例名称为ECS-test,登录密码为ECS@test1234,数量为1台。\n\n```\nhttp(s)://ecs.aliyuncs.com/?Action=RunInstances\n&RegionId=cn-hangzhou\n&ImageId=aliyun_3_x64_20G_alibase_20221102.vhd\n&InstanceType=ecs.g7.large\n&SecurityGroupId=sg-bp150uqocpf9jj70****\n&VSwitchId=vsw-bp1qo7s91cbch5i4l****\n&InstanceChargeType=PostPaid\n&SystemDisk.Size=40\n&DataDisk.1.Size=100\n&DataDisk.1.Category=cloud_essd\n&SystemDisk.Category=cloud_essd\n&HostName=ECS-test\n&Password=ECS@test1234\n&InternetMaxBandwidthOut=10\n&公共请求参数\n```\n\n### 示例3:创建抢占式实例\n\n实例所在地域为华东1(杭州),计费方式为抢占式实例,竞价策略为系统自动出价,跟随当前市场实际价格,实例保留时长为1小时,镜像ID为:aliyun_3_x64_20G_alibase_20221102.vhd,实例规格为:ecs.g7.large,40 GiB ESSD云盘,挂载100 GiB ESSD云数据盘,公网出带宽为10 Mbit/s,自动分配私网IP和公网IP,实例名称为ECS-test,登录密码为ECS@test1234,数量为1台。\n\n```\nhttp(s)://ecs.aliyuncs.com/?Action=RunInstances\n&RegionId=cn-hangzhou\n&ImageId=aliyun_3_x64_20G_alibase_20221102.vhd\n&InstanceType=ecs.g7.large\n&SecurityGroupId=sg-bp150uqocpf9jj70****\n&VSwitchId=vsw-bp1qo7s91cbch5i4l****\n&InstanceChargeType=PostPaid\n&SystemDisk.Size=40\n&DataDisk.1.Size=100\n&DataDisk.1.Category=cloud_essd\n&SystemDisk.Category=cloud_essd\n&HostName=ECS-test\n&Password=ECS@test1234\n&InternetMaxBandwidthOut=10\n&SpotStrategy=SpotAsPriceGo\n&SpotDuration=1\n&公共请求参数\n```\n\n### 示例4:在专有宿主机上创建包年包月实例\n\n实例所在地域为华东1(杭州),专有宿主机为dh-bp12w10wll9xcjq2****,计费方式包年包月,购买时长一个月,镜像ID为:aliyun_3_x64_20G_alibase_20221102.vhd,实例规格为:ecs.g7.large,40 GiB ESSD云盘,挂载100 GiB ESSD云数据盘,公网出带宽为10 Mbit/s,自动分配私网IP和公网IP,实例名称为ECS-test,登录密码为ECS@test1234,购买数量为1台。\n\n```\nhttp(s)://ecs.aliyuncs.com/?Action=RunInstances\n&RegionId=cn-hangzhou\n&ImageId=aliyun_3_x64_20G_alibase_20221102.vhd\n&InstanceType=ecs.g7.large\n&SecurityGroupId=sg-bp150uqocpf9jj70****\n&VSwitchId=vsw-bp1qo7s91cbch5i4l****\n&InstanceChargeType=PrePaid\n&Amount=1\n&Period=1\n&PeriodUnit=Month\n&SystemDisk.Size=40\n&DataDisk.1.Size=100\n&DataDisk.1.Category=cloud_essd\n&SystemDisk.Category=cloud_essd\n&HostName=ECS-test\n&Password=ECS@test1234\n&InternetMaxBandwidthOut=10\n&DedicatedHostId=dh-bp12w10wll9xcjq2****\n&公共请求参数\n```', ext: { diff --git a/media/src/pages/_app.tsx b/media/src/pages/_app.tsx index 8c36329..43616fc 100644 --- a/media/src/pages/_app.tsx +++ b/media/src/pages/_app.tsx @@ -2,7 +2,7 @@ import type { AppProps } from "next/app"; import "./document/index.module.scss"; import "./document/index.scss"; import "../styles/globals.css"; -import "../main.css" +import "../main.css"; import "@alicloud/console-components/dist/wind.css"; import React from "react"; From fccb10fbc75ae0a322e846c488e15fd60dce388f Mon Sep 17 00:00:00 2001 From: yini-chen Date: Wed, 15 May 2024 16:27:59 +0800 Subject: [PATCH 3/4] fix: experience questionnaire --- media/src/components/APIPage/API.tsx | 28 +++++- media/src/service/UIService.ts | 128 ++++++++++++++------------- package.json | 14 ++- src/Service.ts | 103 ++++++++++++--------- src/commands.ts | 10 ++- 5 files changed, 176 insertions(+), 107 deletions(-) diff --git a/media/src/components/APIPage/API.tsx b/media/src/components/APIPage/API.tsx index e3644cf..ec5424e 100644 --- a/media/src/components/APIPage/API.tsx +++ b/media/src/components/APIPage/API.tsx @@ -3,7 +3,7 @@ * @description */ import { Tab, Tag } from "@alicloud/console-components"; -import { Segmented } from "antd"; +import { Segmented, notification } from "antd"; import _ from "lodash"; import * as PontSpec from "pontx-spec"; import * as React from "react"; @@ -19,6 +19,7 @@ import { ApiParamsDoc } from "./APIDocument/ApiParamsDoc"; import { TryAPI } from "./TryAPI/TryAPI"; import TrySDK from "./TrySDK/TrySDK"; import { APIPageContext } from "./context"; +import { PontUIService } from "../../service/UIService"; export class APIProps { selectedApi?: PontSpec.PontAPI; @@ -226,6 +227,31 @@ export const API: React.FC = (props) => { } }, [mode, boxWidth, isExpand]); + const openNotification = () => { + notification.open({ + message: "体验调研", + duration: null, + description: ( + + 您对插件的使用体验满意吗?点击 + 体验问卷 + 进行吐槽或夸赞,您的反馈对我们十分重要! + + ), + onClose: () => { + PontUIService.updateQuestionnaireExpiration(14); + }, + }); + }; + + React.useEffect(() => { + PontUIService.getNoticeFlag().then((res) => { + if (res === true) { + openNotification(); + } + }); + }, []); + return (
{/* */} diff --git a/media/src/service/UIService.ts b/media/src/service/UIService.ts index 62862e3..b1403e4 100644 --- a/media/src/service/UIService.ts +++ b/media/src/service/UIService.ts @@ -4,67 +4,71 @@ import { MakeCodeResponse, OpenAPIResponse } from "../types/openAPI"; /** 不同使用场景,各自注册服务来源 */ const defaultSpecs: any[] = []; export const PontUIService = { - /** 获取本地元数据列表 */ - requestPontSpecs: async () => { - return { - localSpecs: defaultSpecs as any[] as PontSpec[], - remoteSpecs: defaultSpecs as any[] as PontSpec[], - currentOriginName: "", - }; - }, - - requestDefinitions: async (specName: string) => { - return {} as any; - }, - - /** 获取 本地/远程 的diff信息 */ - requestDiffs: async () => { - return [] as any; - }, - - /** 重新生成SDK */ - requestGenerateSdk: async (): Promise => {}, - - /** 重新拉取远程数据源 */ - syncRemoteSpec: async (specNames = ""): Promise => {}, - - updateLocalSpec: async (spec: PontSpec): Promise => {}, - - /** 更新本地数据源 */ - updateSpecBySpecNames: async (specNames = ""): Promise => {}, - - /** 更新本地模块 */ - updateMod: async (modName: string, specName = ""): Promise => {}, - - /** 更新本地 API */ - updateAPI: async (modName: string, apiName: string, specName = ""): Promise => {}, - - /** 更新类 */ - updateBaseClass: async (className: string, specName = ""): Promise => {}, - - openMeta: async (meta: { - name: string; - specName: string; - modName?: string; - type: string; - spec: any; - }): Promise => {}, + /** 获取本地元数据列表 */ + requestPontSpecs: async () => { + return { + localSpecs: defaultSpecs as any[] as PontSpec[], + remoteSpecs: defaultSpecs as any[] as PontSpec[], + currentOriginName: "", + }; + }, - /** request openapi */ - openAPIRequest: async (params = {}): Promise => new OpenAPIResponse, + requestDefinitions: async (specName: string) => { + return {} as any; + }, - /** get endpoints list */ - requestEndpoints: async (product: string) => { - return [] as any; - }, - /** get sdk demo */ - makeCodeRequest: async (params = {}): Promise => new MakeCodeResponse, - /** get local language */ - getLocalLanguage : async () => "", - /** update local language */ - updateLocalLanguage : async (language:string) => "", - /** open in ide */ - openInCode: async (codeInfo:{code:string,language:string}): Promise => {}, - /** save to file */ - saveToFile: async (code:string): Promise => {}, - }; \ No newline at end of file + /** 获取 本地/远程 的diff信息 */ + requestDiffs: async () => { + return [] as any; + }, + + /** 重新生成SDK */ + requestGenerateSdk: async (): Promise => {}, + + /** 重新拉取远程数据源 */ + syncRemoteSpec: async (specNames = ""): Promise => {}, + + updateLocalSpec: async (spec: PontSpec): Promise => {}, + + /** 更新本地数据源 */ + updateSpecBySpecNames: async (specNames = ""): Promise => {}, + + /** 更新本地模块 */ + updateMod: async (modName: string, specName = ""): Promise => {}, + + /** 更新本地 API */ + updateAPI: async (modName: string, apiName: string, specName = ""): Promise => {}, + + /** 更新类 */ + updateBaseClass: async (className: string, specName = ""): Promise => {}, + + openMeta: async (meta: { + name: string; + specName: string; + modName?: string; + type: string; + spec: any; + }): Promise => {}, + + /** request openapi */ + openAPIRequest: async (params = {}): Promise => new OpenAPIResponse(), + + /** get endpoints list */ + requestEndpoints: async (product: string) => { + return [] as any; + }, + /** get sdk demo */ + makeCodeRequest: async (params = {}): Promise => new MakeCodeResponse(), + /** get local language */ + getLocalLanguage: async () => "", + /** update local language */ + updateLocalLanguage: async (language: string) => "", + /** open in ide */ + openInCode: async (codeInfo: { code: string; language: string }): Promise => {}, + /** save to file */ + saveToFile: async (code: string): Promise => {}, + /** 是否弹出通知框 */ + getNoticeFlag: async (): Promise => true, + /** 更新体验弹窗弹出的时间 */ + updateQuestionnaireExpiration: async (days: number): Promise => {}, +}; diff --git a/package.json b/package.json index d631321..916f592 100644 --- a/package.json +++ b/package.json @@ -25,10 +25,15 @@ "title": "导入依赖" }, { - "command": "alicloud.api.githubIssue", - "title": "feedback", + "command": "alicloud.api.feedback", + "title": "反馈", "icon": "$(feedback)" }, + { + "command": "alicloud.api.githubIssue", + "title": "Issues", + "icon": "$(issues)" + }, { "command": "alicloud.api.findInterface", "title": "查找 API", @@ -178,6 +183,11 @@ "command": "alicloud.api.githubIssue", "when": "view == alicloudApiExplorer", "group": "navigation@4" + }, + { + "command": "alicloud.api.feedback", + "when": "view == alicloudApiExplorer", + "group": "navigation@5" } ], "view/item/context": [ diff --git a/src/Service.ts b/src/Service.ts index 2e8e8e5..8927391 100644 --- a/src/Service.ts +++ b/src/Service.ts @@ -150,30 +150,31 @@ export class AlicloudAPIService { return res?.data?.endpoints || []; } - async openInCode(codeInfo:{code:string,language:string}){ - const {language, code} = codeInfo + async openInCode(codeInfo: { code: string; language: string }) { + const { language, code } = codeInfo; // 创建新的文件 - vscode.workspace.openTextDocument({ - content: code, - language: language?.toLocaleLowerCase(), - }).then(newDocument => { - vscode.window.showTextDocument(newDocument,{ - viewColumn: vscode.ViewColumn.Beside, + vscode.workspace + .openTextDocument({ + content: code, + language: language?.toLocaleLowerCase(), + }) + .then((newDocument) => { + vscode.window.showTextDocument(newDocument, { + viewColumn: vscode.ViewColumn.Beside, + }); }); - }); - return {} + return {}; } - async saveToFile(code:string){ + async saveToFile(code: string) { const uri = await vscode.window.showSaveDialog(); if (uri) { - const buf = Buffer.from(code, 'utf8'); - await vscode.workspace.fs.writeFile(uri, buf); + const buf = Buffer.from(code, "utf8"); + await vscode.workspace.fs.writeFile(uri, buf); } - return {} + return {}; } - async loadProfiles() { const configFilePath = path.join(os.homedir(), ".aliyun/config.json"); const { R_OK, W_OK } = fs.constants; @@ -188,11 +189,32 @@ export class AlicloudAPIService { } async updateLocalLanguage(lang) { - this.context.globalState.update('defaultLanguage', lang); + this.context.globalState.update("defaultLanguage", lang); } async getLocalLanguage() { - return this.context.globalState.get('defaultLanguage') + return this.context.globalState.get("defaultLanguage"); + } + + async getNoticeFlag() { + const globalState = this.context.globalState; + const experienceQuestionnaireKey = "questionnaireExpiration"; + const lastPromptKey = "lastPromptTime"; + // 检查上次提示的时间 + const lastPromptTime = globalState.get(lastPromptKey) as any; + const questionnaireExpiration = globalState.get(experienceQuestionnaireKey) as any; + if (!lastPromptTime || Date.now() - lastPromptTime > (questionnaireExpiration || 0) * 24 * 60 * 60 * 1000) { + return true; + } + return false; + } + + async updateQuestionnaireExpiration(days: number) { + const globalState = this.context.globalState; + const experienceQuestionnaireKey = "questionnaireExpiration"; + const lastPromptKey = "lastPromptTime"; + globalState.update(experienceQuestionnaireKey, days); + globalState.update(lastPromptKey, Date.now()); } async makeCodeRequest(requestData) { @@ -208,23 +230,22 @@ export class AlicloudAPIService { : "ak" : "ak"; const body = { - "apiName": apiMeta?.name, - "apiVersion": version, - "product": product, - "sdkType": "dara", - "params": newParamsValue || {}, - "regionId": regionId, - "endpoint": endpoint, - "credential": {type: defaultCredentialType}, - "runtimeOptions": {}, - "useCommon": false - } - const resStr = await fetch( - `https://api.aliyun.com/api/product/makeCode`, - {method: 'post', + apiName: apiMeta?.name, + apiVersion: version, + product: product, + sdkType: "dara", + params: newParamsValue || {}, + regionId: regionId, + endpoint: endpoint, + credential: { type: defaultCredentialType }, + runtimeOptions: {}, + useCommon: false, + }; + const resStr = await fetch(`https://api.aliyun.com/api/product/makeCode`, { + method: "post", body: JSON.stringify(body), - headers: {'Content-Type': 'application/json'}}, - ).then((res) => res.text()); + headers: { "Content-Type": "application/json" }, + }).then((res) => res.text()); const res = JSON.parse(resStr); return res; } @@ -247,7 +268,7 @@ export class AlicloudAPIService { : "ak" : "ak"; if (profiles?.length) { - const profile = profiles?.find(item=>item.name === profilesInfo.current) + const profile = profiles?.find((item) => item.name === profilesInfo.current); const start = Date.now(); try { data = await request({ @@ -260,7 +281,7 @@ export class AlicloudAPIService { productName: product, meta: apiMeta, bodyStyle: undefined, - credential: {type: defaultCredentialType}, + credential: { type: defaultCredentialType }, }); response = data; // 设置状态码 @@ -302,13 +323,13 @@ export class AlicloudAPIService { requestId: requestData.requestId, doc: `${product}::${version}::${apiMeta.name}`, type: "openAPIResponse", - response + 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')); - } + } 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")); + } } } diff --git a/src/commands.ts b/src/commands.ts index 68cef10..3c7eef1 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -78,7 +78,15 @@ export class AlicloudApiCommands { const service = alicloudAPIMessageService; vscode.commands.registerCommand("alicloud.api.githubIssue", async () => { - vscode.env.openExternal(vscode.Uri.parse("https://github.com/aliyun/alibabacloud-api-vscode-toolkit/issues")); + vscode.env.openExternal( + vscode.Uri.parse("https://github.com/aliyun/alibabacloud-api-vscode-toolkit/issues?q=is%3Aissue+is%3Aclosed"), + ); + }); + + vscode.commands.registerCommand("alicloud.api.feedback", async () => { + vscode.env.openExternal( + vscode.Uri.parse("https://g.alicdn.com/aes/tracker-survey-preview/0.0.13/survey.html?pid=fePxMy&id=3486"), + ); }); vscode.commands.registerCommand("alicloud.api.findInterface", () => { From 08e244d10615377c9aa07d248e0155719ac92176 Mon Sep 17 00:00:00 2001 From: yini-chen Date: Wed, 15 May 2024 16:34:34 +0800 Subject: [PATCH 4/4] fix: experience questionnaire --- media/src/mocks/routerMeta.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media/src/mocks/routerMeta.ts b/media/src/mocks/routerMeta.ts index 4f256b3..fc0d26e 100644 --- a/media/src/mocks/routerMeta.ts +++ b/media/src/mocks/routerMeta.ts @@ -3,7 +3,7 @@ export const routerMeta = { modName: "", spec: { consumes: ["application/xml"], - deprecated: false, + deprecated: true, description: '## 接口说明\n\n\n\n- **准备工作**:\n - 通过实名认证。更多信息,请参见[账号实名认证相关文档](~~48263~~)。 \n - 成本估算:了解云服务器ECS的计费方式。更多信息,请参见[计费概述](~~25398~~)。\n - 产品选型:调用[DescribeInstanceTypes](~~25620~~)查看目标实例规格的性能数据,或者参见[选型配置](~~58291~~)了解如何选择实例规格。\n - 查询库存:调用[DescribeAvailableResource](~~66186~~)查看指定地域或者可用区内的资源供给情况。\n - 网络规划:您需要确保您已经有可用的安全组。更多信息,请参见[CreateSecurityGroup](~~25553~~)。创建专有网络VPC类型实例前,您需要预先在相应的阿里云地域[创建VPC](~~65430~~)。\n\n\n\n\n\n\n- **准备工作**:\n - 成本估算:了解云服务器ECS的计费方式。更多信息,请参见[计费概述](~~25398~~)。\n - 产品选型:调用[DescribeInstanceTypes](~~25620~~)查看目标实例规格的性能数据,或者参见[选型配置](~~58291~~)了解如何选择实例规格。\n - 查询库存:调用[DescribeAvailableResource](~~66186~~)查看指定地域或者可用区内的资源供给情况。\n - 网络规划:您需要确保您已经有可用的安全组。更多信息,请参见[CreateSecurityGroup](~~25553~~)。创建专有网络VPC类型实例前,您需要预先在相应的阿里云地域[创建VPC](~~65430~~)。\n\n\n\n- **与CreateInstance对比差异**:\n\n 和CreateInstance接口相比,RunInstances接口有以下优点:\n \n - 单次最多可以创建100台实例,避免重复多次调用CreateInstance。\n - 实例创建之后,实例会自动变成`Starting`状态,然后变成`Running`状态,不需要再调用[StartInstance](~~25500~~)启动实例。\n - 创建实例时可以指定`InternetMaxBandwidthOut`为ECS实例分配公网IP,不需要您再调用[AllocatePublicIpAddress](~~25544~~)分配公网IP。\n - 您可以指定`AutoReleaseTime`参数来设定自动释放时间,不需要再调用[ModifyInstanceAutoReleaseTime](~~47576~~)设置自动释放时间。\n - 您可以指定`LaunchTemplateId`和`LaunchTemplateVersion`使用启动模板,可以免除您每次创建实例时都需要填入大量配置参数。\n - 可以指定`UniqueSuffix`参数批量设置有序的实例名称或主机名称,方便管理与检索。\n - 使用RunInstances创建实例时支持设置Enclave机密计算模式和可信系统模式。\n - 可以指定 `NetworkOptions.EnableJumboFrame`参数为true在创建时开启Jumbo frame特性。 更多信息,请参见 [ECS实例MTU](~~200512~~)。\n\n- **注意事项**:\n\n - 单次最多能创建100台实例。\n - 您可以指定参数`AutoReleaseTime`设置实例自动释放时间。\n - 创建成功后会返回实例ID列表,您可以通过[DescribeInstances](~~25506~~)查询新建实例状态。\n - 创建实例时,默认自动启动实例,直到实例状态变成运行中(`Running`)。\n - 自2020年11月27日起,创建和变配ECS实例时带宽峰值受账户限速策略影响。如需更大带宽峰值,请提交工单。具体限速策略:单个地域下,所有按使用流量计费ECS实例的实际运行带宽峰值总和不大于5 Gbit/s;所有按固定带宽计费ECS实例的实际运行带宽峰值总和不大于50 Gbit/s。\n - 与[CreateInstance](~~25499~~)相比,通过`RunInstances`创建的实例如果参数`InternetMaxBandwidthOut`的值大于0,则自动为实例分配公网IP。\n - RunInstances支持以下任一方式绑定主网卡,但需要注意一次调用只能选用一种方式配置主网卡,同时使用两种方式将会调用失败并返回错误信息。\n - 通过`SecurityGroupId`、`VSwitchId`、`PrivateIpAddress`、`NetworkInterfaceQueueNumber`与`Ipv6AddressCount`等参数直接设置主网卡的相关配置信息。\n - 通过`NetworkInterface.N.*`设置主网卡以及辅助网卡的配置信息。当`NetworkInterface.N.InstanceType`取值为`Primary`时,表示设置主网卡;当`NetworkInterface.N.InstanceType`取值为`Secondary`或空值时,表示设置辅助网卡。\n - 提交创建任务后,参数不合法或者库存不足的情况下会报错,具体的报错原因参见错误码。\n\n - 如果创建实例时返回`QuotaExceed.ElasticQuota`错误,表示您在当前地域选择的实例规格所要创建的台数超出系统限额,或者全实例规格vCPU配额超出系统限额,您可以前往[ECS管理控制台](https://ecs.console.aliyun.com/?spm=a2c8b.12215451.favorites.decs.5e3a336aMGTtzy#/privileges/quota)或[配额中心](https://quotas.console.aliyun.com/products/ecs/quotas)申请提高限额。\n \n - 如果创建实例时返回`QuotaExceed.DiskCapacity`错误,表示您当前选择的磁盘类型所要创建的总容量超出指定可用区的系统限额,您可以前往[配额中心](https://quotas.console.aliyun.com/products/disk/quotas)查询和申请提高磁盘容量配额。\n\n\n\n\n- **最佳实践**:\n\n - 单次大批量创建ECS实例(大于100台)遇到库存不足的场景;对实例规格或可用区等资源配置无指定要求,更关注如何快速创建实例的场景;对ECS实例数量无指定要求,更关注总算力vCPU个数等场景下,阿里云推荐您使用弹性供应组。您可以通过[CreateAutoProvisioningGroup](~~122738~~)创建弹性供应组,一键式地部署跨计费方式、跨可用区、跨实例规格族的实例集群。更多信息,请参见[使用弹性供应组API批量创建ECS实例](~~200772~~)。\n\n - `RunInstances`可以执行批量创建任务,为便于管理与检索,建议您为每批次启动的实例指定标签(`Tag.N.Key`和`Tag.N.Value`),并且为主机名(`HostName`)和实例名称(`InstanceName`)添加有序后缀(`UniqueSuffix`)。\n\n - 实例启动模板能免除您每次创建实例时都需要填入大量配置参数,您可以创建实例启动模板([CreateLaunchTemplate](~~74686~~))后,在`RunInstances`请求中指定`LaunchTemplateId`和`LaunchTemplateVersion`使用启动模板。\n\n\n\n\n\n- **最佳实践**:\n\n - 单次大批量创建ECS实例(大于100台)遇到库存不足的场景;对实例规格或可用区等资源配置无指定要求,更关注如何快速创建实例的场景;对ECS实例数量无指定要求,更关注总算力vCPU个数等场景下,阿里云推荐您使用弹性供应组。您可以通过[CreateAutoProvisioningGroup](~~122738~~)创建弹性供应组,一键式地部署跨计费方式、跨可用区、跨实例规格族的实例集群。更多信息,请参见[使用弹性供应组API批量创建ECS实例](~~200772~~)。\n\n - `RunInstances`可以执行批量创建任务,为便于管理与检索,建议您为每批次启动的实例指定标签(`Tag.N.Key`和`Tag.N.Value`),并且为主机名(`HostName`)和实例名称(`InstanceName`)添加有序后缀(`UniqueSuffix`)。\n\n - 实例启动模板能免除您每次创建实例时都需要填入大量配置参数,您可以创建实例启动模板([CreateLaunchTemplate](~~74686~~))后,在`RunInstances`请求中指定`LaunchTemplateId`和`LaunchTemplateVersion`使用启动模板。\n\n\n\n### 示例1:创建包年包月实例\n\n实例所在地域为华东1(杭州),计费方式为包年包月,购买时长一个月,到期自动续费一个月,镜像ID为:aliyun_3_x64_20G_alibase_20221102.vhd,实例规格为:ecs.g7.large,40 GiB ESSD云盘,挂载100 GiB ESSD云数据盘,公网出带宽为10 Mbit/s,自动分配私网IP和公网IP,实例名称为ECS-test,登录密码为ECS@test1234,数量为1台。\n\n```\nhttp(s)://ecs.aliyuncs.com/?Action=RunInstances\n&RegionId=cn-hangzhou\n&ImageId=aliyun_3_x64_20G_alibase_20221102.vhd\n&InstanceType=ecs.g7.large\n&SecurityGroupId=sg-bp150uqocpf9jj70****\n&VSwitchId=vsw-bp1qo7s91cbch5i4l****\n&InstanceChargeType=PrePaid\n&SystemDisk.Size=40\n&DataDisk.1.Size=100\n&DataDisk.1.Category=cloud_essd\n&SystemDisk.Category=cloud_essd\n&Amount=1\n&Period=1\n&PeriodUnit=Month\n&AutoRenew=true\n&AutoRenewPeriod=1\n&HostName=ECS-test\n&Password=ECS@test1234\n&InternetMaxBandwidthOut=10\n&公共请求参数\n```\n\n### 示例2:创建按量付费实例\n\n实例所在地域为华东1(杭州),计费方式为按量付费,镜像ID为:aliyun_3_x64_20G_alibase_20221102.vhd,实例规格为:ecs.g7.large,40 GiB ESSD云盘,挂载100 GiB ESSD云数据盘,公网出带宽为10 Mbit/s,自动分配私网IP和公网IP,实例名称为ECS-test,登录密码为ECS@test1234,数量为1台。\n\n```\nhttp(s)://ecs.aliyuncs.com/?Action=RunInstances\n&RegionId=cn-hangzhou\n&ImageId=aliyun_3_x64_20G_alibase_20221102.vhd\n&InstanceType=ecs.g7.large\n&SecurityGroupId=sg-bp150uqocpf9jj70****\n&VSwitchId=vsw-bp1qo7s91cbch5i4l****\n&InstanceChargeType=PostPaid\n&SystemDisk.Size=40\n&DataDisk.1.Size=100\n&DataDisk.1.Category=cloud_essd\n&SystemDisk.Category=cloud_essd\n&HostName=ECS-test\n&Password=ECS@test1234\n&InternetMaxBandwidthOut=10\n&公共请求参数\n```\n\n### 示例3:创建抢占式实例\n\n实例所在地域为华东1(杭州),计费方式为抢占式实例,竞价策略为系统自动出价,跟随当前市场实际价格,实例保留时长为1小时,镜像ID为:aliyun_3_x64_20G_alibase_20221102.vhd,实例规格为:ecs.g7.large,40 GiB ESSD云盘,挂载100 GiB ESSD云数据盘,公网出带宽为10 Mbit/s,自动分配私网IP和公网IP,实例名称为ECS-test,登录密码为ECS@test1234,数量为1台。\n\n```\nhttp(s)://ecs.aliyuncs.com/?Action=RunInstances\n&RegionId=cn-hangzhou\n&ImageId=aliyun_3_x64_20G_alibase_20221102.vhd\n&InstanceType=ecs.g7.large\n&SecurityGroupId=sg-bp150uqocpf9jj70****\n&VSwitchId=vsw-bp1qo7s91cbch5i4l****\n&InstanceChargeType=PostPaid\n&SystemDisk.Size=40\n&DataDisk.1.Size=100\n&DataDisk.1.Category=cloud_essd\n&SystemDisk.Category=cloud_essd\n&HostName=ECS-test\n&Password=ECS@test1234\n&InternetMaxBandwidthOut=10\n&SpotStrategy=SpotAsPriceGo\n&SpotDuration=1\n&公共请求参数\n```\n\n### 示例4:在专有宿主机上创建包年包月实例\n\n实例所在地域为华东1(杭州),专有宿主机为dh-bp12w10wll9xcjq2****,计费方式包年包月,购买时长一个月,镜像ID为:aliyun_3_x64_20G_alibase_20221102.vhd,实例规格为:ecs.g7.large,40 GiB ESSD云盘,挂载100 GiB ESSD云数据盘,公网出带宽为10 Mbit/s,自动分配私网IP和公网IP,实例名称为ECS-test,登录密码为ECS@test1234,购买数量为1台。\n\n```\nhttp(s)://ecs.aliyuncs.com/?Action=RunInstances\n&RegionId=cn-hangzhou\n&ImageId=aliyun_3_x64_20G_alibase_20221102.vhd\n&InstanceType=ecs.g7.large\n&SecurityGroupId=sg-bp150uqocpf9jj70****\n&VSwitchId=vsw-bp1qo7s91cbch5i4l****\n&InstanceChargeType=PrePaid\n&Amount=1\n&Period=1\n&PeriodUnit=Month\n&SystemDisk.Size=40\n&DataDisk.1.Size=100\n&DataDisk.1.Category=cloud_essd\n&SystemDisk.Category=cloud_essd\n&HostName=ECS-test\n&Password=ECS@test1234\n&InternetMaxBandwidthOut=10\n&DedicatedHostId=dh-bp12w10wll9xcjq2****\n&公共请求参数\n```', ext: {