xto-fronted 0.1.7 → 0.1.8

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 +23 -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
@@ -1,126 +0,0 @@
1
- /**
2
- * Axios 请求封装
3
- */
4
-
5
- import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse, InternalAxiosRequestConfig } from 'axios'
6
- import { getToken, getTokenType, clearToken } from './auth'
7
- import { Message } from '@xto/feedback'
8
- import config from '@/config'
9
-
10
- // 响应数据接口
11
- export interface ApiResponse<T = unknown> {
12
- code: number
13
- data: T
14
- message: string
15
- }
16
-
17
- // 分页参数
18
- export interface PageParams {
19
- page: number
20
- pageSize: number
21
- }
22
-
23
- // 分页响应
24
- export interface PageResponse<T> {
25
- list: T[]
26
- total: number
27
- page: number
28
- pageSize: number
29
- }
30
-
31
- // 创建 axios 实例
32
- const createRequest = (): AxiosInstance => {
33
- const instance = axios.create({
34
- baseURL: config.baseUrl,
35
- timeout: 15000,
36
- headers: {
37
- 'Content-Type': 'application/json'
38
- }
39
- })
40
-
41
- // 请求拦截器
42
- instance.interceptors.request.use(
43
- (config: InternalAxiosRequestConfig) => {
44
- const token = getToken()
45
- if (token) {
46
- const tokenType = getTokenType()
47
- config.headers.Authorization = `${tokenType} ${token}`
48
- }
49
- return config
50
- },
51
- (error) => {
52
- return Promise.reject(error)
53
- }
54
- )
55
-
56
- // 响应拦截器
57
- instance.interceptors.response.use(
58
- (response: AxiosResponse<ApiResponse>) => {
59
- const { data } = response
60
-
61
- // 成功
62
- if (data.code === 200 || data.code === 0) {
63
- return response
64
- }
65
-
66
- // 业务错误
67
- Message.error(data.message || '请求失败')
68
- return Promise.reject(new Error(data.message || '请求失败'))
69
- },
70
- (error) => {
71
- const { response } = error
72
-
73
- if (response) {
74
- switch (response.status) {
75
- case 401:
76
- case 403:
77
- Message.error('登录已过期,请重新登录')
78
- clearToken()
79
- window.location.href = '/login'
80
- break
81
- case 404:
82
- Message.error('请求资源不存在')
83
- break
84
- case 500:
85
- Message.error('服务器错误')
86
- break
87
- default:
88
- Message.error(response.data?.message || '请求失败')
89
- }
90
- } else {
91
- Message.error('网络连接失败')
92
- }
93
-
94
- return Promise.reject(error)
95
- }
96
- )
97
-
98
- return instance
99
- }
100
-
101
- const request = createRequest()
102
-
103
- // 请求方法
104
- export const http = {
105
- get<T = unknown>(url: string, config?: AxiosRequestConfig): Promise<ApiResponse<T>> {
106
- return request.get(url, config).then((res) => res.data)
107
- },
108
-
109
- post<T = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<ApiResponse<T>> {
110
- return request.post(url, data, config).then((res) => res.data)
111
- },
112
-
113
- put<T = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<ApiResponse<T>> {
114
- return request.put(url, data, config).then((res) => res.data)
115
- },
116
-
117
- patch<T = unknown>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<ApiResponse<T>> {
118
- return request.patch(url, data, config).then((res) => res.data)
119
- },
120
-
121
- delete<T = unknown>(url: string, config?: AxiosRequestConfig): Promise<ApiResponse<T>> {
122
- return request.delete(url, config).then((res) => res.data)
123
- }
124
- }
125
-
126
- export default request
@@ -1,72 +0,0 @@
1
- /**
2
- * 本地存储封装
3
- */
4
-
5
- import config from '@/config'
6
-
7
- // toboyu-cloud 格式的 key 前缀
8
- const getPrefix = (): string => {
9
- return `tooyu-cloud:${config.appId}:`
10
- }
11
-
12
- interface StorageWrapper {
13
- get<T>(key: string): T | null
14
- set(key: string, value: unknown): void
15
- remove(key: string): void
16
- clear(): void
17
- }
18
-
19
- const createStorage = (storage: globalThis.Storage): StorageWrapper => {
20
- return {
21
- get<T>(key: string): T | null {
22
- const prefix = getPrefix()
23
- const value = storage.getItem(prefix + key)
24
- if (!value) return null
25
- try {
26
- return JSON.parse(value) as T
27
- } catch {
28
- return value as unknown as T
29
- }
30
- },
31
- set(key: string, value: unknown): void {
32
- const prefix = getPrefix()
33
- if (value === null || value === undefined) {
34
- storage.removeItem(prefix + key)
35
- return
36
- }
37
- const stringValue = typeof value === 'string' ? value : JSON.stringify(value)
38
- storage.setItem(prefix + key, stringValue)
39
- },
40
- remove(key: string): void {
41
- const prefix = getPrefix()
42
- storage.removeItem(prefix + key)
43
- },
44
- clear(): void {
45
- const prefix = getPrefix()
46
- const keys = Object.keys(storage)
47
- keys.forEach(key => {
48
- if (key.startsWith(prefix)) {
49
- storage.removeItem(key)
50
- }
51
- })
52
- }
53
- }
54
- }
55
-
56
- export const localStorageUtil = createStorage(window.localStorage)
57
- export const sessionStorageUtil = createStorage(window.sessionStorage)
58
-
59
- // 快捷方法
60
- export const local = {
61
- get: localStorageUtil.get,
62
- set: localStorageUtil.set,
63
- remove: localStorageUtil.remove,
64
- clear: localStorageUtil.clear
65
- }
66
-
67
- export const session = {
68
- get: sessionStorageUtil.get,
69
- set: sessionStorageUtil.set,
70
- remove: sessionStorageUtil.remove,
71
- clear: sessionStorageUtil.clear
72
- }
@@ -1,32 +0,0 @@
1
- <script setup lang="ts">
2
- </script>
3
-
4
- <template>
5
- <div class="dashboard">
6
- <div class="dashboard__placeholder">
7
- <h2>首页</h2>
8
- <p>功能开发中...</p>
9
- </div>
10
- </div>
11
- </template>
12
-
13
- <style lang="scss" scoped>
14
- .dashboard {
15
- padding: 20px;
16
- height: 100%;
17
-
18
- &__placeholder {
19
- display: flex;
20
- flex-direction: column;
21
- align-items: center;
22
- justify-content: center;
23
- height: 100%;
24
- color: var(--color-text-secondary);
25
-
26
- h2 {
27
- margin-bottom: 10px;
28
- color: var(--color-text-primary);
29
- }
30
- }
31
- }
32
- </style>
@@ -1,57 +0,0 @@
1
- <script setup lang="ts">
2
- import { useRouter } from 'vue-router'
3
- import { Button } from '@xto/base'
4
-
5
- const router = useRouter()
6
-
7
- const goBack = () => {
8
- router.push('/')
9
- }
10
- </script>
11
-
12
- <template>
13
- <div class="error-page">
14
- <div class="error-page__content">
15
- <div class="error-page__code">403</div>
16
- <div class="error-page__title">无访问权限</div>
17
- <div class="error-page__desc">抱歉,您没有权限访问此页面</div>
18
- <Button type="primary" @click="goBack">返回首页</Button>
19
- </div>
20
- </div>
21
- </template>
22
-
23
- <style lang="scss" scoped>
24
- .error-page {
25
- width: 100%;
26
- height: 100vh;
27
- display: flex;
28
- align-items: center;
29
- justify-content: center;
30
- background-color: var(--bg-color-page);
31
-
32
- &__content {
33
- text-align: center;
34
- }
35
-
36
- &__code {
37
- font-size: 120px;
38
- font-weight: 600;
39
- color: var(--color-warning);
40
- line-height: 1;
41
- margin-bottom: 20px;
42
- }
43
-
44
- &__title {
45
- font-size: 24px;
46
- font-weight: 500;
47
- color: var(--color-text-primary);
48
- margin-bottom: 10px;
49
- }
50
-
51
- &__desc {
52
- font-size: 14px;
53
- color: var(--color-text-secondary);
54
- margin-bottom: 30px;
55
- }
56
- }
57
- </style>
@@ -1,57 +0,0 @@
1
- <script setup lang="ts">
2
- import { useRouter } from 'vue-router'
3
- import { Button } from '@xto/base'
4
-
5
- const router = useRouter()
6
-
7
- const goBack = () => {
8
- router.push('/')
9
- }
10
- </script>
11
-
12
- <template>
13
- <div class="error-page">
14
- <div class="error-page__content">
15
- <div class="error-page__code">404</div>
16
- <div class="error-page__title">页面不存在</div>
17
- <div class="error-page__desc">抱歉,您访问的页面不存在或已被删除</div>
18
- <Button type="primary" @click="goBack">返回首页</Button>
19
- </div>
20
- </div>
21
- </template>
22
-
23
- <style lang="scss" scoped>
24
- .error-page {
25
- width: 100%;
26
- height: 100vh;
27
- display: flex;
28
- align-items: center;
29
- justify-content: center;
30
- background-color: var(--bg-color-page);
31
-
32
- &__content {
33
- text-align: center;
34
- }
35
-
36
- &__code {
37
- font-size: 120px;
38
- font-weight: 600;
39
- color: var(--color-primary);
40
- line-height: 1;
41
- margin-bottom: 20px;
42
- }
43
-
44
- &__title {
45
- font-size: 24px;
46
- font-weight: 500;
47
- color: var(--color-text-primary);
48
- margin-bottom: 10px;
49
- }
50
-
51
- &__desc {
52
- font-size: 14px;
53
- color: var(--color-text-secondary);
54
- margin-bottom: 30px;
55
- }
56
- }
57
- </style>
@@ -1,141 +0,0 @@
1
- <script setup lang="ts">
2
- /**
3
- * 登录页面
4
- * 使用统一的 useApp hooks
5
- */
6
- import { ref, reactive } from 'vue'
7
- import { Button } from '@xto/base'
8
- import { Form, FormItem, Input } from '@xto/form'
9
- import { useApp } from '@/composables'
10
-
11
- const { login, loading } = useApp()
12
-
13
- const formData = reactive({
14
- uid: '',
15
- password: ''
16
- })
17
-
18
- const rules: Record<string, any[]> = {
19
- uid: [
20
- { required: true, message: '请输入账号', trigger: 'blur' }
21
- ],
22
- password: [
23
- { required: true, message: '请输入密码', trigger: 'blur' }
24
- ]
25
- }
26
-
27
- const formRef = ref()
28
-
29
- // 登录
30
- const handleLogin = async () => {
31
- try {
32
- await formRef.value?.validate()
33
- await login(formData.uid, formData.password)
34
- } catch (error) {
35
- console.error('登录失败', error)
36
- }
37
- }
38
- </script>
39
-
40
- <template>
41
- <div class="login">
42
- <div class="login__container">
43
- <div class="login__header">
44
- <img src="/vite.svg" alt="Logo" class="login__logo" />
45
- <h1 class="login__title">Analysis Web</h1>
46
- <p class="login__subtitle">后台管理系统</p>
47
- </div>
48
-
49
- <Form
50
- ref="formRef"
51
- :model="formData"
52
- :rules="rules"
53
- class="login__form"
54
- label-width="0"
55
- >
56
- <FormItem prop="uid">
57
- <Input
58
- v-model="formData.uid"
59
- placeholder="请输入账号"
60
- size="large"
61
- />
62
- </FormItem>
63
-
64
- <FormItem prop="password">
65
- <Input
66
- v-model="formData.password"
67
- type="password"
68
- placeholder="请输入密码"
69
- size="large"
70
- show-password
71
- @keyup.enter="handleLogin"
72
- />
73
- </FormItem>
74
-
75
- <FormItem>
76
- <Button
77
- type="primary"
78
- size="large"
79
- :loading="loading"
80
- class="login__submit"
81
- @click="handleLogin"
82
- >
83
- 登录
84
- </Button>
85
- </FormItem>
86
- </Form>
87
- </div>
88
- </div>
89
- </template>
90
-
91
- <style lang="scss" scoped>
92
- .login {
93
- width: 100%;
94
- min-height: 100vh;
95
- display: flex;
96
- align-items: center;
97
- justify-content: flex-end;
98
- padding-right: 15%;
99
- background: linear-gradient(135deg, var(--color-primary-light-9) 0%, var(--color-primary-light-7) 100%);
100
-
101
- &__container {
102
- width: 400px;
103
- padding: 40px;
104
- background-color: var(--bg-color);
105
- border-radius: var(--border-radius-large);
106
- box-shadow: var(--box-shadow-dark);
107
- }
108
-
109
- &__header {
110
- text-align: center;
111
- margin-bottom: 30px;
112
- }
113
-
114
- &__logo {
115
- width: 60px;
116
- height: 60px;
117
- }
118
-
119
- &__title {
120
- font-size: 28px;
121
- font-weight: 600;
122
- color: var(--color-primary);
123
- margin: 15px 0 5px;
124
- }
125
-
126
- &__subtitle {
127
- font-size: 14px;
128
- color: var(--color-text-secondary);
129
- }
130
-
131
- &__form {
132
- :deep(.t-form-item) {
133
- margin-bottom: 20px;
134
- }
135
- }
136
-
137
- &__submit {
138
- width: 100%;
139
- }
140
- }
141
- </style>
@@ -1,32 +0,0 @@
1
- <script setup lang="ts">
2
- </script>
3
-
4
- <template>
5
- <div class="page">
6
- <div class="page__placeholder">
7
- <h2>菜单管理</h2>
8
- <p>功能开发中...</p>
9
- </div>
10
- </div>
11
- </template>
12
-
13
- <style lang="scss" scoped>
14
- .page {
15
- padding: 20px;
16
- height: 100%;
17
-
18
- &__placeholder {
19
- display: flex;
20
- flex-direction: column;
21
- align-items: center;
22
- justify-content: center;
23
- height: 100%;
24
- color: var(--color-text-secondary);
25
-
26
- h2 {
27
- margin-bottom: 10px;
28
- color: var(--color-text-primary);
29
- }
30
- }
31
- }
32
- </style>
@@ -1,32 +0,0 @@
1
- <script setup lang="ts">
2
- </script>
3
-
4
- <template>
5
- <div class="page">
6
- <div class="page__placeholder">
7
- <h2>角色管理</h2>
8
- <p>功能开发中...</p>
9
- </div>
10
- </div>
11
- </template>
12
-
13
- <style lang="scss" scoped>
14
- .page {
15
- padding: 20px;
16
- height: 100%;
17
-
18
- &__placeholder {
19
- display: flex;
20
- flex-direction: column;
21
- align-items: center;
22
- justify-content: center;
23
- height: 100%;
24
- color: var(--color-text-secondary);
25
-
26
- h2 {
27
- margin-bottom: 10px;
28
- color: var(--color-text-primary);
29
- }
30
- }
31
- }
32
- </style>
@@ -1,32 +0,0 @@
1
- <script setup lang="ts">
2
- </script>
3
-
4
- <template>
5
- <div class="page">
6
- <div class="page__placeholder">
7
- <h2>用户管理</h2>
8
- <p>功能开发中...</p>
9
- </div>
10
- </div>
11
- </template>
12
-
13
- <style lang="scss" scoped>
14
- .page {
15
- padding: 20px;
16
- height: 100%;
17
-
18
- &__placeholder {
19
- display: flex;
20
- flex-direction: column;
21
- align-items: center;
22
- justify-content: center;
23
- height: 100%;
24
- color: var(--color-text-secondary);
25
-
26
- h2 {
27
- margin-bottom: 10px;
28
- color: var(--color-text-primary);
29
- }
30
- }
31
- }
32
- </style>
package/tsconfig.json DELETED
@@ -1,26 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "useDefineForClassFields": true,
5
- "module": "ESNext",
6
- "lib": ["ES2020", "DOM", "DOM.Iterable"],
7
- "skipLibCheck": true,
8
- "moduleResolution": "bundler",
9
- "allowImportingTsExtensions": true,
10
- "resolveJsonModule": true,
11
- "isolatedModules": true,
12
- "noEmit": true,
13
- "jsx": "preserve",
14
- "strict": true,
15
- "noUnusedLocals": true,
16
- "noUnusedParameters": true,
17
- "noFallthroughCasesInSwitch": true,
18
- "baseUrl": ".",
19
- "paths": {
20
- "@/*": ["src/*"]
21
- },
22
- "types": ["vite/client", "node"]
23
- },
24
- "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"],
25
- "references": [{ "path": "./tsconfig.node.json" }]
26
- }
@@ -1,11 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "composite": true,
4
- "skipLibCheck": true,
5
- "module": "ESNext",
6
- "moduleResolution": "bundler",
7
- "allowSyntheticDefaultImports": true,
8
- "strict": true
9
- },
10
- "include": ["vite.config.ts"]
11
- }