@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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mouseless/baked",
3
3
  "configKey": "baked",
4
- "version": "1.0.0",
4
+ "version": "1.0.2",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -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(() => errorInfos[`${statusCode.value}`] ?? errorInfos["999"]);
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>
@@ -8,4 +8,6 @@ export default function _default(): {
8
8
  } | null>;
9
9
  setCurrent: (value: any, dispatch?: boolean) => void;
10
10
  onChanged: (callback: any) => void;
11
+ offChanged: (callback: any) => void;
12
+ decode: (value: any) => any;
11
13
  };
@@ -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 - 10
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. options template makes sure every
22
- // request has those objects to be set to an empty object.
23
- return await interceptors.execute({ request, options: { ...optionsTemplate, ...options } });
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mouseless/baked",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Baked is an opinionated framework for .NET and Vue. This is the UI package of Baked project.",
5
5
  "keywords": [
6
6
  "baked",