Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 文件列表记录最后一次位置 #1753

Merged
merged 1 commit into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions frontend/src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const GlobalStore = defineStore({
hasNewVersion: false,
ignoreCaptcha: true,
device: DeviceType.Desktop,
lastFilePath: '',
}),
getters: {},
actions: {
Expand Down Expand Up @@ -60,6 +61,9 @@ export const GlobalStore = defineStore({
isMobile() {
return this.device === DeviceType.Mobile;
},
setLastFilePath(path: string) {
this.lastFilePath = path;
},
},
persist: piniaPersistConfig('GlobalState'),
});
Expand Down
1 change: 1 addition & 0 deletions frontend/src/store/interface/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface GlobalState {
hasNewVersion: boolean;
ignoreCaptcha: boolean;
device: DeviceType;
lastFilePath: string;
}

export interface MenuState {
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/views/host/file-management/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,8 @@ const jump = async (url: string) => {
req.containSub = false;
req.search = '';
let searchResult = await searchFile();

globalStore.setLastFilePath(req.path);
// check search result,the file is exists?
if (!searchResult.data.path) {
req.path = oldUrl;
Expand Down Expand Up @@ -636,6 +638,12 @@ onMounted(() => {
if (router.currentRoute.value.query.path) {
req.path = String(router.currentRoute.value.query.path);
getPaths(req.path);
globalStore.setLastFilePath(req.path);
} else {
if (globalStore.lastFilePath && globalStore.lastFilePath != '') {
req.path = globalStore.lastFilePath;
getPaths(req.path);
}
}
pathWidth.value = pathRef.value.offsetWidth * 0.7;
search();
Expand Down
Loading