images store part
This commit is contained in:
parent
24705fe8e0
commit
a38f5ad12c
|
@ -1,6 +1,6 @@
|
||||||
export default defineAppConfig({
|
export default defineAppConfig({
|
||||||
ui: {
|
ui: {
|
||||||
primary: 'pink',
|
primary: 'pink',
|
||||||
gray: 'cool'
|
gray: 'stone'
|
||||||
}
|
}
|
||||||
})
|
})
|
|
@ -5,10 +5,10 @@ import Logo from 'assets/logo.svg'
|
||||||
<template>
|
<template>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<div class="logo">
|
<NuxtLink to="/" class="logo">
|
||||||
<Logo />
|
<Logo />
|
||||||
</div>
|
Инвентаризация
|
||||||
<NuxtLink to="/">Инвентаризация</NuxtLink>
|
</NuxtLink>
|
||||||
</div>
|
</div>
|
||||||
<div class="sidebar">
|
<div class="sidebar">
|
||||||
<Sidebar />
|
<Sidebar />
|
||||||
|
|
|
@ -15,10 +15,6 @@
|
||||||
@apply text-lg;
|
@apply text-lg;
|
||||||
}
|
}
|
||||||
|
|
||||||
a[href]:not([class*=text]) {
|
|
||||||
// @apply text-primary-500 hover:text-primary-600
|
|
||||||
}
|
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
@apply grid grid-cols-12 mx-auto gap-4
|
@apply grid grid-cols-12 mx-auto gap-4
|
||||||
}
|
}
|
||||||
|
@ -27,6 +23,9 @@
|
||||||
@apply col-span-12 flex gap-2 p-2.5 border-b border-primary-700 bg-gradient-to-l from-primary-700;
|
@apply col-span-12 flex gap-2 p-2.5 border-b border-primary-700 bg-gradient-to-l from-primary-700;
|
||||||
.logo {
|
.logo {
|
||||||
@apply text-2xl;
|
@apply text-2xl;
|
||||||
|
svg {
|
||||||
|
@apply text-3xl inline-block;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +38,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-header {
|
.page-header {
|
||||||
@apply border-b border-primary-200 dark:border-primary-950 py-4 bg-gradient-to-l from-primary-200 dark:from-primary-950;
|
@apply border-b border-primary-200 dark:border-primary-950 py-2.5 bg-gradient-to-l from-primary-200 dark:from-primary-950;
|
||||||
}
|
}
|
||||||
|
|
||||||
dl {
|
dl {
|
||||||
|
|
|
@ -1,28 +1,27 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { useImagesStore } from '~/store/images';
|
||||||
|
|
||||||
const props = defineProps(['file_id'])
|
const props = defineProps(['file_id'])
|
||||||
|
const imagesStore = useImagesStore()
|
||||||
|
|
||||||
import { apiBase } from '~/helpers';
|
const img = ref(imagesStore.getImage(props.file_id))
|
||||||
const headers = new Headers();
|
|
||||||
headers.append("Content-Type", "application/json");
|
|
||||||
|
|
||||||
const isOpen = ref(false)
|
const isOpen = ref(false)
|
||||||
const file_url = ref()
|
|
||||||
|
|
||||||
const file_url_data = await $fetch(`${apiBase}/tgbot/items/get_image/${props.file_id}/`, { headers })
|
|
||||||
if ((file_url_data as string[]).length > 0) {
|
|
||||||
file_url.value = (file_url_data as string[])[0]
|
|
||||||
}
|
|
||||||
const openImage = () => {
|
const openImage = () => {
|
||||||
isOpen.value = !isOpen.value
|
isOpen.value = !isOpen.value
|
||||||
}
|
}
|
||||||
|
console.log(imagesStore.getImage(props.file_id))
|
||||||
|
watch(imagesStore, () => {
|
||||||
|
img.value = imagesStore.getImage(props.file_id)
|
||||||
|
}, { deep: true })
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<template v-if="file_url">
|
<template v-if="img.result">
|
||||||
<a href="#">
|
<a href="#">
|
||||||
<Icon name="i-mdi-image" @click="openImage" />
|
<Icon name="i-mdi-image" @click="openImage" />
|
||||||
</a>
|
</a>
|
||||||
<UModal v-model="isOpen">
|
<UModal v-model="isOpen">
|
||||||
<img :src="file_url" />
|
<img :src="img.result" />
|
||||||
</UModal>
|
</UModal>
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
|
@ -20,5 +20,5 @@ const links = [
|
||||||
]
|
]
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<UVerticalNavigation :links="links" />
|
<UVerticalNavigation :links="links" />
|
||||||
</template>
|
</template>
|
|
@ -8,14 +8,13 @@ export const useImagesStore = defineStore('images', {
|
||||||
state: () => ({ list: {} as imagesList }),
|
state: () => ({ list: {} as imagesList }),
|
||||||
actions: {
|
actions: {
|
||||||
getImage(name: string) {
|
getImage(name: string) {
|
||||||
if (this.list[name]) {
|
if (!this.list[name]) {
|
||||||
return this.list[name].result
|
|
||||||
} else {
|
|
||||||
this.list[name] = {
|
this.list[name] = {
|
||||||
status: 'idle',
|
status: 'idle',
|
||||||
result: 'https://media.istockphoto.com/id/1490517357/photo/scientists-are-researching-and-analyzing-harmful-contaminants-in-the-laboratory.webp?s=170667a&w=0&k=20&c=Fh4t-P_b-a1QxwyBUzUa0AuLp8FLNyLy4hl4HUm82Ao='
|
result: 'https://media.istockphoto.com/id/1490517357/photo/scientists-are-researching-and-analyzing-harmful-contaminants-in-the-laboratory.webp?s=170667a&w=0&k=20&c=Fh4t-P_b-a1QxwyBUzUa0AuLp8FLNyLy4hl4HUm82Ao='
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return this.list[name]
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
Loading…
Reference in New Issue