Skip to content

Commit b3a9530

Browse files
committed
fix:所有文件列表都采用时间倒序排列
1 parent cc7a1ef commit b3a9530

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,27 +53,27 @@
5353
},
5454
{
5555
"command": "codeReDesign.analyzeCode",
56-
"title": "CodeReDesign: Analyze Code",
56+
"title": "Analyze Code",
5757
"category": "CodeReDesign",
5858
"icon": "${bug}"
5959
},
6060
{
6161
"command": "codeReDesign.applyThisCvb",
62-
"title": "Apply this CVB to Workspace",
62+
"title": "sidebar Apply this CVB to Workspace",
6363
"when": "false",
6464
"category": "CodeReDesign",
6565
"icon": "${save}"
6666
},
6767
{
6868
"command": "codeReDesign.uploadThisCvb",
69-
"title": "Upload this CVB and Call API",
69+
"title": "sidebar Upload this CVB and Call API",
7070
"when": "false",
7171
"category": "CodeReDesign",
7272
"icon": "${cloud-upload}"
7373
},
7474
{
7575
"command": "codeReDesign.analyzeThisCvb",
76-
"title": "Analyze this CVB",
76+
"title": "sidebar Analyze this CVB",
7777
"when": "false",
7878
"category": "CodeReDesign",
7979
"icon": "${bug}"

src/extension.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,13 @@ export function activate(context: vscode.ExtensionContext) {
177177
vscode.window.showErrorMessage('No CVB files found in the tmp directory.');
178178
return;
179179
}
180+
181+
// 按照创建时间逆序排序
182+
cvbFiles.sort((a, b) => {
183+
const statsA = fs.statSync(path.join(tmpDir, a));
184+
const statsB = fs.statSync(path.join(tmpDir, b));
185+
return statsB.birthtime.getTime() - statsA.birthtime.getTime(); // 逆序排序
186+
});
180187

181188
const selectedCvbFile = await vscode.window.showQuickPick(cvbFiles, {
182189
placeHolder: 'Select a CVB file to upload',
@@ -266,6 +273,13 @@ export function activate(context: vscode.ExtensionContext) {
266273
return;
267274
}
268275

276+
// 按照创建时间逆序排序
277+
cvbFiles.sort((a, b) => {
278+
const statsA = fs.statSync(path.join(tmpDir, a));
279+
const statsB = fs.statSync(path.join(tmpDir, b));
280+
return statsB.birthtime.getTime() - statsA.birthtime.getTime(); // 逆序排序
281+
});
282+
269283
// 让用户选择要分析的 CVB 文件
270284
const selectedCvbFile = await vscode.window.showQuickPick(cvbFiles, {
271285
placeHolder: 'Select a CVB file to analyze',

src/siderBar.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,13 @@ class CvbViewProvider implements vscode.TreeDataProvider<vscode.TreeItem> {
109109
});
110110
}
111111

112-
// 修改后的排序逻辑
113-
files.sort((a, b) => {
114-
const labelA = a.label ? a.label.toString() : '';
115-
const labelB = b.label ? b.label.toString() : '';
116-
return labelA.localeCompare(labelB, undefined, { sensitivity: 'base' });
112+
// 按创建时间逆序排序
113+
files.sort((a, b) => {
114+
const filePathA = a.resourceUri?.fsPath || "";
115+
const filePathB = b.resourceUri?.fsPath || "";
116+
const statsA = fs.statSync(filePathA);
117+
const statsB = fs.statSync(filePathB);
118+
return statsB.birthtime.getTime() - statsA.birthtime.getTime(); // 逆序排序
117119
});
118120

119121
return files;

0 commit comments

Comments
 (0)