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

Refs https://github.com/1Panel-dev/1Panel/issues/1254
This commit is contained in:
zhengkunwang 2023-07-25 17:26:12 +08:00 committed by GitHub
parent 4d368a4de8
commit 1a6c45c526
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 0 deletions

View file

@ -26,6 +26,7 @@ export const GlobalStore = defineStore({
hasNewVersion: false,
ignoreCaptcha: true,
device: DeviceType.Desktop,
lastFilePath: '',
}),
getters: {},
actions: {
@ -60,6 +61,9 @@ export const GlobalStore = defineStore({
isMobile() {
return this.device === DeviceType.Mobile;
},
setLastFilePath(path: string) {
this.lastFilePath = path;
},
},
persist: piniaPersistConfig('GlobalState'),
});

View file

@ -21,6 +21,7 @@ export interface GlobalState {
hasNewVersion: boolean;
ignoreCaptcha: boolean;
device: DeviceType;
lastFilePath: string;
}
export interface MenuState {

View file

@ -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;
@ -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();