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:
2026-04-26 16:06:44 +08:00
parent b1996f3cd1
commit 9dff5a04b6
+37 -9
View File
@@ -22,19 +22,21 @@
></van-grid-item> ></van-grid-item>
</van-grid> </van-grid>
</template> </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> </template>
<iframe v-else src="https://huiwings.cn"></iframe> <van-empty v-else description="账号未启用或未通过注册审核" />
</template> </template>
<iframe v-if="!has_login" src="https://huiwings.cn"></iframe> <van-empty v-if="!has_login" description="请返回微信小程序完成登录" />
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts">
import { computed, defineComponent, onMounted } from "vue"; import { computed, defineComponent, onMounted, watchEffect } from "vue";
import useUser from "~/store/user"; import useUser from "~/store/user";
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
import { HtyBaseRoles, HtyStates, WxScenes, UserStates } from "~/types"; import { HtyBaseRoles, HtyStates, HtySuperRoles, WxScenes, UserStates } from "~/types";
import { import {
Button, Button,
CellGroup, CellGroup,
@@ -43,6 +45,7 @@ import {
Form, Form,
Grid, Grid,
GridItem, GridItem,
Loading,
Picker, Picker,
Popup, Popup,
Radio, Radio,
@@ -65,6 +68,7 @@ export default defineComponent({
[RadioGroup.name!]: RadioGroup, [RadioGroup.name!]: RadioGroup,
[Form.name!]: Form, [Form.name!]: Form,
[Popup.name!]: Popup, [Popup.name!]: Popup,
[Loading.name!]: Loading,
}, },
props: ["params"], props: ["params"],
setup({ 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) => { const chooseTeacher = async (teacher_id: string, teacher_name: string) => {
await showConfirmDialog({message: "确认选择【" + teacher_name + "】老师?"}) await showConfirmDialog({message: "确认选择【" + teacher_name + "】老师?"})
await claimTeacher(store.current.hty_id, teacher_id); await claimTeacher(store.current.hty_id, teacher_id);
@@ -180,10 +206,12 @@ export default defineComponent({
color: #ed6a0c; color: #ed6a0c;
} }
iframe { .role-home-redirect {
width: 100%; display: flex;
height: 100%; align-items: center;
border: none; justify-content: center;
min-height: 40vh;
padding: 1rem;
} }
} }
</style> </style>