App.vue 1.34 KB
<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>