Skip to content

Commit bd45531

Browse files
committed
feat: 目录返回文件信息
1 parent c22ee35 commit bd45531

3 files changed

Lines changed: 26 additions & 9 deletions

File tree

backend/src/router/dir.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,27 @@ module.exports = async function read({ query }) {
3030
const itemStats = fs.statSync(fullPath);
3131

3232
if (itemStats.isDirectory()) {
33-
result.dirs.push(item);
33+
result.dirs.push({
34+
name: item,
35+
});
3436
} else {
35-
result.files.push(item);
37+
result.files.push({
38+
name: item,
39+
size: itemStats.size,
40+
updateDate: itemStats.mtime,
41+
});
3642
}
3743
});
3844

3945
result.files.sort((i, j) =>
40-
(i || "").toLocaleLowerCase() > (j || "").toLocaleLowerCase() ? 1 : -1
46+
(i.name || "").toLocaleLowerCase() > (j.name || "").toLocaleLowerCase()
47+
? 1
48+
: -1
4149
);
4250
result.dirs.sort((i, j) =>
43-
(i || "").toLocaleLowerCase() > (j || "").toLocaleLowerCase() ? 1 : -1
51+
(i.name || "").toLocaleLowerCase() > (j.name || "").toLocaleLowerCase()
52+
? 1
53+
: -1
4454
);
4555

4656
return {

frontend/src/components/MonacoEditor.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ onMounted(() => {
135135
display: flex;
136136
align-items: center;
137137
gap: 8px;
138-
padding: 0 4px;
138+
padding: 0 8px;
139139
background-color: var(--el-bg-color);
140140
141141
> * {

frontend/src/layout/ViewLeft/ViewFolder.vue

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ const loadNode = async (node: RenderContentContext['node'], resolve: (v: TreeDat
122122
123123
const { data: result } = await axios.get<{
124124
code: number
125-
data: { dirs: string[]; files: string[] }
125+
data: { dirs: { name: string }[]; files: { name: string; size: number; updateDate: string }[] }
126126
}>(HOST, {
127127
params: { _api: 'dir', path: root },
128128
})
@@ -133,12 +133,19 @@ const loadNode = async (node: RenderContentContext['node'], resolve: (v: TreeDat
133133
134134
resolve(
135135
[
136-
...result.data.dirs.map((i) => ({ label: i, value: `${root}/${i}`, leaf: false, dir: true })),
136+
...result.data.dirs.map((i) => ({
137+
label: i.name,
138+
value: `${root}/${i.name}`,
139+
leaf: false,
140+
dir: true,
141+
})),
137142
...result.data.files.map((i) => ({
138-
label: i,
139-
value: `${root}/${i}`,
143+
label: i.name,
144+
value: `${root}/${i.name}`,
140145
leaf: true,
141146
dir: false,
147+
size: i.size,
148+
updateDate: i.updateDate,
142149
})),
143150
].filter((i) => !user.cfg.folderHidePrefix.some((x) => i.label.indexOf(x) === 0)),
144151
)

0 commit comments

Comments
 (0)