websocket优化

This commit is contained in:
kron
2025-06-22 02:39:03 +08:00
parent 322f23efb4
commit d075844cb0
6 changed files with 50 additions and 22 deletions

View File

@@ -11,7 +11,7 @@ import { storeToRefs } from "pinia";
const store = useStore();
const { updateConfig, updateUser, updateDevice } = store;
// 使用storeToRefs用于UI里显示保持响应性
const { user, device } = storeToRefs(store);
const { user, device, remoteConnect } = storeToRefs(store);
const showModal = ref(false);
const isIos = ref(true);
@@ -48,18 +48,21 @@ onMounted(async () => {
const config = await getAppConfig();
console.log("全局配置:", config);
updateConfig(config);
const result = await getHomeData();
if (result.user) {
updateUser(result.user);
const devices = await getMyDevicesAPI();
if (devices.bindings && devices.bindings.length) {
updateDevice(
devices.bindings[0].deviceId,
devices.bindings[0].deviceName
);
const token = uni.getStorageSync("token");
if (token) {
const result = await getHomeData();
if (result.user) {
updateUser(result.user);
const devices = await getMyDevicesAPI();
if (devices.bindings && devices.bindings.length) {
updateDevice(
devices.bindings[0].deviceId,
devices.bindings[0].deviceName
);
}
}
console.log("首页数据:", result);
}
console.log("首页数据:", result);
} catch (error) {
console.error("获取配置失败:", error);
}
@@ -129,7 +132,7 @@ onMounted(async () => {
<image src="../static/avatar.png" mode="aspectFill" />
</view>
<view class="more-players" @click.stop="toRankListPage"
><text>4563</text></view
><text>456{{ remoteConnect ? 1 : 0 }}</text></view
>
</view>
</view>