Merge 7805a7bd35
into 218070eb13
This commit is contained in:
commit
d8334f0b6f
|
@ -106,6 +106,11 @@ export async function common(createVue: () => Promise<App<Element>>) {
|
||||||
window.history.replaceState(null, '', window.location.href.replace('#pswp', ''));
|
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 => {
|
reloadChannel.addEventListener('message', path => {
|
||||||
if (path !== null) window.location.href = path;
|
if (path !== null) window.location.href = path;
|
||||||
|
|
|
@ -27,7 +27,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { onMounted, ref } from 'vue';
|
import { onMounted, onUnmounted, ref } from 'vue';
|
||||||
import { claimZIndex } from '@/os.js';
|
import { claimZIndex } from '@/os.js';
|
||||||
import { prefer } from '@/preferences.js';
|
import { prefer } from '@/preferences.js';
|
||||||
|
|
||||||
|
@ -49,9 +49,34 @@ function closePage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function onClosed() {
|
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');
|
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>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" module>
|
<style lang="scss" module>
|
||||||
|
|
Loading…
Reference in New Issue