@data-fair/lib-vue 1.14.0 → 1.15.1
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/package.json +1 -1
- package/session.d.ts +3 -1
- package/session.js +10 -7
- package/ui-notif.js +2 -2
package/package.json
CHANGED
package/session.d.ts
CHANGED
|
@@ -51,6 +51,8 @@ interface FullSiteInfo {
|
|
|
51
51
|
darkColors?: Colors;
|
|
52
52
|
hc: boolean;
|
|
53
53
|
hcColors?: Colors;
|
|
54
|
+
hcDark: boolean;
|
|
55
|
+
hcDarkColors?: Colors;
|
|
54
56
|
};
|
|
55
57
|
}
|
|
56
58
|
export interface SiteInfo {
|
|
@@ -59,7 +61,7 @@ export interface SiteInfo {
|
|
|
59
61
|
dark?: boolean;
|
|
60
62
|
colors: Colors;
|
|
61
63
|
}
|
|
62
|
-
type Theme = 'default' | 'dark' | 'hc';
|
|
64
|
+
type Theme = 'default' | 'dark' | 'hc' | 'hc-dark';
|
|
63
65
|
export interface Session {
|
|
64
66
|
state: SessionState;
|
|
65
67
|
user: ComputedRef<SessionState['user']>;
|
package/session.js
CHANGED
|
@@ -11,12 +11,11 @@ const debug = Debug('session')
|
|
|
11
11
|
debug.log = console.log.bind(console)
|
|
12
12
|
function getDefaultTheme (site) {
|
|
13
13
|
// see https://www.scottohara.me/blog/2021/10/01/detect-high-contrast-and-dark-modes.html
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
if (site.theme.
|
|
18
|
-
|
|
19
|
-
}
|
|
14
|
+
const preferDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
15
|
+
const preferHC = window.matchMedia && window.matchMedia('(forced-colors: active)').matches
|
|
16
|
+
if (site.theme.hcDark && preferDark && preferHC) { return 'hc-dark' }
|
|
17
|
+
if (site.theme.hc && preferHC) { return 'hc' }
|
|
18
|
+
if (site.theme.dark && preferDark) { return 'dark' }
|
|
20
19
|
return 'default'
|
|
21
20
|
}
|
|
22
21
|
function jwtDecodeAlive (jwt) {
|
|
@@ -73,7 +72,7 @@ export async function getSession (initOptions) {
|
|
|
73
72
|
// cookies are the source of truth and this information is transformed into the state reactive object
|
|
74
73
|
const cookies = initOptions?.cookies ?? new Cookies(options.req?.headers.cookie)
|
|
75
74
|
const readState = () => {
|
|
76
|
-
theme.value = cookies.get('theme') ??
|
|
75
|
+
theme.value = cookies.get('theme') ?? null
|
|
77
76
|
const langCookie = cookies.get('i18n_lang')
|
|
78
77
|
state.lang = langCookie ?? options.defaultLang
|
|
79
78
|
const idToken = cookies.get('id_token')
|
|
@@ -250,6 +249,10 @@ export async function getSession (initOptions) {
|
|
|
250
249
|
partialSite.colors = siteInfo.theme.darkColors
|
|
251
250
|
partialSite.dark = true
|
|
252
251
|
}
|
|
252
|
+
if (theme.value === 'hc-dark') {
|
|
253
|
+
partialSite.colors = siteInfo.theme.hcDarkColors
|
|
254
|
+
partialSite.dark = true
|
|
255
|
+
}
|
|
253
256
|
site.value = partialSite
|
|
254
257
|
} else {
|
|
255
258
|
site.value = siteInfo
|
package/ui-notif.js
CHANGED
|
@@ -15,8 +15,8 @@ export function getErrorMsg (error) {
|
|
|
15
15
|
if (typeof error === 'string') { return error }
|
|
16
16
|
if (error.data && typeof error.data === 'string') { return error.data }
|
|
17
17
|
if (error.response?.data && typeof error.response.data === 'string') { return error.response.data }
|
|
18
|
-
if (typeof error.statusText === 'string') { return error.statusText }
|
|
19
|
-
if (typeof error.response?.statusText === 'string') { return error.response?.statusText }
|
|
18
|
+
if (error.statusText && typeof error.statusText === 'string') { return error.statusText }
|
|
19
|
+
if (error.response?.statusText && typeof error.response?.statusText === 'string') { return error.response?.statusText }
|
|
20
20
|
if (error.message) { return error.message }
|
|
21
21
|
return 'erreur inconnue'
|
|
22
22
|
}
|