@duxweb/dvha-core 0.0.6 → 0.0.7

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 (120) hide show
  1. package/dist/cjs/components/common/logo.cjs +1 -0
  2. package/dist/cjs/components/overlay/overlay.cjs +1 -0
  3. package/dist/cjs/hooks/auth.cjs +1 -0
  4. package/dist/cjs/hooks/config.cjs +1 -0
  5. package/dist/cjs/hooks/data.cjs +1 -0
  6. package/dist/cjs/hooks/manage.cjs +1 -0
  7. package/dist/cjs/hooks/menu.cjs +1 -0
  8. package/dist/cjs/hooks/overlay.cjs +1 -0
  9. package/dist/cjs/hooks/theme.cjs +1 -0
  10. package/dist/cjs/index.cjs +1 -0
  11. package/dist/cjs/main.cjs +1 -0
  12. package/dist/cjs/provider/app.cjs +1 -0
  13. package/dist/cjs/provider/tab.cjs +1 -0
  14. package/dist/cjs/router/route.cjs +1 -0
  15. package/dist/cjs/simple/authProvider.cjs +1 -0
  16. package/dist/cjs/simple/dataProvider.cjs +1 -0
  17. package/dist/cjs/stores/auth.cjs +1 -0
  18. package/dist/cjs/stores/route.cjs +1 -0
  19. package/dist/cjs/stores/tab.cjs +1 -0
  20. package/dist/cjs/utils/tree.cjs +1 -0
  21. package/dist/esm/components/common/logo.js +50 -0
  22. package/dist/esm/components/overlay/overlay.js +72 -0
  23. package/dist/esm/hooks/auth.js +125 -0
  24. package/dist/esm/hooks/config.js +10 -0
  25. package/dist/esm/hooks/data.js +369 -0
  26. package/dist/esm/hooks/manage.js +24 -0
  27. package/dist/esm/hooks/menu.js +75 -0
  28. package/dist/esm/hooks/overlay.js +14 -0
  29. package/dist/esm/hooks/theme.js +31 -0
  30. package/dist/esm/index.js +67 -0
  31. package/dist/esm/main.js +22 -0
  32. package/dist/esm/provider/app.js +127 -0
  33. package/dist/esm/provider/tab.js +64 -0
  34. package/dist/esm/router/route.js +49 -0
  35. package/dist/esm/simple/authProvider.js +90 -0
  36. package/dist/esm/simple/dataProvider.js +99 -0
  37. package/dist/esm/stores/auth.js +50 -0
  38. package/dist/esm/stores/route.js +65 -0
  39. package/dist/esm/stores/tab.js +70 -0
  40. package/dist/esm/utils/tree.js +41 -0
  41. package/dist/types/components/common/index.d.ts +1 -0
  42. package/dist/types/components/common/logo.d.ts +22 -0
  43. package/dist/types/components/index.d.ts +3 -0
  44. package/dist/types/components/loader/iframe.d.ts +2 -0
  45. package/dist/types/components/loader/index.d.ts +1 -0
  46. package/dist/types/components/overlay/index.d.ts +1 -0
  47. package/dist/types/components/overlay/overlay.d.ts +44 -0
  48. package/dist/types/hooks/auth.d.ts +109 -0
  49. package/dist/types/hooks/config.d.ts +7 -0
  50. package/dist/types/hooks/data.d.ts +1487 -0
  51. package/dist/types/hooks/index.d.ts +7 -0
  52. package/dist/types/hooks/manage.d.ts +13 -0
  53. package/dist/types/hooks/menu.d.ts +16 -0
  54. package/dist/types/hooks/overlay.d.ts +7 -0
  55. package/dist/types/hooks/theme.d.ts +12 -0
  56. package/dist/types/index.d.ts +9 -0
  57. package/dist/types/main.d.ts +5 -0
  58. package/dist/types/provider/app.d.ts +1 -0
  59. package/dist/types/provider/index.d.ts +2 -0
  60. package/dist/types/provider/tab.d.ts +1 -0
  61. package/dist/types/router/index.d.ts +1 -0
  62. package/dist/types/router/route.d.ts +2 -0
  63. package/dist/types/simple/authProvider.d.ts +2 -0
  64. package/dist/types/simple/dataProvider.d.ts +2 -0
  65. package/dist/types/simple/index.d.ts +2 -0
  66. package/dist/types/stores/auth.d.ts +31 -0
  67. package/dist/types/stores/index.d.ts +3 -0
  68. package/dist/types/stores/route.d.ts +4040 -0
  69. package/dist/types/stores/tab.d.ts +1660 -0
  70. package/dist/types/types/auth.d.ts +36 -0
  71. package/dist/types/types/config.d.ts +32 -0
  72. package/dist/types/types/data.d.ts +84 -0
  73. package/dist/types/types/index.d.ts +6 -0
  74. package/dist/types/types/manage.d.ts +29 -0
  75. package/dist/types/types/menu.d.ts +13 -0
  76. package/dist/types/types/theme.d.ts +10 -0
  77. package/dist/types/utils/index.d.ts +1 -0
  78. package/dist/types/utils/tree.d.ts +13 -0
  79. package/package.json +36 -9
  80. package/CHANGELOG.md +0 -31
  81. package/src/components/common/index.ts +0 -1
  82. package/src/components/common/logo.tsx +0 -62
  83. package/src/components/index.ts +0 -3
  84. package/src/components/loader/iframe.tsx +0 -12
  85. package/src/components/loader/index.ts +0 -1
  86. package/src/components/overlay/index.ts +0 -1
  87. package/src/components/overlay/overlay.tsx +0 -84
  88. package/src/hooks/auth.ts +0 -261
  89. package/src/hooks/config.ts +0 -16
  90. package/src/hooks/data.ts +0 -647
  91. package/src/hooks/index.ts +0 -7
  92. package/src/hooks/manage.ts +0 -71
  93. package/src/hooks/menu.ts +0 -146
  94. package/src/hooks/overlay.ts +0 -21
  95. package/src/hooks/theme.ts +0 -49
  96. package/src/index.ts +0 -9
  97. package/src/main.ts +0 -28
  98. package/src/provider/app.tsx +0 -200
  99. package/src/provider/index.ts +0 -2
  100. package/src/provider/tab.tsx +0 -76
  101. package/src/router/index.ts +0 -1
  102. package/src/router/route.ts +0 -47
  103. package/src/simple/authProvider.ts +0 -99
  104. package/src/simple/dataProvider.ts +0 -153
  105. package/src/simple/index.ts +0 -2
  106. package/src/stores/auth.ts +0 -73
  107. package/src/stores/index.ts +0 -3
  108. package/src/stores/route.ts +0 -159
  109. package/src/stores/tab.ts +0 -120
  110. package/src/types/auth.ts +0 -44
  111. package/src/types/config.ts +0 -51
  112. package/src/types/data.ts +0 -108
  113. package/src/types/index.ts +0 -6
  114. package/src/types/manage.ts +0 -40
  115. package/src/types/menu.ts +0 -24
  116. package/src/types/theme.ts +0 -12
  117. package/src/utils/index.ts +0 -1
  118. package/src/utils/tree.ts +0 -63
  119. package/tsconfig.json +0 -41
  120. package/typings.d.ts +0 -10
package/src/hooks/auth.ts DELETED
@@ -1,261 +0,0 @@
1
- import type { IAuthActionResponse, IAuthCheckResponse, IAuthErrorResponse, IAuthLoginResponse, IAuthLogoutResponse } from '../types'
2
- import { ref } from 'vue'
3
- import { useRouter } from 'vue-router'
4
- import { useAuthStore } from '../stores/auth'
5
- import { useManage } from './manage'
6
-
7
- /**
8
- * Auth login params
9
- */
10
- export interface IAuthLoginParams {
11
- onSuccess?: (data?: IAuthLoginResponse) => void
12
- onError?: (error?: IAuthLoginResponse) => void
13
- }
14
-
15
- /**
16
- * Auth logout params
17
- */
18
- export interface IAuthLogoutParams {
19
- onSuccess?: (data?: IAuthLogoutResponse) => void
20
- onError?: (error?: IAuthLogoutResponse) => void
21
- }
22
-
23
- /**
24
- * Auth check params
25
- */
26
- export interface IAuthCheckParams {
27
- onSuccess?: (data?: IAuthCheckResponse) => void
28
- onError?: (error?: IAuthCheckResponse) => void
29
- }
30
-
31
- /**
32
- * Auth action params
33
- */
34
- export interface IAuthActionParams {
35
- onSuccess?: (data?: IAuthActionResponse) => void
36
- onError?: (error?: IAuthActionResponse) => void
37
- }
38
-
39
- /**
40
- * Login
41
- * login to manage
42
- * @param onSuccess Login success callback
43
- * @param onError Login error callback
44
- * @returns Login method
45
- */
46
- export function useLogin({ onSuccess, onError }: IAuthLoginParams) {
47
- const manage = useManage()
48
- const authStore = useAuthStore()
49
- const router = useRouter()
50
- const loading = ref(false)
51
-
52
- const mutate = async (data: Record<string, any>) => {
53
- loading.value = true
54
- const result = await manage.config.authProvider?.login(data, manage)
55
- loading.value = false
56
- if (result?.success) {
57
- if (!result?.data) {
58
- throw new Error('Login response data is undefined')
59
- }
60
- onSuccess?.(result)
61
- authStore.login(manage.config.name, result.data)
62
- router.push(manage.getRoutePath(result.redirectTo || '/'))
63
- return
64
- }
65
- onError?.(result)
66
- }
67
-
68
- return {
69
- mutate,
70
- isLoading: loading,
71
- }
72
- }
73
-
74
- /**
75
- * Logout
76
- * logout from manage
77
- * @param onSuccess Logout success callback
78
- * @param onError Logout error callback
79
- * @returns Logout method
80
- */
81
- export function useLogout({ onSuccess, onError }: IAuthLogoutParams) {
82
- const { config: manage, getRoutePath } = useManage()
83
- const authStore = useAuthStore()
84
- const router = useRouter()
85
-
86
- const mutate = async (params?: any) => {
87
- const result = await manage.authProvider?.logout(params)
88
- if (result?.success) {
89
- onSuccess?.(result)
90
- authStore.logout(manage.name)
91
- router.push(getRoutePath(result.redirectTo || '/login'))
92
- return
93
- }
94
- onError?.(result)
95
- }
96
-
97
- return {
98
- mutate,
99
- }
100
- }
101
-
102
- /**
103
- * Check
104
- * check auth
105
- * @param onSuccess Check success callback
106
- * @param onError Check error callback
107
- * @returns Check method
108
- */
109
- export function useCheck({ onSuccess, onError }: IAuthCheckParams) {
110
- const { config: manage, getRoutePath } = useManage()
111
- const authStore = useAuthStore()
112
- const router = useRouter()
113
-
114
- const mutate = async (params?: any) => {
115
- const result = await manage.authProvider?.check(params)
116
- if (result?.success) {
117
- onSuccess?.(result)
118
- if (!result?.data) {
119
- throw new Error('Check response data is undefined')
120
- }
121
- authStore.update(manage.name, result.data)
122
- return
123
- }
124
- onError?.(result)
125
- if (result?.logout) {
126
- router.push(getRoutePath(result.redirectTo || '/login'))
127
- }
128
- }
129
-
130
- return {
131
- mutate,
132
- }
133
- }
134
-
135
- /**
136
- * Register
137
- * register to manage
138
- * @param onSuccess Register success callback
139
- * @param onError Register error callback
140
- * @returns Register method
141
- */
142
- export function useRegister({ onSuccess, onError }: IAuthLoginParams) {
143
- const { config: manage, getRoutePath } = useManage()
144
- const authStore = useAuthStore()
145
- const router = useRouter()
146
- const mutate = async (data: Record<string, any>) => {
147
- const result = await manage.authProvider?.register(data)
148
- if (result?.success) {
149
- onSuccess?.(result)
150
- if (!result?.data) {
151
- throw new Error('Register response data is undefined')
152
- }
153
- authStore.login(manage.name, result.data)
154
- router.push(getRoutePath(result.redirectTo || ''))
155
- return
156
- }
157
- onError?.(result)
158
- }
159
- return {
160
- mutate,
161
- }
162
- }
163
-
164
- /**
165
- * Forgot password
166
- * @param onSuccess Forgot password success callback
167
- * @param onError Forgot password error callback
168
- * @returns Forgot password method
169
- */
170
- export function useForgotPassword({ onSuccess, onError }: IAuthActionParams) {
171
- const { config: manage, getRoutePath } = useManage()
172
- const router = useRouter()
173
-
174
- const mutate = async (params?: any) => {
175
- const result = await manage.authProvider?.forgotPassword(params)
176
- if (result?.success) {
177
- onSuccess?.(result)
178
- if (result.redirectTo) {
179
- router.push(getRoutePath(result.redirectTo))
180
- }
181
- return
182
- }
183
- onError?.(result)
184
- }
185
-
186
- return {
187
- mutate,
188
- }
189
- }
190
-
191
- /**
192
- * Update password
193
- * @param onSuccess Update password success callback
194
- * @param onError Update password error callback
195
- * @returns Update password method
196
- */
197
- export function useUpdatePassword({ onSuccess, onError }: IAuthActionParams) {
198
- const { config: manage, getRoutePath } = useManage()
199
- const router = useRouter()
200
-
201
- const mutate = async (params?: any) => {
202
- const result = await manage.authProvider?.updatePassword(params)
203
- if (result?.success) {
204
- onSuccess?.(result)
205
- if (result.redirectTo) {
206
- router.push(getRoutePath(result.redirectTo))
207
- }
208
- return
209
- }
210
- onError?.(result)
211
- }
212
-
213
- return {
214
- mutate,
215
- }
216
- }
217
-
218
- /**
219
- * Error
220
- * handle auth error
221
- * @param onCallback Error callback
222
- * @returns Error method
223
- */
224
- export function useError(onCallback?: (data?: IAuthErrorResponse) => void) {
225
- const { config: manage, getRoutePath } = useManage()
226
- const router = useRouter()
227
-
228
- const mutate = async (error: any) => {
229
- const result = await manage.authProvider?.onError(error)
230
- onCallback?.(result)
231
- if (result?.logout) {
232
- router.push(getRoutePath(result.redirectTo || '/login'))
233
- }
234
- }
235
- return {
236
- mutate,
237
- }
238
- }
239
-
240
- /**
241
- * Get auth
242
- * get auth info
243
- * @returns Auth info
244
- */
245
- export function useGetAuth(manageName?: string) {
246
- const { config: manage } = useManage(manageName)
247
- const authStore = useAuthStore()
248
- const user = authStore.getUser(manage.name)
249
- return user
250
- }
251
-
252
- /**
253
- * Is login
254
- * check if user is login
255
- * @returns Is login
256
- */
257
- export function useIsLogin(manageName?: string) {
258
- const { config: manage } = useManage(manageName)
259
- const authStore = useAuthStore()
260
- return authStore.isLogin(manage.name)
261
- }
@@ -1,16 +0,0 @@
1
- import type { IConfig } from '../types'
2
- import { inject } from 'vue'
3
-
4
- /**
5
- * Config
6
- * get global config
7
- * @returns Config
8
- */
9
- export function useConfig(): IConfig {
10
- const config = inject<IConfig>('dux.config')
11
- if (!config) {
12
- throw new Error('config is not defined')
13
- }
14
-
15
- return config
16
- }