@hostlink/nuxt-light 1.20.6 → 1.21.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.
@@ -1,9 +1,14 @@
1
1
  <script setup>
2
2
  import { ref, computed, watch } from "vue";
3
3
  import { useQuasar } from 'quasar';
4
- import { q, m } from '../';
4
+ import { api } from '#imports';
5
+ const props = defineProps({
6
+ driveIndex: Number,
7
+ })
8
+
5
9
  const emit = defineEmits(["selected"]);
6
- const data = await q("fsListFolders", { path: "/" }, ["name", "path"]);
10
+
11
+ const data = await api.drive(props.driveIndex).folders.list("/")
7
12
  const folders = ref(data);
8
13
  const mode = ref("move");
9
14
  const folder = ref("/");
@@ -11,8 +16,10 @@ const parent = ref("/");
11
16
 
12
17
  const qua = useQuasar();
13
18
 
19
+ const drive = api.drive(props.driveIndex);
20
+
14
21
  watch(folder, async () => {
15
- folders.value = await q("fsListFolders", { path: folder.value }, ["name", "path"]);
22
+ folders.value = await drive.folders.list(folder.value)
16
23
  });
17
24
 
18
25
  const clickBack = () => {
@@ -31,10 +38,8 @@ const newFolder = ref(null);
31
38
 
32
39
  const onClickCreate = async () => {
33
40
  let f = folder.value + "/" + newFolder.value;
34
- await m("fsCreateFolder", { path: f });
35
-
41
+ await drive.folders.create(f);
36
42
  folder.value = f;
37
-
38
43
  mode.value = "move";
39
44
  }
40
45
 
@@ -58,9 +63,9 @@ const onClickMove = async () => {
58
63
  })
59
64
  }
60
65
 
61
- </script >
66
+ </script>
62
67
  <template>
63
- <q-menu transition-show="jump-down" transition-hide="jump-up" ref="menu" @before-show="show">
68
+ <q-menu transition-show="jump-down" transition-hide="jump-up" ref="menu">
64
69
  <q-card>
65
70
  <q-toolbar>
66
71
  <template v-if="mode == 'create'">
@@ -1,23 +1,33 @@
1
1
  <script setup>
2
2
  import { format, useQuasar } from "quasar"
3
3
  import { computed } from 'vue'
4
- import { q } from '../';
4
+ import { q, api } from '#imports';
5
5
  const { humanStorageSize } = format
6
6
 
7
- const props = defineProps(["modelValue"]);
8
7
  const quasar = useQuasar()
9
8
 
9
+ const props = defineProps({
10
+ path: {
11
+ type: String,
12
+ required: true
13
+ },
14
+ driveIndex: {
15
+ type: Number,
16
+ default: 0
17
+ },
18
+ })
10
19
 
11
- const file = await q("fsFile", {
12
- path: props.modelValue.path
13
- }, ["canPreview", "imagePath"])
20
+ const file = await api.drive(props.driveIndex).files.get(props.path, {
21
+ name: true,
22
+ size: true,
23
+ mime: true,
24
+ url: true,
25
+ lastModified: true,
26
+ lastModifiedHuman: true,
27
+ path: true,
28
+ });
29
+ const size = humanStorageSize(file.size)
14
30
 
15
- const size = humanStorageSize(props.modelValue.size)
16
-
17
- const full_url = computed(() => {
18
- let url = window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : '');
19
- return url + props.modelValue.imagePath;
20
- })
21
31
 
22
32
  const copyToClipboard = (text) => {
23
33
  navigator.clipboard.writeText(text).then(() => {
@@ -34,52 +44,35 @@ const copyToClipboard = (text) => {
34
44
  });
35
45
  }
36
46
 
47
+
48
+ const canPreview = computed(() => {
49
+ //check file mime type
50
+ const mime = ['image/jpeg', 'image/png', 'image/gif'];
51
+ return mime.includes(file.mime);
52
+
53
+ });
54
+
37
55
  </script>
38
56
  <template>
39
- <template v-if="file.canPreview">
40
- <q-img :src="file.imagePath"></q-img>
57
+ <template v-if="canPreview">
58
+ <q-img :src="file.url"></q-img>
41
59
  </template>
42
60
  <q-list dense>
61
+ <l-item label="Name">{{ file.name }}</l-item>
62
+ <l-item label="Size">{{ size }} ({{ file.size }})</l-item>
63
+ <l-item label="Location">{{ file.path }}</l-item>
64
+ <l-item label="Last modified">{{ file.lastModifiedHuman }}</l-item>
65
+
43
66
  <q-item>
44
- <q-item-section>
45
- <q-item-label>Name</q-item-label>
46
- </q-item-section>
47
- <q-item-section side>
48
- <q-item-label lines="1">
49
- {{ modelValue.name }}
50
- </q-item-label>
51
- </q-item-section>
52
- </q-item>
53
- <q-item>
54
- <q-item-section>
55
- <q-item-label>Size</q-item-label>
56
- </q-item-section>
57
- <q-item-section side>{{ size }} ({{ modelValue.size }}) </q-item-section>
58
- </q-item>
59
- <q-item>
60
- <q-item-section>
61
- <q-item-label>Location</q-item-label>
62
- </q-item-section>
63
67
  <q-item-section side>
64
- <q-item-label lines="1">{{ modelValue.path }}</q-item-label>
65
- </q-item-section>
66
- </q-item>
67
- <q-item>
68
- <q-item-section>
69
- <q-item-label>Last modified</q-item-label>
70
- </q-item-section>
71
- <q-item-section side>{{ modelValue.lastModifiedHuman }}</q-item-section>
72
- </q-item>
73
- <q-item>
74
- <q-item-section>
75
68
  <q-item-label>URL</q-item-label>
76
69
  </q-item-section>
77
- <q-item-section side>
78
- <q-item-label lines="1">{{ full_url }}</q-item-label>
70
+ <q-item-section style="align-items: flex-end;">
71
+ <q-item-label lines="1">{{ file.url }}</q-item-label>
79
72
  </q-item-section>
80
73
 
81
74
  <q-item-section top side>
82
- <q-btn size="md" flat danse round icon="sym_o_content_copy" @click="copyToClipboard(full_url)"></q-btn>
75
+ <q-btn size="md" flat danse round icon="sym_o_content_copy" @click="copyToClipboard(file.url)"></q-btn>
83
76
  </q-item-section>
84
77
  </q-item>
85
78
  </q-list>