fix(scene): 错误态图标合法性、响应数组校验与持久化字段归一化
This commit is contained in:
parent
cc6dec3970
commit
d0e47266da
|
|
@ -8,7 +8,7 @@
|
|||
</view>
|
||||
|
||||
<view v-else-if="loadError" class="state-wrap">
|
||||
<up-empty mode="error" text="加载失败,请检查网络" />
|
||||
<up-empty mode="wifi" text="加载失败,请检查网络" />
|
||||
<up-button type="success" shape="circle" text="重试" class="retry-btn" @click="loadScenes" />
|
||||
</view>
|
||||
|
||||
|
|
@ -58,7 +58,8 @@ export default {
|
|||
this.loading = true
|
||||
this.loadError = false
|
||||
try {
|
||||
this.sceneList = (await getSceneList()) || []
|
||||
const data = await getSceneList()
|
||||
this.sceneList = Array.isArray(data) ? data : []
|
||||
} catch (error) {
|
||||
this.loadError = true
|
||||
} finally {
|
||||
|
|
|
|||
|
|
@ -25,12 +25,12 @@ export function getCurrentScene() {
|
|||
}
|
||||
|
||||
/**
|
||||
* 设置当前场景并持久化。
|
||||
* 设置当前场景并持久化(仅保留 id/name,避免后端多余字段进缓存)。
|
||||
* @param {{ id: *, name: string }} scene
|
||||
*/
|
||||
export function setCurrentScene(scene) {
|
||||
currentScene = scene
|
||||
uni.setStorageSync(STORAGE_KEY, scene)
|
||||
currentScene = { id: scene.id, name: scene.name }
|
||||
uni.setStorageSync(STORAGE_KEY, currentScene)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue