|
@@ -2,7 +2,7 @@ import type { StartDirectiveValue } from '@/composables/start/start.directive';
|
|
|
|
|
|
|
|
import { showLoadingToast } from 'vant';
|
|
import { showLoadingToast } from 'vant';
|
|
|
import { Notify } from '@/platform';
|
|
import { Notify } from '@/platform';
|
|
|
-import { registerVisitorMethod } from '@/request/api';
|
|
|
|
|
|
|
+import { registerVisitorMethod, toggleApplicationMethod } from '@/request/api';
|
|
|
import { useFlowStore, useVisitor } from '@/stores';
|
|
import { useFlowStore, useVisitor } from '@/stores';
|
|
|
|
|
|
|
|
const showLoading = () => {
|
|
const showLoading = () => {
|
|
@@ -12,16 +12,25 @@ const showLoading = () => {
|
|
|
duration: 0,
|
|
duration: 0,
|
|
|
});
|
|
});
|
|
|
return () => instance.close();
|
|
return () => instance.close();
|
|
|
-}
|
|
|
|
|
|
|
+};
|
|
|
|
|
|
|
|
export function useStart(ui?: boolean) {
|
|
export function useStart(ui?: boolean) {
|
|
|
|
|
+ const router = useRouter();
|
|
|
const Visitor = useVisitor();
|
|
const Visitor = useVisitor();
|
|
|
const Flow = useFlowStore();
|
|
const Flow = useFlowStore();
|
|
|
const { flow } = storeToRefs(Flow);
|
|
const { flow } = storeToRefs(Flow);
|
|
|
|
|
|
|
|
const extra: StartDirectiveValue = {
|
|
const extra: StartDirectiveValue = {
|
|
|
threshold: 1000 * 5,
|
|
threshold: 1000 * 5,
|
|
|
- fn() {},
|
|
|
|
|
|
|
+ async fn() {
|
|
|
|
|
+ await toggleApplicationMethod().send(true);
|
|
|
|
|
+ await showConfirmDialog({ title: '应用需要重新加载', showCancelButton: false });
|
|
|
|
|
+ try {
|
|
|
|
|
+ await router.replace('/');
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ location.href = location.origin;
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const register = async () => {
|
|
const register = async () => {
|
|
@@ -34,7 +43,7 @@ export function useStart(ui?: boolean) {
|
|
|
Notify.error(error.message);
|
|
Notify.error(error.message);
|
|
|
} finally {
|
|
} finally {
|
|
|
loading.value = false;
|
|
loading.value = false;
|
|
|
- close?.()
|
|
|
|
|
|
|
+ close?.();
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|