From be4e2d7c2b330c3b8991a0286ea16cc1285b9ec0 Mon Sep 17 00:00:00 2001
From: 罗广辉 <guanghui.luo@foxmail.com>
Date: Fri, 08 May 2026 17:47:32 +0800
Subject: [PATCH] feat: 微信小程序支持上传头像
---
src/App.vue | 69 +++++++++-------------------------
1 files changed, 18 insertions(+), 51 deletions(-)
diff --git a/src/App.vue b/src/App.vue
index 498f372..5101c82 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -1,56 +1,12 @@
<script setup>
-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
+import { onHide, onLaunch, onShow } from "@dcloudio/uni-app";
+import { useAppStore, useUserStore } from "@/store";
+import { useGlobalWS } from "@/hooks/useGlobalWS.js";
+
const appStore = useAppStore();
const userStore = useUserStore();
-onLaunch(() => {
- // 初始化系统信息
- appStore.initSystemInfo();
-
- // #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})
+useGlobalWS();
onShow(() => {
console.log("App Show");
@@ -59,6 +15,17 @@
onHide(() => {
console.log("App Hide");
});
+
+onLaunch(() => {
+ // 初始化系统信息
+ appStore.initSystemInfo();
+ if (!userStore.userInfo) {
+ //不存在则跳转至登录页
+ uni.reLaunch({
+ url: "/pages/login/index",
+ });
+ }
+});
</script>
<style lang="scss">
@@ -66,7 +33,7 @@
@import "uview-plus/index.scss";
@import "@/static/styles/common.scss";
-.TUICallKit-mobile{
+.TUICallKit-mobile {
position: fixed;
left: 0;
top: 0;
@@ -74,7 +41,7 @@
}
page {
- background-image: url('~@/static/images/user/bg.png');
+ background-image: url("https://wrj.shuixiongit.com/aiskyminio/cloud-bucket/ztzf_app_assets/images/user/bg.png");
background-size: cover;
background-position: center;
background-repeat: no-repeat;
--
Gitblit v1.9.3