flat: bug修复

This commit is contained in:
Apcallover
2025-12-17 19:48:45 +08:00
parent ab3201b015
commit a10fd29440
6 changed files with 359 additions and 305 deletions

35
App.vue
View File

@@ -25,7 +25,7 @@ onLaunch((options) => {
useUserStore().changMachineEnv(false); useUserStore().changMachineEnv(false);
return; return;
} }
if (!isY9MachineType()) { if (isY9MachineType()) {
console.warn('求职一体机环境'); console.warn('求职一体机环境');
baseDB.resetAndReinit(); // 清空indexdb baseDB.resetAndReinit(); // 清空indexdb
useUserStore().logOutApp(); useUserStore().logOutApp();
@@ -63,15 +63,16 @@ onHide(() => {
console.log('App Hide'); console.log('App Hide');
}); });
async function handleInactivity() { function handleInactivity() {
console.log('【全局】60秒无操作执行安全逻辑'); console.log('【全局】60秒无操作执行安全逻辑');
if (inactivityModalTimer) { if (inactivityModalTimer) {
clearTimeout(inactivityModalTimer); clearTimeout(inactivityModalTimer);
inactivityModalTimer = null; inactivityModalTimer = null;
} }
if (useUserStore().hasLogin) { if (useUserStore().hasLogin) {
// 示例:弹窗确认 // 1. 正常弹出确认
await $confirm({ $confirm({
title: '会话即将过期', title: '会话即将过期',
content: '长时间无操作,是否继续使用?', content: '长时间无操作,是否继续使用?',
success: (res) => { success: (res) => {
@@ -80,25 +81,33 @@ async function handleInactivity() {
inactivityModalTimer = null; inactivityModalTimer = null;
} }
if (res.confirm) { if (res.confirm) {
inactivityManager?.resume(); // 恢复监听 inactivityManager?.resume();
} else { } else {
performLogout(); performLogout();
} }
}, },
fail: () => { fail: () => {
if (inactivityModalTimer) clearTimeout(inactivityModalTimer); if (inactivityModalTimer) {
clearTimeout(inactivityModalTimer);
inactivityModalTimer = null;
}
performLogout(); performLogout();
}, },
}); });
// 2. 启动 10 秒倒计时
inactivityModalTimer = setTimeout(() => {
inactivityModalTimer = null;
console.log('【自动登出】10秒无响应强制清理状态');
// 【关键改进】:通知全局组件强制关闭弹窗,防止用户点击陈旧弹窗
uni.$emit('hide-global-popup');
performLogout();
}, 10000);
} else { } else {
inactivityManager?.resume(); // 恢复监听 inactivityManager?.resume();
} }
// 启动 10 秒自动登出定时器
inactivityModalTimer = setTimeout(() => {
inactivityModalTimer = null;
console.log('【自动登出】用户10秒未操作');
performLogout();
}, 10000); // 10秒
} }
function performLogout() { function performLogout() {

View File

@@ -1,6 +1,6 @@
export default { export default {
// baseUrl: 'https://fw.rc.qingdao.gov.cn/rgpp-api/api', // 内网 baseUrl: 'https://fw.rc.qingdao.gov.cn/rgpp-api/api', // 内网
baseUrl: 'https://qd.zhaopinzao8dian.com/api', // 测试 // baseUrl: 'https://qd.zhaopinzao8dian.com/api', // 测试
// baseUrl: 'http://192.168.3.29:8081', // baseUrl: 'http://192.168.3.29:8081',
// baseUrl: 'http://10.213.6.207:19010/api', // baseUrl: 'http://10.213.6.207:19010/api',
// 语音转文字 // 语音转文字

View File

@@ -182,7 +182,7 @@
</tabcontrolVue> </tabcontrolVue>
<SelectJobs ref="selectJobsModel"></SelectJobs> <SelectJobs ref="selectJobsModel"></SelectJobs>
<!-- 后门 --> <!-- 后门 -->
<view class="backdoor" @click="loginbackdoor"> <view class="backdoor" v-if="!isMachineEnv" @click="loginbackdoor">
<my-icons type="gift-filled" size="60"></my-icons> <my-icons type="gift-filled" size="60"></my-icons>
</view> </view>
</AppLayout> </AppLayout>
@@ -276,9 +276,7 @@ const resetCountdown = () => {
const returnToHome = () => { const returnToHome = () => {
stopCountdown(); stopCountdown();
stopScanAnimation(); stopScanAnimation();
uni.switchTab({ useUserStore().logOutApp();
url: '/pages/index/index',
});
}; };
// 取消登录 // 取消登录

View File

@@ -2,7 +2,7 @@
<scroll-view :scroll-y="true" class="nearby-scroll" @scrolltolower="scrollBottom"> <scroll-view :scroll-y="true" class="nearby-scroll" @scrolltolower="scrollBottom">
<view class="nearby-map" @touchmove.stop.prevent> <view class="nearby-map" @touchmove.stop.prevent>
<map <map
style="width: 100%; height:410rpx " style="width: 100%; height: 410rpx"
:latitude="latitudeVal" :latitude="latitudeVal"
:longitude="longitudeVal" :longitude="longitudeVal"
:markers="mapCovers" :markers="mapCovers"
@@ -16,7 +16,7 @@
<image class="view-sx" :class="{ active: rangeShow }" src="@/static/icon/shaixun.png"></image> <image class="view-sx" :class="{ active: rangeShow }" src="@/static/icon/shaixun.png"></image>
</view> </view>
<transition name="fade-slide"> <transition name="fade-slide">
<view class="select-list" v-if="rangeShow"> <view class="select-list" v-show="rangeShow">
<view class="list-item button-click" v-for="(item, index) in range" @click="changeRadius(item)"> <view class="list-item button-click" v-for="(item, index) in range" @click="changeRadius(item)">
{{ item }}km {{ item }}km
</view> </view>
@@ -147,6 +147,7 @@ function changeRangeShow() {
} }
function changeRadius(item) { function changeRadius(item) {
console.log(item);
pageState.search.radius = item; pageState.search.radius = item;
rangeShow.value = false; rangeShow.value = false;
progressChange(item); progressChange(item);
@@ -244,7 +245,7 @@ function getInit() {
} }
function progressChange(value) { function progressChange(value) {
const range = 1 + value; const range = value < 1 ? 1 : value;
pageState.search.radius = range; pageState.search.radius = range;
mapCircles.value = [ mapCircles.value = [
{ {

View File

@@ -1,283 +1,329 @@
import { defineStore } from 'pinia'; import {
import { ref, computed } from 'vue'; defineStore
} from 'pinia';
// 屏幕检测管理器类 import {
class ScreenDetectionManager { ref,
constructor() { computed
this.WIDE_SCREEN_CSS_ID = 'wide-screen-css'; } from 'vue';
this.WIDE_SCREEN_CSS_PATH = '../common/wide-screen.css'; import wideScreenStyles from '../common/wide-screen.css?inline';
this.resizeTimer = null;
this.resizeListeners = []; // 屏幕检测管理器类
this.cssLink = null; class ScreenDetectionManager {
} constructor() {
this.WIDE_SCREEN_CSS_ID = 'wide-screen-css';
// 获取屏幕宽度 this.WIDE_SCREEN_CSS_PATH = '../common/wide-screen.css';
getScreenWidth() { this.resizeTimer = null;
if (typeof window === 'undefined') return 0; this.resizeListeners = [];
this.cssLink = null;
// 优先使用 uni.getSystemInfo this.STYLE_ID = 'wide-screen-style-tag';
if (typeof uni !== 'undefined' && uni.getSystemInfo) { this.styleTag = null;
return new Promise((resolve) => { }
uni.getSystemInfo({
success: (res) => { // 获取屏幕宽度
const width = res.screenWidth || res.windowWidth || window.innerWidth; getScreenWidth() {
resolve(width); if (typeof window === 'undefined') return 0;
},
fail: () => { // 优先使用 uni.getSystemInfo
resolve(this.getWindowWidth()); if (typeof uni !== 'undefined' && uni.getSystemInfo) {
} return new Promise((resolve) => {
}); uni.getSystemInfo({
}); success: (res) => {
} const width = res.screenWidth || res.windowWidth || window.innerWidth;
resolve(width);
return Promise.resolve(this.getWindowWidth()); },
} fail: () => {
resolve(this.getWindowWidth());
// 备用方案:使用 window 对象 }
getWindowWidth() { });
if (typeof window === 'undefined') return 0; });
return window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; }
}
return Promise.resolve(this.getWindowWidth());
// 检测折叠屏 }
checkVisualViewport() {
if (window.visualViewport?.segments?.length > 1) { // 备用方案:使用 window 对象
return { getWindowWidth() {
foldable: true, if (typeof window === 'undefined') return 0;
count: window.visualViewport.segments.length - 1 return window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
} }
}
else { // 检测折叠屏
return { checkVisualViewport() {
foldable: false, if (window.visualViewport?.segments?.length > 1) {
count: 1 return {
} foldable: true,
} count: window.visualViewport.segments.length - 1
} }
} else {
// 动态加载 CSS return {
loadWideScreenCSS() { foldable: false,
if (typeof window === 'undefined' || this.cssLink) return null; count: 1
}
try { }
this.cssLink = document.createElement('link'); }
this.cssLink.id = this.WIDE_SCREEN_CSS_ID;
this.cssLink.rel = 'stylesheet'; // 动态加载 CSS
this.cssLink.href = this.WIDE_SCREEN_CSS_PATH; loadWideScreenCSS() {
if (typeof window === 'undefined' || this.cssLink) return null;
// 添加加载成功/失败监听
this.cssLink.onload = () => { try {
console.log('🎨 宽屏 CSS 文件加载成功'); this.cssLink = document.createElement('link');
}; this.cssLink.id = this.WIDE_SCREEN_CSS_ID;
this.cssLink.rel = 'stylesheet';
this.cssLink.onerror = () => { this.cssLink.href = this.WIDE_SCREEN_CSS_PATH;
console.error('❌ 宽屏 CSS 文件加载失败');
this.cssLink = null; // 添加加载成功/失败监听
}; this.cssLink.onload = () => {
console.log('🎨 宽屏 CSS 文件加载成功');
document.head.appendChild(this.cssLink); };
return this.cssLink;
} catch (error) { this.cssLink.onerror = () => {
console.error('加载 CSS 失败:', error); console.error('❌ 宽屏 CSS 文件加载失败');
this.cssLink = null; this.cssLink = null;
return null; };
}
} document.head.appendChild(this.cssLink);
return this.cssLink;
// 移除 CSS } catch (error) {
removeWideScreenCSS() { console.error('加载 CSS 失败:', error);
if (this.cssLink && this.cssLink.parentNode) { this.cssLink = null;
try { return null;
this.cssLink.parentNode.removeChild(this.cssLink); }
this.cssLink = null; }
console.log('🗑️ 宽屏 CSS 文件已移除');
return true; // 移除 CSS
} catch (error) { removeWideScreenCSS() {
console.error('移除 CSS 失败:', error); if (this.cssLink && this.cssLink.parentNode) {
return false; try {
} this.cssLink.parentNode.removeChild(this.cssLink);
} this.cssLink = null;
return false; console.log('🗑️ 宽屏 CSS 文件已移除');
} return true;
} catch (error) {
// 更新 CSS 状态 console.error('移除 CSS 失败:', error);
updateWideScreenCSS(isWideScreen) { return false;
if (isWideScreen) { }
return this.loadWideScreenCSS(); }
} else { return false;
return this.removeWideScreenCSS(); }
}
} // 更新 CSS 状态
//显示/隐藏默认tabbar // updateWideScreenCSS(isWideScreen) {
updateTabbar(isWideScreen){ // if (isWideScreen) {
if(isWideScreen) uni.hideTabBar() // return this.loadWideScreenCSS();
else uni.showTabBar() // } else {
} // return this.removeWideScreenCSS();
// }
// 添加 resize 监听器 // }
addResizeListener(callback, delay = 250) {
if (typeof window === 'undefined') return () => {}; updateWideScreenCSS(isWideScreen) {
if (typeof document === 'undefined') return;
const handler = () => {
clearTimeout(this.resizeTimer); if (isWideScreen) {
this.resizeTimer = setTimeout(() => { // 如果已经是宽屏且标签已存在,则不重复创建
callback(); if (document.getElementById(this.STYLE_ID)) return;
}, delay);
}; this.styleTag = document.createElement('style');
this.styleTag.id = this.STYLE_ID;
window.addEventListener('resize', handler); this.styleTag.innerHTML = wideScreenStyles; // 将 CSS 文本注入
this.resizeListeners.push({ callback, handler }); document.head.appendChild(this.styleTag);
console.log('宽屏样式已通过内联方式注入');
// 返回清理函数 } else {
return () => this.removeResizeListener(callback); // 非宽屏时移除标签
} const existingTag = document.getElementById(this.STYLE_ID);
if (existingTag) {
// 移除 resize 监听器 existingTag.remove();
removeResizeListener(callback) { this.styleTag = null;
const index = this.resizeListeners.findIndex(item => item.callback === callback); console.log('宽屏样式已移除');
if (index > -1) { }
const { handler } = this.resizeListeners[index]; }
window.removeEventListener('resize', handler); }
this.resizeListeners.splice(index, 1);
} //显示/隐藏默认tabbar
} updateTabbar(isWideScreen) {
if (isWideScreen) uni.hideTabBar()
else uni.showTabBar()
} }
// 创建屏幕状态 store // 添加 resize 监听器
const useScreenStore = defineStore('screen', () => { addResizeListener(callback, delay = 250) {
// 状态 if (typeof window === 'undefined') return () => {};
const screenWidth = ref(0);
const isInitialized = ref(false); const handler = () => {
const isLoading = ref(false); clearTimeout(this.resizeTimer);
const foldFeature = ref(false); this.resizeTimer = setTimeout(() => {
const foldCount = ref(0); callback();
}, delay);
};
const isWideScreen = computed(() => {
return screenWidth.value >= 900; window.addEventListener('resize', handler);
}); this.resizeListeners.push({
callback,
handler
});
// 返回清理函数
// 管理器实例 return () => this.removeResizeListener(callback);
const manager = new ScreenDetectionManager(); }
// 初始化屏幕检测 // 移除 resize 监听器
const initScreenDetection = async () => { removeResizeListener(callback) {
if (isLoading.value || isInitialized.value) return; const index = this.resizeListeners.findIndex(item => item.callback === callback);
isLoading.value = true; if (index > -1) {
try { const {
// 检测屏幕状态 handler
const width = await manager.getScreenWidth(); } = this.resizeListeners[index];
const { foldable, count } = manager.checkVisualViewport(); window.removeEventListener('resize', handler);
this.resizeListeners.splice(index, 1);
foldFeature.value = foldable; }
foldCount.value = count; }
screenWidth.value = width;
isInitialized.value = true;
}
console.log(`📱 屏幕检测完成: ${width}px, 宽屏: ${isWideScreen.value}`);
console.log(`是否为折叠屏: ${foldFeature.value},折叠屏数量:${foldCount.value}`); // 创建屏幕状态 store
const useScreenStore = defineStore('screen', () => {
// 根据状态加载或移除 CSS // 状态
manager.updateWideScreenCSS(isWideScreen.value); const screenWidth = ref(0);
manager.updateTabbar(isWideScreen.value); const isInitialized = ref(false);
const isLoading = ref(false);
// 设置 resize 监听 const foldFeature = ref(false);
setupResizeListener(); const foldCount = ref(0);
return {
screenWidth: width,
isWideScreen: isWideScreen.value, const isWideScreen = computed(() => {
foldable, return screenWidth.value >= 900;
count });
};
} catch (error) {
console.error('初始化屏幕检测失败:', error);
return null;
} finally {
isLoading.value = false; // 管理器实例
} const manager = new ScreenDetectionManager();
};
// 初始化屏幕检测
// 手动更新屏幕状态 const initScreenDetection = async () => {
const updateScreenStatus = async () => { if (isLoading.value || isInitialized.value) return;
try { isLoading.value = true;
const width = await manager.getScreenWidth(); try {
const { foldable, count } = manager.checkVisualViewport(); // 检测屏幕状态
const width = await manager.getScreenWidth();
// 保存旧状态 const {
const oldWidth = screenWidth.value; foldable,
const oldIsWideScreen = isWideScreen.value; count
const oldFoldable = foldFeature.value; } = manager.checkVisualViewport();
const oldFoldCount = foldCount.value;
foldFeature.value = foldable;
// 更新状态 foldCount.value = count;
screenWidth.value = width; screenWidth.value = width;
foldFeature.value = foldable; isInitialized.value = true;
foldCount.value = count;
console.log(`📱 屏幕检测完成: ${width}px, 宽屏: ${isWideScreen.value}`);
// 检查宽屏状态是否发生变化 console.log(`是否为折叠屏: ${foldFeature.value},折叠屏数量:${foldCount.value}`);
if (oldIsWideScreen !== isWideScreen.value) {
console.log(`🔄 屏幕状态变化: ${oldIsWideScreen ? '宽屏' : '非宽屏'} -> ${isWideScreen.value ? '宽屏' : '非宽屏'}`); // 根据状态加载或移除 CSS
console.log(`屏幕宽度变化: ${oldWidth}px -> ${width}px`); manager.updateWideScreenCSS(isWideScreen.value);
manager.updateWideScreenCSS(isWideScreen.value); manager.updateTabbar(isWideScreen.value);
manager.updateTabbar(isWideScreen.value);
} // 设置 resize 监听
setupResizeListener();
// 检查折叠屏状态是否发生变化 return {
if (oldFoldable !== foldable || oldFoldCount !== count) { screenWidth: width,
console.log(`折叠屏状态变化: ${oldFoldable ? '是' : '否'}->${foldable ? '是' : '否'}, 折叠数: ${oldFoldCount}->${count}`); isWideScreen: isWideScreen.value,
} foldable,
count
return { };
screenWidth: width, } catch (error) {
isWideScreen: isWideScreen.value, console.error('初始化屏幕检测失败:', error);
foldable, return null;
count } finally {
}; isLoading.value = false;
} catch (error) { }
console.error('更新屏幕状态失败:', error); };
return null;
} // 手动更新屏幕状态
}; const updateScreenStatus = async () => {
try {
// 设置 resize 监听 const width = await manager.getScreenWidth();
let cleanupResizeListener = () => {}; const {
const setupResizeListener = () => { foldable,
if (typeof window === 'undefined') return; count
} = manager.checkVisualViewport();
cleanupResizeListener = manager.addResizeListener(async () => {
await updateScreenStatus(); // 保存旧状态
}, 300); const oldWidth = screenWidth.value;
}; const oldIsWideScreen = isWideScreen.value;
const oldFoldable = foldFeature.value;
// 手动触发屏幕检测 const oldFoldCount = foldCount.value;
const detectScreen = () => {
return updateScreenStatus(); // 更新状态
}; screenWidth.value = width;
foldFeature.value = foldable;
foldCount.value = count;
return { // 检查宽屏状态是否发生变化
// 状态 if (oldIsWideScreen !== isWideScreen.value) {
foldFeature, console.log(
foldCount, `🔄 屏幕状态变化: ${oldIsWideScreen ? '宽屏' : '非宽屏'} -> ${isWideScreen.value ? '宽屏' : '非宽屏'}`
screenWidth, );
isInitialized, console.log(`屏幕宽度变化: ${oldWidth}px -> ${width}px`);
isLoading, manager.updateWideScreenCSS(isWideScreen.value);
manager.updateTabbar(isWideScreen.value);
// 响应式计算属性 }
isWideScreen,
// 检查折叠屏状态是否发生变化
// 方法 if (oldFoldable !== foldable || oldFoldCount !== count) {
initScreenDetection, console.log(
updateScreenStatus, `折叠屏状态变化: ${oldFoldable ? '是' : '否'}->${foldable ? '是' : '否'}, 折叠数: ${oldFoldCount}->${count}`
detectScreen, );
}; }
});
return {
screenWidth: width,
isWideScreen: isWideScreen.value,
foldable,
count
};
} catch (error) {
console.error('更新屏幕状态失败:', error);
return null;
}
};
// 设置 resize 监听
let cleanupResizeListener = () => {};
const setupResizeListener = () => {
if (typeof window === 'undefined') return;
cleanupResizeListener = manager.addResizeListener(async () => {
await updateScreenStatus();
}, 300);
};
// 手动触发屏幕检测
const detectScreen = () => {
return updateScreenStatus();
};
return {
// 状态
foldFeature,
foldCount,
screenWidth,
isInitialized,
isLoading,
// 响应式计算属性
isWideScreen,
// 方法
initScreenDetection,
updateScreenStatus,
detectScreen,
};
});
export default useScreenStore; export default useScreenStore;

View File

@@ -53,7 +53,7 @@ export default function viteInjectPopup() {
'\n <global-popup />\n' + '\n <global-popup />\n' +
code.slice(lastTemplateEndIndex); code.slice(lastTemplateEndIndex);
console.log(`🎯 [精准注入]: ${relativePath}`); console.log(`[精准注入]: ${relativePath}`);
return { return {
code: newCode, code: newCode,
map: null map: null