代码优化

This commit is contained in:
kron
2025-06-02 14:42:07 +08:00
parent 43889669d7
commit 1eab5a151e
6 changed files with 118 additions and 119 deletions

View File

@@ -8,6 +8,7 @@ import useStore from "@/store";
import { storeToRefs } from "pinia";
const store = useStore();
const { updateConfig } = store;
// 使用storeToRefs用于UI里显示保持响应性
const { user } = storeToRefs(store);
@@ -61,28 +62,15 @@ const toMyDevicePage = () => {
}
};
const toAddDevicePage = () => {
if (isLogin()) {
uni.navigateTo({
url: "/pages/add-device",
});
}
};
// 获取全局配置
const getConfig = async () => {
onMounted(async () => {
try {
const config = await getAppConfig();
console.log("全局配置:", config);
updateConfig(config);
// 这里可以处理配置数据
} catch (error) {
console.error("获取配置失败:", error);
}
};
// 页面加载完成后检查本地存储的用户信息并获取配置
onMounted(() => {
getConfig();
});
</script>