setting-center-core
Setting Center Core System - Complete pages and functionality for organizational management
643
| Install | |
|---|---|
npm install setting-center-core |
|
| Latest Version: | 1.0.0 |
| Vue: | 3 |
| License: | MIT |
| Last Updated: | Oct 10, 2025 |
| Links: | npm |
Maintainer: caojianyong0
@setting-center/core
设置中心核心包,提供完整的组织管理页面和功能。
安装
npm install @setting-center/core
# 或
yarn add @setting-center/core
# 或
pnpm add @setting-center/core
依赖项
确保您的项目中已安装以下依赖:
npm install vue@>=3.3.0 vue-router@>=4.2.0 pinia@>=2.1.0 vue-i18n@>=9.2.0 vuetify@>=3.5.0 @casl/ability@>=6.0.0 @iconify/vue@>=4.0.0
使用方法
1. 作为插件使用
import { createApp } from 'vue'
import { createRouter, createWebHistory } from 'vue-router'
import { createPinia } from 'pinia'
import { createI18n } from 'vue-i18n'
import { createSettingCenter } from '@setting-center/core'
const app = createApp(App)
const router = createRouter({ history: createWebHistory(), routes: [] })
const pinia = createPinia()
const i18n = createI18n({ locale: 'zh-CN', messages: {} })
// 安装设置中心插件
app.use(createSettingCenter({
basePath: '/setting-center', // 基础路由路径,可选,默认为'/setting-center'
router,
pinia,
i18n,
apiBaseURL: 'https://api.example.com', // API基础URL,可选
getAuthToken: () => localStorage.getItem('token'), // 获取认证token的函数,可选
onAuthError: (code) => console.error('认证错误:', code) // 认证错误处理函数,可选
}))
app.use(router)
app.use(pinia)
app.use(i18n)
app.mount('#app')
2. 仅使用路由
import { createRouter, createWebHistory } from 'vue-router'
import { settingCenterRoutes } from '@setting-center/core/routes'
const router = createRouter({
history: createWebHistory(),
routes: [
// 其他路由
...settingCenterRoutes
]
})
或者自定义路由路径:
import { createRouter, createWebHistory } from 'vue-router'
import { createSettingCenterRoutes } from '@setting-center/core'
const router = createRouter({
history: createWebHistory(),
routes: [
// 其他路由
createSettingCenterRoutes('/custom-path')
]
})
3. 引入样式
// 在入口文件中引入样式
import '@setting-center/core/styles'
主要功能
- 组织管理
- 角色权限管理
- 系统设置
- 用户管理
配置选项
| 选项 | 类型 | 描述 | 是否必需 |
|---|---|---|---|
| basePath | string | 基础路由路径 | 否,默认'/setting-center' |
| apiBaseURL | string | API基础URL | 否 |
| getAuthToken | function | 获取认证token的函数 | 否 |
| router | VueRouter | Vue Router实例 | 否 |
| pinia | Pinia | Pinia实例 | 否 |
| i18n | VueI18n | Vue I18n实例 | 否 |
| onAuthError | function | 认证错误处理函数 | 否 |
多语言支持
设置中心默认支持中英文两种语言:
- 中文 (zh-CN)
- 英文 (en)
多语言文件会自动合并到您的Vue I18n实例中。
开发
# 进入目录
cd packages/core
# 安装依赖
pnpm install
# 构建包
pnpm run build
许可证
MIT
Related Packages
Version History
| Version | Released | Vue | License |
|---|---|---|---|
| 1.0.0 | >=3.3.0 | MIT |