Commit 90f4d11b by 张立顺

feat tabmine组件修复

1 parent 9c2add61
......@@ -2,7 +2,7 @@
import api from '~/pages/tabMine/api'
const app = getApp()
import constantData from '../../pages/constant/data'
import { withTabRefreshInFlight } from '../../packageEquity/services/tabRefreshService.js'
import { withTabRefreshInFlight } from '~/utils/tabRefreshService.js'
const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/mine/'
Component({
/**
......
......@@ -18,12 +18,12 @@ export const appId = "wx570d9331f9ace0bd";
* 4预发布
* 5cdptest
*/
let index = 3;
let index = 2;
const accountInfo = wx.getAccountInfoSync();
const systemInfo = wx.getSystemInfoSync();
const envName = accountInfo.miniProgram.envVersion;
//手动控制体验版环境的请求 true就依据下面index false就默认2
const manual = true;
const manual = false;
const release = false;
// 判断小程序环境
......
/**
* 权益 Tab 子页(Tab1–4)刷新 in-flight 合并。
*
* 设计原则:
* - **每次** `show=true` 都会执行刷新(与 Tab0 对齐)
* - 仅合并同一 key 下同一 tick 的并发调用(如 observer + 其它入口叠加)
* - **不做 TTL**,切走再切回应重新请求
*
* @module packageEquity/services/tabRefreshService
*/
/** @type {Map<string, Promise<void>>} key → 进行中的刷新 */
const inFlightByKey = new Map()
/**
* 清空单测/调试用的 in-flight 状态。
*/
export function clearTabRefreshState() {
inFlightByKey.clear()
}
/**
* 在 in-flight 去重下执行子 Tab 刷新。
*
* @param {'quotation'|'equityList'|'materials'|'mine'} key - Tab 业务隔离键
* @param {() => Promise<void>|void} fn - 实际刷新函数(如 refreshQuotationTab)
* @returns {Promise<void>}
*/
export async function withTabRefreshInFlight(key, fn) {
if (inFlightByKey.has(key)) {
return inFlightByKey.get(key)
}
const promise = Promise.resolve()
.then(fn)
.finally(() => {
if (inFlightByKey.get(key) === promise) {
inFlightByKey.delete(key)
}
})
inFlightByKey.set(key, promise)
return promise
}
export { withTabRefreshInFlight, clearTabRefreshState } from '../../utils/tabRefreshService.js'
......@@ -3,7 +3,7 @@ import assert from 'node:assert/strict'
import {
withTabRefreshInFlight,
clearTabRefreshState
} from '../services/tabRefreshService.js'
} from '../../utils/tabRefreshService.js'
describe('tabRefreshService', () => {
beforeEach(() => {
......
/**
* Tab 子页刷新 in-flight 合并(主包共享,供各场景 TabBar 子页使用)。
*
* 设计原则:
* - **每次** `show=true` 都会执行刷新(与 Tab0 对齐)
* - 仅合并同一 key 下同一 tick 的并发调用(如 observer + 其它入口叠加)
* - **不做 TTL**,切走再切回应重新请求
*
* @module utils/tabRefreshService
*/
/** @type {Map<string, Promise<void>>} key → 进行中的刷新 */
const inFlightByKey = new Map()
/**
* 清空单测/调试用的 in-flight 状态。
*/
export function clearTabRefreshState() {
inFlightByKey.clear()
}
/**
* 在 in-flight 去重下执行子 Tab 刷新。
*
* @param {'quotation'|'equityList'|'materials'|'mine'} key - Tab 业务隔离键
* @param {() => Promise<void>|void} fn - 实际刷新函数(如 refreshQuotationTab)
* @returns {Promise<void>}
*/
export async function withTabRefreshInFlight(key, fn) {
if (inFlightByKey.has(key)) {
return inFlightByKey.get(key)
}
const promise = Promise.resolve()
.then(fn)
.finally(() => {
if (inFlightByKey.get(key) === promise) {
inFlightByKey.delete(key)
}
})
inFlightByKey.set(key, promise)
return promise
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!