Skip to content

Commit 1a6c45c

Browse files
feat: 文件列表记录最后一次位置 (#1753)
Refs #1254
1 parent 4d368a4 commit 1a6c45c

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

frontend/src/store/index.ts

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export const GlobalStore = defineStore({
2626
hasNewVersion: false,
2727
ignoreCaptcha: true,
2828
device: DeviceType.Desktop,
29+
lastFilePath: '',
2930
}),
3031
getters: {},
3132
actions: {
@@ -60,6 +61,9 @@ export const GlobalStore = defineStore({
6061
isMobile() {
6162
return this.device === DeviceType.Mobile;
6263
},
64+
setLastFilePath(path: string) {
65+
this.lastFilePath = path;
66+
},
6367
},
6468
persist: piniaPersistConfig('GlobalState'),
6569
});

frontend/src/store/interface/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export interface GlobalState {
2121
hasNewVersion: boolean;
2222
ignoreCaptcha: boolean;
2323
device: DeviceType;
24+
lastFilePath: string;
2425
}
2526

2627
export interface MenuState {

frontend/src/views/host/file-management/index.vue

+8
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,8 @@ const jump = async (url: string) => {
363363
req.containSub = false;
364364
req.search = '';
365365
let searchResult = await searchFile();
366+
367+
globalStore.setLastFilePath(req.path);
366368
// check search result,the file is exists?
367369
if (!searchResult.data.path) {
368370
req.path = oldUrl;
@@ -636,6 +638,12 @@ onMounted(() => {
636638
if (router.currentRoute.value.query.path) {
637639
req.path = String(router.currentRoute.value.query.path);
638640
getPaths(req.path);
641+
globalStore.setLastFilePath(req.path);
642+
} else {
643+
if (globalStore.lastFilePath && globalStore.lastFilePath != '') {
644+
req.path = globalStore.lastFilePath;
645+
getPaths(req.path);
646+
}
639647
}
640648
pathWidth.value = pathRef.value.offsetWidth * 0.7;
641649
search();

0 commit comments

Comments
 (0)