npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@tickbird-dev/embed-host-vue2

v1.0.0

Published

Tickbird 嵌入式工作台宿主 SDK 的 Vue 2.6 适配层(依赖 @vue/composition-api)

Downloads

627

Readme

@tickbird-dev/embed-host-vue2

Tickbird 嵌入式工作台宿主 SDK 的 Vue 2.6 适配层(基于 @vue/composition-api)。协议与全部机制在 @tickbird-dev/embed-host-core。

pnpm add @tickbird-dev/embed-host-vue2 @vue/composition-api

三处与 Vue 3 版本的差异

都由 Vue 2 本身决定,不是实现偏好:

1. 必须先安装插件,否则 composable 一调用就抛错:

import Vue from "vue";
import VueCompositionAPI from "@vue/composition-api";
Vue.use(VueCompositionAPI);

忘了装会拿到一条明确指向本包的错误信息,而不是 @vue/composition-api 那句不知道谁在用它的原始报错。

2. 只能在组件 setup 内调用。 Vue 2.6 没有 effectScope / onScopeDispose,清理只能绑在 onUnmounted 上。

3. ref 属性不接受函数,Vue 3 的 :ref="setFrame" 在这里无效。用返回的 frameRef 配同名模板 ref:

<template>
  <iframe ref="frameRef" :src="embedUrl" />
</template>

<script>
import { computed } from "@vue/composition-api";
import { useTickbirdEmbed } from "@tickbird-dev/embed-host-vue2";

export default {
  setup() {
    const embedTheme = computed(() => ({
      mode: resolvedTheme.value, // 宿主自己解析成 light / dark
      tokens: { primary: "#2563eb", primaryForeground: "#ffffff", ring: "#2563eb" },
    }));
    const embed = useTickbirdEmbed({
      embedOrigin,
      hostSessionId,
      context: businessContext,
      locale,
      theme: embedTheme,
      acquireToken: () => fetchEmbedTokenFromOwnBff(),
      onNotificationReceived: (notification) => {
        showToast(notification.title, notification.body, () => {
          if (notification.path) embed.navigate(notification.path);
        });
      },
      onUnreadCountChanged: (count) => { unreadCount.value = count; },
    });
    // frameRef 必须原样返回,名字要和模板里的 ref 一致
    return { ...embed };
  },
};
</script>

模板 ref 在渲染完成后才被填上,所以适配层用 post-flush 的 watch 观察它,而不是像 Vue 3 那样由函数式 ref 同步回调。也可以完全不用 frameRef,自己在拿到元素后调 setFrame(el)。

协议 v2 的 theme 是 { mode, tokens? } 完整快照;SDK 会监听 mode 与 tokens 的变化。Vue 2 中增删已有响应式对象的键应使用 Vue.set / Vue.delete,也可像示例一样用 computed 返回新快照。移除 token 后恢复当前 mode 的默认值。颜色契约与 v1 迁移说明。

其余 API 与 Vue 3 版本 完全一致。

通知回调自 0.3.0 起提供,使用时需要配套升级宿主包与 iframe,通信协议仍为 v2。

宿主自行实现示例中的 showToast 和 unreadCount。通知参数 EmbeddedNotification 可从本包导入;path 为有权访问的嵌入工单路径,无跳转目标时为 null。适配层在事件到达时读取配置上的最新回调,响应式替换处理函数不会重建通道。

onUnreadCountChanged 首次加载返回当前未读数,之后随变化更新;onNotificationReceived 只报告实时新通知和断线期间的新通知,首次连接不重放历史记录。游标只保存在 iframe 内存中,重载 iframe 会重新建立基线。提示、声音与角标由宿主处理,嵌入端不弹系统通知。

接收通知和调用 navigate 都不会自动将通知标为已读。宿主跨多个嵌入实例或 iframe 重载保留提示时,可用 notificationId 去重。

完整可运行的 Vue 2.6 宿主接入见 vue2-admin-embed。