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

@yingzhixiaoyi/vue-app-core

v0.1.3

Published

Vue router, toast and popup application foundations

Readme

@yingzhixiaoyi/vue-app-core

Vue 应用基础能力:统一 Toast 默认时长、子应用 Router 和动态 Popup 服务。

普通 Toast 插件默认时长为 800ms;错误 Toast 通过 patchToastErrorAutoClose 默认使用 2000ms,两者保持不同语义。

能力边界

本包依赖 Vue、Vue Router 和 Vue3 Toastify peer dependency;不依赖 Wujie、Pinia、crypto、业务接口或具体组件目录。Wujie 弹窗深度同步通过可选的 setPopupHistoryBridge 回调完成,包本身不引入 @yingzhixiaoyi/wujie-bus。

使用

import { createSubAppRouter, installPopupNavigationListener, sharedToastPlugin } from '@yingzhixiaoyi/vue-app-core'

const router = createSubAppRouter({ prefix: '/child', routes })
app.use(router).use(sharedToastPlugin.name, sharedToastPlugin.options)

// 在独立 H5 的 main.ts 最早阶段安装;Wujie 内嵌时会自动跳过。
installPopupNavigationListener({
  loadPopupController: () => import('@/pop_components').then(({ popupController }) => popupController),
})

子应用启动接线约束

installPopupNavigationListener 只负责在独立 H5 中最早捕获 popstate,不会替应用 初始化 Router、插件或 Native Bridge。调用方必须遵守以下顺序:

  1. 在 main.ts 顶层静态导入并调用 installPopupNavigationListener;
  2. 再动态加载 App.vue、plugin、event 和 wujie_bus;
  3. Promise.all 返回后先执行 setupSubAppNativeBridge;
  4. 然后依次执行 createApp、异常监控、registerPlugin、initConfig,最后 mount。

Promise.all 只保证结果数组顺序,不保证这些模块的初始化先后;不要把需要顺序 保证的初始化逻辑放进并行 import。loadPopupController 必须保持懒加载,避免 main.ts 顶层直接导入业务 Popup 造成 Router / Popup / Plugin 循环依赖。

没有业务 Popup 的应用不要调用该 API;Wujie 内嵌时 API 会检测 $wujie 并跳过 独立 H5 的浏览器返回处理,内嵌返回由主应用统一协调。

Popup 使用构建工具提供的静态 fileList:

import { createPopupService, setPopupHistoryBridge } from '@yingzhixiaoyi/vue-app-core'

const { show_popup, popupController } = createPopupService({
  fileList,
  registerPlugin: app => app.use(router),
})

// 同一组件承载不同业务内容时,用业务键区分实例
await show_popup('account', { only: true, instanceKey: 'account-001', content: '...' })
await show_popup('account', { only: true, instanceKey: 'account-002', content: '...' })

// 不需要任何唯一性约束时,显式允许多实例
await show_popup('account', { only: false, content: '...' })

// Wujie 子应用:同步弹窗深度给主应用,不压假 history
setPopupHistoryBridge({
  push: id => wujieBus.toMain('popup-history-push', { id }),
  settle: (id, fromPopState) => wujieBus.toMain('popup-history-settle', { id, fromPopState }),
})

only 仍保留用于兼容旧调用:不传 instanceKey 时按弹窗名称唯一;传入 instanceKey 后按“名称 + 业务键”唯一。可通过 popupController.closeByKey(name, instanceKey) 关闭指定业务实例。beforeClose 可返回 false 阻止关闭,popupController.closeTop({ immediate, fromPopState }) 只关闭最上层弹窗。

独立 H5 默认使用同 URL history 守卫(打开 push、关闭 replace 成残留层);no_popstate: true 可关闭。Wujie 内嵌时注册 setPopupHistoryBridge 后由宿主拦截返回。

路由返回时,包会优先消费浏览器返回事件关闭最上层弹窗;真正发生路由切换前会清理当前弹窗。

Pinia 持久化和 crypto 序列化不属于本包,避免将未确认的密钥协议带入通用 Vue 基础包。