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 🙏

© 2024 – Pkg Stats / Ryan Hefner

microapp-plugin-apploader

v1.0.1

Published

微应用框架应用加载器

Downloads

16

Readme

microapp-plugin-apploader

微应用框架应用加载器。

安装

安装采用 npm :

npm install --save microapp-plugin-apploader

使用

应用加载器采用 Vue 插件方式开发,使用时导入插件并加载至 Vue 即可:

import MicroAppLoader from 'microapp-plugin-apploader'

Vue.use(MicroAppLoader);

它提供了两个标签:

  • <ma-link> 用于链接至应用
  • <ma-loader> 用于渲染加载器并加载应用

典型用法示例:

<div class="menu">
    <ma-link :to="{name: 'vue', path: 'https://cn.vuejs.org', opened: true}">
        <button>Vue</button>
    </ma-link>
    <ma-link :to="{name: 'router', path: 'https://router.vuejs.org/zh/', keepAlive: true}">
        <button>Vue Router</button>
    </ma-link>
</div>
<ma-loader style="height: 300px"/>

另外,该插件通过注入 $apploader 实例对象,提供了一些便捷的操作函数。

1. 注册应用

如果提前注册应用,则可以在 <ma-link> 中直接指定应用名。 提前注册可以通过 <ma-loader>initData 属性,也可以通过 this.$apploader.register({...}) 函数实现:

<template>
    <div style="height: 300px">
        <div class="menu">
            <ma-link to="vue">
                <button>Vue</button>
            </ma-link>
            <ma-link to="router">
                <button>Vue Router</button>
            </ma-link>
            <ma-link to="vuex">
                <button>Vuex</button>
            </ma-link>
        </div>
        <ma-loader style="height: 280px" :initData="apps"/>
    </div>
</template>

<script>
    export default {
        data () {
            return {
                // 此处示例使用 initData 注册
                apps: [
                    {name: 'vue', path: 'https://cn.vuejs.org', opened: true},
                    {name: 'router', path: 'https://router.vuejs.org/zh/', keepAlive: true}
                ]
            };
        },
        mounted () {
            // 此处示例使用函数注册
            this.$apploader.register({name: 'vuex', path: 'https://vuex.vuejs.org/zh/', opened: true});
        }
    }
</script>

应用支持的配置属性有:

  • type 应用类型,url 或 vue(暂不支持)
  • name 应用名
  • path 路径
  • keepAlive 是否保活。为 true 则再次打开时不会重新加载
  • opened: 初始状态下是否打开

2. 调用 API 方法

该插件提供了一些 API 方法,以便于使用者动态灵活调用。所有 API 方法都被注入 this.$apploader 中,例如:

<template>
    <div style="height: 300px">
        <div class="menu">
            <ma-link to="vue">
                <button>Vue</button>
            </ma-link>
            <button @click="onClickRouter">Vue Router</button>
        </div>
        <ma-loader style="height: 300px" :initData="apps"/>
    </div>
</template>

<script>
    export default {
        data () {
            return {
                apps: [
                    {name: 'vue', path: 'https://cn.vuejs.org', opened: true},
                    {name: 'router', path: 'https://router.vuejs.org/zh/', keepAlive: true}
                ]
            };
        },
        methods: {
            onClickRouter () {
                // 调用 open 方法打开应用
                this.$apploader.open('router');
            }
        }
    }
</script>

支持的 API 方法有:

  • register 注册应用
  • unregister 注销应用
  • isRegistered 检测应用是否已注册
  • open 打开应用
  • close 关闭应用
  • refresh 刷新当前打开的应用
  • getCurrent 获取当前应用名