@hostlink/nuxt-light 0.0.15 → 0.0.17

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.15"
4
+ "version": "0.0.17"
5
5
  }
@@ -1,7 +1,9 @@
1
1
  <script setup>
2
2
  import { useI18n } from 'vue-i18n';
3
3
  import { useLight, q, getCurrentUser } from '../light';
4
- import { ref, computed, reactive } from 'vue';
4
+ import { ref, computed, reactive, provide } from 'vue';
5
+
6
+
5
7
 
6
8
 
7
9
  const light = useLight();
@@ -12,6 +14,7 @@ const props = defineProps({
12
14
  });
13
15
 
14
16
  let app = await q("app", ["menus"]);
17
+ const menus = ref(app.menus)
15
18
 
16
19
  const i18n = useI18n();
17
20
  i18n.locale = 'zh-hk';
@@ -37,8 +40,6 @@ if (user.value && user.value.roles.indexOf('Administrators') != -1) {
37
40
  showViewAs = true;
38
41
  }
39
42
 
40
- //const menus = (await queryContent("/menus").findOne()).menus;
41
- const menus = [];
42
43
 
43
44
  const menuOverlayHeader = ref(false)
44
45
  const layoutView = computed(() => {
@@ -100,6 +101,14 @@ const errors = computed(() => {
100
101
  return light.getErrors();
101
102
  })
102
103
 
104
+ const reloadMenu = async () => {
105
+ //menus.value = app.menus;
106
+ let app = await q("app", ["menus"]);
107
+ menus.value = app.menus
108
+ }
109
+
110
+ provide('reloadMenu', reloadMenu)
111
+
103
112
  </script>
104
113
 
105
114
 
@@ -177,8 +186,7 @@ const errors = computed(() => {
177
186
  @mouseover="isMouseOnDrawer = true">
178
187
  <!-- drawer content -->
179
188
  <q-scroll-area class="fit">
180
- <l-menu v-for="menu in app.menus" :value="menu" v-if="isAdmin" :dense="style.dense" />
181
- <l-menu v-for="menu in menus" :value="menu" />
189
+ <l-menu v-for="menu in menus" :value="menu" v-if="isAdmin" :dense="style.dense" />
182
190
  </q-scroll-area>
183
191
  </q-drawer>
184
192
 
@@ -201,7 +209,7 @@ const errors = computed(() => {
201
209
  error }}
202
210
  </q-card-section>
203
211
  </q-card>
204
- <slot />
212
+ <slot :reload="reloadMenu" />
205
213
  </q-page-container>
206
214
 
207
215
 
@@ -1,6 +1,6 @@
1
1
  <script setup>
2
2
 
3
- defineProps(["value","dense"])
3
+ defineProps(["value", "dense"])
4
4
 
5
5
  </script>
6
6
 
@@ -19,9 +19,9 @@ defineProps(["value","dense"])
19
19
  </style>
20
20
 
21
21
  <template>
22
- <q-expansion-item v-if="value.menus" :label="value.label" :icon="value.icon" :dense="dense">
22
+ <q-expansion-item v-if="value.children?.length > 0" :label="value.label" :icon="value.icon" :dense="dense">
23
23
  <q-list class="q-pl-md">
24
- <l-menu :value="menu" v-for="menu in value.menus" :dense="dense"></l-menu>
24
+ <l-menu :value="menu" v-for="menu in value.children" :dense="dense"></l-menu>
25
25
  </q-list>
26
26
  </q-expansion-item>
27
27
  <q-list v-else class="menu-list" :dense="dense">
@@ -1,5 +1,5 @@
1
1
  <script setup>
2
- import { reactive, ref, computed } from 'vue';
2
+ import { reactive, ref, computed, inject } from 'vue';
3
3
  import { m, q } from "../../../light";
4
4
  import { useQuasar } from 'quasar';
5
5
 
@@ -82,11 +82,12 @@ const onRemove = (node) => {
82
82
  }
83
83
  }
84
84
 
85
- const splitterModel = ref(50)
85
+ const splitterModel = ref(38)
86
86
 
87
87
  const selectedNode = computed(() => {
88
88
  return tree1.value.getNodeByKey(selected.value);
89
89
  });
90
+ const reloadMenu = inject('reloadMenu')
90
91
 
91
92
  const onSave = () => {
92
93
 
@@ -107,8 +108,10 @@ const onSave = () => {
107
108
  position: 'top',
108
109
  timeout: 1000,
109
110
  });
110
- }
111
111
 
112
+ //
113
+ }
114
+ reloadMenu()
112
115
  });
113
116
  }
114
117
 
@@ -151,9 +154,31 @@ const onMoveToRoot = () => {
151
154
  menus.value.push(newNode);
152
155
 
153
156
  showMove.value = false;
157
+ }
154
158
 
159
+ const getParentNode = (node) => {
160
+ if (!node.parent) return menus.value;
161
+ return tree1.value.getNodeByKey(node.parent);
162
+ }
155
163
 
164
+ const onMoveUp = (node) => {
165
+ const parent = getParentNode(node);
166
+ const index = parent.children.findIndex((item) => item.uuid === node.uuid);
167
+ if (index > 0) {
168
+ const temp = parent.children[index - 1];
169
+ parent.children[index - 1] = node;
170
+ parent.children[index] = temp;
171
+ }
172
+ }
156
173
 
174
+ const onMoveDown = (node) => {
175
+ const parent = getParentNode(node);
176
+ const index = parent.children.findIndex((item) => item.uuid === node.uuid);
177
+ if (index < parent.children.length - 1) {
178
+ const temp = parent.children[index + 1];
179
+ parent.children[index + 1] = node;
180
+ parent.children[index] = temp;
181
+ }
157
182
  }
158
183
  </script>
159
184
 
@@ -199,6 +224,11 @@ const onMoveToRoot = () => {
199
224
  <q-btn outline rounded color="primary" @click="onMove(selectedNode)" label="Move"
200
225
  icon="sym_o_move" />
201
226
 
227
+ <q-btn outline rounded color="primary" @click="onMoveUp(selectedNode)" label="Up"
228
+ icon="sym_o_arrow_upward" />
229
+
230
+ <q-btn outline rounded color="primary" @click="onMoveDown(selectedNode)" label="Up"
231
+ icon="sym_o_arrow_downward" />
202
232
  </q-card-section>
203
233
 
204
234
 
@@ -1,8 +1,20 @@
1
+ <script setup>
2
+ import { inject } from "vue";
3
+
4
+
5
+ const reloadMenu = inject('reloadMenu')
6
+
7
+ const onClick = (parent) => {
8
+ reloadMenu()
9
+
10
+ }
11
+ </script>
1
12
  <template>
2
13
  <q-page padding>
3
14
  <l-card>
4
15
  <q-card-section>
5
- Hello
16
+ Helloas
17
+ <q-btn label="click" @click="onClick($parent)"></q-btn>
6
18
  </q-card-section>
7
19
  </l-card>
8
20
  </q-page>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostlink/nuxt-light",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "description": "HostLink Nuxt Light Framework",
5
5
  "repository": "@hostlink/nuxt-light",
6
6
  "license": "MIT",