<style lang="scss">
/* 注意要写在第一行，同时给style标签加入lang="scss"属性 */
@import "uview-plus/index.scss";
</style>
<script setup>
import { onLaunch, onShow, onHide } from "@dcloudio/uni-app";
import { userInfoModules } from "@/store/modules/userInfo";
import { loginApi } from "./api/login";
import { findImageApi, findGlodApi } from "./api/home";
const userInfoModulesPinia = userInfoModules();
onLaunch(() => {
  console.log("App Launch!");

  // 获取平台及系统信息
  uni.getSystemInfo({
    success: function (res) {
      let uniPlatform = "";
      let osName = "";
      if (res.uniPlatform == "web") {
        uniPlatform = 1;
      } else if (res.uniPlatform == "mp-weixin") {
        uniPlatform = 2;
      } else if (res.uniPlatform == "mp-toutiao") {
        uniPlatform = 3;
      }
      if (res.osName == "windows") {
        osName = 1;
      } else if (res.osName == "ios") {
        osName = 2;
      } else if (res.osName == "android") {
        osName = 3;
      } else if (res.osName == "mac") {
        osName = 4;
      } else if (res.osName == "linux") {
        osName = 5;
      }

      userInfoModulesPinia.platForm = uniPlatform; // 平台
      userInfoModulesPinia.hostSystem = osName; // 系统
      console.log(res.uniPlatform, uniPlatform, "PlatForm");
      console.log(res.osName, osName, "System");
    },
  });

  uni.setStorageSync("userId", "114514");

  const updateManager = uni.getUpdateManager();

  updateManager.onUpdateReady(function (res) {
    uni.showModal({
      title: "更新提示",
      content: "有新的版本哦，请重启小程序应用更新",
      showCancel: false,
      confirmText: "立刻重启",
      confirmColor: "#ff4f00",
      success(res) {
        if (res.confirm) {
          // 新的版本已经下载好，调用 applyUpdate 应用新版本并重启
          updateManager.applyUpdate();
        }
      },
    });
  });
});
onShow(() => {
  console.log("App Show!");
});
onHide(() => {
  console.log("App Hide!");
});
</script>

<style>
/*每个页面公共css */
</style>
