@hostlink/nuxt-light 1.41.0 → 1.42.0
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/l-app-main.vue +3 -9
- package/dist/runtime/components/l-table.vue +6 -9
- package/dist/runtime/components/l-table.vue.d.ts +2 -2
- package/dist/runtime/composables/useLight.d.ts +6 -6
- package/dist/runtime/plugin.js +4 -3
- package/package.json +1 -1
- package/dist/runtime/composables/useAsyncObject.d.ts +0 -1
- package/dist/runtime/composables/useAsyncObject.js +0 -43
package/dist/module.json
CHANGED
|
@@ -3,7 +3,7 @@ import { useRoute, useRouter } from "vue-router";
|
|
|
3
3
|
import { useLight, q, m } from "#imports";
|
|
4
4
|
import { useQuasar } from "quasar";
|
|
5
5
|
import { useI18n } from "vue-i18n";
|
|
6
|
-
import { ref, computed, reactive, provide, watch, toRaw } from "vue";
|
|
6
|
+
import { ref, computed, reactive, provide, watch, toRaw, onBeforeUnmount } from "vue";
|
|
7
7
|
import { useRuntimeConfig } from "nuxt/app";
|
|
8
8
|
import { api } from "#imports";
|
|
9
9
|
const emits = defineEmits(["logout"]);
|
|
@@ -58,6 +58,7 @@ light.init(my.styles);
|
|
|
58
58
|
light.setMyRoles(my.roles);
|
|
59
59
|
light.setPermissions(my.permissions);
|
|
60
60
|
light.setMyFavorites(toRaw(my.myFavorites));
|
|
61
|
+
const _errorTimers = /* @__PURE__ */ new Map();
|
|
61
62
|
const myFavorites = computed(() => {
|
|
62
63
|
return light.getMyFavorites();
|
|
63
64
|
});
|
|
@@ -361,14 +362,7 @@ const onLogout = async () => {
|
|
|
361
362
|
<q-page-container :class="containerClass" :style="containerStyle"> <!-- Error message -->
|
|
362
363
|
<div class="q-gutter-sm q-pa-sm" v-if="system.devMode && $light.errors.length > 0">
|
|
363
364
|
<q-banner dense inline-actions class="bg-grey-4" v-for="error in $light.errors" rounded>
|
|
364
|
-
|
|
365
|
-
<q-card>
|
|
366
|
-
<q-card-section style="white-space: pre-wrap; overflow: auto;">
|
|
367
|
-
{{ error.stack }}
|
|
368
|
-
</q-card-section>
|
|
369
|
-
</q-card>
|
|
370
|
-
</q-expansion-item>
|
|
371
|
-
|
|
365
|
+
{{ error }}
|
|
372
366
|
<template v-slot:action>
|
|
373
367
|
<q-btn flat icon="sym_o_close" round dense @click="$light.removeError(error)" />
|
|
374
368
|
</template>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { useQuasar, QTable, Dialog } from "quasar";
|
|
3
|
+
import { defu } from "defu";
|
|
3
4
|
import { ref, computed, onMounted, useSlots, watch, reactive } from "vue";
|
|
4
5
|
import useLight from "../composables/useLight";
|
|
5
6
|
import GQLFieldBuilder from "../composables/GQLFieldBuilder";
|
|
@@ -256,9 +257,7 @@ const onLocalRequest = async (p) => {
|
|
|
256
257
|
p.pagination.rowsPerPage = saved;
|
|
257
258
|
}
|
|
258
259
|
}
|
|
259
|
-
|
|
260
|
-
builder.add(f);
|
|
261
|
-
});
|
|
260
|
+
builder.add(fields);
|
|
262
261
|
let localFilters = getFilterValue();
|
|
263
262
|
if (filters2) {
|
|
264
263
|
localFilters = {
|
|
@@ -601,13 +600,11 @@ const searchSelectFilter = (val, update, name) => {
|
|
|
601
600
|
|
|
602
601
|
<template v-if="col.searchType == 'select'">
|
|
603
602
|
<q-select dense clearable filled square v-model="filters[col.name]"
|
|
604
|
-
@update:model-value="onFilters" options-dense :options="localSearchOptions[col.name]"
|
|
605
|
-
map-options :multiple="col.searchMultiple" :color="$light.color" use-input
|
|
606
|
-
input-debounce="0"
|
|
607
|
-
@filter="(val, update) => {
|
|
603
|
+
@update:model-value="onFilters" options-dense :options="localSearchOptions[col.name]"
|
|
604
|
+
emit-value map-options :multiple="col.searchMultiple" :color="$light.color" use-input
|
|
605
|
+
input-debounce="0" @filter="(val, update) => {
|
|
608
606
|
searchSelectFilter(val, update, col.name);
|
|
609
|
-
}"
|
|
610
|
-
/>
|
|
607
|
+
}" />
|
|
611
608
|
</template>
|
|
612
609
|
|
|
613
610
|
<template v-if="col.searchType == 'date'">
|
|
@@ -44,8 +44,8 @@ export interface LTableRequest {
|
|
|
44
44
|
};
|
|
45
45
|
offset: number;
|
|
46
46
|
limit: number;
|
|
47
|
-
loadData: (model: string, filters: any, fields: Array<any>) => void;
|
|
48
|
-
loadObjects: (model: string, filters: any, fields: Array<any>) => void;
|
|
47
|
+
loadData: (model: string, filters: any, fields: Array<any> | Object) => void;
|
|
48
|
+
loadObjects: (model: string, filters: any, fields: Array<any> | Object) => void;
|
|
49
49
|
setData: (data: {
|
|
50
50
|
data: Array<{
|
|
51
51
|
data: any;
|
|
@@ -17,7 +17,7 @@ declare const light: {
|
|
|
17
17
|
devMode: boolean;
|
|
18
18
|
styles: any;
|
|
19
19
|
version: string;
|
|
20
|
-
errors: Array<
|
|
20
|
+
errors: Array<string>;
|
|
21
21
|
$q: {
|
|
22
22
|
addressbarColor: {
|
|
23
23
|
set: (hexColor: string) => void;
|
|
@@ -608,8 +608,8 @@ declare const light: {
|
|
|
608
608
|
reloadMyFavorites: () => Promise<void>;
|
|
609
609
|
getMyFavorites: () => any[];
|
|
610
610
|
isDarkMode: () => boolean;
|
|
611
|
-
addError: (err:
|
|
612
|
-
removeError: (error:
|
|
611
|
+
addError: (err: string) => void;
|
|
612
|
+
removeError: (error: string) => void;
|
|
613
613
|
setStyle: (name: string, value: any) => Promise<void>;
|
|
614
614
|
setCurrentRoute: (to: any) => void;
|
|
615
615
|
getID: () => number | null;
|
|
@@ -623,7 +623,7 @@ declare const _default: () => {
|
|
|
623
623
|
devMode: boolean;
|
|
624
624
|
styles: any;
|
|
625
625
|
version: string;
|
|
626
|
-
errors: Array<
|
|
626
|
+
errors: Array<string>;
|
|
627
627
|
$q: {
|
|
628
628
|
addressbarColor: {
|
|
629
629
|
set: (hexColor: string) => void;
|
|
@@ -1214,8 +1214,8 @@ declare const _default: () => {
|
|
|
1214
1214
|
reloadMyFavorites: () => Promise<void>;
|
|
1215
1215
|
getMyFavorites: () => any[];
|
|
1216
1216
|
isDarkMode: () => boolean;
|
|
1217
|
-
addError: (err:
|
|
1218
|
-
removeError: (error:
|
|
1217
|
+
addError: (err: string) => void;
|
|
1218
|
+
removeError: (error: string) => void;
|
|
1219
1219
|
setStyle: (name: string, value: any) => Promise<void>;
|
|
1220
1220
|
setCurrentRoute: (to: any) => void;
|
|
1221
1221
|
getID: () => number | null;
|
package/dist/runtime/plugin.js
CHANGED
|
@@ -2,7 +2,7 @@ import QMarkdownVuePlugin from "@quasar/quasar-ui-qmarkdown";
|
|
|
2
2
|
import "@quasar/quasar-ui-qmarkdown/dist/index.css";
|
|
3
3
|
import { createI18n } from "vue-i18n";
|
|
4
4
|
import createLight from "./composables/createLight.js";
|
|
5
|
-
import { defineNuxtPlugin } from "#app";
|
|
5
|
+
import { defineNuxtPlugin, useRoute } from "#app";
|
|
6
6
|
import "./assets/main.css";
|
|
7
7
|
import message_en from "./locales/en.json";
|
|
8
8
|
import message_zh from "./locales/zh-hk.json";
|
|
@@ -35,14 +35,15 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|
|
35
35
|
api.model("SystemValue").setDataPath("app.listSystemValue");
|
|
36
36
|
api.model("Permission").setDataPath("app.listPermission");
|
|
37
37
|
nuxtApp.vueApp.config.errorHandler = (err, instance, info) => {
|
|
38
|
+
const $route = useRoute();
|
|
38
39
|
const light = useLight();
|
|
39
40
|
if (light.devMode) {
|
|
40
41
|
console.log(err);
|
|
41
42
|
}
|
|
42
43
|
if (err instanceof Error) {
|
|
43
|
-
light.addError(err);
|
|
44
|
+
light.addError(err.message + " at " + $route.fullPath);
|
|
44
45
|
} else {
|
|
45
|
-
light.addError(
|
|
46
|
+
light.addError(JSON.stringify(err) + " at " + $route.fullPath);
|
|
46
47
|
}
|
|
47
48
|
};
|
|
48
49
|
nuxtApp.vueApp.use(QMarkdownVuePlugin);
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function (fields: Object): import("#app").AsyncData<any, import("#app").NuxtError<unknown> | undefined> | undefined;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { toQuery } from "@hostlink/light";
|
|
2
|
-
import { default as getModelField } from "./getModelField.js";
|
|
3
|
-
import { default as collect } from "./collect.js";
|
|
4
|
-
import { defu } from "defu";
|
|
5
|
-
import { useAsyncData, useRoute } from "#app";
|
|
6
|
-
let route = useRoute();
|
|
7
|
-
export default function(fields) {
|
|
8
|
-
if (!route.name) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
const [module, id_name] = route.name.split("-");
|
|
12
|
-
if (isNaN(Number(route.params[id_name]))) {
|
|
13
|
-
return useAsyncData(async () => {
|
|
14
|
-
return {};
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
const id = parseInt(route.params[id_name]);
|
|
18
|
-
let query = {};
|
|
19
|
-
const specialFields = {};
|
|
20
|
-
for (const [key, value] of Object.entries(fields)) {
|
|
21
|
-
const f = getModelField(module, key);
|
|
22
|
-
if (f) {
|
|
23
|
-
const gqlField = f.getGQLField();
|
|
24
|
-
if (typeof gqlField === "string") {
|
|
25
|
-
query[gqlField] = value;
|
|
26
|
-
} else {
|
|
27
|
-
query = defu(query, gqlField);
|
|
28
|
-
specialFields[key] = f;
|
|
29
|
-
}
|
|
30
|
-
} else {
|
|
31
|
-
query[key] = value;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return useAsyncData(async () => {
|
|
35
|
-
const data = await collect(module, toQuery(query)).where(id_name, id).first();
|
|
36
|
-
for (const [key, value] of Object.entries(specialFields)) {
|
|
37
|
-
if (value && typeof value === "object" && typeof value.getValue === "function") {
|
|
38
|
-
data[key] = value.getValue(data);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return data;
|
|
42
|
-
});
|
|
43
|
-
}
|