This commit is contained in:
parent
45f01f129c
commit
4c13799f44
83
components/ShortText.vue
Normal file
83
components/ShortText.vue
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
<template>
|
||||||
|
<div ref="wrapper" class="short-text">
|
||||||
|
<!-- Mobile -->
|
||||||
|
<UTooltip
|
||||||
|
v-if="isMobile"
|
||||||
|
:text="text"
|
||||||
|
:open="open"
|
||||||
|
:disabled="!tooltipEnabled"
|
||||||
|
:ui="{ text: 'whitespace-normal break-words', content: 'max-w-50 h-auto' }"
|
||||||
|
>
|
||||||
|
<span :ref="checkSize" :class="textPrimary ? 'short-text--primary' : ''">{{ text }}</span>
|
||||||
|
<Icon
|
||||||
|
v-if="tooltipEnabled"
|
||||||
|
name="heroicons:information-circle"
|
||||||
|
class="short-text__icon"
|
||||||
|
@click.stop="open = !open"
|
||||||
|
/>
|
||||||
|
</UTooltip>
|
||||||
|
|
||||||
|
<!-- Desktop -->
|
||||||
|
<UTooltip
|
||||||
|
v-else
|
||||||
|
:text="text"
|
||||||
|
:disabled="!tooltipEnabled"
|
||||||
|
:ui="{ text: 'whitespace-normal break-words', content: 'max-w-80 h-auto' }"
|
||||||
|
>
|
||||||
|
<span :ref="checkSize" :class="textPrimary ? 'short-text--primary' : ''">{{ text }}</span>
|
||||||
|
</UTooltip>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { onClickOutside, unrefElement } from '@vueuse/core'
|
||||||
|
|
||||||
|
defineProps<{ text: string, textPrimary?: boolean }>()
|
||||||
|
|
||||||
|
const wrapper = ref<HTMLElement | null>(null)
|
||||||
|
const open = ref(false)
|
||||||
|
const tooltipEnabled = ref(true)
|
||||||
|
|
||||||
|
const { isMobile } = useScreen()
|
||||||
|
|
||||||
|
onClickOutside(wrapper, () => {
|
||||||
|
open.value = false
|
||||||
|
})
|
||||||
|
|
||||||
|
function checkSize(_el: HTMLElement) {
|
||||||
|
const el = unrefElement(_el)
|
||||||
|
|
||||||
|
tooltipEnabled.value = el ? el.scrollWidth > el.clientWidth : false
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.short-text {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
|
||||||
|
&--primary {
|
||||||
|
cursor: pointer;
|
||||||
|
text-decoration: underline;
|
||||||
|
color: var(--ui-primary);
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: var(--ui-primary-hover);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
> span {
|
||||||
|
display: block;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__icon {
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -10,15 +10,12 @@
|
|||||||
<tr
|
<tr
|
||||||
v-for="headerGroup in table?.getHeaderGroups()"
|
v-for="headerGroup in table?.getHeaderGroups()"
|
||||||
:key="headerGroup?.id"
|
:key="headerGroup?.id"
|
||||||
|
:style="{ gridTemplateColumns }"
|
||||||
>
|
>
|
||||||
<th
|
<th
|
||||||
v-for="header in headerGroup?.headers"
|
v-for="header in headerGroup?.headers"
|
||||||
:key="header.id"
|
:key="header.id"
|
||||||
:colspan="header?.colSpan"
|
:colspan="header?.colSpan"
|
||||||
:style="[
|
|
||||||
header?.column?.columnDef?.meta?.style,
|
|
||||||
{ width: `${header?.getSize()}px` },
|
|
||||||
]"
|
|
||||||
@click="header?.column?.getToggleSortingHandler()?.($event)"
|
@click="header?.column?.getToggleSortingHandler()?.($event)"
|
||||||
>
|
>
|
||||||
<FlexRender
|
<FlexRender
|
||||||
@ -38,15 +35,11 @@
|
|||||||
:ref="measureElement"
|
:ref="measureElement"
|
||||||
:key="rows[vRow?.index]?.id"
|
:key="rows[vRow?.index]?.id"
|
||||||
:data-index=" vRow?.index"
|
:data-index=" vRow?.index"
|
||||||
:style="{ transform: `translateY(${vRow?.start}px)` }"
|
:style="{ gridTemplateColumns, transform: `translateY(${vRow?.start}px)` }"
|
||||||
>
|
>
|
||||||
<td
|
<td
|
||||||
v-for="cell in rows[vRow?.index]?.getVisibleCells()"
|
v-for="cell in rows[vRow?.index]?.getVisibleCells()"
|
||||||
:key="cell?.id"
|
:key="cell?.id"
|
||||||
:style="[
|
|
||||||
cell?.column?.columnDef.meta?.style,
|
|
||||||
{ width: `${cell?.column?.getSize()}px` },
|
|
||||||
]"
|
|
||||||
>
|
>
|
||||||
<FlexRender
|
<FlexRender
|
||||||
:render="cell?.column?.columnDef?.cell"
|
:render="cell?.column?.columnDef?.cell"
|
||||||
@ -61,10 +54,17 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import type { RowData } from '@tanstack/table-core'
|
||||||
import type { ColumnDef } from '@tanstack/vue-table'
|
import type { ColumnDef } from '@tanstack/vue-table'
|
||||||
import { FlexRender, getCoreRowModel, getSortedRowModel, useVueTable } from '@tanstack/vue-table'
|
import { FlexRender, getCoreRowModel, getSortedRowModel, useVueTable } from '@tanstack/vue-table'
|
||||||
import { useVirtualizer } from '@tanstack/vue-virtual'
|
import { useVirtualizer } from '@tanstack/vue-virtual'
|
||||||
|
|
||||||
|
declare module '@tanstack/vue-table' {
|
||||||
|
interface ColumnMeta<TData extends RowData, TValue> {
|
||||||
|
width?: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
tableData: any[]
|
tableData: any[]
|
||||||
columns: ColumnDef<any>[]
|
columns: ColumnDef<any>[]
|
||||||
@ -98,6 +98,12 @@ const rowVirtualizer = useVirtualizer(rowVirtualizerOptions)
|
|||||||
const virtualRows = computed(() => rowVirtualizer?.value?.getVirtualItems())
|
const virtualRows = computed(() => rowVirtualizer?.value?.getVirtualItems())
|
||||||
const totalSize = computed(() => rowVirtualizer?.value?.getTotalSize())
|
const totalSize = computed(() => rowVirtualizer?.value?.getTotalSize())
|
||||||
|
|
||||||
|
const gridTemplateColumns = computed(() => {
|
||||||
|
return props.columns.map((column) => {
|
||||||
|
return column.meta?.width || '1fr'
|
||||||
|
}).join(' ')
|
||||||
|
})
|
||||||
|
|
||||||
function measureElement(el?: Element) {
|
function measureElement(el?: Element) {
|
||||||
if (!el) {
|
if (!el) {
|
||||||
return
|
return
|
||||||
@ -116,14 +122,16 @@ function measureElement(el?: Element) {
|
|||||||
margin-top: calc(40px + 10px);
|
margin-top: calc(40px + 10px);
|
||||||
border-radius: 14px;
|
border-radius: 14px;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
@include mobile {
|
@include mobile {
|
||||||
height: 500px;
|
height: 500px !important;
|
||||||
|
width: 100% !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
table {
|
table {
|
||||||
min-width: 100%;
|
width: 100%;
|
||||||
border-collapse: separate;
|
border-collapse: separate;
|
||||||
border-spacing: 0;
|
border-spacing: 0;
|
||||||
|
|
||||||
@ -135,7 +143,6 @@ table {
|
|||||||
/* -------------------- HEADER -------------------- */
|
/* -------------------- HEADER -------------------- */
|
||||||
|
|
||||||
thead {
|
thead {
|
||||||
display: grid;
|
|
||||||
position: sticky;
|
position: sticky;
|
||||||
top: 0;
|
top: 0;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
@ -143,11 +150,11 @@ thead {
|
|||||||
}
|
}
|
||||||
|
|
||||||
thead tr {
|
thead tr {
|
||||||
display: flex;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
thead th {
|
thead th {
|
||||||
|
flex-shrink: 0;
|
||||||
background: var(--ui-bg-accented);
|
background: var(--ui-bg-accented);
|
||||||
color: var(--ui-text);
|
color: var(--ui-text);
|
||||||
padding: 12px 14px;
|
padding: 12px 14px;
|
||||||
@ -165,12 +172,10 @@ thead th:hover {
|
|||||||
/* -------------------- BODY -------------------- */
|
/* -------------------- BODY -------------------- */
|
||||||
|
|
||||||
tbody {
|
tbody {
|
||||||
display: grid;
|
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
tbody tr {
|
tbody tr {
|
||||||
display: flex;
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 50px;
|
height: 50px;
|
||||||
@ -186,6 +191,10 @@ tbody tr:hover {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tbody td {
|
tbody td {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
flex-shrink: 0;
|
||||||
padding: 10px 12px;
|
padding: 10px 12px;
|
||||||
border-bottom: 1px solid var(--ui-border-subtle);
|
border-bottom: 1px solid var(--ui-border-subtle);
|
||||||
}
|
}
|
||||||
@ -193,4 +202,13 @@ tbody td {
|
|||||||
tbody tr:last-child td {
|
tbody tr:last-child td {
|
||||||
border-bottom: none;
|
border-bottom: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tr {
|
||||||
|
display: grid;
|
||||||
|
}
|
||||||
|
|
||||||
|
th,
|
||||||
|
td {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -1,36 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div ref="wrapper" class="table-short-text" v-bind="attrs">
|
|
||||||
<UTooltip v-if="isMobile" :text="text" :open="open">
|
|
||||||
{{ truncate(text, maxLength) }}
|
|
||||||
<Icon
|
|
||||||
v-if="!hideIcon"
|
|
||||||
name="heroicons:information-circle"
|
|
||||||
@click="open = !open"
|
|
||||||
/>
|
|
||||||
</UTooltip>
|
|
||||||
|
|
||||||
<UTooltip v-else :text="text">
|
|
||||||
<span>{{ truncate(text, maxLength) }}</span>
|
|
||||||
</UTooltip>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { onClickOutside, useMediaQuery } from '@vueuse/core'
|
|
||||||
|
|
||||||
defineProps<{ text: string, maxLength: number, hideIcon: boolean }>()
|
|
||||||
const attrs = useAttrs()
|
|
||||||
|
|
||||||
const wrapper = ref<HTMLElement | null>(null)
|
|
||||||
const open = ref(false)
|
|
||||||
|
|
||||||
const isMobile = useMediaQuery('(max-width: 1280px)')
|
|
||||||
|
|
||||||
onClickOutside(wrapper, () => {
|
|
||||||
open.value = false
|
|
||||||
})
|
|
||||||
|
|
||||||
function truncate(text: string, max = 15) {
|
|
||||||
return text?.length > max ? `${text?.slice(0, max)}…` : text
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@ -1,36 +1,74 @@
|
|||||||
<template>
|
<template>
|
||||||
<UModal v-model:open="open" :title="selectedUser.email">
|
<UModal
|
||||||
|
v-model:open="open"
|
||||||
|
:title="user.email"
|
||||||
|
class="user-modal"
|
||||||
|
@after:leave="emit('close')"
|
||||||
|
>
|
||||||
<template #body>
|
<template #body>
|
||||||
<div>
|
<div>
|
||||||
<div>Имя: {{ selectedUser.name }}</div>
|
<div>Имя: {{ user.name }}</div>
|
||||||
<div>Логин: {{ selectedUser.username }}</div>
|
<div>Логин: {{ user.username }}</div>
|
||||||
<div>
|
<div>
|
||||||
<a
|
<a
|
||||||
:href="`mailto:${selectedUser.email}`"
|
:href="`mailto:${user.email}`"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
>
|
>
|
||||||
Электронная почта: {{ selectedUser.email }}
|
Электронная почта: <span>{{ user.email }}</span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<a
|
<a
|
||||||
:href="`tel:${selectedUser.phone}`"
|
:href="`tel:${user.phone}`"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
>
|
>
|
||||||
Телефон: {{ selectedUser.phone }}
|
Телефон: <span>{{ user.phone }}</span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<a :href="`https://${selectedUser.website}`" target="_blank">Веб-сайт: <span class="title-cell">{{ selectedUser.website }}</span></a>
|
<a
|
||||||
<div>Название компании: {{ selectedUser.company.name }}</div>
|
:href="`https://${user.website}`"
|
||||||
<div>Адрес: {{ `${selectedUser.address.street} ${selectedUser.address.suite} ${selectedUser.address.city}` }}</div>
|
target="_blank"
|
||||||
|
>
|
||||||
|
Веб-сайт: <span>{{ user.website }}</span>
|
||||||
|
</a>
|
||||||
|
<div>Название компании: {{ user.company.name }}</div>
|
||||||
|
<div>Адрес: {{ `${user.address.street} ${user.address.suite} ${user.address.city}` }}</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</UModal>
|
</UModal>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
defineProps<{ selectedUser: User }>()
|
const props = defineProps<{ user: User }>()
|
||||||
const open = defineModel<boolean>('modelValue')
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
close: []
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const open = ref(!!props.user)
|
||||||
|
|
||||||
|
watch(() => props.user, (user) => {
|
||||||
|
if (!user)
|
||||||
|
return
|
||||||
|
|
||||||
|
open.value = true
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.user-modal {
|
||||||
|
a {
|
||||||
|
span {
|
||||||
|
cursor: pointer;
|
||||||
|
text-decoration: underline;
|
||||||
|
color: var(--ui-primary);
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: var(--ui-primary-hover);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
12
composables/useScreen.ts
Normal file
12
composables/useScreen.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { useMediaQuery } from '@vueuse/core'
|
||||||
|
|
||||||
|
export default function useScreen() {
|
||||||
|
const isMobile = useMediaQuery('(max-width: 1279px)')
|
||||||
|
|
||||||
|
const isDesktop = computed(() => !isMobile.value)
|
||||||
|
|
||||||
|
return {
|
||||||
|
isMobile,
|
||||||
|
isDesktop,
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -13,19 +13,19 @@
|
|||||||
|
|
||||||
<UiTable :table-data="tableData" :columns="columns" height="600px" width="600px" />
|
<UiTable :table-data="tableData" :columns="columns" height="600px" width="600px" />
|
||||||
|
|
||||||
<UserModal v-if="selectedUser" v-model:model-value="open" :selected-user="selectedUser" />
|
<UserModal v-if="selectedUser" :user="selectedUser" @close="selectedUser = null" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { UiTableShortText } from '#components'
|
import type { ColumnDef } from '@tanstack/table-core'
|
||||||
import { createColumnHelper } from '@tanstack/vue-table'
|
import { createColumnHelper } from '@tanstack/vue-table'
|
||||||
import { useDebounceFn } from '@vueuse/core'
|
import { useDebounceFn } from '@vueuse/core'
|
||||||
import { useGetPosts, useGetUsers } from '~/api/queries'
|
import { useGetPosts, useGetUsers } from '~/api/queries'
|
||||||
import UserModal from '~/components/modals/UserModal.vue'
|
import UserModal from '~/components/modals/UserModal.vue'
|
||||||
|
import ShortText from '~/components/ShortText.vue'
|
||||||
import UiTable from '~/components/UiTable.vue'
|
import UiTable from '~/components/UiTable.vue'
|
||||||
|
|
||||||
const open = ref(false)
|
|
||||||
const selectedUser = ref<User | null>(null)
|
const selectedUser = ref<User | null>(null)
|
||||||
const search = ref('')
|
const search = ref('')
|
||||||
const updateSearch = useDebounceFn((value: string) => {
|
const updateSearch = useDebounceFn((value: string) => {
|
||||||
@ -34,67 +34,66 @@ const updateSearch = useDebounceFn((value: string) => {
|
|||||||
const { data: posts, isLoading: postsIsLoading } = useGetPosts(search)
|
const { data: posts, isLoading: postsIsLoading } = useGetPosts(search)
|
||||||
const { data: users, isLoading: usersIsLoading } = useGetUsers()
|
const { data: users, isLoading: usersIsLoading } = useGetUsers()
|
||||||
|
|
||||||
const tableData = computed(() => (posts?.value ?? []).map(post => ({
|
interface TablePost extends Post {
|
||||||
userId: post?.userId,
|
userEmail: User['email']
|
||||||
userEmail: users?.value?.find(user => user?.id === post?.userId)?.email,
|
}
|
||||||
id: post?.id,
|
|
||||||
title: post?.title,
|
|
||||||
body: post?.body,
|
|
||||||
})))
|
|
||||||
|
|
||||||
const columnHelper = createColumnHelper<Posts>()
|
const tableData = computed(() => {
|
||||||
|
return (posts?.value ?? []).map(post => ({
|
||||||
|
userId: post?.userId,
|
||||||
|
userEmail: users?.value?.find(user => user?.id === post?.userId)?.email,
|
||||||
|
id: post?.id,
|
||||||
|
title: post?.title,
|
||||||
|
body: post?.body,
|
||||||
|
} as TablePost))
|
||||||
|
})
|
||||||
|
|
||||||
|
const columnHelper = createColumnHelper<TablePost>()
|
||||||
const columns = [
|
const columns = [
|
||||||
columnHelper.accessor('id', {
|
columnHelper.accessor('id', {
|
||||||
header: 'ID',
|
header: 'ID',
|
||||||
footer: props => props?.column?.id,
|
|
||||||
meta: {
|
meta: {
|
||||||
style: {
|
width: '50px',
|
||||||
display: 'flex',
|
|
||||||
justifyContent: 'center',
|
|
||||||
alignItems: 'center',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
size: 50,
|
|
||||||
}),
|
}),
|
||||||
columnHelper.accessor('title', {
|
columnHelper.accessor('title', {
|
||||||
header: 'Заголовок',
|
header: 'Заголовок',
|
||||||
cell: info => h(UiTableShortText, {
|
cell: info => h(ShortText, {
|
||||||
text: info.getValue(),
|
text: info.getValue(),
|
||||||
maxLength: 10,
|
|
||||||
}),
|
}),
|
||||||
size: 150,
|
meta: {
|
||||||
|
width: '150px',
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
columnHelper.accessor('userEmail', {
|
columnHelper.accessor('userEmail', {
|
||||||
header: 'Автор',
|
header: 'Автор',
|
||||||
cell: info =>
|
cell: info =>
|
||||||
h(UiTableShortText, {
|
h(ShortText, {
|
||||||
text: info.getValue(),
|
text: info.getValue(),
|
||||||
hideIcon: true,
|
textPrimary: true,
|
||||||
class: 'title-cell',
|
|
||||||
onClick: () => openPost(info.row.original),
|
onClick: () => openPost(info.row.original),
|
||||||
}),
|
}),
|
||||||
meta: {
|
meta: {
|
||||||
style: {
|
width: '170px',
|
||||||
display: 'flex',
|
|
||||||
justifyContent: 'center',
|
|
||||||
alignItems: 'center',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
size: 170,
|
|
||||||
}),
|
}),
|
||||||
columnHelper.accessor('body', {
|
columnHelper.accessor('body', {
|
||||||
header: 'Контент',
|
header: 'Контент',
|
||||||
cell: info => h(UiTableShortText, {
|
cell: info => h(ShortText, {
|
||||||
text: info.getValue(),
|
text: info.getValue(),
|
||||||
maxLength: 18,
|
|
||||||
}),
|
}),
|
||||||
size: 230,
|
meta: {
|
||||||
|
width: 'minmax(220px, 1fr)',
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
]
|
] as ColumnDef<TablePost>[]
|
||||||
|
|
||||||
function openPost(post: Post) {
|
function openPost(post: Post) {
|
||||||
selectedUser.value = users?.value?.find(user => user?.id === post?.userId)
|
const foundUser = users?.value?.find(user => user?.id === post?.userId)
|
||||||
open.value = true
|
|
||||||
|
if (foundUser) {
|
||||||
|
selectedUser.value = foundUser
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -124,15 +123,4 @@ function openPost(post: Post) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//userEmail
|
|
||||||
.title-cell {
|
|
||||||
cursor: pointer;
|
|
||||||
text-decoration: underline;
|
|
||||||
color: var(--ui-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.title-cell:hover {
|
|
||||||
color: var(--ui-primary-hover);
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { defineEventHandler, getQuery } from 'h3'
|
|||||||
export default defineEventHandler(async (event) => {
|
export default defineEventHandler(async (event) => {
|
||||||
try {
|
try {
|
||||||
const { search } = getQuery(event)
|
const { search } = getQuery(event)
|
||||||
const apiUrl = process.env.VITE_MY_API_BASE_URL!
|
const apiUrl = import.meta.env.VITE_MY_API_BASE_URL!
|
||||||
|
|
||||||
return await $fetch<Posts>(`${apiUrl}/posts?title_like=${search}`, {
|
return await $fetch<Posts>(`${apiUrl}/posts?title_like=${search}`, {
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { createError, defineEventHandler, sendError } from 'h3'
|
|||||||
|
|
||||||
export default defineEventHandler(async (event) => {
|
export default defineEventHandler(async (event) => {
|
||||||
try {
|
try {
|
||||||
const apiUrl = process.env.VITE_MY_API_BASE_URL!
|
const apiUrl = import.meta.env.VITE_MY_API_BASE_URL!
|
||||||
|
|
||||||
return await $fetch<Users>(`${apiUrl}/users`, {
|
return await $fetch<Users>(`${apiUrl}/users`, {
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user