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 {
353
353
response,
354
354
} ;
355
355
} 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 ( ) ;
359
359
}
360
360
}
361
361
}
Original file line number Diff line number Diff line change @@ -71,11 +71,31 @@ export class ProfileManager {
71
71
await this . saveProfiles ( config ) ;
72
72
}
73
73
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
+
74
92
async loadProfiles ( ) {
75
93
const configFilePath = path . join ( os . homedir ( ) , ".aliyun/config.json" ) ;
76
94
const { R_OK , W_OK } = fs . constants ;
77
95
try {
96
+ await this . checkAliyunDir ( ) ;
78
97
await fsx . access ( configFilePath , R_OK | W_OK ) ;
98
+ // 检查 dirTest 文件夹是否存在
79
99
const content = await fsx . readFile ( configFilePath , "utf-8" ) ;
80
100
return JSON . parse ( content ) ;
81
101
} catch ( ex ) {
You can’t perform that action at this time.
0 commit comments