@fy-/fws-vue 2.1.6 → 2.1.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/components/fws/CmsArticleBoxed.vue +23 -20
- package/components/fws/CmsArticleSingle.vue +74 -68
- package/components/fws/DataTable.vue +132 -125
- package/components/fws/FilterData.vue +99 -101
- package/components/fws/UserData.vue +33 -32
- package/components/fws/UserFlow.vue +163 -155
- package/components/fws/UserOAuth2.vue +73 -72
- package/components/fws/UserProfile.vue +98 -101
- package/components/fws/UserProfileStrict.vue +65 -64
- package/components/ssr/ClientOnly.ts +7 -7
- package/components/ui/DefaultBreadcrumb.vue +13 -13
- package/components/ui/DefaultConfirm.vue +35 -34
- package/components/ui/DefaultDateSelection.vue +19 -17
- package/components/ui/DefaultDropdown.vue +25 -25
- package/components/ui/DefaultDropdownLink.vue +15 -14
- package/components/ui/DefaultGallery.vue +179 -168
- package/components/ui/DefaultInput.vue +121 -126
- package/components/ui/DefaultLoader.vue +17 -17
- package/components/ui/DefaultModal.vue +35 -33
- package/components/ui/DefaultNotif.vue +50 -52
- package/components/ui/DefaultPaging.vue +92 -95
- package/components/ui/DefaultSidebar.vue +29 -25
- package/components/ui/DefaultTagInput.vue +121 -119
- package/components/ui/transitions/CollapseTransition.vue +1 -1
- package/components/ui/transitions/ExpandTransition.vue +1 -1
- package/components/ui/transitions/FadeTransition.vue +1 -1
- package/components/ui/transitions/ScaleTransition.vue +1 -1
- package/components/ui/transitions/SlideTransition.vue +3 -3
- package/composables/event-bus.ts +10 -8
- package/composables/rest.ts +59 -56
- package/composables/seo.ts +106 -95
- package/composables/ssr.ts +64 -62
- package/composables/templating.ts +57 -57
- package/composables/translations.ts +13 -13
- package/env.d.ts +6 -4
- package/index.ts +101 -98
- package/package.json +7 -7
- package/stores/serverRouter.ts +25 -25
- package/stores/user.ts +79 -72
- package/types.d.ts +65 -65
package/index.ts
CHANGED
|
@@ -1,23 +1,33 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
1
|
+
import type { Emitter } from 'mitt'
|
|
2
|
+
import type { App, Plugin } from 'vue'
|
|
3
|
+
import type { Events } from './composables/event-bus'
|
|
4
|
+
import i18next from 'i18next'
|
|
5
|
+
import mitt from 'mitt'
|
|
6
|
+
import CmsArticleBoxed from './components/fws/CmsArticleBoxed.vue'
|
|
7
|
+
import CmsArticleSingle from './components/fws/CmsArticleSingle.vue'
|
|
8
|
+
import DataTable from './components/fws/DataTable.vue'
|
|
9
|
+
import FilterData from './components/fws/FilterData.vue'
|
|
10
|
+
import UserData from './components/fws/UserData.vue'
|
|
11
|
+
import { ClientOnly } from './components/ssr/ClientOnly'
|
|
12
|
+
import DefaultBreadcrumb from './components/ui/DefaultBreadcrumb.vue'
|
|
13
|
+
import DefaultConfirm from './components/ui/DefaultConfirm.vue'
|
|
14
|
+
|
|
15
|
+
import DefaultDropdown from './components/ui/DefaultDropdown.vue'
|
|
16
|
+
import DefaultDropdownLink from './components/ui/DefaultDropdownLink.vue'
|
|
17
|
+
import DefaultGallery from './components/ui/DefaultGallery.vue'
|
|
18
|
+
import CollapseTransition from './components/ui/transitions/CollapseTransition.vue'
|
|
19
|
+
import ExpandTransition from './components/ui/transitions/ExpandTransition.vue'
|
|
20
|
+
|
|
21
|
+
import FadeTransition from './components/ui/transitions/FadeTransition.vue'
|
|
22
|
+
import ScaleTransition from './components/ui/transitions/ScaleTransition.vue'
|
|
23
|
+
import { useEventBus } from './composables/event-bus'
|
|
24
|
+
import { useRest } from './composables/rest'
|
|
25
|
+
import { useSeo } from './composables/seo'
|
|
8
26
|
import {
|
|
9
27
|
initVueClient,
|
|
10
28
|
initVueServer,
|
|
11
29
|
isServerRendered,
|
|
12
|
-
} from
|
|
13
|
-
import { useSeo } from "./composables/seo";
|
|
14
|
-
import {
|
|
15
|
-
useUserStore,
|
|
16
|
-
useUserCheck,
|
|
17
|
-
useUserCheckAsync,
|
|
18
|
-
useUserCheckAsyncSimple,
|
|
19
|
-
} from "./stores/user";
|
|
20
|
-
import { ClientOnly } from "./components/ssr/ClientOnly";
|
|
30
|
+
} from './composables/ssr'
|
|
21
31
|
import {
|
|
22
32
|
cropText,
|
|
23
33
|
formatBytes,
|
|
@@ -25,118 +35,111 @@ import {
|
|
|
25
35
|
formatDatetime,
|
|
26
36
|
formatTimeago,
|
|
27
37
|
getContrastingTextColor,
|
|
28
|
-
} from
|
|
29
|
-
import {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
38
|
+
} from './composables/templating'
|
|
39
|
+
import { i18nextPromise, useTranslation } from './composables/translations'
|
|
40
|
+
import { useServerRouter } from './stores/serverRouter'
|
|
41
|
+
import {
|
|
42
|
+
useUserCheck,
|
|
43
|
+
useUserCheckAsync,
|
|
44
|
+
useUserCheckAsyncSimple,
|
|
45
|
+
useUserStore,
|
|
46
|
+
} from './stores/user'
|
|
33
47
|
// Components/UI/Transitions
|
|
34
|
-
import SlideTransition from
|
|
35
|
-
import ExpandTransition from "./components/ui/transitions/ExpandTransition.vue";
|
|
36
|
-
import CollapseTransition from "./components/ui/transitions/CollapseTransition.vue";
|
|
37
|
-
import ScaleTransition from "./components/ui/transitions/ScaleTransition.vue";
|
|
38
|
-
import FadeTransition from "./components/ui/transitions/FadeTransition.vue";
|
|
39
|
-
|
|
48
|
+
import SlideTransition from './components/ui/transitions/SlideTransition.vue'
|
|
40
49
|
// Components/UI
|
|
41
|
-
import DefaultInput from
|
|
42
|
-
import
|
|
43
|
-
import
|
|
44
|
-
import
|
|
45
|
-
import
|
|
46
|
-
import
|
|
47
|
-
import
|
|
48
|
-
import DefaultGallery from "./components/ui/DefaultGallery.vue";
|
|
49
|
-
import DefaultDropdown from "./components/ui/DefaultDropdown.vue";
|
|
50
|
-
import DefaultDropdownLink from "./components/ui/DefaultDropdownLink.vue";
|
|
51
|
-
import DefaultTagInput from "./components/ui/DefaultTagInput.vue";
|
|
52
|
-
import DefaultNotif from "./components/ui/DefaultNotif.vue";
|
|
50
|
+
import DefaultInput from './components/ui/DefaultInput.vue'
|
|
51
|
+
import DefaultLoader from './components/ui/DefaultLoader.vue'
|
|
52
|
+
import DefaultModal from './components/ui/DefaultModal.vue'
|
|
53
|
+
import DefaultNotif from './components/ui/DefaultNotif.vue'
|
|
54
|
+
import DefaultPaging from './components/ui/DefaultPaging.vue'
|
|
55
|
+
import DefaultSidebar from './components/ui/DefaultSidebar.vue'
|
|
56
|
+
import DefaultTagInput from './components/ui/DefaultTagInput.vue'
|
|
53
57
|
// Components/FWS
|
|
54
|
-
import UserFlow from
|
|
55
|
-
import
|
|
56
|
-
import
|
|
57
|
-
import
|
|
58
|
-
import CmsArticleSingle from "./components/fws/CmsArticleSingle.vue";
|
|
59
|
-
import UserOAuth2 from "./components/fws/UserOAuth2.vue";
|
|
60
|
-
import UserData from "./components/fws/UserData.vue";
|
|
61
|
-
import UserProfile from "./components/fws/UserProfile.vue";
|
|
62
|
-
import UserProfileStrict from "./components/fws/UserProfileStrict.vue";
|
|
58
|
+
import UserFlow from './components/fws/UserFlow.vue'
|
|
59
|
+
import UserOAuth2 from './components/fws/UserOAuth2.vue'
|
|
60
|
+
import UserProfile from './components/fws/UserProfile.vue'
|
|
61
|
+
import UserProfileStrict from './components/fws/UserProfileStrict.vue'
|
|
63
62
|
// Css
|
|
64
|
-
import
|
|
63
|
+
import './style.css'
|
|
64
|
+
|
|
65
|
+
export * from './stores/serverRouter'
|
|
66
|
+
export type * from './types'
|
|
65
67
|
|
|
66
68
|
function createFWS(): Plugin {
|
|
67
|
-
|
|
69
|
+
// @ts-expect-error: Emitter<Events> is not assignable to Emitter<Events>
|
|
70
|
+
const eventBus: Emitter<Events> = mitt<Events>()
|
|
68
71
|
|
|
69
72
|
return {
|
|
70
73
|
install(app: App) {
|
|
71
74
|
if (app.config.globalProperties) {
|
|
72
|
-
app.config.globalProperties.$eventBus = eventBus
|
|
73
|
-
app.provide(
|
|
75
|
+
app.config.globalProperties.$eventBus = eventBus
|
|
76
|
+
app.provide('fwsVueEventBus', eventBus)
|
|
74
77
|
|
|
75
78
|
// i18next
|
|
76
|
-
app.config.globalProperties.$t = i18next.t
|
|
77
|
-
app.provide(
|
|
79
|
+
app.config.globalProperties.$t = i18next.t
|
|
80
|
+
app.provide('fwsVueTranslate', i18next.t)
|
|
78
81
|
|
|
79
82
|
// Templating
|
|
80
|
-
app.config.globalProperties.$cropText = cropText
|
|
81
|
-
app.config.globalProperties.$formatBytes = formatBytes
|
|
82
|
-
app.config.globalProperties.$formatTimeago = formatTimeago
|
|
83
|
-
app.config.globalProperties.$formatDatetime = formatDatetime
|
|
84
|
-
app.config.globalProperties.$formatDate = formatDate
|
|
85
|
-
app.config.globalProperties.$getContrastingTextColor
|
|
86
|
-
getContrastingTextColor
|
|
83
|
+
app.config.globalProperties.$cropText = cropText
|
|
84
|
+
app.config.globalProperties.$formatBytes = formatBytes
|
|
85
|
+
app.config.globalProperties.$formatTimeago = formatTimeago
|
|
86
|
+
app.config.globalProperties.$formatDatetime = formatDatetime
|
|
87
|
+
app.config.globalProperties.$formatDate = formatDate
|
|
88
|
+
app.config.globalProperties.$getContrastingTextColor
|
|
89
|
+
= getContrastingTextColor
|
|
87
90
|
|
|
88
|
-
app.component(
|
|
91
|
+
app.component('ClientOnly', ClientOnly)
|
|
89
92
|
}
|
|
90
93
|
},
|
|
91
|
-
}
|
|
94
|
+
}
|
|
92
95
|
}
|
|
93
96
|
|
|
94
97
|
export {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
createFWS,
|
|
98
|
-
useServerRouter,
|
|
99
|
-
useEventBus,
|
|
100
|
-
initVueClient,
|
|
101
|
-
initVueServer,
|
|
102
|
-
isServerRendered,
|
|
103
|
-
useSeo,
|
|
104
|
-
useUserStore,
|
|
105
|
-
useUserCheck,
|
|
106
|
-
useUserCheckAsync,
|
|
107
|
-
useRest,
|
|
108
|
-
useUserCheckAsyncSimple,
|
|
109
|
-
|
|
110
|
-
// Components
|
|
111
|
-
// UI/Transitions
|
|
112
|
-
SlideTransition,
|
|
113
|
-
ExpandTransition,
|
|
98
|
+
CmsArticleBoxed,
|
|
99
|
+
CmsArticleSingle,
|
|
114
100
|
CollapseTransition,
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
101
|
+
createFWS,
|
|
102
|
+
DataTable,
|
|
103
|
+
DefaultBreadcrumb,
|
|
104
|
+
DefaultConfirm,
|
|
105
|
+
DefaultDropdown,
|
|
106
|
+
DefaultDropdownLink,
|
|
107
|
+
DefaultGallery,
|
|
118
108
|
// UI
|
|
119
109
|
DefaultInput,
|
|
110
|
+
DefaultLoader,
|
|
120
111
|
DefaultModal,
|
|
121
|
-
|
|
112
|
+
DefaultNotif,
|
|
113
|
+
|
|
122
114
|
DefaultPaging,
|
|
123
|
-
DefaultBreadcrumb,
|
|
124
|
-
DefaultLoader,
|
|
125
115
|
DefaultSidebar,
|
|
126
|
-
DefaultGallery,
|
|
127
|
-
DefaultDropdown,
|
|
128
|
-
DefaultDropdownLink,
|
|
129
116
|
DefaultTagInput,
|
|
130
|
-
|
|
117
|
+
ExpandTransition,
|
|
118
|
+
FadeTransition,
|
|
131
119
|
|
|
120
|
+
FilterData,
|
|
121
|
+
i18nextPromise,
|
|
122
|
+
initVueClient,
|
|
123
|
+
initVueServer,
|
|
124
|
+
isServerRendered,
|
|
125
|
+
ScaleTransition,
|
|
126
|
+
// Components
|
|
127
|
+
// UI/Transitions
|
|
128
|
+
SlideTransition,
|
|
129
|
+
useEventBus,
|
|
130
|
+
UserData,
|
|
131
|
+
useRest,
|
|
132
132
|
// FWS
|
|
133
133
|
UserFlow,
|
|
134
134
|
UserOAuth2,
|
|
135
|
-
|
|
136
|
-
FilterData,
|
|
137
|
-
CmsArticleBoxed,
|
|
138
|
-
CmsArticleSingle,
|
|
139
|
-
UserData,
|
|
135
|
+
|
|
140
136
|
UserProfile,
|
|
141
137
|
UserProfileStrict,
|
|
142
|
-
|
|
138
|
+
useSeo,
|
|
139
|
+
useServerRouter,
|
|
140
|
+
useTranslation,
|
|
141
|
+
useUserCheck,
|
|
142
|
+
useUserCheckAsync,
|
|
143
|
+
useUserCheckAsyncSimple,
|
|
144
|
+
useUserStore,
|
|
145
|
+
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fy-/fws-vue",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.7",
|
|
4
4
|
"author": "Florian 'Fy' Gasquez <m@fy.to>",
|
|
5
5
|
"license": "MIT",
|
|
6
|
+
"homepage": "https://github.com/fy-to/FWJS#readme",
|
|
6
7
|
"repository": {
|
|
7
8
|
"type": "git",
|
|
8
9
|
"url": "git+https://github.com/fy-to/FWJS.git"
|
|
@@ -10,11 +11,6 @@
|
|
|
10
11
|
"bugs": {
|
|
11
12
|
"url": "https://github.com/fy-to/FWJS/issues"
|
|
12
13
|
},
|
|
13
|
-
"homepage": "https://github.com/fy-to/FWJS#readme",
|
|
14
|
-
"main": "index.ts",
|
|
15
|
-
"module": "index.ts",
|
|
16
|
-
"typings": "index.ts",
|
|
17
|
-
"types": "index.ts",
|
|
18
14
|
"exports": {
|
|
19
15
|
".": {
|
|
20
16
|
"import": "./index.ts",
|
|
@@ -26,12 +22,16 @@
|
|
|
26
22
|
"require": "./style.css"
|
|
27
23
|
}
|
|
28
24
|
},
|
|
25
|
+
"main": "index.ts",
|
|
26
|
+
"module": "index.ts",
|
|
27
|
+
"typings": "index.ts",
|
|
28
|
+
"types": "index.ts",
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@fy-/fws-js": "^0.0.x",
|
|
31
31
|
"@fy-/fws-types": "^0.0.x",
|
|
32
|
+
"@unhead/schema-org": "1.9.x",
|
|
32
33
|
"@unhead/ssr": "^1.9.x",
|
|
33
34
|
"@unhead/vue": "^1.9.x",
|
|
34
|
-
"@unhead/schema-org": "1.9.x",
|
|
35
35
|
"@vuelidate/core": "^2.0.x",
|
|
36
36
|
"@vuelidate/validators": "^2.0.x",
|
|
37
37
|
"@vueuse/core": "^10.x.x",
|
package/stores/serverRouter.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import type { Router } from 'vue-router'
|
|
2
|
+
import { defineStore } from 'pinia'
|
|
3
3
|
|
|
4
4
|
export interface ServerRouterState {
|
|
5
|
-
_router: any | null
|
|
6
|
-
status: number
|
|
7
|
-
redirect?: string
|
|
8
|
-
results: Record<number, any | undefined
|
|
5
|
+
_router: any | null
|
|
6
|
+
status: number
|
|
7
|
+
redirect?: string
|
|
8
|
+
results: Record<number, any | undefined>
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export const useServerRouter = defineStore({
|
|
12
|
-
id:
|
|
12
|
+
id: 'routerStore',
|
|
13
13
|
state: () =>
|
|
14
14
|
({
|
|
15
15
|
_router: null,
|
|
@@ -18,46 +18,46 @@ export const useServerRouter = defineStore({
|
|
|
18
18
|
results: {},
|
|
19
19
|
}) as ServerRouterState,
|
|
20
20
|
getters: {
|
|
21
|
-
currentRoute:
|
|
22
|
-
route:
|
|
21
|
+
currentRoute: state => state._router?.currentRoute,
|
|
22
|
+
route: state => state._router?.currentRoute,
|
|
23
23
|
},
|
|
24
24
|
actions: {
|
|
25
25
|
setStatus(status: number) {
|
|
26
|
-
this.status = status
|
|
26
|
+
this.status = status
|
|
27
27
|
},
|
|
28
28
|
_setRouter(_router: Router | null) {
|
|
29
|
-
(this._router as unknown as Router | null) = _router
|
|
29
|
+
(this._router as unknown as Router | null) = _router
|
|
30
30
|
},
|
|
31
31
|
push(path: any, status = 302) {
|
|
32
|
-
this.status = status
|
|
33
|
-
if (status
|
|
34
|
-
return this._router?.push(path)
|
|
32
|
+
this.status = status
|
|
33
|
+
if (status !== 302) this.redirect = path
|
|
34
|
+
return this._router?.push(path)
|
|
35
35
|
},
|
|
36
36
|
replace(path: any, status = 302) {
|
|
37
|
-
this.status = status
|
|
38
|
-
if (status
|
|
39
|
-
return this._router?.replace(path)
|
|
37
|
+
this.status = status
|
|
38
|
+
if (status !== 302) this.redirect = path
|
|
39
|
+
return this._router?.replace(path)
|
|
40
40
|
},
|
|
41
41
|
go(delta: number) {
|
|
42
|
-
this._router?.go(delta)
|
|
42
|
+
this._router?.go(delta)
|
|
43
43
|
},
|
|
44
44
|
back() {
|
|
45
|
-
this._router?.go(-1)
|
|
45
|
+
this._router?.go(-1)
|
|
46
46
|
},
|
|
47
47
|
forward() {
|
|
48
|
-
this._router?.go(1)
|
|
48
|
+
this._router?.go(1)
|
|
49
49
|
},
|
|
50
50
|
addResult(id: number, result: any) {
|
|
51
|
-
this.results[id] = result
|
|
51
|
+
this.results[id] = result
|
|
52
52
|
},
|
|
53
53
|
hasResult(id: number) {
|
|
54
|
-
return this.results[id] !== undefined
|
|
54
|
+
return this.results[id] !== undefined
|
|
55
55
|
},
|
|
56
56
|
getResult(id: number) {
|
|
57
|
-
return this.results[id]
|
|
57
|
+
return this.results[id]
|
|
58
58
|
},
|
|
59
59
|
removeResult(id: number) {
|
|
60
|
-
delete this.results[id]
|
|
60
|
+
delete this.results[id]
|
|
61
61
|
},
|
|
62
62
|
},
|
|
63
|
-
})
|
|
63
|
+
})
|
package/stores/user.ts
CHANGED
|
@@ -1,138 +1,145 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
3
|
-
import { APIResult } from
|
|
4
|
-
import { rest } from
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { useServerRouter } from
|
|
8
|
-
import { useEventBus } from "../composables/event-bus";
|
|
1
|
+
import type { User } from '@fy-/fws-types'
|
|
2
|
+
import type { RouteLocation } from 'vue-router'
|
|
3
|
+
import type { APIResult } from '../composables/rest'
|
|
4
|
+
import { rest } from '@fy-/fws-js'
|
|
5
|
+
import { defineStore } from 'pinia'
|
|
6
|
+
import { computed } from 'vue'
|
|
7
|
+
import { useServerRouter } from './serverRouter'
|
|
9
8
|
|
|
10
|
-
export
|
|
11
|
-
user: User | null
|
|
12
|
-
}
|
|
9
|
+
export interface UserStore {
|
|
10
|
+
user: User | null
|
|
11
|
+
}
|
|
13
12
|
|
|
14
13
|
export const useUserStore = defineStore({
|
|
15
|
-
id:
|
|
14
|
+
id: 'userStore',
|
|
16
15
|
state: (): UserStore => ({
|
|
17
16
|
user: null,
|
|
18
17
|
}),
|
|
19
18
|
getters: {
|
|
20
19
|
isAuth: (state): boolean => {
|
|
21
|
-
return !(state.user === null)
|
|
20
|
+
return !(state.user === null)
|
|
22
21
|
},
|
|
23
22
|
},
|
|
24
23
|
actions: {
|
|
25
24
|
async refreshUser() {
|
|
26
|
-
const user: APIResult = await rest(
|
|
27
|
-
this.setUser(null)
|
|
28
|
-
})
|
|
29
|
-
if (user.result ===
|
|
30
|
-
this.setUser(user.data)
|
|
31
|
-
}
|
|
32
|
-
|
|
25
|
+
const user: APIResult = await rest('User:get', 'GET').catch(() => {
|
|
26
|
+
this.setUser(null)
|
|
27
|
+
})
|
|
28
|
+
if (user.result === 'success') {
|
|
29
|
+
this.setUser(user.data)
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
this.setUser(null)
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
async logout() {
|
|
36
|
-
const user: APIResult = await rest(
|
|
37
|
-
this.setUser(null)
|
|
38
|
-
})
|
|
39
|
-
if (user.result ===
|
|
40
|
-
this.setUser(null)
|
|
41
|
-
}
|
|
42
|
-
|
|
36
|
+
const user: APIResult = await rest('User:logout', 'POST').catch(() => {
|
|
37
|
+
this.setUser(null)
|
|
38
|
+
})
|
|
39
|
+
if (user.result === 'success') {
|
|
40
|
+
this.setUser(null)
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
this.setUser(null)
|
|
43
44
|
}
|
|
44
45
|
},
|
|
45
46
|
setUser(user: User | null) {
|
|
46
|
-
this.user = user
|
|
47
|
+
this.user = user
|
|
47
48
|
},
|
|
48
49
|
},
|
|
49
|
-
})
|
|
50
|
+
})
|
|
50
51
|
|
|
51
52
|
export async function useUserCheckAsyncSimple(
|
|
52
|
-
path =
|
|
53
|
+
path = '/login',
|
|
53
54
|
redirectLink = false,
|
|
54
55
|
) {
|
|
55
|
-
const userStore = useUserStore()
|
|
56
|
-
await userStore.refreshUser()
|
|
57
|
-
const isAuth = computed(() => userStore.isAuth)
|
|
58
|
-
const router = useServerRouter()
|
|
56
|
+
const userStore = useUserStore()
|
|
57
|
+
await userStore.refreshUser()
|
|
58
|
+
const isAuth = computed(() => userStore.isAuth)
|
|
59
|
+
const router = useServerRouter()
|
|
59
60
|
|
|
60
61
|
const checkUser = (route: RouteLocation) => {
|
|
61
62
|
if (route.meta.reqLogin) {
|
|
62
63
|
if (!isAuth.value) {
|
|
63
|
-
if (!redirectLink)
|
|
64
|
+
if (!redirectLink) {
|
|
65
|
+
router.push(path)
|
|
66
|
+
}
|
|
64
67
|
else {
|
|
65
|
-
router.status = 307
|
|
66
|
-
router.push(`${path}?return_to=${route.path}`)
|
|
68
|
+
router.status = 307
|
|
69
|
+
router.push(`${path}?return_to=${route.path}`)
|
|
67
70
|
}
|
|
68
71
|
}
|
|
69
72
|
}
|
|
70
|
-
}
|
|
71
|
-
checkUser(router.currentRoute)
|
|
73
|
+
}
|
|
74
|
+
checkUser(router.currentRoute)
|
|
72
75
|
|
|
73
76
|
router._router.beforeEach((to: any) => {
|
|
74
|
-
if (to.fullPath
|
|
75
|
-
checkUser(to)
|
|
77
|
+
if (to.fullPath !== path) {
|
|
78
|
+
checkUser(to)
|
|
76
79
|
}
|
|
77
|
-
})
|
|
80
|
+
})
|
|
78
81
|
}
|
|
79
82
|
|
|
80
|
-
export async function useUserCheckAsync(path =
|
|
81
|
-
const userStore = useUserStore()
|
|
82
|
-
await userStore.refreshUser()
|
|
83
|
-
const isAuth = computed(() => userStore.isAuth)
|
|
84
|
-
const router = useServerRouter()
|
|
83
|
+
export async function useUserCheckAsync(path = '/login', redirectLink = false) {
|
|
84
|
+
const userStore = useUserStore()
|
|
85
|
+
await userStore.refreshUser()
|
|
86
|
+
const isAuth = computed(() => userStore.isAuth)
|
|
87
|
+
const router = useServerRouter()
|
|
85
88
|
|
|
86
89
|
const checkUser = (route: RouteLocation) => {
|
|
87
90
|
if (route.meta.reqLogin) {
|
|
88
91
|
if (!isAuth.value) {
|
|
89
|
-
if (!redirectLink)
|
|
92
|
+
if (!redirectLink) {
|
|
93
|
+
router.push(path)
|
|
94
|
+
}
|
|
90
95
|
else {
|
|
91
|
-
router.status = 307
|
|
92
|
-
router.push(`${path}?return_to=${route.path}`)
|
|
96
|
+
router.status = 307
|
|
97
|
+
router.push(`${path}?return_to=${route.path}`)
|
|
93
98
|
}
|
|
94
99
|
}
|
|
95
100
|
}
|
|
96
|
-
}
|
|
97
|
-
checkUser(router.currentRoute)
|
|
101
|
+
}
|
|
102
|
+
checkUser(router.currentRoute)
|
|
98
103
|
|
|
99
104
|
router._router.afterEach(async () => {
|
|
100
|
-
await userStore.refreshUser()
|
|
101
|
-
})
|
|
105
|
+
await userStore.refreshUser()
|
|
106
|
+
})
|
|
102
107
|
router._router.beforeEach((to: any) => {
|
|
103
|
-
if (to.fullPath
|
|
104
|
-
checkUser(to)
|
|
108
|
+
if (to.fullPath !== path) {
|
|
109
|
+
checkUser(to)
|
|
105
110
|
}
|
|
106
|
-
})
|
|
111
|
+
})
|
|
107
112
|
}
|
|
108
113
|
|
|
109
|
-
export function useUserCheck(path =
|
|
110
|
-
const userStore = useUserStore()
|
|
111
|
-
const isAuth = computed(() => userStore.isAuth)
|
|
112
|
-
const router = useServerRouter()
|
|
114
|
+
export function useUserCheck(path = '/login', redirectLink = false) {
|
|
115
|
+
const userStore = useUserStore()
|
|
116
|
+
const isAuth = computed(() => userStore.isAuth)
|
|
117
|
+
const router = useServerRouter()
|
|
113
118
|
|
|
114
119
|
const checkUser = (route: RouteLocation) => {
|
|
115
120
|
if (route.meta.reqLogin) {
|
|
116
121
|
if (!isAuth.value) {
|
|
117
|
-
if (!redirectLink)
|
|
122
|
+
if (!redirectLink) {
|
|
123
|
+
router.push(path)
|
|
124
|
+
}
|
|
118
125
|
else {
|
|
119
|
-
router.status = 307
|
|
120
|
-
router.push(`${path}?return_to=${route.path}`)
|
|
126
|
+
router.status = 307
|
|
127
|
+
router.push(`${path}?return_to=${route.path}`)
|
|
121
128
|
}
|
|
122
129
|
}
|
|
123
130
|
}
|
|
124
|
-
}
|
|
131
|
+
}
|
|
125
132
|
userStore.refreshUser().then(() => {
|
|
126
133
|
if (router.currentRoute) {
|
|
127
|
-
checkUser(router.currentRoute)
|
|
134
|
+
checkUser(router.currentRoute)
|
|
128
135
|
}
|
|
129
|
-
})
|
|
136
|
+
})
|
|
130
137
|
router._router.afterEach(async () => {
|
|
131
|
-
await userStore.refreshUser()
|
|
132
|
-
})
|
|
138
|
+
await userStore.refreshUser()
|
|
139
|
+
})
|
|
133
140
|
router._router.beforeEach((to: any) => {
|
|
134
|
-
if (to.fullPath
|
|
135
|
-
checkUser(to)
|
|
141
|
+
if (to.fullPath !== path) {
|
|
142
|
+
checkUser(to)
|
|
136
143
|
}
|
|
137
|
-
})
|
|
144
|
+
})
|
|
138
145
|
}
|