shuishen
2025-11-13 df2a71cf5feb914a9ca0540142bb6bf1865e26fb
src/App.vue
@@ -1,58 +1,137 @@
<script setup>
import { onHide, onLaunch, onShow } from "@dcloudio/uni-app";
import { useAppStore } from "@/store";
import {mpUpdate} from "@/utils/index";
const appStore = useAppStore();
onLaunch(() => {
  console.log("App Launch");
  // 初始化系统信息
  appStore.initSystemInfo();
  // #ifdef MP-WEIXIN
  mpUpdate();
  import {
    onHide,
    onLaunch,
    onShow
  } from "@dcloudio/uni-app";
  import {
    useAppStore,
    useUserStore
  } from "@/store";
  import {
    mpUpdate
  } from "@/utils/index";
  import {
    genTestUserSig
  } from '@/utils/voiceCallByTX/GenerateTestUserSig.js';
  // #ifdef H5
  import {
    TUICallKitAPI
  } from '@trtc/calls-uikit-vue'
  // #endif
});
  const appStore = useAppStore();
  const userStore = useUserStore();
onShow(() => {
  console.log("App Show");
});
  onLaunch(() => {
    // 初始化系统信息
    appStore.initSystemInfo();
onHide(() => {
  console.log("App Hide");
});
    if (!userStore.userInfo) {
      //不存在则跳转至登录页
      uni.reLaunch({
        url: "/pages/login/index",
      })
    }
    // #ifdef MP-WEIXIN
    mpUpdate();
    // #endif
  });
  const userId = computed(() => userStore?.userInfo?.user_id)
  function initVoiceCallFromApp() {
    const TUICallKit = uni.requireNativePlugin('TencentCloud-TUICallKit');
    const {
      userSig,
      SDKAppID
    } = genTestUserSig(userId.value);
    uni.$TUICallKit = TUICallKit;
    uni.$TUICallKit.login({
      SDKAppID,
      userID: userId.value,
      userSig: userSig,
    })
  }
  async function initVoiceCallFromH5() {
    const {
      userSig,
      SDKAppID
    } = genTestUserSig(userId.value)
    await TUICallKitAPI.init({
      userID: userId.value,
      userSig,
      SDKAppID,
    })
  }
  // 初始化登陆腾讯音频平台
  watch(userId, () => {
    if (!userId.value) return
    // #ifdef H5
    initVoiceCallFromH5()
    // #endif
    // #ifdef APP-PLUS
    initVoiceCallFromApp()
    // #endif
  }, {
    immediate: true
  })
  onShow(() => {
    console.log("App Show");
  });
  onHide(() => {
    console.log("App Hide");
  });
</script>
<style lang="scss">
/* 每个页面公共css */
@import "uview-plus/index.scss";
@import "@/static/styles/common.scss";
page {
  background-image: url('~@/static/images/user/allBg.svg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  // min-height: 10vh;
}
.uni-tabbar__item:nth-child(4) {
  .uni-tabbar__bd {
    .uni-tabbar__icon {
      width: 60px !important;
      height: 60px !important;
      margin-top: -20px;
  /* 每个页面公共css */
  @import "uview-plus/index.scss";
  @import "@/static/styles/common.scss";
  .TUICallKit-mobile {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 9999;
  }
  page {
    background-image: url('~@/static/images/user/bg.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    // min-height: 10vh;
  }
  .uni-tabbar__item:nth-child(4) {
    .uni-tabbar__bd {
      .uni-tabbar__icon {
        width: 60px !important;
        height: 60px !important;
        margin-top: -20px;
      }
    }
  }
}
.uni-page-head__title {
 font-family: Source Han Sans CN, Source Han Sans CN !important;
 font-weight: 400 !important;
 font-size: 17px !important;
 color: #222324 !important;
}
.uni-page-head {
   background-image: url(/drone-app/src/static/images/user/allBg.svg) !important;
}
  .uni-tabbar-border {
    background-color: #f6f6f6 !important;
  }
  .uni-page-head__title {
    font-family: Source Han Sans CN, Source Han Sans CN !important;
    font-weight: 400 !important;
    font-size: 17px !important;
    color: #222324 !important;
  }
  .uni-page-head {
    background: transparent !important;
  }
</style>