mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-26 09:43:08 +02:00
c2370a1be6
* chore: Add the SPDX information to each file Add copyright and licensing information as defined in version 3.0 of the REUSE Specification. * tweak format --------- Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
50 lines
987 B
TypeScript
50 lines
987 B
TypeScript
/*
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
import { Ref } from 'vue';
|
|
|
|
export function useLeaveGuard(enabled: Ref<boolean>) {
|
|
/* TODO
|
|
const setLeaveGuard = inject('setLeaveGuard');
|
|
|
|
if (setLeaveGuard) {
|
|
setLeaveGuard(async () => {
|
|
if (!enabled.value) return false;
|
|
|
|
const { canceled } = await os.confirm({
|
|
type: 'warning',
|
|
text: i18n.ts.leaveConfirm,
|
|
});
|
|
|
|
return canceled;
|
|
});
|
|
} else {
|
|
onBeforeRouteLeave(async (to, from) => {
|
|
if (!enabled.value) return true;
|
|
|
|
const { canceled } = await os.confirm({
|
|
type: 'warning',
|
|
text: i18n.ts.leaveConfirm,
|
|
});
|
|
|
|
return !canceled;
|
|
});
|
|
}
|
|
*/
|
|
|
|
/*
|
|
function onBeforeLeave(ev: BeforeUnloadEvent) {
|
|
if (enabled.value) {
|
|
ev.preventDefault();
|
|
ev.returnValue = '';
|
|
}
|
|
}
|
|
|
|
window.addEventListener('beforeunload', onBeforeLeave);
|
|
onUnmounted(() => {
|
|
window.removeEventListener('beforeunload', onBeforeLeave);
|
|
});
|
|
*/
|
|
}
|