wip: refactor(client): migrate components to composition api

This commit is contained in:
syuilo
2022-01-16 21:31:09 +09:00
parent 3e9677904d
commit 9885c6ba6c
3 changed files with 175 additions and 208 deletions

View File

@ -1,4 +1,5 @@
import { inject, onUnmounted, Ref } from 'vue';
import { onBeforeRouteLeave } from 'vue-router';
import { i18n } from '@/i18n';
import * as os from '@/os';
@ -16,6 +17,17 @@ export function useLeaveGuard(enabled: Ref<boolean>) {
return canceled;
});
} else {
onBeforeRouteLeave(async (to, from) => {
if (!enabled.value) return true;
const { canceled } = await os.confirm({
type: 'warning',
text: i18n.locale.leaveConfirm,
});
return !canceled;
});
}
/*