fix(scene): 错误态图标合法性、响应数组校验与持久化字段归一化

This commit is contained in:
ozh 2026-08-18 17:38:58 +08:00
parent cc6dec3970
commit d0e47266da
2 changed files with 6 additions and 5 deletions

View File

@ -8,7 +8,7 @@
</view> </view>
<view v-else-if="loadError" class="state-wrap"> <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" /> <up-button type="success" shape="circle" text="重试" class="retry-btn" @click="loadScenes" />
</view> </view>
@ -58,7 +58,8 @@ export default {
this.loading = true this.loading = true
this.loadError = false this.loadError = false
try { try {
this.sceneList = (await getSceneList()) || [] const data = await getSceneList()
this.sceneList = Array.isArray(data) ? data : []
} catch (error) { } catch (error) {
this.loadError = true this.loadError = true
} finally { } finally {

View File

@ -25,12 +25,12 @@ export function getCurrentScene() {
} }
/** /**
* 设置当前场景并持久化 * 设置当前场景并持久化仅保留 id/name避免后端多余字段进缓存
* @param {{ id: *, name: string }} scene * @param {{ id: *, name: string }} scene
*/ */
export function setCurrentScene(scene) { export function setCurrentScene(scene) {
currentScene = scene currentScene = { id: scene.id, name: scene.name }
uni.setStorageSync(STORAGE_KEY, scene) uni.setStorageSync(STORAGE_KEY, currentScene)
} }
/** /**