@hostlink/nuxt-light 0.0.88 → 0.0.90

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,5 +1,5 @@
1
1
  {
2
2
  "name": "light",
3
3
  "configKey": "light",
4
- "version": "0.0.88"
4
+ "version": "0.0.90"
5
5
  }
@@ -1,7 +1,8 @@
1
1
  <script setup>
2
+ import { useLight } from "#imports";
2
3
  import { useQuasar } from 'quasar';
3
4
  import { useI18n } from 'vue-i18n';
4
- import { useLight, q, getCurrentUser, m, f } from '../';
5
+ import { q, getCurrentUser, m, f } from '../';
5
6
  import { ref, computed, reactive, provide, watch } from 'vue';
6
7
  import { useRuntimeConfig } from 'nuxt/app';
7
8
 
@@ -17,12 +18,6 @@ const quasar = useQuasar();
17
18
  quasar.dark.set(false);
18
19
  const light = useLight();
19
20
 
20
- const props = defineProps({
21
- company: {
22
- type: String
23
- }
24
- });
25
-
26
21
  const tt = await q({
27
22
  app: ["menus", "viewAsMode", "languages", { i18nMessages: ["name", "value"] }],
28
23
  my: ["styles", "language", f('granted_storage:granted', { right: "system.storage" }, [])],
@@ -204,7 +199,7 @@ const storageUsagePercent = computed(() => {
204
199
  <q-btn dense flat round icon="menu" class="q-mr-sm" @click="toggleLeftDrawer" />
205
200
 
206
201
  <q-toolbar-title>
207
- {{ company }}
202
+ {{ light.getCompany() }}
208
203
  </q-toolbar-title>
209
204
 
210
205
  <q-space />
@@ -338,7 +333,7 @@ const storageUsagePercent = computed(() => {
338
333
  <q-footer class="bg-white text-grey" bordered>
339
334
  <q-item>
340
335
  <q-item-section>
341
- {{ company }} {{ appVersion }} - Copyright 2023 HostLink(HK). Build {{ light.getVersion() }}
336
+ {{ light.getCompany() }} {{ appVersion }} - Copyright 2023 HostLink(HK). Build {{ light.getVersion() }}
342
337
  </q-item-section>
343
338
  </q-item>
344
339
  </q-footer>
@@ -1,4 +1,5 @@
1
1
  <script setup>
2
+ import { useLight } from "#imports";
2
3
  import { useRuntimeConfig } from 'nuxt/app'
3
4
  import { setApiUrl } from '@hostlink/light'
4
5
  import { Dialog } from 'quasar'
@@ -8,9 +9,11 @@ setApiUrl(config?.public?.apiBase ?? '/api/');
8
9
 
9
10
 
10
11
  let app = null
11
-
12
+ const light = useLight()
12
13
  try {
13
14
  app = (await q({ app: ['company', 'companyLogo', 'logged', 'twoFactorAuthentication', 'googleClientId'] })).app;
15
+ light.setCompany(app.company);
16
+ light.setCompanyLogo(app.companyLogo);
14
17
  } catch (e) {
15
18
  Dialog.create({
16
19
  title: 'Error',
@@ -27,13 +30,13 @@ try {
27
30
  <q-layout v-if="!app.logged">
28
31
  <q-page-container class="bg-grey-2" style="color:#1f1f1f">
29
32
  <q-page padding>
30
- <l-login :company="app.company" :company-logo="app.companyLogo"
31
- :twoFactorAuthentication="app.twoFactorAuthentication" :google-client-id="app.googleClientId"></l-login>
33
+ <l-login :twoFactojrAuthentication="app.twoFactorAuthentication"
34
+ :google-client-id="app.googleClientId"></l-login>
32
35
  </q-page>
33
36
  </q-page-container>
34
37
  </q-layout>
35
38
 
36
- <l-app-main v-else :company="app.company">
39
+ <l-app-main>
37
40
  <slot></slot>
38
41
  </l-app-main>
39
42
  </template>
@@ -1,19 +1,15 @@
1
1
  <script setup>
2
+ import { useLight } from "#imports";
2
3
  import { ref, reactive, onMounted } from 'vue'
3
4
  import { useQuasar, Notify } from 'quasar';
4
5
  import { useI18n } from 'vue-i18n';
5
6
  import { m, notify } from '../';
6
7
 
7
- import { useRuntimeConfig } from 'nuxt/app';
8
-
9
8
  import { login, webauthnLogin } from '@hostlink/light';
10
9
 
11
- const config = useRuntimeConfig();
12
-
10
+ const light = useLight();
13
11
 
14
12
  const props = defineProps({
15
- company: String,
16
- companyLogo: String,
17
13
  twoFactorAuthentication: Boolean,
18
14
  googleClientId: String
19
15
  })
@@ -178,9 +174,9 @@ onMounted(() => {
178
174
  <template>
179
175
  <q-card bordered flat style="min-width:400px;max-width: 400px;" class="fixed-center">
180
176
  <q-card-section>
181
- <q-img :src="companyLogo" class="full-width" />
177
+ <q-img :src="light.getCompanyLogo()" class="full-width" />
182
178
  <div class="text-h6">
183
- {{ company }}
179
+ {{ light.getCompany() }}
184
180
  </div>
185
181
  <q-form ref="form1">
186
182
  <div class="q-gutter-sm">
@@ -1,11 +1,31 @@
1
1
  <script setup>
2
- import { useI18n } from 'vue-i18n';
3
- const i18n = useI18n();
2
+ import { ref } from 'vue'
3
+ const props = defineProps(["value", "dense"])
4
+ const menus = ref(null);
4
5
 
5
- defineProps(["value", "dense"])
6
6
 
7
- </script>
7
+ const expansion = ref(null);
8
+
9
+ const onShowChild = (menu) => {
10
+ menus.value.forEach((m) => {
11
+ if (m.value() !== menu) {
12
+ m.hide()
13
+ }
14
+ })
15
+ }
8
16
 
17
+ defineExpose({
18
+ hide: () => {
19
+ if (expansion.value) {
20
+ expansion.value.hide();
21
+ }
22
+ },
23
+ value: () => {
24
+ return props.value;
25
+ }
26
+ })
27
+
28
+ </script>
9
29
 
10
30
  <style scoped>
11
31
  .menu-list .q-item {
@@ -19,11 +39,12 @@ defineProps(["value", "dense"])
19
39
  color: #fff;
20
40
  }
21
41
  </style>
22
-
23
42
  <template>
24
- <q-expansion-item v-if="value.children?.length > 0" :label="i18n.t(value.label)" :icon="value.icon" :dense="dense">
43
+ <q-expansion-item v-if="value.children?.length > 0" :label="$t(value.label)" :icon="value.icon" :dense="dense"
44
+ ref="expansion">
25
45
  <q-list class="q-pl-md">
26
- <l-menu :value="menu" v-for="menu in value.children" :dense="dense"></l-menu>
46
+ <l-menu :value="menu" v-for="menu in value.children" :dense="dense" @show="onShowChild(menu)"
47
+ ref="menus"></l-menu>
27
48
  </q-list>
28
49
  </q-expansion-item>
29
50
  <q-list v-else class="menu-list" :dense="dense">
@@ -32,8 +53,8 @@ defineProps(["value", "dense"])
32
53
  <q-icon :name="value.icon" />
33
54
  </q-item-section>
34
55
  <q-item-section>
35
- <q-item-label v-text="i18n.t(value.label)"></q-item-label>
56
+ <q-item-label v-text="$t(value.label)"></q-item-label>
36
57
  </q-item-section>
37
58
  </q-item>
38
59
  </q-list>
39
- </template>
60
+ </template>
@@ -1,11 +1,11 @@
1
1
  <script setup>
2
+ import { useHead, useLight } from "#imports";
2
3
  import { useRouter, useRoute } from "vue-router"
3
4
  import { removeObject, getID } from '../'
4
- import { useI18n } from 'vue-i18n';
5
5
 
6
- const i18n = useI18n();
7
6
  const router = useRouter();
8
7
  const route = useRoute();
8
+ const light = useLight();
9
9
 
10
10
  const props = defineProps({
11
11
  type: {
@@ -71,7 +71,12 @@ if (props.addBtn) {
71
71
  showAddBtn = true
72
72
  }
73
73
 
74
- const title = props.title || route.path.split("/")[1].replace(/([a-z])(?=[A-Z])/g, '$1 ').replace(/([A-Z]*)(?=[A-Z][a-z])/g, '$1 ')
74
+ let title = props.title || route.path.split("/")[1].replace(/([a-z])(?=[A-Z])/g, '$1 ').replace(/([A-Z]*)(?=[A-Z][a-z])/g, '$1 ')
75
+
76
+ //remove double space
77
+ title = title.replace(/\s\s+/g, ' ');
78
+ //trim title
79
+ title = title.trim()
75
80
  const module = route.path.split("/")[1];
76
81
  const onDelete = async () => {
77
82
 
@@ -79,6 +84,10 @@ const onDelete = async () => {
79
84
  router.push(`/${module}`);
80
85
  }
81
86
  }
87
+
88
+ useHead({
89
+ title: light.getCompany() + " - " + title,
90
+ })
82
91
  </script>
83
92
 
84
93
  <template>
@@ -88,7 +97,7 @@ const onDelete = async () => {
88
97
  <l-add-btn v-if="showAddBtn" />
89
98
  <l-edit-btn v-if="showEditBtn" />
90
99
  <l-delete-btn v-if="showDeleteBtn" @submit="onDelete" />
91
- <q-toolbar-title>{{ i18n.t(title) }}</q-toolbar-title>
100
+ <q-toolbar-title>{{ $t(title) }}</q-toolbar-title>
92
101
  </q-toolbar>
93
102
 
94
103
  <div class="q-gutter-sm q-mb-sm">
@@ -5,6 +5,10 @@ interface Light {
5
5
  getStyle: (name: String, defaultValue: any) => any;
6
6
  setStyles: (styles: Object) => void;
7
7
  getVersion(): string;
8
+ getCompany(): string;
9
+ setCompany(company: string): void;
10
+ getCompanyLogo(): string;
11
+ setCompanyLogo(logo: string): void;
8
12
  }
9
- export declare function useLight(): Light;
13
+ export declare const useLight: () => Light;
10
14
  export * from "./lib";
@@ -1,8 +1,24 @@
1
1
  import packageJson from "../../package.json";
2
2
  const errors = [];
3
3
  let styles = {};
4
- export function useLight() {
4
+ const app = {
5
+ company: "",
6
+ companyLogo: ""
7
+ };
8
+ export const useLight = () => {
5
9
  return {
10
+ setCompany: (company) => {
11
+ app.company = company;
12
+ },
13
+ getCompany: () => {
14
+ return app.company;
15
+ },
16
+ setCompanyLogo: (logo) => {
17
+ app.companyLogo = logo;
18
+ },
19
+ getCompanyLogo: () => {
20
+ return app.companyLogo;
21
+ },
6
22
  getVersion: () => {
7
23
  return packageJson.version;
8
24
  },
@@ -28,5 +44,5 @@ export function useLight() {
28
44
  styles = s;
29
45
  }
30
46
  };
31
- }
47
+ };
32
48
  export * from "./lib/index.mjs";
@@ -18,6 +18,7 @@
18
18
  "System": "系統",
19
19
  "SystemBackup": "系統備份",
20
20
  "SystemValue": "系統值",
21
+ "System Value": "系統值",
21
22
  "Translate": "翻譯",
22
23
  "User": "使用者",
23
24
  "Setting": "設定",
@@ -151,5 +152,9 @@
151
152
  "Login": "登入",
152
153
  "Forget password": "忘記密碼",
153
154
  "Password is required": "密碼為必填",
154
- "Username is required": "使用者名稱為必填"
155
+ "Username is required": "使用者名稱為必填",
156
+ "Export": "匯出",
157
+ "Event Log": "事件紀錄",
158
+ "Mail Log": "郵件紀錄",
159
+ "User Log": "使用者紀錄"
155
160
  }
@@ -1,5 +1,3 @@
1
- import { loadSV, getSV } from "./../lib/SystemValue.mjs";
2
- loadSV("UserStatus");
3
1
  export default {
4
2
  username: {
5
3
  label: "Username",
@@ -39,7 +37,7 @@ export default {
39
37
  status: {
40
38
  label: "Status",
41
39
  format: (value) => {
42
- return getSV("UserStatus", value);
40
+ return ["Active", "Inactive"][value];
43
41
  }
44
42
  }
45
43
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostlink/nuxt-light",
3
- "version": "0.0.88",
3
+ "version": "0.0.90",
4
4
  "description": "HostLink Nuxt Light Framework",
5
5
  "repository": "@hostlink/nuxt-light",
6
6
  "license": "MIT",
@@ -1,10 +0,0 @@
1
- declare const _default: {
2
- label: string;
3
- icon: string;
4
- menus: {
5
- label: string;
6
- link: string;
7
- icon: string;
8
- }[];
9
- }[];
10
- export default _default;
@@ -1,37 +0,0 @@
1
- export default [
2
- {
3
- label: "系統管理",
4
- icon: "sym_o_settings",
5
- menus: [
6
- {
7
- label: "使用者管理",
8
- link: "/User",
9
- icon: "sym_o_person"
10
- }, {
11
- label: "角色管理",
12
- link: "/Role",
13
- icon: "sym_o_group"
14
- }, {
15
- label: "權限管理",
16
- link: "/Permission",
17
- icon: "sym_o_key"
18
- }, {
19
- label: "系統設定",
20
- link: "/Setting",
21
- icon: "sym_o_settings"
22
- }, {
23
- label: "User log",
24
- link: "/UserLog",
25
- icon: "sym_o_description"
26
- }, {
27
- label: "Mail log",
28
- link: "/MailLog",
29
- icon: "sym_o_description"
30
- }, {
31
- label: "Event log",
32
- link: "/EventLog",
33
- icon: "sym_o_description"
34
- }
35
- ]
36
- }
37
- ];