@chidiui/base-platform

基础平台-后台管理包

Usage no npm install needed!

<script type="module">
  import chidiuiBasePlatform from 'https://cdn.skypack.dev/@chidiui/base-platform';
</script>

README

基础平台

  • 成勘院数字分公司研发中心专用包

说明

  1. 为避免与其他组件冲突,基础平台所有组件都添加有bp(base-platform)前缀
  2. 此包强制依赖一下第三方库:
    • axios
    • vue
    • element-ui
    • moment
    • js-md5
    • vue-json-viewer
  3. 在引入包之前请确保element-ui已初始化
  4. 此组件强依赖于vuex,并需要业务系统在主业务store中的getters中配置current对象,current对象为/api/current接口返回的data数据
// 示例
export const getters = {
  current : state => state.user.loginInfo
}
  1. 引入Permission组件,根据当前用户所拥有的权限以及所用有的角色,决定此组件下的内容是否渲染,此组件强依赖于store.getters.current
<template>
  <!--
    1、此组件如果不传入code属性,则permission下的内容默认渲染
    2、code = String | Array, excludeRole = String | Array
    3、不传入code,子组件默认渲染
    4、current.permissons中如果包含code传入的内容,渲染
    5、如果current.permissions中不能匹配,而excludeRole能与current.roles相匹配,也能渲染
  -->
  <permission code="run" exclude-role="super">
    <el-button>测试</el-button>
  </permission>
</template>

组件地图

用法

// 在业务系统入口文件中添加以下逻辑
// 基础平台包必须在系统登录成功后进行初始化
import Vue from 'vue'; 
import basePlatform from '@chidiui/base-platform';

Vue.use(basePlatform);
/* NOTE: 基础平台初始化 结束*/

// TODO: 其他业务逻辑

系统参数的获取

  • 基础平台在载入后会自动获取以下后端系统配置参数
    1. 密码是否需要md5加密
    2. 系统登录是否需要验证码
    3. jwt参数名
    4. 业务通知id
    5. 系统默认密码
  • 在业务系统的开发中,这些参数不必在额外发送请求获取,通过基础平台提供的api直接获取即可
  • 示例
/**
 * 获取系统配置信息
 * getSystemConfig (configName) : any;
**/
import { getSystemConfig } from '@chidiui/base-platform';

// 获取系统密码是否需要md5加密配置
const needMd5 = getSystemConfig('needMd5');
// 获取系统是否需要严重吗功能
const needkaptcha = getSystemConfig('needkaptcha');
// 获取系统传递token时的参数名,作为请求header参数或者params参数使用
const jwtParamName = getSystemConfig('jwtParamName');
// 获取系统websocket业务消息id
const noticeBusinessId = getSystemConfig('noticeBusinessId');
// 获取系统默认密码
const defaultPwd = getSystemConfig('defaultPwd');
// 获取当前登录用户
const current = getSystemConfig('current');

单组件用法

import {BpApi} from '@chidiui/base-platform';

export defualt {
  components : {
    BpApi
  }
};