Blame view

泰额版/Food Labeling Management App UniApp/src/App.vue 1.34 KB
59e51671   “wangming”   1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
  <script setup lang="ts">
  import { onLaunch, onShow, onHide } from "@dcloudio/uni-app";
  import { initOfflineSqlite } from "./utils/sqliteSync";
  import { syncNowAndRefreshCaches } from "./utils/offlineSyncManager";
  import { isLoggedIn } from "./utils/authSession";
  
  let networkSyncInFlight = false;
  
  onLaunch(() => {
    void initOfflineSqlite();
    uni.onNetworkStatusChange((res) => {
      if (!res.isConnected || !isLoggedIn() || networkSyncInFlight) return;
      networkSyncInFlight = true;
      void syncNowAndRefreshCaches()
        .catch(() => {})
        .finally(() => {
          networkSyncInFlight = false;
        });
    });
  });
  
  onShow(() => {
    // App Show
  });
  
  onHide(() => {
    // App Hide
  });
  </script>
  
  <style>
  /* 主题色 - :root 确保 H5 等环境下 var(--theme-primary) 可用 */
  :root {
    --theme-primary: #1F3A8A;
    --theme-primary-dark: #142a6c;
    --theme-primary-light: #e8ecf5;
    --theme-primary-shadow: rgba(31, 58, 138, 0.35);
    --theme-primary-shadow-light: rgba(31, 58, 138, 0.2);
  }
  
  page { 
    background: #f9fafb;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    color: #111827;
    overflow-x: hidden;
    overflow-x: clip;
    width: 100%;
    max-width: 100vw;
  }
  
  /* H5 移动端防横向溢出 */
  html, body, #app {
    overflow-x: hidden;
    overflow-x: clip;
    width: 100%;
    max-width: 100vw;
  }
  </style>