1.1.39 • Published 6 months ago

@witlink/usercenter v1.1.39

Weekly downloads
-
License
ISC
Repository
-
Last release
6 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

6 months ago

1.1.28

6 months ago

1.1.30

6 months ago

1.1.34

6 months ago

1.1.33

6 months ago

1.1.32

6 months ago

1.1.31

6 months ago

1.1.38

6 months ago

1.1.37

6 months ago

1.1.36

6 months ago

1.1.35

6 months ago

1.1.39

6 months ago

1.1.9

6 months ago

1.1.8

6 months ago

1.1.12

6 months ago

1.1.11

6 months ago

1.1.10

6 months ago

1.1.16

6 months ago

1.1.15

6 months ago

1.1.14

6 months ago

1.1.13

6 months ago

1.1.19

6 months ago

1.1.18

6 months ago

1.1.17

6 months ago

1.1.23

6 months ago

1.1.22

6 months ago

1.1.21

6 months ago

1.1.20

6 months ago

1.1.27

6 months ago

1.1.26

6 months ago

1.1.25

6 months ago

1.1.24

6 months ago

1.1.7

6 months ago

1.1.6

6 months ago

1.1.5

6 months ago

1.1.4

6 months ago

1.1.3

6 months ago

1.0.37

6 months ago

1.1.1

6 months ago

1.1.0

6 months ago

1.0.39

6 months ago

1.0.38

6 months ago

1.1.2

6 months ago

1.0.40

6 months ago

1.0.44

6 months ago

1.0.43

6 months ago

1.0.42

6 months ago

1.0.41

6 months ago

1.0.48

6 months ago

1.0.47

6 months ago

1.0.46

6 months ago

1.0.45

6 months ago

1.0.49

6 months ago

1.0.51

6 months ago

1.0.50

6 months ago

1.0.54

6 months ago

1.0.53

6 months ago

1.0.52

6 months ago

1.0.33

6 months ago

1.0.32

6 months ago

1.0.31

6 months ago

1.0.36

6 months ago

1.0.35

6 months ago

1.0.34

6 months ago

1.0.30

6 months ago

1.0.29

6 months ago

1.0.28

6 months ago

1.0.27

6 months ago

1.0.26

6 months ago

1.0.25

6 months ago

1.0.24

6 months ago

1.0.23

7 months ago

1.0.22

7 months ago

1.0.21

7 months ago

1.0.20

7 months ago

1.0.19

7 months ago

1.0.18

7 months ago

1.0.17

7 months ago

1.0.16

7 months ago

1.0.15

7 months ago

1.0.14

7 months ago

1.0.13

7 months ago

1.0.12

7 months ago

1.0.11

7 months ago

1.0.10

7 months ago

1.0.9

7 months ago

1.0.8

7 months ago

1.0.7

7 months ago

1.0.6

7 months ago

1.0.5

7 months ago

1.0.4

7 months ago

1.0.3

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago