fix(index): replace huiwings.cn iframe with in-app role home redirect
Logged-in users on music-room.moicen.com saw a blank center because iframe targeted huiwings.cn (cross-origin / no session). Redirect to /student/home, /teacher/home, /admin/teachers, /tester, or supervisor path on same origin. Made-with: Cursor
This commit is contained in:
+37
-9
@@ -22,19 +22,21 @@
|
||||
></van-grid-item>
|
||||
</van-grid>
|
||||
</template>
|
||||
<iframe v-else src="https://huiwings.cn"></iframe>
|
||||
<div v-else class="role-home-redirect">
|
||||
<van-loading size="24px" vertical>进入工作台…</van-loading>
|
||||
</div>
|
||||
</template>
|
||||
<iframe v-else src="https://huiwings.cn"></iframe>
|
||||
<van-empty v-else description="账号未启用或未通过注册审核" />
|
||||
</template>
|
||||
<iframe v-if="!has_login" src="https://huiwings.cn"></iframe>
|
||||
<van-empty v-if="!has_login" description="请返回微信小程序完成登录" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { computed, defineComponent, onMounted } from "vue";
|
||||
import { computed, defineComponent, onMounted, watchEffect } from "vue";
|
||||
import useUser from "~/store/user";
|
||||
import { useRouter } from "vue-router";
|
||||
import { HtyBaseRoles, HtyStates, WxScenes, UserStates } from "~/types";
|
||||
import { HtyBaseRoles, HtyStates, HtySuperRoles, WxScenes, UserStates } from "~/types";
|
||||
import {
|
||||
Button,
|
||||
CellGroup,
|
||||
@@ -43,6 +45,7 @@ import {
|
||||
Form,
|
||||
Grid,
|
||||
GridItem,
|
||||
Loading,
|
||||
Picker,
|
||||
Popup,
|
||||
Radio,
|
||||
@@ -65,6 +68,7 @@ export default defineComponent({
|
||||
[RadioGroup.name!]: RadioGroup,
|
||||
[Form.name!]: Form,
|
||||
[Popup.name!]: Popup,
|
||||
[Loading.name!]: Loading,
|
||||
},
|
||||
props: ["params"],
|
||||
setup({ params }) {
|
||||
@@ -143,6 +147,28 @@ export default defineComponent({
|
||||
}
|
||||
}
|
||||
|
||||
const landingPathForRole = (role: string | undefined): string | null => {
|
||||
if (!role) return null
|
||||
if (role === HtyBaseRoles.STUDENT) return '/student/home'
|
||||
if (role === HtyBaseRoles.TEACHER) return '/teacher/home'
|
||||
if (role === HtySuperRoles.ADMIN) return '/admin/teachers'
|
||||
if (role === HtySuperRoles.TESTER) return '/tester'
|
||||
if (role === HtySuperRoles.SUPERVISOR) return '/supervisor/subsidiaries'
|
||||
return '/guest/profile'
|
||||
}
|
||||
|
||||
watchEffect(() => {
|
||||
if (router.currentRoute.value.path !== '/') return
|
||||
if (!store.current.hty_id) return
|
||||
if (!store.current.enabled || !store.current.is_registered) return
|
||||
if (!store.currentRole) return
|
||||
if (store.currentRole === HtyBaseRoles.STUDENT && store.teachers.mine.length === 0) return
|
||||
const target = landingPathForRole(store.currentRole)
|
||||
if (target && target !== '/') {
|
||||
void router.replace(target)
|
||||
}
|
||||
})
|
||||
|
||||
const chooseTeacher = async (teacher_id: string, teacher_name: string) => {
|
||||
await showConfirmDialog({message: "确认选择【" + teacher_name + "】老师?"})
|
||||
await claimTeacher(store.current.hty_id, teacher_id);
|
||||
@@ -180,10 +206,12 @@ export default defineComponent({
|
||||
color: #ed6a0c;
|
||||
}
|
||||
|
||||
iframe {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: none;
|
||||
.role-home-redirect {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 40vh;
|
||||
padding: 1rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user