@mouseless/baked 1.0.0 → 1.0.2
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/module.json +1 -1
- package/dist/runtime/components/ErrorPage.vue +15 -3
- package/dist/runtime/composables/useToken.d.ts +2 -0
- package/dist/runtime/composables/useToken.js +13 -1
- package/dist/runtime/plugins/auth.js +1 -1
- package/dist/runtime/plugins/fetch.js +7 -4
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
<div class="text-2xl">
|
|
17
17
|
{{ l(errorInfo.message) }}
|
|
18
18
|
</div>
|
|
19
|
-
<AuthorizedContent>
|
|
19
|
+
<AuthorizedContent v-if="errorInfo.showSafeLinks">
|
|
20
20
|
<div class="text-2xl">
|
|
21
21
|
{{ l(safeLinksMessage) }}
|
|
22
22
|
</div>
|
|
23
23
|
</AuthorizedContent>
|
|
24
24
|
</div>
|
|
25
|
-
<AuthorizedContent>
|
|
25
|
+
<AuthorizedContent v-if="errorInfo.showSafeLinks">
|
|
26
26
|
<Divider
|
|
27
27
|
type="dashed"
|
|
28
28
|
class="my-8"
|
|
@@ -61,5 +61,17 @@ const statusCode = computed(() => {
|
|
|
61
61
|
const code = data.value?.data?.status ?? data.value?.statusCode ?? 999;
|
|
62
62
|
return code === 999 ? "APP" : code;
|
|
63
63
|
});
|
|
64
|
-
const errorInfo = computed(() =>
|
|
64
|
+
const errorInfo = computed(() => {
|
|
65
|
+
let result = errorInfos[`${statusCode.value}`];
|
|
66
|
+
if (!result) {
|
|
67
|
+
return errorInfos["999"];
|
|
68
|
+
}
|
|
69
|
+
if (result.customMessage) {
|
|
70
|
+
result = {
|
|
71
|
+
...result,
|
|
72
|
+
message: data.value?.data?.detail ?? data.value?.message ?? result.message
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
return result;
|
|
76
|
+
});
|
|
65
77
|
</script>
|
|
@@ -61,10 +61,22 @@ export default function() {
|
|
|
61
61
|
globalThis.addEventListener("token-changed", callback);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
function offChanged(callback) {
|
|
65
|
+
globalThis.removeEventListener("token-changed", callback);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function decode(value) {
|
|
69
|
+
const { access } = JSON.parse(value);
|
|
70
|
+
|
|
71
|
+
return JSON.parse(atob(access.split(".")[1]));
|
|
72
|
+
}
|
|
73
|
+
|
|
64
74
|
return {
|
|
65
75
|
current,
|
|
66
76
|
setCurrent,
|
|
67
|
-
onChanged
|
|
77
|
+
onChanged,
|
|
78
|
+
offChanged,
|
|
79
|
+
decode
|
|
68
80
|
};
|
|
69
81
|
};
|
|
70
82
|
|
|
@@ -37,7 +37,7 @@ export default defineNuxtPlugin({
|
|
|
37
37
|
// this is to prevent any unintended result when user is not authorized while it should be
|
|
38
38
|
//
|
|
39
39
|
// -10 is to leave a room just in case it is needed
|
|
40
|
-
Number.MIN_SAFE_INTEGER
|
|
40
|
+
Number.MIN_SAFE_INTEGER + 10
|
|
41
41
|
);
|
|
42
42
|
|
|
43
43
|
$router.beforeEach(async to => {
|
|
@@ -7,7 +7,6 @@ export default defineNuxtPlugin({
|
|
|
7
7
|
setup(nuxtApp) {
|
|
8
8
|
const fetch = ofetch.create();
|
|
9
9
|
const interceptors = Interceptors();
|
|
10
|
-
const optionsTemplate = { headers: { }, query: { }, attributes: { } };
|
|
11
10
|
|
|
12
11
|
// register the actual fetch at the end of the interceptor pipeline
|
|
13
12
|
interceptors.register("actual-fetch",
|
|
@@ -18,9 +17,13 @@ export default defineNuxtPlugin({
|
|
|
18
17
|
// wrap $fetch using interceptors to allow around interception
|
|
19
18
|
globalThis.$fetch = async(request, options) => {
|
|
20
19
|
// not all requests have headers, query, attributes objects. this might
|
|
21
|
-
// cause interceptors to fail.
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
// cause interceptors to fail. create fresh empty objects for each request.
|
|
21
|
+
return await interceptors.execute({ request, options: {
|
|
22
|
+
headers: {},
|
|
23
|
+
query: {},
|
|
24
|
+
attributes: {},
|
|
25
|
+
...options
|
|
26
|
+
} });
|
|
24
27
|
};
|
|
25
28
|
|
|
26
29
|
// Add to nuxtApp for access from plugins
|