fix(mobile): reset page scroll on route entry
This commit is contained in:
@@ -225,6 +225,7 @@ mobile-uni/
|
|||||||
- `mobile-uni` 本地 dev 代理已对齐 portless:默认 `/dev-api -> https://wygj-api.localhost`,不再依赖裸 `8080`;真实浏览器登录链路已复跑通过。
|
- `mobile-uni` 本地 dev 代理已对齐 portless:默认 `/dev-api -> https://wygj-api.localhost`,不再依赖裸 `8080`;真实浏览器登录链路已复跑通过。
|
||||||
- 员工今日页“今日安排”已优先回读真实 `/api/aihr/mobile/practice/assignments`;有待训练专项或每日三题时覆盖公开 home seed,真实浏览器已验证 `13900000998` 首页显示当天 daily 任务并可跳到练习页。
|
- 员工今日页“今日安排”已优先回读真实 `/api/aihr/mobile/practice/assignments`;有待训练专项或每日三题时覆盖公开 home seed,真实浏览器已验证 `13900000998` 首页显示当天 daily 任务并可跳到练习页。
|
||||||
- 员工今日页到练习页已补任务上下文传递:首页点“开始”会把当前 assignment 带到练习页,daily 任务高亮并提示填写,主管专项可直接启动,减少跳页后的二次选择。
|
- 员工今日页到练习页已补任务上下文传递:首页点“开始”会把当前 assignment 带到练习页,daily 任务高亮并提示填写,主管专项可直接启动,减少跳页后的二次选择。
|
||||||
|
- 移动端 hash 路由滚动复位已补:员工/候选人/主管/登录/建设中页面激活时回到顶部,真实浏览器验证从长页切回今日页后 `scrollY=0`,避免首屏被旧滚动位置截断。
|
||||||
|
|
||||||
## 7. 风险
|
## 7. 风险
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import { onShow } from '@dcloudio/uni-app';
|
|||||||
import type { LoginResult } from '@/types/api';
|
import type { LoginResult } from '@/types/api';
|
||||||
import { apiRequest } from '@/services/api';
|
import { apiRequest } from '@/services/api';
|
||||||
import { consumeLoginRedirect, getAuth, isLoggedIn, phoneKey, saveAuth, validatePhone } from '@/services/auth';
|
import { consumeLoginRedirect, getAuth, isLoggedIn, phoneKey, saveAuth, validatePhone } from '@/services/auth';
|
||||||
|
import { resetPageScroll } from '@/services/navigation';
|
||||||
|
|
||||||
const stored = getAuth();
|
const stored = getAuth();
|
||||||
const phone = ref(stored.phone || uni.getStorageSync(phoneKey) || '');
|
const phone = ref(stored.phone || uni.getStorageSync(phoneKey) || '');
|
||||||
@@ -123,6 +124,7 @@ const login = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onShow(() => {
|
onShow(() => {
|
||||||
|
resetPageScroll();
|
||||||
if (isLoggedIn()) {
|
if (isLoggedIn()) {
|
||||||
goAfterLogin();
|
goAfterLogin();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,6 +154,7 @@ import type { CandidateMaterial, InterviewFinishResponse, InterviewQuestion, Int
|
|||||||
import { getMobileHome } from '@/services/home';
|
import { getMobileHome } from '@/services/home';
|
||||||
import { isLoggedIn, rememberLoginRedirect } from '@/services/auth';
|
import { isLoggedIn, rememberLoginRedirect } from '@/services/auth';
|
||||||
import { searchKnowledge } from '@/services/knowledge';
|
import { searchKnowledge } from '@/services/knowledge';
|
||||||
|
import { resetPageScroll } from '@/services/navigation';
|
||||||
import {
|
import {
|
||||||
chooseCandidateFile,
|
chooseCandidateFile,
|
||||||
finishCandidateInterview,
|
finishCandidateInterview,
|
||||||
@@ -404,7 +405,10 @@ const goLogin = () => {
|
|||||||
uni.navigateTo({ url: '/pages/auth/login/index' });
|
uni.navigateTo({ url: '/pages/auth/login/index' });
|
||||||
};
|
};
|
||||||
|
|
||||||
onShow(loadPage);
|
onShow(() => {
|
||||||
|
resetPageScroll();
|
||||||
|
void loadPage();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
@@ -13,10 +13,12 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { onLoad } from '@dcloudio/uni-app';
|
import { onLoad } from '@dcloudio/uni-app';
|
||||||
|
import { resetPageScroll } from '@/services/navigation';
|
||||||
|
|
||||||
const title = ref('建设中');
|
const title = ref('建设中');
|
||||||
|
|
||||||
onLoad((query) => {
|
onLoad((query) => {
|
||||||
|
resetPageScroll();
|
||||||
title.value = query?.title ? `${decodeURIComponent(String(query.title))} · 建设中` : '建设中';
|
title.value = query?.title ? `${decodeURIComponent(String(query.title))} · 建设中` : '建设中';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -239,6 +239,7 @@ import { computed, nextTick, ref } from 'vue';
|
|||||||
import { onShow } from '@dcloudio/uni-app';
|
import { onShow } from '@dcloudio/uni-app';
|
||||||
import type { PracticeAlert, PracticeAssignment, PracticeRecord, ReviewDetail } from '@/types/api';
|
import type { PracticeAlert, PracticeAssignment, PracticeRecord, ReviewDetail } from '@/types/api';
|
||||||
import { isLoggedIn, rememberLoginRedirect } from '@/services/auth';
|
import { isLoggedIn, rememberLoginRedirect } from '@/services/auth';
|
||||||
|
import { resetPageScroll } from '@/services/navigation';
|
||||||
import {
|
import {
|
||||||
createPracticeAssignment,
|
createPracticeAssignment,
|
||||||
getPracticeAlerts,
|
getPracticeAlerts,
|
||||||
@@ -616,7 +617,10 @@ const goLogin = () => {
|
|||||||
uni.navigateTo({ url: '/pages/auth/login/index' });
|
uni.navigateTo({ url: '/pages/auth/login/index' });
|
||||||
};
|
};
|
||||||
|
|
||||||
onShow(loadPage);
|
onShow(() => {
|
||||||
|
resetPageScroll();
|
||||||
|
void loadPage();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ import { onShow } from '@dcloudio/uni-app';
|
|||||||
import type { CaseCurateResponse, CaseOrganizeResponse, CaseRecord, CaseSelectedFile, CaseUploadResponse } from '@/types/api';
|
import type { CaseCurateResponse, CaseOrganizeResponse, CaseRecord, CaseSelectedFile, CaseUploadResponse } from '@/types/api';
|
||||||
import { chooseCaseAudio, curateCase, getCaseRecords, organizeCase, uploadCaseAudio } from '@/services/case';
|
import { chooseCaseAudio, curateCase, getCaseRecords, organizeCase, uploadCaseAudio } from '@/services/case';
|
||||||
import { isLoggedIn, rememberLoginRedirect } from '@/services/auth';
|
import { isLoggedIn, rememberLoginRedirect } from '@/services/auth';
|
||||||
|
import { resetPageScroll } from '@/services/navigation';
|
||||||
|
|
||||||
const loggedIn = ref(false);
|
const loggedIn = ref(false);
|
||||||
const selectedFile = ref<CaseSelectedFile | null>(null);
|
const selectedFile = ref<CaseSelectedFile | null>(null);
|
||||||
@@ -198,6 +199,7 @@ const formatSize = (size: number) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onShow(() => {
|
onShow(() => {
|
||||||
|
resetPageScroll();
|
||||||
refreshAuthState();
|
refreshAuthState();
|
||||||
if (loggedIn.value) {
|
if (loggedIn.value) {
|
||||||
void loadRecords();
|
void loadRecords();
|
||||||
|
|||||||
@@ -169,6 +169,7 @@ import type {
|
|||||||
import { answerDailyDrill, finishPractice, getPracticeAssignments, getPracticePrepCard, startPractice, submitPracticeTurn } from '@/services/practice';
|
import { answerDailyDrill, finishPractice, getPracticeAssignments, getPracticePrepCard, startPractice, submitPracticeTurn } from '@/services/practice';
|
||||||
import { isLoggedIn, rememberLoginRedirect } from '@/services/auth';
|
import { isLoggedIn, rememberLoginRedirect } from '@/services/auth';
|
||||||
import { searchKnowledge } from '@/services/knowledge';
|
import { searchKnowledge } from '@/services/knowledge';
|
||||||
|
import { resetPageScroll } from '@/services/navigation';
|
||||||
|
|
||||||
type PracticeStatus = 'idle' | 'starting' | 'active' | 'submitting' | 'finished';
|
type PracticeStatus = 'idle' | 'starting' | 'active' | 'submitting' | 'finished';
|
||||||
|
|
||||||
@@ -538,6 +539,7 @@ const finish = async (force = false) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onShow(() => {
|
onShow(() => {
|
||||||
|
resetPageScroll();
|
||||||
refreshAuthState();
|
refreshAuthState();
|
||||||
void loadAssignments();
|
void loadAssignments();
|
||||||
void loadPrepCard();
|
void loadPrepCard();
|
||||||
|
|||||||
@@ -119,6 +119,7 @@ import { onShow } from '@dcloudio/uni-app';
|
|||||||
import type { CompetencyProfile, PracticeRecord, PromotionEvidence } from '@/types/api';
|
import type { CompetencyProfile, PracticeRecord, PromotionEvidence } from '@/types/api';
|
||||||
import { clearAuth, getAuth, isLoggedIn, rememberLoginRedirect } from '@/services/auth';
|
import { clearAuth, getAuth, isLoggedIn, rememberLoginRedirect } from '@/services/auth';
|
||||||
import { getCompetencyProfile, getPracticeHistory, getPromotionEvidence } from '@/services/practice';
|
import { getCompetencyProfile, getPracticeHistory, getPromotionEvidence } from '@/services/practice';
|
||||||
|
import { resetPageScroll } from '@/services/navigation';
|
||||||
|
|
||||||
const loggedIn = ref(false);
|
const loggedIn = ref(false);
|
||||||
const phone = ref('');
|
const phone = ref('');
|
||||||
@@ -182,7 +183,10 @@ const logout = () => {
|
|||||||
uni.showToast({ title: '已退出', icon: 'none' });
|
uni.showToast({ title: '已退出', icon: 'none' });
|
||||||
};
|
};
|
||||||
|
|
||||||
onShow(loadData);
|
onShow(() => {
|
||||||
|
resetPageScroll();
|
||||||
|
void loadData();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
@@ -120,6 +120,7 @@ import {
|
|||||||
submitAnswerFeedback
|
submitAnswerFeedback
|
||||||
} from '@/services/knowledge';
|
} from '@/services/knowledge';
|
||||||
import { isLoggedIn, rememberLoginRedirect } from '@/services/auth';
|
import { isLoggedIn, rememberLoginRedirect } from '@/services/auth';
|
||||||
|
import { resetPageScroll } from '@/services/navigation';
|
||||||
|
|
||||||
const quickQuestions = ['业主投诉噪音怎么安抚', '停车费催缴怎么说', '生活顾问的一天做什么'];
|
const quickQuestions = ['业主投诉噪音怎么安抚', '停车费催缴怎么说', '生活顾问的一天做什么'];
|
||||||
const query = ref('');
|
const query = ref('');
|
||||||
@@ -250,6 +251,7 @@ const goLogin = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onShow(() => {
|
onShow(() => {
|
||||||
|
resetPageScroll();
|
||||||
refreshAuthState();
|
refreshAuthState();
|
||||||
if (!loggedIn.value) {
|
if (!loggedIn.value) {
|
||||||
resetResultState();
|
resetResultState();
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ import type { PracticeAssignment, RoleHome } from '@/types/api';
|
|||||||
import { getMobileHome } from '@/services/home';
|
import { getMobileHome } from '@/services/home';
|
||||||
import { getPracticeAssignments } from '@/services/practice';
|
import { getPracticeAssignments } from '@/services/practice';
|
||||||
import { getAuth, isLoggedIn, rememberLoginRedirect } from '@/services/auth';
|
import { getAuth, isLoggedIn, rememberLoginRedirect } from '@/services/auth';
|
||||||
|
import { resetPageScroll } from '@/services/navigation';
|
||||||
|
|
||||||
const home = ref<RoleHome | null>(null);
|
const home = ref<RoleHome | null>(null);
|
||||||
const assignments = ref<PracticeAssignment[]>([]);
|
const assignments = ref<PracticeAssignment[]>([]);
|
||||||
@@ -241,7 +242,10 @@ const openTool = (title: string) => {
|
|||||||
uni.navigateTo({ url: `/pages/common/building/index?title=${encodeURIComponent(title)}` });
|
uni.navigateTo({ url: `/pages/common/building/index?title=${encodeURIComponent(title)}` });
|
||||||
};
|
};
|
||||||
|
|
||||||
onShow(loadHome);
|
onShow(() => {
|
||||||
|
resetPageScroll();
|
||||||
|
void loadHome();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
export const resetPageScroll = () => {
|
||||||
|
const scrollTop = () => {
|
||||||
|
uni.pageScrollTo({ scrollTop: 0, duration: 0 });
|
||||||
|
};
|
||||||
|
|
||||||
|
scrollTop();
|
||||||
|
setTimeout(scrollTop, 0);
|
||||||
|
setTimeout(scrollTop, 80);
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user