aviana-plugin-vue

Aviana前端微应用插件

Usage no npm install needed!

<script type="module">
  import avianaPluginVue from 'https://cdn.skypack.dev/aviana-plugin-vue';
</script>

README

Aviana 前端微应用插件(Vue 版本),基于 axios, vue-router, Element UI, lodash

** 插件说明 **

  1. 插件使用:
import AvianaPlugin from "aviana-plugin-vue";
Vue.use(AvianaPlugin, {
  entry: App,
  routes: routes,
  store: store,
  config: config,
});

const { start, bootstrap, mount, unmount } = AvianaPlugin;
export { bootstrap, mount, unmount };
start();
  1. 插件提供:
1. 封装微应用的注册逻辑
2. 全局的 $http 对象,通过config中的httpConfig, httpMock注册接口及mock数据
    提供设置独立运行时Token及网络状态获取方法 { setIsolatedToken, getHttpInfo }
    提供网络调用方法 { domain, fileDomain, get, getBy, post, update, remove, removeBy }
3. 全局的 $iac 对象,提供发布消息,监听消息,获取全局数据等方法
    提供应用间通信方法 { name, obtainApp, open, set, get, getOwn, emit, on, once, release, call, callOwn }
4. 全局混入响应式的 userInfo, companyInfo, token
5. 可在 config 配置defaultUser, defaultCompany, mock用于单应用开发调试
6. 全局的 log 方法,可在 template 中直接打印变量值进行调试

** 发布 NPM 包到 Github Packages **

  1. 在 Github 申请一个 TOKEN, 用来发布和获取 npm 包
  2. 在本项目的根目录添加 .npmrc 文件,并添加如下配置 registry=https://npm.pkg.github.com //npm.pkg.github.com/:_authToken=TOKEN
  3. 在 package.json 中更新版本号, npm run build:lib 打包库文件
  4. npm publish 发布包到 Github

** 其他工程获取 NPM 包 **

  1. 在 package.json 添加依赖 "@ucloudcastle/aviana-plugin-vue": "^x.x.x"
  2. 拷贝本项目下的 .npmrc 文件
  3. npm install

** 发布 NPM 包到 npmjs **

  1. https://www.npmjs.com/ 注册账户并申请 Token, 用来发布和获取 npm 包
  2. 在本项目的根目录添加 .npmrc 文件,并添加如下配置 registry=http://registry.npmjs.org //registry.npmjs.org/:_authToken=TOKEN
  3. 在 package.json 中更新版本号, npm run build:lib 打包库文件
  4. npm publish 发布包到 npmjs

** 其他工程获取 NPM 包 **

  1. 在 package.json 添加依赖 "aviana-plugin-vue": "^x.x.x"
  2. npm install

** 代码打包说明 ** npm run build builds the library to dist, generating three files:

  • dist/aviana-plugin-vue.cjs.js A CommonJS bundle, suitable for use in Node.js, that requires the external dependency. This corresponds to the "main" field in package.json
  • dist/dist/aviana-plugin-vue.esm.js an ES module bundle, suitable for use in other people's libraries and applications, that imports the external dependency. This corresponds to the "module" field in package.json
  • dist/dist/aviana-plugin-vue.umd.js a UMD build, suitable for use in any environment (including the browser, as a <script> tag), that includes the external dependency. This corresponds to the "browser" field in package.json

npm run dev builds the library, then keeps rebuilding it whenever the source files change using rollup-watch.

npm test builds the library, then tests it.