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