jcloud/dashboard/src2/pages/Welcome.vue
2025-04-12 17:39:38 +08:00

49 lines
1.2 KiB
Vue

<template>
<div class="px-5 py-10" v-if="$team?.pg">
<Onboarding @payment-mode-added="routeToSourcePage" />
</div>
</template>
<script>
import { getTeam } from '../data/team';
import Onboarding from '../components/Onboarding.vue';
import OnboardingWithoutPayment from '../components/OnboardingWithoutPayment.vue';
export default {
name: 'Welcome',
components: {
Onboarding,
OnboardingWithoutPayment,
},
data() {
return {
from: {},
};
},
mounted() {
this.from = window.from;
},
beforeRouteEnter: (to, from, next) => {
// 添加到 window 对象以便在 mounted 中访问
// 因为 beforeRouteEnter 在 mounted 之前调用
window.from = from;
let $team = getTeam();
window.$team = $team;
if ($team.pg.onboarding.complete && $team.pg.onboarding.site_created) {
next({ name: '站点列表' });
} else if (to.query.is_redirect && $team.pg.onboarding.site_created) {
next({ name: '站点列表' });
} else {
next();
}
},
methods: {
routeToSourcePage() {
if (this.from.name) {
this.$router.push({ name: this.from.name, params: this.from.params });
} else {
this.$router.push({ name: '站点列表' });
}
},
},
};
</script>