App.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <script>
  2. import { getUnreadCount } from './api/message.js';
  3. import { messageStore } from './store/message.js';
  4. export default {
  5. onLaunch: function() { // 强制刷新页面路由配置 - 2026-03-15 16:32
  6. console.log('App Launch - Route Refresh - My Secondary Pages') // Final Build Trigger
  7. // 自动登录:如果本地有缓存的 token,直接跳转首页,无需再走登录流程
  8. const token = uni.getStorageSync('token');
  9. if (token) {
  10. uni.switchTab({
  11. url: '/pages/jobs/jobs',
  12. fail: () => {
  13. uni.reLaunch({ url: '/pages/jobs/jobs' });
  14. }
  15. });
  16. }
  17. },
  18. onShow: function() {
  19. console.log('App Show');
  20. const token = uni.getStorageSync('token');
  21. if (!token) {
  22. // 未登录时重置未读数为 0
  23. messageStore.setUnreadCount(0);
  24. return;
  25. }
  26. // 每次进入前台都刷新真实未读数
  27. getUnreadCount()
  28. .then(res => {
  29. if (res && res.code === 200 && typeof res.data === 'number') {
  30. messageStore.setUnreadCount(res.data);
  31. }
  32. })
  33. .catch(() => {
  34. // 失败时保持当前值即可,不提示用户
  35. });
  36. },
  37. onHide: function() {
  38. console.log('App Hide')
  39. }
  40. }
  41. </script>
  42. <style lang="scss">
  43. /* 全局样式:强制隐藏所有页面的系统滚动条,提升沉浸式体验 */
  44. /* 针对页面根节点、普通视图和滚动容器 */
  45. page, view, scroll-view {
  46. -ms-overflow-style: none; /* IE and Edge */
  47. scrollbar-width: none; /* Firefox */
  48. &::-webkit-scrollbar {
  49. display: none !important;
  50. width: 0 !important;
  51. height: 0 !important;
  52. -webkit-appearance: none;
  53. background: transparent;
  54. color: transparent;
  55. }
  56. }
  57. /* 额外确保在部分环境下彻底移除 */
  58. ::-webkit-scrollbar {
  59. display: none !important;
  60. width: 0 !important;
  61. height: 0 !important;
  62. }
  63. </style>