@duxweb/dvha-core 0.0.5 → 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.
- package/dist/cjs/components/common/logo.cjs +1 -0
- package/dist/cjs/components/overlay/overlay.cjs +1 -0
- package/dist/cjs/hooks/auth.cjs +1 -0
- package/dist/cjs/hooks/config.cjs +1 -0
- package/dist/cjs/hooks/data.cjs +1 -0
- package/dist/cjs/hooks/manage.cjs +1 -0
- package/dist/cjs/hooks/menu.cjs +1 -0
- package/dist/cjs/hooks/overlay.cjs +1 -0
- package/dist/cjs/hooks/theme.cjs +1 -0
- package/dist/cjs/index.cjs +1 -0
- package/dist/cjs/main.cjs +1 -0
- package/dist/cjs/provider/app.cjs +1 -0
- package/dist/cjs/provider/tab.cjs +1 -0
- package/dist/cjs/router/route.cjs +1 -0
- package/dist/cjs/simple/authProvider.cjs +1 -0
- package/dist/cjs/simple/dataProvider.cjs +1 -0
- package/dist/cjs/stores/auth.cjs +1 -0
- package/dist/cjs/stores/route.cjs +1 -0
- package/dist/cjs/stores/tab.cjs +1 -0
- package/dist/cjs/utils/tree.cjs +1 -0
- package/dist/esm/components/common/logo.js +50 -0
- package/dist/esm/components/overlay/overlay.js +72 -0
- package/dist/esm/hooks/auth.js +125 -0
- package/dist/esm/hooks/config.js +10 -0
- package/dist/esm/hooks/data.js +369 -0
- package/dist/esm/hooks/manage.js +24 -0
- package/dist/esm/hooks/menu.js +75 -0
- package/dist/esm/hooks/overlay.js +14 -0
- package/dist/esm/hooks/theme.js +31 -0
- package/dist/esm/index.js +67 -0
- package/dist/esm/main.js +22 -0
- package/dist/esm/provider/app.js +127 -0
- package/dist/esm/provider/tab.js +64 -0
- package/dist/esm/router/route.js +49 -0
- package/dist/esm/simple/authProvider.js +90 -0
- package/dist/esm/simple/dataProvider.js +99 -0
- package/dist/esm/stores/auth.js +50 -0
- package/dist/esm/stores/route.js +65 -0
- package/dist/esm/stores/tab.js +70 -0
- package/dist/esm/utils/tree.js +41 -0
- package/dist/types/components/common/index.d.ts +1 -0
- package/dist/types/components/common/logo.d.ts +22 -0
- package/dist/types/components/index.d.ts +3 -0
- package/dist/types/components/loader/iframe.d.ts +2 -0
- package/dist/types/components/loader/index.d.ts +1 -0
- package/dist/types/components/overlay/index.d.ts +1 -0
- package/dist/types/components/overlay/overlay.d.ts +44 -0
- package/dist/types/hooks/auth.d.ts +109 -0
- package/dist/types/hooks/config.d.ts +7 -0
- package/dist/types/hooks/data.d.ts +1487 -0
- package/dist/types/hooks/index.d.ts +7 -0
- package/dist/types/hooks/manage.d.ts +13 -0
- package/dist/types/hooks/menu.d.ts +16 -0
- package/dist/types/hooks/overlay.d.ts +7 -0
- package/dist/types/hooks/theme.d.ts +12 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/main.d.ts +5 -0
- package/dist/types/provider/app.d.ts +1 -0
- package/dist/types/provider/index.d.ts +2 -0
- package/dist/types/provider/tab.d.ts +1 -0
- package/dist/types/router/index.d.ts +1 -0
- package/dist/types/router/route.d.ts +2 -0
- package/dist/types/simple/authProvider.d.ts +2 -0
- package/dist/types/simple/dataProvider.d.ts +2 -0
- package/dist/types/simple/index.d.ts +2 -0
- package/dist/types/stores/auth.d.ts +31 -0
- package/dist/types/stores/index.d.ts +3 -0
- package/dist/types/stores/route.d.ts +4040 -0
- package/dist/types/stores/tab.d.ts +1660 -0
- package/dist/types/types/auth.d.ts +36 -0
- package/dist/types/types/config.d.ts +32 -0
- package/dist/types/types/data.d.ts +84 -0
- package/dist/types/types/index.d.ts +6 -0
- package/dist/types/types/manage.d.ts +29 -0
- package/dist/types/types/menu.d.ts +13 -0
- package/dist/types/types/theme.d.ts +10 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/tree.d.ts +13 -0
- package/package.json +38 -12
- package/CHANGELOG.md +0 -25
- package/src/components/common/index.ts +0 -1
- package/src/components/common/logo.tsx +0 -62
- package/src/components/index.ts +0 -3
- package/src/components/loader/iframe.tsx +0 -12
- package/src/components/loader/index.ts +0 -1
- package/src/components/overlay/index.ts +0 -1
- package/src/components/overlay/overlay.tsx +0 -84
- package/src/hooks/auth.ts +0 -261
- package/src/hooks/config.ts +0 -16
- package/src/hooks/data.ts +0 -648
- package/src/hooks/index.ts +0 -7
- package/src/hooks/manage.ts +0 -71
- package/src/hooks/menu.ts +0 -146
- package/src/hooks/overlay.ts +0 -21
- package/src/hooks/theme.ts +0 -49
- package/src/index.ts +0 -9
- package/src/main.ts +0 -28
- package/src/provider/app.tsx +0 -200
- package/src/provider/index.ts +0 -2
- package/src/provider/tab.tsx +0 -76
- package/src/router/index.ts +0 -1
- package/src/router/route.ts +0 -47
- package/src/simple/authProvider.ts +0 -99
- package/src/simple/dataProvider.ts +0 -153
- package/src/simple/index.ts +0 -2
- package/src/stores/auth.ts +0 -73
- package/src/stores/index.ts +0 -3
- package/src/stores/route.ts +0 -159
- package/src/stores/tab.ts +0 -120
- package/src/types/auth.ts +0 -44
- package/src/types/config.ts +0 -51
- package/src/types/data.ts +0 -108
- package/src/types/index.ts +0 -6
- package/src/types/manage.ts +0 -40
- package/src/types/menu.ts +0 -24
- package/src/types/theme.ts +0 -12
- package/src/utils/index.ts +0 -1
- package/src/utils/tree.ts +0 -63
- package/tsconfig.json +0 -41
- 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
|
-
}
|
package/src/hooks/config.ts
DELETED
|
@@ -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
|
-
}
|