File tree Expand file tree Collapse file tree 2 files changed +23
-3
lines changed
Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -353,9 +353,9 @@ export class AlicloudAPIService {
353353 response,
354354 } ;
355355 } else {
356- let result = await vscode . window . showErrorMessage ( "请完成AK/SK配置后,再发起调用" , "查看配置方法 " , "取消" ) ;
357- if ( result === "查看配置方法 " ) {
358- vscode . env . openExternal ( vscode . Uri . parse ( "https://github.com/aliyun/aliyun-cli?tab=readme-ov-file#configure" ) ) ;
356+ let result = await vscode . window . showErrorMessage ( "请完成AK/SK配置后,再发起调用" , "去配置 " , "取消" ) ;
357+ if ( result === "去配置 " ) {
358+ this . openProfileManager ( ) ;
359359 }
360360 }
361361 }
Original file line number Diff line number Diff line change @@ -71,11 +71,31 @@ export class ProfileManager {
7171 await this . saveProfiles ( config ) ;
7272 }
7373
74+ async checkAliyunDir ( ) {
75+ const filePath = path . join ( os . homedir ( ) , ".aliyun" ) ;
76+ const { R_OK , W_OK } = fs . constants ;
77+ try {
78+ // 检测写入权限
79+ await fsx . access ( os . homedir ( ) , R_OK | W_OK ) ;
80+ // 检查文件夹是否存在
81+ fs . stat ( filePath , async ( err ) => {
82+ if ( err && err . code === "ENOENT" ) {
83+ // 不存在,创建它
84+ await fs . promises . mkdir ( filePath ) ;
85+ }
86+ } ) ;
87+ } catch ( ex ) {
88+ console . error ( "创建文件夹时出错:" , ex ) ;
89+ }
90+ }
91+
7492 async loadProfiles ( ) {
7593 const configFilePath = path . join ( os . homedir ( ) , ".aliyun/config.json" ) ;
7694 const { R_OK , W_OK } = fs . constants ;
7795 try {
96+ await this . checkAliyunDir ( ) ;
7897 await fsx . access ( configFilePath , R_OK | W_OK ) ;
98+ // 检查 dirTest 文件夹是否存在
7999 const content = await fsx . readFile ( configFilePath , "utf-8" ) ;
80100 return JSON . parse ( content ) ;
81101 } catch ( ex ) {
You can’t perform that action at this time.
0 commit comments