diff --git a/src/pages/home/home.vue b/src/pages/home/home.vue index 4bf8ea9..e82f296 100644 --- a/src/pages/home/home.vue +++ b/src/pages/home/home.vue @@ -57,7 +57,11 @@ return '晚上好' } }, - onShow() { if (!requireSession()) return; this.user = session.currentUser; this.loadWarehouseProfile() }, + onShow() { + if (!requireSession()) return + this.user = session.currentUser + if (!this.user?.warehouseCode || !this.user?.warehouseName) this.loadWarehouseProfile() + }, onBackPress() { if (!this.menuOpen) return false this.$refs.portalHeader.closeMenu() diff --git a/tests/project-contract.test.mjs b/tests/project-contract.test.mjs index c253e14..f481166 100644 --- a/tests/project-contract.test.mjs +++ b/tests/project-contract.test.mjs @@ -145,3 +145,8 @@ test('Chinese English and Spanish locale selection is persisted from profile wit assert.match(profile, /uni\.showActionSheet[\s\S]*setLocale\(selected\.value\)/) assert.match(inbound, /warehouse-profile/) }) + +test('home reuses the persisted warehouse profile instead of requesting it on every show', async () => { + const home = await read('../src/pages/home/home.vue') + assert.match(home, /if \(!this\.user\?\.warehouseCode \|\| !this\.user\?\.warehouseName\) this\.loadWarehouseProfile\(\)/) +})