1.优化主站彩金池配置页面当前彩金池多渠道显示错误问题
This commit is contained in:
@@ -27,12 +27,35 @@ export interface ChannelDeptScopeContext {
|
||||
export const CHANNEL_DEPT_SCOPE_KEY: InjectionKey<ChannelDeptScopeContext> =
|
||||
Symbol('channelDeptScope')
|
||||
|
||||
/**
|
||||
* 当前应用中处于激活态的超管渠道上下文。
|
||||
* 仅有一个 SuperAdminChannelShell 实例,所以可以在模块作用域内缓存其 ctx,
|
||||
* 供 setInterval / 异步回调 / 事件处理器等"setup 外"路径取用——
|
||||
* 这些路径上 Vue 的 inject() 会失效(getCurrentInstance() 为 null)。
|
||||
*/
|
||||
let activeChannelCtx: ChannelDeptScopeContext | null = null
|
||||
|
||||
export function provideChannelDeptScope(ctx: ChannelDeptScopeContext) {
|
||||
provide(CHANNEL_DEPT_SCOPE_KEY, ctx)
|
||||
activeChannelCtx = ctx
|
||||
onScopeDispose(() => {
|
||||
if (activeChannelCtx === ctx) {
|
||||
activeChannelCtx = null
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function useInjectedChannelDept(): ChannelDeptScopeContext | null {
|
||||
return inject(CHANNEL_DEPT_SCOPE_KEY, null)
|
||||
// 仅在组件 setup 同步路径下调用 inject() 才可靠;
|
||||
// 否则(异步回调、setInterval、事件处理器等)退化为读取模块级激活上下文,
|
||||
// 避免渠道切换后 getCurrentPool/withChannelDeptParams 等仍按超管自身部门发请求。
|
||||
if (getCurrentInstance()) {
|
||||
const ctx = inject(CHANNEL_DEPT_SCOPE_KEY, null)
|
||||
if (ctx) {
|
||||
return ctx
|
||||
}
|
||||
}
|
||||
return activeChannelCtx
|
||||
}
|
||||
|
||||
/** 超管全局渠道栏:创建并 provide 渠道上下文 */
|
||||
|
||||
@@ -239,6 +239,8 @@
|
||||
() => props.modelValue,
|
||||
(open) => {
|
||||
if (open) {
|
||||
// 切换渠道后再打开弹窗时,先清掉旧池数据,避免视觉残留
|
||||
pool.value = null
|
||||
loadPool().then(() => startPolling())
|
||||
} else {
|
||||
stopPolling()
|
||||
|
||||
Reference in New Issue
Block a user