summaryrefslogtreecommitdiff
path: root/packages/client/src/scripts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2022-01-16 21:31:09 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2022-01-16 21:31:09 +0900
commit9885c6ba6cb17c38ff723e529834ec2fff210d86 (patch)
tree7b600c0e870b072b0497a561edf21ae84f90fab6 /packages/client/src/scripts
parentwip: refactor(client): migrate components to composition api (diff)
downloadsharkey-9885c6ba6cb17c38ff723e529834ec2fff210d86.tar.gz
sharkey-9885c6ba6cb17c38ff723e529834ec2fff210d86.tar.bz2
sharkey-9885c6ba6cb17c38ff723e529834ec2fff210d86.zip
wip: refactor(client): migrate components to composition api
Diffstat (limited to 'packages/client/src/scripts')
-rw-r--r--packages/client/src/scripts/use-leave-guard.ts12
1 files changed, 12 insertions, 0 deletions
diff --git a/packages/client/src/scripts/use-leave-guard.ts b/packages/client/src/scripts/use-leave-guard.ts
index 21899af59a..3984256251 100644
--- a/packages/client/src/scripts/use-leave-guard.ts
+++ b/packages/client/src/scripts/use-leave-guard.ts
@@ -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;
+ });
}
/*