Compare commits

...

6 Commits

Author SHA1 Message Date
Copilot 433397e8da
Merge 7805a7bd35 into f0fb3a56a8 2025-10-01 18:10:03 +08:00
copilot-swe-agent[bot] 7805a7bd35 Add variable extraction for folder hash consistency
Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
2025-09-16 23:29:32 +00:00
copilot-swe-agent[bot] 5393045dfd Fix function declaration style for popstateHandler
Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
2025-09-16 23:27:29 +00:00
copilot-swe-agent[bot] fb864ecd6c Refine browser back button implementation using hash-based approach
Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
2025-09-16 03:46:10 +00:00
copilot-swe-agent[bot] a1c93d9b25 Implement browser back button support for FolderPageView
Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
2025-09-16 03:43:53 +00:00
copilot-swe-agent[bot] 384eebf3d1 Initial plan 2025-09-16 03:39:00 +00:00
2 changed files with 31 additions and 1 deletions

View File

@ -106,6 +106,11 @@ export async function common(createVue: () => Promise<App<Element>>) {
window.history.replaceState(null, '', window.location.href.replace('#pswp', ''));
}
// URLに#folder-を含む場合は取り除くFolderPageView用
if (window.location.hash.startsWith('#folder-')) {
window.history.replaceState(null, '', window.location.href.replace(window.location.hash, ''));
}
// 一斉リロード
reloadChannel.addEventListener('message', path => {
if (path !== null) window.location.href = path;

View File

@ -27,7 +27,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>
<script lang="ts" setup>
import { onMounted, ref } from 'vue';
import { onMounted, onUnmounted, ref } from 'vue';
import { claimZIndex } from '@/os.js';
import { prefer } from '@/preferences.js';
@ -49,9 +49,34 @@ function closePage() {
}
function onClosed() {
// When closing, remove our history entry if we're still on our hash
if (window.location.hash === `#folder-${props.pageId}`) {
window.history.back();
}
emit('closed');
}
function popstateHandler(): void {
// If the hash is no longer our folder hash, close the page
if (window.location.hash !== `#folder-${props.pageId}`) {
closePage();
}
}
onMounted(() => {
// Push a new history state with a unique hash when the folder page opens
const folderHash = `#folder-${props.pageId}`;
window.history.pushState(null, '', folderHash);
// Listen for popstate events (browser back button)
window.addEventListener('popstate', popstateHandler);
});
onUnmounted(() => {
// Clean up the event listener
window.removeEventListener('popstate', popstateHandler);
});
</script>
<style lang="scss" module>