websocket优化
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user