wip: refactor(client): migrate components to composition api
This commit is contained in:
@ -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;
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user