1.1.39 • Published 9 months ago

@witlink/usercenter v1.1.39

Weekly downloads
-
License
ISC
Repository
-
Last release
9 months ago

@witlink/usercenter lib库介绍

用户中心的用户管理、角色管理、菜单管理和组织机构管理页面,在内部多系统都有使用需要。而且页面的功能、交互逻辑差异不大。因此,希望用户中心在作为独立的管理系统的同时,还可以将部分页面提供给其他系统使用。

如何发布npm包

如何发布npm包

如何使用@witlink/usercenter包

1. 安装@witlink/usercenter包
npm install @witlink/usercenter
2. 使用@witlink/usercenter包
import {
  changeLanguage,     // 切换多语言方法
  changeTheme,        // 切换用户中心页面主题颜色
  UserCenter,         // 用户中心初始化注册内部使用的 vue-i18n、pinia等
  setToken,           // 存储token到localStorage的方法

  // 以下为组件
  SysFunctions,       // 菜单管理
  SysOrgan,           // 组织架构管理
  SysRole,            // 角色管理
  SysUser,            // 用户管理
  SysUserInfo,        //个人中心 
} from '@witlink/usercenter'
  • 初始化用户中心
// 在应用初始化时调用该方法
import { UserCenter } from "@witlink/usercenter"

const app = createApp(App)

// i18n 为vue-i18n实例  pinia 为pinia实例
// export interface UserCenterOptions {
//   lang?: LangType
//   i18n: any
//   pinia?: any
//   themeColor?: ColorOptions
// }

app.use(UserCenter, {
  i18n,
  pinia, // 设置用户中心store 如果在主系统已加载piniaPluginPersistedstate 持久化插件则不需要设置
  lang: 'zh_CN',
  themeColor: {
    colorPrimary: '#1677ff',
  },
}) // 引入用户中心Portal
  • 存储token到localStorage的方法
// 在登录成功后获取到token和token变化后调用setToken
import { setToken } from "@witlink/usercenter"
const token = 'xxx'
setToken(token: string)
  • 切换多语言
// 在应用初始化和切换多语言时调用该方法
import { changeLanguage } from "@witlink/usercenter"
type LangType = 'zh_CN' | 'en_US' | 'fr_FR'
changeLanguage(lang: LangType)
  • 切换用户中心页面主题颜色
import { changeTheme } from "@witlink/usercenter";
export interface ColorOptions {
  colorPrimary?: string
  colorPrimaryBorder?: string
  colorPrimaryBorderHover?: string
  colorPrimaryText?: string
  colorPrimaryTextActive?: string
  colorPrimaryTextHover?: string
  colorLink?: string
  colorLinkHover?: string
  colorLinkActive?: string
}
const options: ColorOptions = {
  colorPrimary: '#1677ff',
}
changeTheme(options)
  • usercenter页面的使用
import {
  SysFunctions,       // 菜单管理
  SysOrgan,           // 组织架构管理
  SysRole,            // 角色管理
  SysUser,            // 用户管理
} from '@witlink/usercenter'

// 创建路由实例
const router = createRouter({
  history: createWebHashHistory(),
  routes: [
    {
      path: "/role",
      name: "role",
      component: SysRole,
      meta: {
        title: "角色管理",
      },
    },
    {
      path: "/user",
      name: "user",
      component: SysUser,
      meta: {
        title: "用户管理",
      },
    },
    {
      path: "/functions",
      name: "functions",
      component: SysFunctions,
      meta: {
        title: "菜单管理",
      },
    },
    {
      path: "/organ",
      name: "organ",
      component: SysOrgan,
      meta: {
        title: "组织机构管理",
      },
    },
  ],
  scrollBehavior: () => ({ left: 0, top: 0 }),
});

export default router;
  • 用户中心接口转发配置
// 在开发环境
// vite.config.ts中
 server: {
    host: true,
    cors: true,
    proxy: {
      '/usercenter/api': {
        target: 'https://192.168.2.240', //目标url
        changeOrigin: true, //支持跨域
        secure: false, // 跳过 HTTPS 证书检查
      },
    },
  },
# 配置nginx转发
location /usercenter/api/ {
  # proxy_pass  http://webhost;
  proxy_pass  http://https://192.168.2.240;
}
1.1.29

9 months ago

1.1.28

9 months ago

1.1.30

9 months ago

1.1.34

9 months ago

1.1.33

9 months ago

1.1.32

9 months ago

1.1.31

9 months ago

1.1.38

9 months ago

1.1.37

9 months ago

1.1.36

9 months ago

1.1.35

9 months ago

1.1.39

9 months ago

1.1.9

9 months ago

1.1.8

9 months ago

1.1.12

9 months ago

1.1.11

9 months ago

1.1.10

9 months ago

1.1.16

9 months ago

1.1.15

9 months ago

1.1.14

9 months ago

1.1.13

9 months ago

1.1.19

9 months ago

1.1.18

9 months ago

1.1.17

9 months ago

1.1.23

9 months ago

1.1.22

9 months ago

1.1.21

9 months ago

1.1.20

9 months ago

1.1.27

9 months ago

1.1.26

9 months ago

1.1.25

9 months ago

1.1.24

9 months ago

1.1.7

9 months ago

1.1.6

9 months ago

1.1.5

9 months ago

1.1.4

9 months ago

1.1.3

9 months ago

1.0.37

10 months ago

1.1.1

9 months ago

1.1.0

9 months ago

1.0.39

10 months ago

1.0.38

10 months ago

1.1.2

9 months ago

1.0.40

10 months ago

1.0.44

9 months ago

1.0.43

10 months ago

1.0.42

10 months ago

1.0.41

10 months ago

1.0.48

9 months ago

1.0.47

9 months ago

1.0.46

9 months ago

1.0.45

9 months ago

1.0.49

9 months ago

1.0.51

9 months ago

1.0.50

9 months ago

1.0.54

9 months ago

1.0.53

9 months ago

1.0.52

9 months ago

1.0.33

10 months ago

1.0.32

10 months ago

1.0.31

10 months ago

1.0.36

10 months ago

1.0.35

10 months ago

1.0.34

10 months ago

1.0.30

10 months ago

1.0.29

10 months ago

1.0.28

10 months ago

1.0.27

10 months ago

1.0.26

10 months ago

1.0.25

10 months ago

1.0.24

10 months ago

1.0.23

10 months ago

1.0.22

10 months ago

1.0.21

10 months ago

1.0.20

10 months ago

1.0.19

10 months ago

1.0.18

10 months ago

1.0.17

10 months ago

1.0.16

10 months ago

1.0.15

10 months ago

1.0.14

10 months ago

1.0.13

10 months ago

1.0.12

10 months ago

1.0.11

10 months ago

1.0.10

10 months ago

1.0.9

10 months ago

1.0.8

10 months ago

1.0.7

10 months ago

1.0.6

10 months ago

1.0.5

10 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago