fix(mobile): replace App-Plus unsupported date and query APIs

`URLSearchParams` is absent from the App-Plus JS core, and
`toLocaleDateString('sv-SE', { timeZone: 'Asia/Shanghai' })` depends on full
ICU data that the App runtime does not ship, so the work-result pages built
either a broken query string or the device-local date.

Build query strings with `encodeURIComponent`, and centralise the business day
in `currentShanghaiDate()`, which shifts the epoch by a fixed UTC+8 offset
before slicing the ISO date. Asia/Shanghai has no DST, so the fixed offset is
exact rather than an approximation.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-25 23:57:06 +08:00
co-authored by Claude Opus 5
parent 27f4cdac70
commit 3055d2bec9
7 changed files with 45 additions and 17 deletions
+28 -1
View File
@@ -32,6 +32,33 @@ test('员工成果页与主管成果页复用真实项目成果接口', async ()
assert.match(service, /pageSize/);
});
test('App-Plus 查询参数不依赖 URLSearchParams', async () => {
const [service, supervisorReview] = await Promise.all([
read('../src/services/work-results.ts'),
read('../src/pages/supervisor/review/index.vue')
]);
assert.doesNotMatch(`${service}\n${supervisorReview}`, /URLSearchParams/);
assert.match(service, /encodeURIComponent\(projectCode\)/);
assert.match(supervisorReview, /encodeURIComponent\(assignedScenario\)/);
});
test('App-Plus 工作成果日期固定为上海 yyyy-MM-dd', async () => {
const [dateUtil, selector, employeePage, supervisorPage] = await Promise.all([
read('../src/utils/date.ts'),
read('../src/components/WorkDateSelector.vue'),
read('../src/pages/user/work-results/index.vue'),
read('../src/pages/supervisor/work-results/index.vue')
]);
assert.match(dateUtil, /Date\.now\(\) \+ 8 \* 60 \* 60 \* 1000/);
assert.match(dateUtil, /toISOString\(\)\.slice\(0, 10\)/);
assert.doesNotMatch(`${selector}\n${employeePage}\n${supervisorPage}`, /toLocaleDateString/);
for (const source of [selector, employeePage, supervisorPage]) {
assert.match(source, /currentShanghaiDate/);
}
});
test('主管成果页显式分页,避免把接口上限误当作完整团队', async () => {
const [supervisorPage, service, types] = await Promise.all([
read('../src/pages/supervisor/work-results/index.vue'),
@@ -80,7 +107,7 @@ test('员工与主管成果页复用日期选择器查看历史成果且禁止
assert.match(supervisorPage, /getProjectWorkResult\(currentProject\.value\.projectCode, workDate\.value, pageNum\.value, pageSize\)/);
assert.match(dateSelector, /mode="date"/);
assert.match(dateSelector, /:end="today"/);
assert.match(dateSelector, /props\.maxDate \|\| currentDate\(\)/);
assert.match(dateSelector, /props\.maxDate \|\| currentShanghaiDate\(\)/);
assert.match(dateSelector, /nextDate > today\.value/);
assert.match(employeePage, /这一天没有已确认的工作记录/);
assert.match(employeePage, /回到今天/);