xto-fronted 0.1.7 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/README.md +4 -0
  2. package/dist/components/Login/index.vue.d.ts +15 -0
  3. package/dist/config/index.d.ts +25 -5
  4. package/dist/index.d.ts +17 -4
  5. package/dist/index.es.js +1272 -55
  6. package/dist/index.umd.js +1 -1
  7. package/dist/router/dynamicRoutes.d.ts +19 -25
  8. package/dist/router/index.d.ts +24 -4
  9. package/dist/router/staticRoutes.d.ts +15 -2
  10. package/dist/stores/menu.d.ts +14 -8
  11. package/dist/style.css +1 -1
  12. package/dist/utils/request.d.ts +8 -0
  13. package/package.json +2 -10
  14. package/.env.development +0 -3
  15. package/.env.production +0 -3
  16. package/dist/403-DM5wfQkM.js +0 -31
  17. package/dist/404-BurAu5LC.js +0 -31
  18. package/dist/index-BNiEld34.js +0 -15
  19. package/dist/index-Be9RiEfo.js +0 -98
  20. package/dist/index-BqRv1bdN.js +0 -1185
  21. package/dist/index-CQLVXvNJ.js +0 -15
  22. package/dist/index-CyiE8n2V.js +0 -15
  23. package/dist/index-xauR1bOL.js +0 -15
  24. package/dist/views/dashboard/index.vue.d.ts +0 -2
  25. package/dist/views/login/index.vue.d.ts +0 -4
  26. package/dist/views/system/menu/index.vue.d.ts +0 -2
  27. package/dist/views/system/role/index.vue.d.ts +0 -2
  28. package/dist/views/system/user/index.vue.d.ts +0 -2
  29. package/index.html +0 -13
  30. package/public/vite.svg +0 -10
  31. package/src/App.vue +0 -20
  32. package/src/api/auth.ts +0 -35
  33. package/src/api/menu.ts +0 -13
  34. package/src/api/system.ts +0 -65
  35. package/src/api/user.ts +0 -12
  36. package/src/assets/styles/_dark.scss +0 -407
  37. package/src/assets/styles/_reset.scss +0 -126
  38. package/src/assets/styles/_root.scss +0 -140
  39. package/src/assets/styles/_transition.scss +0 -119
  40. package/src/assets/styles/_variables.scss +0 -45
  41. package/src/assets/styles/index.scss +0 -187
  42. package/src/components/Layout/Footer.vue +0 -17
  43. package/src/components/Layout/Header.vue +0 -335
  44. package/src/components/Layout/Sidebar.vue +0 -213
  45. package/src/components/Layout/Tabs.vue +0 -20
  46. package/src/components/Layout/index.vue +0 -62
  47. package/src/composables/index.ts +0 -9
  48. package/src/composables/useApp.ts +0 -170
  49. package/src/composables/useAuth.ts +0 -70
  50. package/src/composables/useForm.ts +0 -79
  51. package/src/composables/useMenu.ts +0 -141
  52. package/src/composables/useTable.ts +0 -97
  53. package/src/config/index.ts +0 -19
  54. package/src/directives/permission.ts +0 -41
  55. package/src/enums/index.ts +0 -63
  56. package/src/env.d.ts +0 -17
  57. package/src/index.ts +0 -44
  58. package/src/main.ts +0 -29
  59. package/src/router/dynamicRoutes.ts +0 -163
  60. package/src/router/index.ts +0 -71
  61. package/src/router/staticRoutes.ts +0 -43
  62. package/src/stores/app.ts +0 -145
  63. package/src/stores/auth.ts +0 -45
  64. package/src/stores/index.ts +0 -15
  65. package/src/stores/menu.ts +0 -158
  66. package/src/stores/user.ts +0 -41
  67. package/src/types/api.d.ts +0 -103
  68. package/src/types/global.d.ts +0 -45
  69. package/src/types/router.d.ts +0 -48
  70. package/src/types/xto.d.ts +0 -149
  71. package/src/utils/auth.ts +0 -86
  72. package/src/utils/permission.ts +0 -30
  73. package/src/utils/request.ts +0 -126
  74. package/src/utils/storage.ts +0 -72
  75. package/src/views/dashboard/index.vue +0 -32
  76. package/src/views/error/403.vue +0 -57
  77. package/src/views/error/404.vue +0 -57
  78. package/src/views/login/index.vue +0 -141
  79. package/src/views/system/menu/index.vue +0 -32
  80. package/src/views/system/role/index.vue +0 -32
  81. package/src/views/system/user/index.vue +0 -32
  82. package/tsconfig.json +0 -26
  83. package/tsconfig.node.json +0 -11
  84. package/vite.config.ts +0 -139
  85. /package/dist/{views/error → components/Error}/403.vue.d.ts +0 -0
  86. /package/dist/{views/error → components/Error}/404.vue.d.ts +0 -0
package/src/index.ts DELETED
@@ -1,44 +0,0 @@
1
- // 组件
2
- export { default as Layout } from './components/Layout/index.vue'
3
- export { default as Header } from './components/Layout/Header.vue'
4
- export { default as Sidebar } from './components/Layout/Sidebar.vue'
5
- export { default as Tabs } from './components/Layout/Tabs.vue'
6
- export { default as Footer } from './components/Layout/Footer.vue'
7
-
8
- // 组合式函数
9
- export { useApp } from './composables/useApp'
10
- export { useAuth } from './composables/useAuth'
11
- export { useMenu } from './composables/useMenu'
12
- export { useForm } from './composables/useForm'
13
- export { useTable } from './composables/useTable'
14
-
15
- // 工具函数
16
- export * from './utils/auth'
17
- export * from './utils/permission'
18
- export * from './utils/request'
19
- export * from './utils/storage'
20
-
21
- // Store
22
- export * from './stores/app'
23
- export * from './stores/auth'
24
- export * from './stores/menu'
25
- export * from './stores/user'
26
-
27
- // 路由
28
- export { default as router, resetRouter } from './router'
29
- export * from './router/staticRoutes'
30
- export * from './router/dynamicRoutes'
31
-
32
- // API
33
- export * from './api/auth'
34
- export * from './api/menu'
35
- export * from './api/user'
36
-
37
- // 配置
38
- export { default as appConfig } from './config'
39
-
40
- // 枚举
41
- export * from './enums'
42
-
43
- // 指令
44
- export { default as permissionDirective } from './directives/permission'
package/src/main.ts DELETED
@@ -1,29 +0,0 @@
1
- import { createApp } from 'vue'
2
- import { createPinia } from 'pinia'
3
- import App from './App.vue'
4
- import router from './router'
5
-
6
- // 样式
7
- import '@/assets/styles/index.scss'
8
-
9
- // 组件库样式
10
- import '@xto/base/es/style.css'
11
- import '@xto/form/es/style.css'
12
- import '@xto/feedback/es/style.css'
13
- import '@xto/navigation/es/style.css'
14
-
15
- // 全局注册内部组件(解决 resolveComponent 问题)
16
- import { Loading } from '@xto/base'
17
-
18
- const app = createApp(App)
19
-
20
- // 注册内部组件
21
- app.component('x-loading', Loading)
22
-
23
- // Pinia
24
- app.use(createPinia())
25
-
26
- // Router
27
- app.use(router)
28
-
29
- app.mount('#app')
@@ -1,163 +0,0 @@
1
- /**
2
- * 动态路由模板
3
- */
4
-
5
- import type { RouteRecordRaw } from 'vue-router'
6
-
7
- // 布局路由(包含默认子路由)
8
- export const layoutRoute: RouteRecordRaw = {
9
- path: '/',
10
- name: 'Layout',
11
- component: () => import('@/components/Layout/index.vue'),
12
- redirect: '/dashboard',
13
- children: [
14
- {
15
- path: '/dashboard',
16
- name: 'Dashboard',
17
- component: () => import('@/views/dashboard/index.vue'),
18
- meta: {
19
- title: '仪表盘',
20
- icon: 'dashboard',
21
- keepAlive: true,
22
- affix: true
23
- }
24
- },
25
- {
26
- path: '/system/user',
27
- name: 'SystemUser',
28
- component: () => import('@/views/system/user/index.vue'),
29
- meta: {
30
- title: '用户管理',
31
- icon: 'user',
32
- keepAlive: true
33
- }
34
- },
35
- {
36
- path: '/system/role',
37
- name: 'SystemRole',
38
- component: () => import('@/views/system/role/index.vue'),
39
- meta: {
40
- title: '角色管理',
41
- icon: 'role',
42
- keepAlive: true
43
- }
44
- },
45
- {
46
- path: '/system/menu',
47
- name: 'SystemMenu',
48
- component: () => import('@/views/system/menu/index.vue'),
49
- meta: {
50
- title: '菜单管理',
51
- icon: 'menu',
52
- keepAlive: true
53
- }
54
- }
55
- ]
56
- }
57
-
58
- // 默认路由(用于开发,后续由后端返回)
59
- export const defaultDynamicRoutes: RouteRecordRaw[] = [
60
- {
61
- path: '/dashboard',
62
- name: 'Dashboard',
63
- component: () => import('@/views/dashboard/index.vue'),
64
- meta: {
65
- title: '仪表盘',
66
- icon: 'dashboard',
67
- keepAlive: true,
68
- affix: true
69
- }
70
- },
71
- {
72
- path: '/system',
73
- name: 'System',
74
- redirect: '/system/user',
75
- meta: {
76
- title: '系统管理',
77
- icon: 'setting'
78
- },
79
- children: [
80
- {
81
- path: 'user',
82
- name: 'SystemUser',
83
- component: () => import('@/views/system/user/index.vue'),
84
- meta: {
85
- title: '用户管理',
86
- icon: 'user',
87
- keepAlive: true
88
- }
89
- },
90
- {
91
- path: 'role',
92
- name: 'SystemRole',
93
- component: () => import('@/views/system/role/index.vue'),
94
- meta: {
95
- title: '角色管理',
96
- icon: 'role',
97
- keepAlive: true
98
- }
99
- },
100
- {
101
- path: 'menu',
102
- name: 'SystemMenu',
103
- component: () => import('@/views/system/menu/index.vue'),
104
- meta: {
105
- title: '菜单管理',
106
- icon: 'menu',
107
- keepAlive: true
108
- }
109
- }
110
- ]
111
- }
112
- ]
113
-
114
- // Mock 菜单数据
115
- export const mockMenuData = [
116
- {
117
- id: 1,
118
- name: 'Dashboard',
119
- path: '/dashboard',
120
- component: 'dashboard/index',
121
- icon: 'dashboard',
122
- title: '仪表盘',
123
- keepAlive: true,
124
- affix: true
125
- },
126
- {
127
- id: 2,
128
- name: 'System',
129
- path: '/system',
130
- redirect: '/system/user',
131
- icon: 'setting',
132
- title: '系统管理',
133
- children: [
134
- {
135
- id: 21,
136
- name: 'SystemUser',
137
- path: '/system/user',
138
- component: 'system/user/index',
139
- icon: 'user',
140
- title: '用户管理',
141
- keepAlive: true
142
- },
143
- {
144
- id: 22,
145
- name: 'SystemRole',
146
- path: '/system/role',
147
- component: 'system/role/index',
148
- icon: 'role',
149
- title: '角色管理',
150
- keepAlive: true
151
- },
152
- {
153
- id: 23,
154
- name: 'SystemMenu',
155
- path: '/system/menu',
156
- component: 'system/menu/index',
157
- icon: 'menu',
158
- title: '菜单管理',
159
- keepAlive: true
160
- }
161
- ]
162
- }
163
- ]
@@ -1,71 +0,0 @@
1
- /**
2
- * 路由配置
3
- */
4
-
5
- import { createRouter, createWebHistory } from 'vue-router'
6
- import { staticRoutes, errorRoute } from './staticRoutes'
7
- import { layoutRoute } from './dynamicRoutes'
8
- import { hasToken } from '@/utils/auth'
9
- import { useAppStore } from '@/stores/app'
10
- import { useApp } from '@/composables'
11
-
12
- const router = createRouter({
13
- history: createWebHistory(),
14
- routes: [...staticRoutes, layoutRoute, errorRoute],
15
- scrollBehavior: () => ({ left: 0, top: 0 })
16
- })
17
-
18
- // 白名单路由
19
- const whiteList = ['/login', '/404', '/403']
20
-
21
- // 路由守卫
22
- router.beforeEach(async (to, _from, next) => {
23
- const appStore = useAppStore()
24
-
25
- // 初始化主题
26
- appStore.initTheme()
27
-
28
- // 已登录
29
- if (hasToken()) {
30
- if (to.path === '/login') {
31
- // 已登录,跳转到首页
32
- next({ path: '/' })
33
- } else {
34
- // 初始化应用(加载用户信息和菜单)
35
- const { initApp, isLoggedIn } = useApp()
36
-
37
- if (!isLoggedIn.value) {
38
- const success = await initApp()
39
- if (!success) {
40
- // 初始化失败,跳转登录页
41
- next('/login')
42
- return
43
- }
44
- }
45
-
46
- // 添加缓存页面
47
- if (to.name && to.meta.keepAlive) {
48
- appStore.addCachedView(to.name as string)
49
- }
50
- next()
51
- }
52
- } else {
53
- // 未登录
54
- if (whiteList.includes(to.path)) {
55
- next()
56
- } else {
57
- // 记录当前路径,登录后跳转
58
- next({ path: '/login', query: { redirectUrl: encodeURIComponent(to.fullPath) } })
59
- }
60
- }
61
- })
62
-
63
- export function resetRouter() {
64
- const newRouter = createRouter({
65
- history: createWebHistory(),
66
- routes: [...staticRoutes, layoutRoute, errorRoute]
67
- })
68
- ;(router as any).matcher = (newRouter as any).matcher
69
- }
70
-
71
- export default router
@@ -1,43 +0,0 @@
1
- /**
2
- * 静态路由
3
- */
4
-
5
- import type { RouteRecordRaw } from 'vue-router'
6
-
7
- export const staticRoutes: RouteRecordRaw[] = [
8
- {
9
- path: '/login',
10
- name: 'Login',
11
- component: () => import('@/views/login/index.vue'),
12
- meta: {
13
- title: '登录',
14
- hidden: true
15
- }
16
- },
17
- {
18
- path: '/404',
19
- name: 'NotFound',
20
- component: () => import('@/views/error/404.vue'),
21
- meta: {
22
- title: '404',
23
- hidden: true
24
- }
25
- },
26
- {
27
- path: '/403',
28
- name: 'Forbidden',
29
- component: () => import('@/views/error/403.vue'),
30
- meta: {
31
- title: '403',
32
- hidden: true
33
- }
34
- }
35
- ]
36
-
37
- export const errorRoute: RouteRecordRaw = {
38
- path: '/:pathMatch(.*)*',
39
- redirect: '/404',
40
- meta: {
41
- hidden: true
42
- }
43
- }
package/src/stores/app.ts DELETED
@@ -1,145 +0,0 @@
1
- /**
2
- * 应用状态
3
- */
4
-
5
- import { defineStore } from 'pinia'
6
- import { ref, computed, watch } from 'vue'
7
- import { local } from '@/utils/storage'
8
-
9
- export type ThemeMode = 'light' | 'dark'
10
- export type LayoutMode = 'sidebar' | 'top' | 'mix'
11
-
12
- export const useAppStore = defineStore('app', () => {
13
- // 状态
14
- const isDark = ref<boolean>(local.get<boolean>('isDark') || false)
15
- const theme = ref<ThemeMode>(local.get<ThemeMode>('theme') || 'light')
16
- const layout = ref<LayoutMode>(local.get<LayoutMode>('layout') || 'sidebar')
17
- const isCollapsed = ref<boolean>(local.get<boolean>('isCollapsed') || false)
18
- const showTabs = ref<boolean>(local.get<boolean>('showTabs') ?? true)
19
- const showFooter = ref<boolean>(local.get<boolean>('showFooter') ?? true)
20
- const showBreadcrumb = ref<boolean>(local.get<boolean>('showBreadcrumb') ?? true)
21
- const primaryColor = ref<string>(local.get<string>('primaryColor') || '#409eff')
22
- const cachedViews = ref<string[]>([])
23
-
24
- // 计算属性
25
- const themeClass = computed(() => (isDark.value ? 'dark' : 'light'))
26
-
27
- // 切换主题
28
- const toggleTheme = () => {
29
- isDark.value = !isDark.value
30
- theme.value = isDark.value ? 'dark' : 'light'
31
- updateTheme()
32
- }
33
-
34
- // 设置主题
35
- const setTheme = (mode: ThemeMode) => {
36
- theme.value = mode
37
- isDark.value = mode === 'dark'
38
- updateTheme()
39
- }
40
-
41
- // 更新主题
42
- const updateTheme = () => {
43
- const html = document.documentElement
44
- if (isDark.value) {
45
- html.classList.add('dark')
46
- } else {
47
- html.classList.remove('dark')
48
- }
49
- local.set('isDark', isDark.value)
50
- local.set('theme', theme.value)
51
- }
52
-
53
- // 切换菜单折叠
54
- const toggleCollapse = () => {
55
- isCollapsed.value = !isCollapsed.value
56
- local.set('isCollapsed', isCollapsed.value)
57
- }
58
-
59
- // 设置布局
60
- const setLayout = (mode: LayoutMode) => {
61
- layout.value = mode
62
- local.set('layout', mode)
63
- }
64
-
65
- // 切换标签页
66
- const toggleTabs = () => {
67
- showTabs.value = !showTabs.value
68
- local.set('showTabs', showTabs.value)
69
- }
70
-
71
- // 切换底部
72
- const toggleFooter = () => {
73
- showFooter.value = !showFooter.value
74
- local.set('showFooter', showFooter.value)
75
- }
76
-
77
- // 切换面包屑
78
- const toggleBreadcrumb = () => {
79
- showBreadcrumb.value = !showBreadcrumb.value
80
- local.set('showBreadcrumb', showBreadcrumb.value)
81
- }
82
-
83
- // 设置主题色
84
- const setPrimaryColor = (color: string) => {
85
- primaryColor.value = color
86
- document.documentElement.style.setProperty('--color-primary', color)
87
- local.set('primaryColor', color)
88
- }
89
-
90
- // 添加缓存页面
91
- const addCachedView = (name: string) => {
92
- if (!cachedViews.value.includes(name)) {
93
- cachedViews.value.push(name)
94
- }
95
- }
96
-
97
- // 移除缓存页面
98
- const removeCachedView = (name: string) => {
99
- const index = cachedViews.value.indexOf(name)
100
- if (index > -1) {
101
- cachedViews.value.splice(index, 1)
102
- }
103
- }
104
-
105
- // 清除缓存页面
106
- const clearCachedViews = () => {
107
- cachedViews.value = []
108
- }
109
-
110
- // 初始化主题
111
- const initTheme = () => {
112
- updateTheme()
113
- if (primaryColor.value !== '#409eff') {
114
- document.documentElement.style.setProperty('--color-primary', primaryColor.value)
115
- }
116
- }
117
-
118
- // 监听主题变化
119
- watch(isDark, updateTheme)
120
-
121
- return {
122
- isDark,
123
- theme,
124
- layout,
125
- isCollapsed,
126
- showTabs,
127
- showFooter,
128
- showBreadcrumb,
129
- primaryColor,
130
- cachedViews,
131
- themeClass,
132
- toggleTheme,
133
- toggleCollapse,
134
- setTheme,
135
- setLayout,
136
- toggleTabs,
137
- toggleFooter,
138
- toggleBreadcrumb,
139
- setPrimaryColor,
140
- addCachedView,
141
- removeCachedView,
142
- clearCachedViews,
143
- initTheme
144
- }
145
- })
@@ -1,45 +0,0 @@
1
- /**
2
- * 认证状态
3
- */
4
-
5
- import { defineStore } from 'pinia'
6
- import { ref, computed } from 'vue'
7
- import { getLoginInfo, setLoginInfo, clearToken, hasToken } from '@/utils/auth'
8
- import type { LoginInfo } from '@/utils/auth'
9
-
10
- export const useAuthStore = defineStore('auth', () => {
11
- // 状态
12
- const loginInfo = ref<LoginInfo | null>(getLoginInfo())
13
- const isLoggedIn = computed(() => hasToken())
14
-
15
- // 设置登录信息
16
- const login = (data: Record<string, unknown>) => {
17
- setLoginInfo(data)
18
- loginInfo.value = getLoginInfo()
19
- }
20
-
21
- // 登出
22
- const logout = () => {
23
- loginInfo.value = null
24
- clearToken()
25
- }
26
-
27
- // 获取 access token
28
- const accessToken = computed(() => loginInfo.value?.accessToken || null)
29
-
30
- // 获取 token type
31
- const tokenType = computed(() => loginInfo.value?.tokenType || 'Bearer')
32
-
33
- // 获取 code
34
- const code = computed(() => loginInfo.value?.code || null)
35
-
36
- return {
37
- loginInfo,
38
- isLoggedIn,
39
- accessToken,
40
- tokenType,
41
- code,
42
- login,
43
- logout
44
- }
45
- })
@@ -1,15 +0,0 @@
1
- /**
2
- * Pinia Store 入口
3
- */
4
-
5
- import { createPinia } from 'pinia'
6
-
7
- const pinia = createPinia()
8
-
9
- export default pinia
10
-
11
- // 导出所有 stores
12
- export * from './user'
13
- export * from './auth'
14
- export * from './menu'
15
- export * from './app'