broadcast-tab-sync

Uses BroadcastChannel (or the broadcast-channel package) to synchronize client draft refresh signals across browser tabs, suited for multi-tab synchronization, cross-page draft refreshes, and keeping data consistent when multiple CRM pages are open.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "broadcast-tab-sync" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-7a4a990af7cff4c256811c7fe03abca407002ae3787d003d4350ced8e5621aa2. Verify the upstream source and version against https://skillhub.cn/skills/user_f1b049da/wdj20268227 before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Uses BroadcastChannel (or the broadcast-channel package) to synchronize client draft refresh signals across browser tabs, suited for multi-tab synchronization, cross-page draft refreshes, and keeping data consistent when multiple CRM pages are open.

0 Downloads

Introduction source: third_party · user_f1b049da · 1.0.0 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Audience
Not specified in the source documentation.
Inputs and outputs
Not specified in the source documentation.
Software, accounts and paid services
Not specified in the source documentation.
Limits and differences
Not specified in the source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: broadcast-tab-sync
slug: wdj20268227
displayName: 多标签页同步
version: 1.0.0
summary: 用 BroadcastChannel 跨标签页同步客户草稿刷新信号。
license: MIT
description: 用 BroadcastChannel(或 broadcast-channel 包)在浏览器多标签页之间同步客户草稿刷新信号。当用户需要多标签页同步、BroadcastChannel、跨页草稿刷新、打开多页 CRM 同步时使用。

多标签页同步(BroadcastChannel)

灵感:能力工具箱 broadcast-sync(pkg: broadcast-channel)。

同一浏览器内多个 CRM 标签页之间,广播「草稿已保存 / 列表需刷新」等轻量信号,避免一页改了另一页还是旧数据。

何时使用

  • 用户常开多个客户详情/列表页
  • 一页保存草稿后,其他页提示刷新或自动重载本地缓存
  • 需要同源跨 Tab 通信,不必上 WebSocket

硬约束

  1. 使用原生 BroadcastChannel,或 broadcast-channel 包做兼容;频道名固定且带业务前缀(如 crm:draft-sync)。
  2. 消息为可结构化克隆的纯 JSON(type + 少量 id/时间戳),不要广播整份大草稿正文(大内容走 localStorage/IndexedDB,这里只发信号)。
  3. 发送端忽略自己的回环(若库会回投);接收端按 type 分支处理。
  4. 组件卸载 / 路由离开时 close() 频道,防泄漏。
  5. 不发起网络请求;跨浏览器配置文件不同步属预期。

推荐实现要点

export type DraftSyncMsg =
  | { type: 'draft-saved'; customerId: string; at: number }
  | { type: 'list-invalidate'; at: number }

const CHANNEL = 'crm:draft-sync'

export function createDraftSync(onMessage: (msg: DraftSyncMsg) => void) {
  const bc = new BroadcastChannel(CHANNEL)
  bc.onmessage = (ev) => {
    const data = ev.data as DraftSyncMsg
    if (!data || typeof data.type !== 'string') return
    onMessage(data)
  }
  return {
    post(msg: DraftSyncMsg) {
      bc.postMessage(msg)
    },
    close() {
      bc.close()
    },
  }
}

// 保存成功后:
// sync.post({ type: 'draft-saved', customerId, at: Date.now() })
// 其他页:toast「其他标签页已更新该客户」或重新 readLocalDraft(customerId)

若需 IE/旧环境,再用 broadcast-channel npm 包替换 new BroadcastChannel,API 语义保持一致。

Agent 步骤

  1. 封装 createDraftSync,在布局或 store 层挂载一次。
  2. 草稿保存成功 post;他页 onMessage 刷新对应缓存。
  3. 自测:开两个标签,A 保存后 B 收到信号(可用 console / toast 验证)。

附加

Current listing version

1.0.0

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value78/100

Highlights

  • 解决多标签页间轻量信号同步的实际痛点,适用于 CRM 等多页数据一致场景
  • 受众明确(前端开发者),实用价值较高
Trigger Precision85/100

Highlights

  • 触发词覆盖合理,边界清晰,明确列出多标签页同步、BroadcastChannel、跨页草稿刷新等场景
Structure and Standards92/100

Highlights

  • Phase/步骤清晰,有出口条件和自测验证,含端到端代码示例,frontmatter 完整
Execution Reliability88/100

Highlights

  • 工具来源明确,参数正确,覆盖主要异常(消息类型校验、组件卸载 close)
Evidence Verifiability (mean of the first four)86/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Not specified in the source documentation.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.