Compare commits
4 Commits
013059b62f
...
72ca5e9b77
| Author | SHA1 | Date | |
|---|---|---|---|
|
72ca5e9b77
|
|||
|
be35bd24c2
|
|||
|
f5a2be3598
|
|||
|
954eff069b
|
22
app/components.d.ts
vendored
22
app/components.d.ts
vendored
@@ -20,17 +20,24 @@ declare module 'vue' {
|
||||
NCardSection: typeof import('naive-ui')['NCardSection']
|
||||
NCarousel: typeof import('naive-ui')['NCarousel']
|
||||
NCarouselItem: typeof import('naive-ui')['NCarouselItem']
|
||||
NCheckbox: typeof import('naive-ui')['NCheckbox']
|
||||
NChip: typeof import('naive-ui')['NChip']
|
||||
NCode: typeof import('naive-ui')['NCode']
|
||||
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
|
||||
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
|
||||
NDatePicker: typeof import('naive-ui')['NDatePicker']
|
||||
NDialog: typeof import('naive-ui')['NDialog']
|
||||
NDialogProvider: typeof import('naive-ui')['NDialogProvider']
|
||||
NDivider: typeof import('naive-ui')['NDivider']
|
||||
NDrawer: typeof import('naive-ui')['NDrawer']
|
||||
NDrawerContent: typeof import('naive-ui')['NDrawerContent']
|
||||
NDropdown: typeof import('naive-ui')['NDropdown']
|
||||
NEmpty: typeof import('naive-ui')['NEmpty']
|
||||
NForm: typeof import('naive-ui')['NForm']
|
||||
NFormItem: typeof import('naive-ui')['NFormItem']
|
||||
NIcon: typeof import('naive-ui')['NIcon']
|
||||
NImage: typeof import('naive-ui')['NImage']
|
||||
NImagePreview: typeof import('naive-ui')['NImagePreview']
|
||||
NImg: typeof import('naive-ui')['NImg']
|
||||
NInfiniteScroll: typeof import('naive-ui')['NInfiniteScroll']
|
||||
NInput: typeof import('naive-ui')['NInput']
|
||||
@@ -48,9 +55,13 @@ declare module 'vue' {
|
||||
NSelect: typeof import('naive-ui')['NSelect']
|
||||
NSpace: typeof import('naive-ui')['NSpace']
|
||||
NSpin: typeof import('naive-ui')['NSpin']
|
||||
NTab: typeof import('naive-ui')['NTab']
|
||||
NTabPane: typeof import('naive-ui')['NTabPane']
|
||||
NTabs: typeof import('naive-ui')['NTabs']
|
||||
NTag: typeof import('naive-ui')['NTag']
|
||||
NTextarea: typeof import('naive-ui')['NTextarea']
|
||||
NThemeEditor: typeof import('naive-ui')['NThemeEditor']
|
||||
NTooltip: typeof import('naive-ui')['NTooltip']
|
||||
RouterLink: typeof import('vue-router')['RouterLink']
|
||||
RouterView: typeof import('vue-router')['RouterView']
|
||||
}
|
||||
@@ -66,17 +77,24 @@ declare global {
|
||||
const NCardSection: typeof import('naive-ui')['NCardSection']
|
||||
const NCarousel: typeof import('naive-ui')['NCarousel']
|
||||
const NCarouselItem: typeof import('naive-ui')['NCarouselItem']
|
||||
const NCheckbox: typeof import('naive-ui')['NCheckbox']
|
||||
const NChip: typeof import('naive-ui')['NChip']
|
||||
const NCode: typeof import('naive-ui')['NCode']
|
||||
const NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
|
||||
const NConfigProvider: typeof import('naive-ui')['NConfigProvider']
|
||||
const NDatePicker: typeof import('naive-ui')['NDatePicker']
|
||||
const NDialog: typeof import('naive-ui')['NDialog']
|
||||
const NDialogProvider: typeof import('naive-ui')['NDialogProvider']
|
||||
const NDivider: typeof import('naive-ui')['NDivider']
|
||||
const NDrawer: typeof import('naive-ui')['NDrawer']
|
||||
const NDrawerContent: typeof import('naive-ui')['NDrawerContent']
|
||||
const NDropdown: typeof import('naive-ui')['NDropdown']
|
||||
const NEmpty: typeof import('naive-ui')['NEmpty']
|
||||
const NForm: typeof import('naive-ui')['NForm']
|
||||
const NFormItem: typeof import('naive-ui')['NFormItem']
|
||||
const NIcon: typeof import('naive-ui')['NIcon']
|
||||
const NImage: typeof import('naive-ui')['NImage']
|
||||
const NImagePreview: typeof import('naive-ui')['NImagePreview']
|
||||
const NImg: typeof import('naive-ui')['NImg']
|
||||
const NInfiniteScroll: typeof import('naive-ui')['NInfiniteScroll']
|
||||
const NInput: typeof import('naive-ui')['NInput']
|
||||
@@ -94,9 +112,13 @@ declare global {
|
||||
const NSelect: typeof import('naive-ui')['NSelect']
|
||||
const NSpace: typeof import('naive-ui')['NSpace']
|
||||
const NSpin: typeof import('naive-ui')['NSpin']
|
||||
const NTab: typeof import('naive-ui')['NTab']
|
||||
const NTabPane: typeof import('naive-ui')['NTabPane']
|
||||
const NTabs: typeof import('naive-ui')['NTabs']
|
||||
const NTag: typeof import('naive-ui')['NTag']
|
||||
const NTextarea: typeof import('naive-ui')['NTextarea']
|
||||
const NThemeEditor: typeof import('naive-ui')['NThemeEditor']
|
||||
const NTooltip: typeof import('naive-ui')['NTooltip']
|
||||
const RouterLink: typeof import('vue-router')['RouterLink']
|
||||
const RouterView: typeof import('vue-router')['RouterView']
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
<template>
|
||||
<div class="relative rounded-md overflow-hidden" :style="containerStyle">
|
||||
<template v-if="itemType == 'image'">
|
||||
<div
|
||||
v-if="itemType == 'image'"
|
||||
class="flex flex-col items-center justify-center"
|
||||
>
|
||||
<!-- Blurhash placeholder -->
|
||||
<div
|
||||
v-if="blurhash"
|
||||
@@ -22,7 +25,7 @@
|
||||
@load="imageLoaded = true"
|
||||
@error="imageLoaded = true"
|
||||
/>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<audio
|
||||
v-else-if="itemType == 'audio'"
|
||||
@@ -105,8 +108,8 @@ const blurhashContainerStyle = computed(() => {
|
||||
|
||||
const containerStyle = computed(() => {
|
||||
return {
|
||||
"max-height": props.maxHeight ?? "720px",
|
||||
"aspect-ratio": aspectRatio.value
|
||||
maxHeight: props.maxHeight ?? "720px",
|
||||
aspectRatio: aspectRatio.value?.toString()
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -19,9 +19,14 @@
|
||||
v-for="attachment in attachments"
|
||||
:key="attachment.id"
|
||||
height="100%"
|
||||
width="100%"
|
||||
cover
|
||||
>
|
||||
<attachment-item original class="h-full" :item="attachment" />
|
||||
<attachment-item
|
||||
original
|
||||
class="h-full w-full"
|
||||
:item="attachment"
|
||||
/>
|
||||
</n-carousel-item>
|
||||
</n-carousel>
|
||||
</div>
|
||||
|
||||
@@ -1,52 +1,51 @@
|
||||
<template>
|
||||
<div class="post-list">
|
||||
<!-- Error State -->
|
||||
<v-alert
|
||||
<n-alert
|
||||
v-if="hasError"
|
||||
type="error"
|
||||
class="mb-4"
|
||||
closable
|
||||
@click:close="refresh"
|
||||
@close="refresh"
|
||||
class="mb-4"
|
||||
>
|
||||
{{ error }}
|
||||
</v-alert>
|
||||
</n-alert>
|
||||
|
||||
<!-- Posts List -->
|
||||
<v-infinite-scroll
|
||||
height="auto"
|
||||
class="space-y-4 overflow-y-hidden"
|
||||
side="end"
|
||||
@load="loadMore"
|
||||
>
|
||||
<n-infinite-scroll :distance="0" @load="loadMore" style="overflow: auto">
|
||||
<template v-for="item in posts" :key="item.id">
|
||||
<post-item
|
||||
class="mb-4"
|
||||
:item="item"
|
||||
@react="(symbol, attitude, delta) => $emit('react', item.id, symbol, attitude, delta)"
|
||||
@react="
|
||||
(symbol, attitude, delta) =>
|
||||
$emit('react', item.id, symbol, attitude, delta)
|
||||
"
|
||||
@click="router.push('/posts/' + item.id)"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<!-- Loading State -->
|
||||
<template #loading>
|
||||
<div class="flex justify-center py-4">
|
||||
<v-progress-circular indeterminate size="32" />
|
||||
</div>
|
||||
</template>
|
||||
<div v-if="loading" class="flex justify-center py-4">
|
||||
<n-spin size="medium" />
|
||||
</div>
|
||||
|
||||
<!-- Empty State -->
|
||||
<template #empty>
|
||||
<div v-if="!posts" class="text-center py-8 text-muted-foreground">
|
||||
<v-icon icon="mdi-post-outline" size="48" class="mb-2 opacity-50" />
|
||||
<p>No posts found</p>
|
||||
</div>
|
||||
</template>
|
||||
</v-infinite-scroll>
|
||||
<div
|
||||
v-if="!loading && posts.length === 0 && !hasError"
|
||||
class="text-center py-8 text-muted-foreground"
|
||||
>
|
||||
<n-icon :component="FileText" size="48" class="mb-2 opacity-50" />
|
||||
<p>No posts found</p>
|
||||
</div>
|
||||
</n-infinite-scroll>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { usePostList } from "~/composables/usePostList"
|
||||
import type { PostListParams } from "~/composables/usePostList"
|
||||
import { FileText } from "lucide-vue-next"
|
||||
|
||||
import PostItem from "./PostItem.vue"
|
||||
|
||||
@@ -60,12 +59,7 @@ defineEmits<{
|
||||
react: [postId: string, symbol: string, attitude: number, delta: number]
|
||||
}>()
|
||||
|
||||
const { posts, hasError, error, loadMore, refresh } =
|
||||
usePostList(props.params)
|
||||
const { posts, hasError, error, loading, loadMore, refresh } = usePostList(
|
||||
props.params
|
||||
)
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.post-list .v-infinite-scroll .v-infinite-scroll__side:first-child {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
@@ -28,13 +28,13 @@
|
||||
</template>
|
||||
|
||||
<!-- Empty State -->
|
||||
<div
|
||||
<n-empty
|
||||
v-if="!replies || replies.length === 0"
|
||||
class="text-center py-8 text-muted-foreground"
|
||||
size="small"
|
||||
>
|
||||
<v-icon icon="mdi-comment-outline" size="48" class="mb-2 opacity-50" />
|
||||
<p>No replies yet</p>
|
||||
</div>
|
||||
No Replies
|
||||
</n-empty>
|
||||
</div>
|
||||
</n-card>
|
||||
</template>
|
||||
|
||||
@@ -33,15 +33,13 @@
|
||||
</template>
|
||||
|
||||
<!-- Empty State -->
|
||||
<div
|
||||
<n-empty
|
||||
v-if="!replies || replies.length === 0"
|
||||
class="text-center py-8 text-muted-foreground"
|
||||
size="small"
|
||||
>
|
||||
<n-icon size="48" class="mb-2 opacity-50">
|
||||
<i class="mdi mdi-comment-outline"></i>
|
||||
</n-icon>
|
||||
<p>No replies yet</p>
|
||||
</div>
|
||||
No Replies
|
||||
</n-empty>
|
||||
</n-infinite-scroll>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -40,7 +40,7 @@ export const usePostList = (params: PostListParams = {}) => {
|
||||
total: 0
|
||||
})
|
||||
|
||||
const isLoading = computed(() => state.value.loading)
|
||||
const loading = computed(() => state.value.loading)
|
||||
const hasError = computed(() => state.value.error !== null)
|
||||
const posts = computed(() => state.value.posts)
|
||||
const hasMore = computed(() => state.value.hasMore)
|
||||
@@ -153,7 +153,7 @@ export const usePostList = (params: PostListParams = {}) => {
|
||||
|
||||
return {
|
||||
posts,
|
||||
isLoading,
|
||||
loading,
|
||||
hasError,
|
||||
hasMore,
|
||||
error: computed(() => state.value.error),
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="fixed inset-0" :style="pageStyle" />
|
||||
<div class="fixed inset-0 blur-md" :style="pageStyle" />
|
||||
<img
|
||||
:src="userBackground"
|
||||
class="w-full max-h-48 object-cover object-top"
|
||||
:style="{ aspectRatio: '16/7', opacity: headerOpacity }"
|
||||
/>
|
||||
|
||||
<div v-if="user" class="relative min-h-layout backdrop-blur-md">
|
||||
<div v-if="user" class="relative min-h-layout">
|
||||
<div class="container mx-auto p-8 pt-12">
|
||||
<div class="flex items-center gap-6 mb-8">
|
||||
<n-avatar :size="80" round :src="userPicture" />
|
||||
|
||||
@@ -1,91 +1,65 @@
|
||||
<template>
|
||||
<div class="lightbox-container">
|
||||
<div class="lightbox-container h-compact-layout">
|
||||
<!-- Top Toolbar -->
|
||||
<v-app-bar v-if="fileInfo" class="top-toolbar" flat height="56">
|
||||
<v-container fluid>
|
||||
<v-row align="center" class="pa-2">
|
||||
<v-col cols="12" md="4">
|
||||
<div class="d-flex align-center gap-2">
|
||||
<v-tooltip location="bottom" :text="fileInfo.mimeType">
|
||||
<template #activator="{ props }">
|
||||
<v-icon v-bind="props" :icon="fileIcon"></v-icon>
|
||||
</template>
|
||||
</v-tooltip>
|
||||
<v-tooltip location="bottom" :text="fileInfo.name || 'File'">
|
||||
<template #activator="{ props }">
|
||||
<span class="line-clamp-1" v-bind="props">
|
||||
{{ fileInfo.name || "File" }}
|
||||
</span>
|
||||
</template>
|
||||
</v-tooltip>
|
||||
<!-- Action buttons on mobile -->
|
||||
<div class="d-flex d-md-none gap-2 ml-auto">
|
||||
<v-btn
|
||||
icon
|
||||
size="small"
|
||||
density="compact"
|
||||
@click="handleDownload"
|
||||
>
|
||||
<v-icon>mdi-download</v-icon>
|
||||
</v-btn>
|
||||
<v-btn
|
||||
icon
|
||||
size="small"
|
||||
density="compact"
|
||||
@click="infoDialog = true"
|
||||
>
|
||||
<v-icon>mdi-information</v-icon>
|
||||
</v-btn>
|
||||
</div>
|
||||
<header v-if="fileInfo" class="top-toolbar bg-neutral-900/50 text-white">
|
||||
<div class="container mx-auto px-4 h-full">
|
||||
<div class="flex items-center h-full">
|
||||
<div class="flex items-center gap-2 w-full md:w-1/3">
|
||||
<n-tooltip trigger="hover">
|
||||
<template #trigger>
|
||||
<n-icon :component="fileIcon" />
|
||||
</template>
|
||||
{{ fileInfo.mimeType }}
|
||||
</n-tooltip>
|
||||
<n-tooltip trigger="hover">
|
||||
<template #trigger>
|
||||
<span class="line-clamp-1">
|
||||
{{ fileInfo.name || "File" }}
|
||||
</span>
|
||||
</template>
|
||||
{{ fileInfo.name || "File" }}
|
||||
</n-tooltip>
|
||||
<!-- Action buttons on mobile -->
|
||||
<div class="flex md:hidden gap-2 ml-auto">
|
||||
<n-button text style="font-size: 20px" @click="handleDownload">
|
||||
<n-icon :component="Download" />
|
||||
</n-button>
|
||||
<n-button text style="font-size: 20px" @click="infoDialog = true">
|
||||
<n-icon :component="Info" />
|
||||
</n-button>
|
||||
</div>
|
||||
</v-col>
|
||||
<v-col cols="12" md="8" class="d-none d-md-block">
|
||||
<div class="d-flex align-center justify-end gap-4">
|
||||
<span>{{ formatBytes(fileInfo.size) }}</span>
|
||||
<span>{{ new Date(fileInfo.createdAt).toLocaleString() }}</span>
|
||||
<v-btn
|
||||
icon
|
||||
size="small"
|
||||
density="compact"
|
||||
@click="handleDownload"
|
||||
>
|
||||
<v-icon>mdi-download</v-icon>
|
||||
</v-btn>
|
||||
<v-btn
|
||||
icon
|
||||
size="small"
|
||||
density="compact"
|
||||
@click="infoDialog = true"
|
||||
>
|
||||
<v-icon>mdi-information</v-icon>
|
||||
</v-btn>
|
||||
</div>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-container>
|
||||
</v-app-bar>
|
||||
</div>
|
||||
<div class="hidden md:flex items-center justify-end gap-4 w-2/3">
|
||||
<span>{{ formatBytes(fileInfo.size) }}</span>
|
||||
<span>{{ new Date(fileInfo.createdAt).toLocaleString() }}</span>
|
||||
<n-button text style="font-size: 20px" @click="handleDownload">
|
||||
<n-icon :component="Download" />
|
||||
</n-button>
|
||||
<n-button text style="font-size: 20px" @click="infoDialog = true">
|
||||
<n-icon :component="Info" />
|
||||
</n-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- Main Content - File Preview -->
|
||||
<div class="preview-container">
|
||||
<v-progress-circular
|
||||
v-if="!fileInfo && !error"
|
||||
indeterminate
|
||||
size="64"
|
||||
class="loading-spinner"
|
||||
></v-progress-circular>
|
||||
<v-alert
|
||||
<n-spin v-if="!fileInfo && !error" size="large" />
|
||||
<n-alert
|
||||
v-else-if="error"
|
||||
type="error"
|
||||
title="No file was found"
|
||||
:text="error"
|
||||
class="error-alert"
|
||||
></v-alert>
|
||||
class="max-w-md"
|
||||
>
|
||||
{{ error }}
|
||||
</n-alert>
|
||||
<div v-else class="preview-content">
|
||||
<div v-if="fileInfo?.isEncrypted" class="encrypted-notice">
|
||||
<v-alert type="info" title="Encrypted file" class="mb-4">
|
||||
<div v-if="fileInfo?.isEncrypted" class="max-w-md">
|
||||
<n-alert type="info" title="Encrypted file" class="mb-4">
|
||||
The file has been encrypted. Preview not available. Please enter the
|
||||
password to download it.
|
||||
</v-alert>
|
||||
</n-alert>
|
||||
</div>
|
||||
<div
|
||||
v-else
|
||||
@@ -94,13 +68,22 @@
|
||||
@touchstart="handleTouchStart"
|
||||
@touchmove="handleTouchMove"
|
||||
@touchend="handleTouchEnd"
|
||||
@mousedown="handleMouseDown"
|
||||
@mousemove="handleMouseMove"
|
||||
@mouseup="handleMouseUp"
|
||||
@mouseleave="handleMouseUp"
|
||||
@dblclick="handleDoubleClick"
|
||||
>
|
||||
<v-img
|
||||
<img
|
||||
v-if="fileType === 'image'"
|
||||
:src="fileSource"
|
||||
class="preview-image"
|
||||
:style="{ transform: `scale(${zoomLevel})` }"
|
||||
:style="{
|
||||
transform: `translate(${translateX}px, ${translateY}px) scale(${zoomLevel})`,
|
||||
cursor:
|
||||
zoomLevel > 1 ? (isDragging ? 'grabbing' : 'grab') : 'default'
|
||||
}"
|
||||
alt="Image preview"
|
||||
/>
|
||||
<video
|
||||
v-else-if="fileType === 'video'"
|
||||
@@ -114,102 +97,113 @@
|
||||
controls
|
||||
class="preview-audio"
|
||||
/>
|
||||
<v-alert
|
||||
<n-alert
|
||||
v-else
|
||||
type="warning"
|
||||
title="Preview Unavailable"
|
||||
text="How can you preview this file?"
|
||||
class="preview-unavailable"
|
||||
/>
|
||||
class="max-w-md"
|
||||
>
|
||||
A preview for this file type is not available.
|
||||
</n-alert>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Password Dialog -->
|
||||
<v-dialog v-model="secretDialog" max-width="400">
|
||||
<v-card>
|
||||
<v-card-title>
|
||||
<v-icon left>mdi-lock</v-icon>
|
||||
Enter Password
|
||||
</v-card-title>
|
||||
<v-card-text>
|
||||
<v-text-field
|
||||
v-model="dialogPassword"
|
||||
label="Password"
|
||||
type="password"
|
||||
variant="outlined"
|
||||
autofocus
|
||||
@keyup.enter="confirmDownload"
|
||||
/>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn @click="secretDialog = false">Cancel</v-btn>
|
||||
<v-btn color="primary" @click="confirmDownload">Download</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
<n-modal v-model:show="secretDialog">
|
||||
<n-card
|
||||
style="width: 400px"
|
||||
title="Enter Password"
|
||||
:bordered="false"
|
||||
size="huge"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
>
|
||||
<n-input
|
||||
v-model:value="dialogPassword"
|
||||
type="password"
|
||||
show-password-on="click"
|
||||
placeholder="Password"
|
||||
autofocus
|
||||
@keyup.enter="confirmDownload"
|
||||
/>
|
||||
<template #footer>
|
||||
<div class="flex justify-end gap-2">
|
||||
<n-button @click="secretDialog = false">Cancel</n-button>
|
||||
<n-button type="primary" @click="confirmDownload"
|
||||
>Download</n-button
|
||||
>
|
||||
</div>
|
||||
</template>
|
||||
</n-card>
|
||||
</n-modal>
|
||||
|
||||
<!-- Technical Details Dialog -->
|
||||
<v-dialog v-model="infoDialog" max-width="640">
|
||||
<v-card title="File Information" prepend-icon="mdi-information">
|
||||
<v-card-text>
|
||||
<v-row>
|
||||
<v-col cols="12" md="6">
|
||||
<div class="mb-4">
|
||||
<strong>File ID</strong>
|
||||
<div class="text-xs">#{{ fileInfo?.id }}</div>
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<strong>File Name</strong>
|
||||
<div class="text-xs">{{ fileInfo?.name || "N/A" }}</div>
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<strong>MIME Type</strong>
|
||||
<div class="text-xs">{{ fileInfo?.mimeType || "N/A" }}</div>
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<strong>File Size</strong>
|
||||
<div class="text-xs">
|
||||
{{ fileInfo?.size ? formatBytes(fileInfo.size) : "N/A" }}
|
||||
</div>
|
||||
</div>
|
||||
</v-col>
|
||||
<v-col cols="12" md="6">
|
||||
<div class="mb-4">
|
||||
<strong>Created At</strong>
|
||||
<div class="text-xs">
|
||||
{{
|
||||
fileInfo?.createdAt
|
||||
? new Date(fileInfo.createdAt).toLocaleString()
|
||||
: "N/A"
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<strong>Encrypted</strong>
|
||||
<div class="text-xs">
|
||||
{{ fileInfo?.isEncrypted ? "Yes" : "No" }}
|
||||
</div>
|
||||
</div>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<div class="mb-4">
|
||||
<strong>Metadata:</strong>
|
||||
<n-drawer
|
||||
v-model:show="infoDialog"
|
||||
:width="breakpoints.isGreaterOrEqual('md') ? '40vw' : '100vw'"
|
||||
>
|
||||
<n-drawer-content>
|
||||
<template #header>
|
||||
<div class="flex items-center justify-between gap-2">
|
||||
<div>File Information</div>
|
||||
<n-button text size="small" @click="infoDialog = false">
|
||||
<template #icon>
|
||||
<n-icon :component="XIcon" />
|
||||
</template>
|
||||
</n-button>
|
||||
</div>
|
||||
<v-card variant="outlined" class="pa-2">
|
||||
<pre
|
||||
class="overflow-x-auto"
|
||||
style="font-size: 14px"
|
||||
><code>{{ JSON.stringify(fileInfo?.fileMeta, null, 2) }}</code></pre>
|
||||
</v-card>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn @click="infoDialog = false">Close</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</template>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 text-sm">
|
||||
<div class="flex flex-col gap-4">
|
||||
<div>
|
||||
<strong class="font-semibold">File ID</strong>
|
||||
<div class="opacity-80">#{{ fileInfo?.id }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<strong class="font-semibold">File Name</strong>
|
||||
<div class="opacity-80">{{ fileInfo?.name || "N/A" }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<strong class="font-semibold">MIME Type</strong>
|
||||
<div class="opacity-80">{{ fileInfo?.mimeType || "N/A" }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<strong class="font-semibold">File Size</strong>
|
||||
<div class="opacity-80">
|
||||
{{ fileInfo?.size ? formatBytes(fileInfo.size) : "N/A" }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-4">
|
||||
<div>
|
||||
<strong class="font-semibold">Created At</strong>
|
||||
<div class="opacity-80">
|
||||
{{
|
||||
fileInfo?.createdAt
|
||||
? new Date(fileInfo.createdAt).toLocaleString()
|
||||
: "N/A"
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<strong class="font-semibold">Encrypted</strong>
|
||||
<div class="opacity-80">
|
||||
{{ fileInfo?.isEncrypted ? "Yes" : "No" }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-4">
|
||||
<strong class="font-semibold">Metadata:</strong>
|
||||
</div>
|
||||
<n-card :bordered="true" class="mt-2">
|
||||
<pre
|
||||
class="overflow-x-auto text-xs"
|
||||
><code>{{ JSON.stringify(fileInfo?.fileMeta, null, 2) }}</code></pre>
|
||||
</n-card>
|
||||
</n-drawer-content>
|
||||
</n-drawer>
|
||||
|
||||
<!-- View Transition Overlay -->
|
||||
<div
|
||||
@@ -228,11 +222,24 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useRoute } from "vue-router"
|
||||
import { computed, onMounted, ref } from "vue"
|
||||
|
||||
import { computed, onMounted, ref, type Component } from "vue"
|
||||
import {
|
||||
Download,
|
||||
Info,
|
||||
Lock,
|
||||
File,
|
||||
FileImage,
|
||||
FileVideo,
|
||||
FileMusic,
|
||||
FileText,
|
||||
FileCode,
|
||||
FileArchive,
|
||||
XIcon
|
||||
} from "lucide-vue-next"
|
||||
import { downloadAndDecryptFile } from "./secure"
|
||||
import { formatBytes } from "./format"
|
||||
import type { SnCloudFile } from "~/types/api/post"
|
||||
import { breakpointsTailwind, useBreakpoints } from "@vueuse/core"
|
||||
|
||||
const route = useRoute()
|
||||
|
||||
@@ -252,6 +259,13 @@ const zoomLevel = ref<number>(1)
|
||||
const initialDistance = ref<number>(0)
|
||||
const isPinching = ref<boolean>(false)
|
||||
|
||||
// Drag functionality
|
||||
const translateX = ref(0)
|
||||
const translateY = ref(0)
|
||||
const isDragging = ref(false)
|
||||
const startX = ref(0)
|
||||
const startY = ref(0)
|
||||
|
||||
// View transition state
|
||||
const isTransitioning = ref<boolean>(false)
|
||||
const transitionImage = ref<string>("")
|
||||
@@ -289,7 +303,6 @@ function checkForTransition() {
|
||||
isTransitioning.value = true
|
||||
transitionImage.value = data.src
|
||||
|
||||
// Calculate final position (centered in viewport)
|
||||
const viewportWidth = window.innerWidth
|
||||
const viewportHeight = window.innerHeight
|
||||
const finalWidth = Math.min(
|
||||
@@ -300,7 +313,6 @@ function checkForTransition() {
|
||||
const finalX = (viewportWidth - finalWidth) / 2
|
||||
const finalY = (viewportHeight - finalHeight) / 2
|
||||
|
||||
// Set initial position (from original image location)
|
||||
transitionStyle.value = {
|
||||
position: "fixed",
|
||||
top: `${data.y}px`,
|
||||
@@ -311,7 +323,6 @@ function checkForTransition() {
|
||||
transition: "all 0.3s ease-out"
|
||||
}
|
||||
|
||||
// Animate to final position
|
||||
requestAnimationFrame(() => {
|
||||
transitionStyle.value = {
|
||||
...transitionStyle.value,
|
||||
@@ -320,8 +331,6 @@ function checkForTransition() {
|
||||
width: `${finalWidth}px`,
|
||||
height: `${finalHeight}px`
|
||||
}
|
||||
|
||||
// Hide transition after animation
|
||||
setTimeout(() => {
|
||||
isTransitioning.value = false
|
||||
sessionStorage.removeItem("imageTransition")
|
||||
@@ -345,38 +354,38 @@ const fileType = computed(() => {
|
||||
if (!fileInfo.value) return "unknown"
|
||||
return fileInfo.value.mimeType?.split("/")[0] || "unknown"
|
||||
})
|
||||
const fileIcon = computed(() => {
|
||||
if (!fileInfo.value?.mimeType) return "mdi-file"
|
||||
const fileIcon = computed<Component>(() => {
|
||||
if (!fileInfo.value?.mimeType) return File
|
||||
|
||||
const mime = fileInfo.value.mimeType.toLowerCase()
|
||||
|
||||
if (mime.startsWith("image/")) return "mdi-file-image"
|
||||
if (mime.startsWith("video/")) return "mdi-file-video"
|
||||
if (mime.startsWith("audio/")) return "mdi-file-music"
|
||||
if (mime === "application/pdf") return "mdi-file-pdf"
|
||||
if (mime.startsWith("image/")) return FileImage
|
||||
if (mime.startsWith("video/")) return FileVideo
|
||||
if (mime.startsWith("audio/")) return FileMusic
|
||||
if (mime === "application/pdf") return FileText
|
||||
if (
|
||||
mime.startsWith("text/") ||
|
||||
mime.includes("javascript") ||
|
||||
mime.includes("json") ||
|
||||
mime.includes("xml")
|
||||
)
|
||||
return "mdi-file-code"
|
||||
return FileCode
|
||||
if (mime.includes("zip") || mime.includes("rar") || mime.includes("tar"))
|
||||
return "mdi-zip-box"
|
||||
return FileArchive
|
||||
if (
|
||||
mime.includes("document") ||
|
||||
mime.includes("word") ||
|
||||
mime.includes("excel") ||
|
||||
mime.includes("powerpoint")
|
||||
)
|
||||
return "mdi-file-document"
|
||||
return FileText
|
||||
|
||||
return "mdi-file"
|
||||
return File
|
||||
})
|
||||
const fileSource = computed(() => {
|
||||
let url = `${apiBase}/drive/files/${fileId}?original=true`
|
||||
if (passcode) {
|
||||
url += `?passcode=${passcode}`
|
||||
url += `&passcode=${passcode}`
|
||||
}
|
||||
return url
|
||||
})
|
||||
@@ -403,55 +412,111 @@ function handleZoom(event: WheelEvent) {
|
||||
|
||||
event.preventDefault()
|
||||
const delta = event.deltaY > 0 ? -0.1 : 0.1
|
||||
zoomLevel.value = Math.max(0.1, Math.min(5, zoomLevel.value + delta))
|
||||
const newZoom = Math.max(0.1, Math.min(5, zoomLevel.value + delta))
|
||||
|
||||
if (newZoom <= 1) {
|
||||
translateX.value = 0
|
||||
translateY.value = 0
|
||||
}
|
||||
|
||||
zoomLevel.value = newZoom
|
||||
}
|
||||
|
||||
function handleTouchStart(event: TouchEvent) {
|
||||
if (fileType.value !== "image" || event.touches.length !== 2) return
|
||||
if (fileType.value !== "image") return
|
||||
|
||||
event.preventDefault()
|
||||
isPinching.value = true
|
||||
const touch1 = event.touches[0]!
|
||||
const touch2 = event.touches[1]!
|
||||
initialDistance.value = Math.sqrt(
|
||||
Math.pow(touch2.clientX - touch1.clientX, 2) +
|
||||
Math.pow(touch2.clientY - touch1.clientY, 2)
|
||||
)
|
||||
if (event.touches.length === 2) {
|
||||
event.preventDefault()
|
||||
isPinching.value = true
|
||||
const touch1 = event.touches[0]!
|
||||
const touch2 = event.touches[1]!
|
||||
initialDistance.value = Math.sqrt(
|
||||
Math.pow(touch2.clientX - touch1.clientX, 2) +
|
||||
Math.pow(touch2.clientY - touch1.clientY, 2)
|
||||
)
|
||||
} else if (event.touches.length === 1 && zoomLevel.value > 1) {
|
||||
isDragging.value = true
|
||||
startX.value = event.touches[0]!.clientX - translateX.value
|
||||
startY.value = event.touches[0]!.clientY - translateY.value
|
||||
}
|
||||
}
|
||||
|
||||
function handleTouchMove(event: TouchEvent) {
|
||||
if (
|
||||
fileType.value !== "image" ||
|
||||
!isPinching.value ||
|
||||
event.touches.length !== 2
|
||||
)
|
||||
return
|
||||
if (fileType.value !== "image") return
|
||||
|
||||
event.preventDefault()
|
||||
const touch1 = event.touches[0]!
|
||||
const touch2 = event.touches[1]!
|
||||
const currentDistance = Math.sqrt(
|
||||
Math.pow(touch2.clientX - touch1.clientX, 2) +
|
||||
Math.pow(touch2.clientY - touch1.clientY, 2)
|
||||
)
|
||||
if (isPinching.value && event.touches.length === 2) {
|
||||
event.preventDefault()
|
||||
const touch1 = event.touches[0]!
|
||||
const touch2 = event.touches[1]!
|
||||
const currentDistance = Math.sqrt(
|
||||
Math.pow(touch2.clientX - touch1.clientX, 2) +
|
||||
Math.pow(touch2.clientY - touch1.clientY, 2)
|
||||
)
|
||||
|
||||
const scale = currentDistance / initialDistance.value
|
||||
zoomLevel.value = Math.max(0.1, Math.min(5, scale))
|
||||
const scale = currentDistance / initialDistance.value
|
||||
const newZoom = Math.max(0.1, Math.min(5, zoomLevel.value * scale))
|
||||
|
||||
if (newZoom <= 1) {
|
||||
translateX.value = 0
|
||||
translateY.value = 0
|
||||
}
|
||||
|
||||
zoomLevel.value = newZoom
|
||||
} else if (isDragging.value && event.touches.length === 1) {
|
||||
event.preventDefault()
|
||||
translateX.value = event.touches[0]!.clientX - startX.value
|
||||
translateY.value = event.touches[0]!.clientY - startY.value
|
||||
}
|
||||
}
|
||||
|
||||
function handleTouchEnd(_event: TouchEvent) {
|
||||
if (fileType.value !== "image") return
|
||||
|
||||
isPinching.value = false
|
||||
isDragging.value = false
|
||||
}
|
||||
|
||||
function handleMouseDown(event: MouseEvent) {
|
||||
if (fileType.value !== "image" || zoomLevel.value <= 1) return
|
||||
|
||||
event.preventDefault()
|
||||
isDragging.value = true
|
||||
startX.value = event.clientX - translateX.value
|
||||
startY.value = event.clientY - translateY.value
|
||||
}
|
||||
|
||||
function handleMouseMove(event: MouseEvent) {
|
||||
if (!isDragging.value) return
|
||||
|
||||
event.preventDefault()
|
||||
translateX.value = event.clientX - startX.value
|
||||
translateY.value = event.clientY - startY.value
|
||||
}
|
||||
|
||||
function handleMouseUp() {
|
||||
isDragging.value = false
|
||||
}
|
||||
|
||||
function handleDoubleClick() {
|
||||
if (fileType.value !== "image") return
|
||||
|
||||
zoomLevel.value = zoomLevel.value > 1 ? 1 : 2
|
||||
if (zoomLevel.value > 1) {
|
||||
zoomLevel.value = 1
|
||||
translateX.value = 0
|
||||
translateY.value = 0
|
||||
} else {
|
||||
zoomLevel.value = 2
|
||||
}
|
||||
}
|
||||
|
||||
const breakpoints = useBreakpoints(breakpointsTailwind)
|
||||
const message = useMessage()
|
||||
|
||||
async function performDownload(password: string) {
|
||||
const progressMessage = message.loading("Downloading file...", {
|
||||
duration: 0
|
||||
})
|
||||
|
||||
if (fileInfo.value!.isEncrypted) {
|
||||
downloadAndDecryptFile(
|
||||
fileSource.value,
|
||||
@@ -503,6 +568,9 @@ async function performDownload(password: string) {
|
||||
a.click()
|
||||
a.remove()
|
||||
window.URL.revokeObjectURL(blobUrl)
|
||||
|
||||
progressMessage.destroy()
|
||||
message.success("File has been downloaded successfully.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -513,11 +581,7 @@ definePageMeta({
|
||||
|
||||
<style scoped>
|
||||
.lightbox-container {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background: rgba(0, 0, 0, 0.9);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -525,6 +589,7 @@ definePageMeta({
|
||||
}
|
||||
|
||||
.top-toolbar {
|
||||
height: 56px;
|
||||
position: relative;
|
||||
z-index: 1001;
|
||||
}
|
||||
@@ -536,6 +601,7 @@ definePageMeta({
|
||||
justify-content: center;
|
||||
padding: 20px;
|
||||
overflow: auto;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.preview-content {
|
||||
@@ -549,21 +615,17 @@ definePageMeta({
|
||||
.file-preview {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
max-width: calc(100vw - 40px);
|
||||
max-height: calc(
|
||||
100vh - 88px
|
||||
); /* Account for top toolbar (48px) + padding (40px) */
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.preview-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
object-fit: contain;
|
||||
transition: all 0.3s ease-in-out;
|
||||
will-change: contents;
|
||||
transition: transform 0.2s ease-out;
|
||||
will-change: transform;
|
||||
}
|
||||
|
||||
.preview-video,
|
||||
@@ -572,27 +634,6 @@ definePageMeta({
|
||||
max-height: 100%;
|
||||
}
|
||||
|
||||
.preview-unavailable {
|
||||
max-width: 500px;
|
||||
}
|
||||
|
||||
.loading-spinner {
|
||||
color: white;
|
||||
}
|
||||
|
||||
.error-alert {
|
||||
max-width: 500px;
|
||||
}
|
||||
|
||||
.encrypted-notice {
|
||||
max-width: 500px;
|
||||
}
|
||||
|
||||
/* Ensure toolbar doesn't interfere with content */
|
||||
.top-toolbar :deep(.v-app-bar__content) {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* View transition styles */
|
||||
.transition-overlay {
|
||||
pointer-events: none;
|
||||
|
||||
@@ -1,68 +1,63 @@
|
||||
<template>
|
||||
<div class="d-flex align-center justify-center fill-height">
|
||||
<v-card
|
||||
max-width="400"
|
||||
title="Order Payment"
|
||||
prepend-icon="mdi-cash"
|
||||
class="pa-2"
|
||||
>
|
||||
<v-card-text>
|
||||
<v-alert v-if="done" type="success" class="mb-4">
|
||||
The order has been paid successfully. Now you can close this tab and
|
||||
back to the Solar Network!
|
||||
</v-alert>
|
||||
<v-alert
|
||||
v-else-if="!!error"
|
||||
type="error"
|
||||
title="Something went wrong"
|
||||
class="mb-4"
|
||||
>{{ error }}</v-alert
|
||||
>
|
||||
<div v-else-if="!!order">
|
||||
<p class="mb-2">
|
||||
Order for {{ order.productIdentifier ?? "unknown" }}
|
||||
</p>
|
||||
<div class="d-flex align-center gap-2 mb-2">
|
||||
<v-icon size="18">mdi-tag</v-icon>
|
||||
<strong>{{ order.remarks }}</strong>
|
||||
</div>
|
||||
<div class="d-flex align-center gap-2 mb-2">
|
||||
<v-icon size="18">mdi-cash</v-icon>
|
||||
<span>Amount</span>
|
||||
<strong>{{ order.amount }} {{ order.currency }}</strong>
|
||||
</div>
|
||||
<div v-if="order.expiredAt" class="d-flex align-center gap-2 mb-4">
|
||||
<v-icon size="18">mdi-calendar</v-icon>
|
||||
<span>Until</span>
|
||||
<strong>{{ new Date(order.expiredAt).toLocaleString() }}</strong>
|
||||
</div>
|
||||
<div class="mt-4">
|
||||
<v-otp-input
|
||||
v-model="pinCode"
|
||||
label="Pin Code"
|
||||
length="6"
|
||||
type="password"
|
||||
density="comfortable"
|
||||
></v-otp-input>
|
||||
<v-btn
|
||||
color="primary"
|
||||
:loading="submitting"
|
||||
class="mt-4"
|
||||
@click="pay"
|
||||
>
|
||||
<v-icon left>mdi-check</v-icon>
|
||||
Pay
|
||||
</v-btn>
|
||||
</div>
|
||||
<div class="flex items-center justify-center min-h-screen">
|
||||
<n-card title="Order Payment" class="max-w-sm">
|
||||
<template #header-icon>
|
||||
<n-icon :component="Wallet" />
|
||||
</template>
|
||||
<n-alert v-if="done" type="success" class="mb-4">
|
||||
The order has been paid successfully. You can now close this tab and
|
||||
return to Solar Network!
|
||||
</n-alert>
|
||||
<n-alert
|
||||
v-else-if="!!error"
|
||||
type="error"
|
||||
title="Something went wrong"
|
||||
class="mb-4"
|
||||
>
|
||||
{{ error }}
|
||||
</n-alert>
|
||||
<div v-else-if="!!order" class="flex flex-col gap-2">
|
||||
<p>Order for {{ order.productIdentifier ?? "unknown" }}</p>
|
||||
<div class="flex items-center gap-2">
|
||||
<n-icon :component="Tag" />
|
||||
<strong>{{ order.remarks }}</strong>
|
||||
</div>
|
||||
<v-progress-circular
|
||||
v-else
|
||||
indeterminate
|
||||
size="32"
|
||||
class="mt-4"
|
||||
></v-progress-circular>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
<div class="flex items-center gap-2">
|
||||
<n-icon :component="CircleDollarSign" />
|
||||
<span>Amount</span>
|
||||
<strong>{{ order.amount }} {{ order.currency }}</strong>
|
||||
</div>
|
||||
<div v-if="order.expiredAt" class="flex items-center gap-2">
|
||||
<n-icon :component="Calendar" />
|
||||
<span>Until</span>
|
||||
<strong>{{ new Date(order.expiredAt).toLocaleString() }}</strong>
|
||||
</div>
|
||||
<div class="mt-4">
|
||||
<n-input
|
||||
v-model:value="pinCode"
|
||||
type="password"
|
||||
show-password-on="click"
|
||||
placeholder="6-digit PIN"
|
||||
maxlength="6"
|
||||
:input-props="{ autocomplete: 'one-time-code' }"
|
||||
/>
|
||||
<n-button
|
||||
type="primary"
|
||||
:loading="submitting"
|
||||
class="mt-4 w-full"
|
||||
@click="pay"
|
||||
>
|
||||
<template #icon>
|
||||
<n-icon :component="Check" />
|
||||
</template>
|
||||
Pay
|
||||
</n-button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="flex justify-center p-8">
|
||||
<n-spin size="medium" />
|
||||
</div>
|
||||
</n-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -70,6 +65,13 @@
|
||||
import { onMounted, ref } from "vue"
|
||||
import { useRoute } from "vue-router"
|
||||
import type { SnWalletOrder } from "~/types/api/order"
|
||||
import {
|
||||
Wallet,
|
||||
Tag,
|
||||
CircleDollarSign,
|
||||
Calendar,
|
||||
Check
|
||||
} from "lucide-vue-next"
|
||||
|
||||
const route = useRoute()
|
||||
|
||||
@@ -99,6 +101,7 @@ async function fetchOrder() {
|
||||
}
|
||||
|
||||
async function pay() {
|
||||
if (submitting.value) return
|
||||
submitting.value = true
|
||||
try {
|
||||
await api(`/id/orders/${encodeURIComponent(orderId)}/pay`, {
|
||||
@@ -109,6 +112,8 @@ async function pay() {
|
||||
done.value = true
|
||||
} catch (err: unknown) {
|
||||
error.value = err instanceof Error ? err.message : String(err)
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,5 +123,4 @@ definePageMeta({
|
||||
middleware: ["auth"],
|
||||
title: "Solarpay"
|
||||
})
|
||||
</script>
|
||||
|
||||
</script>
|
||||
@@ -1,195 +1,177 @@
|
||||
<template>
|
||||
<div v-if="user">
|
||||
<div>
|
||||
<div class="fixed inset-0 blur-md" :style="pageStyle" />
|
||||
<img
|
||||
:src="userBackground"
|
||||
class="object-cover w-full max-h-48 mb-8"
|
||||
style="aspect-ratio: 16/7"
|
||||
class="w-full max-h-48 object-cover object-top"
|
||||
:style="{ aspectRatio: '16/7', opacity: headerOpacity }"
|
||||
/>
|
||||
|
||||
<v-container>
|
||||
<div class="layout">
|
||||
<div class="main">
|
||||
<!-- Filter Section -->
|
||||
<v-card class="mb-4">
|
||||
<v-tabs
|
||||
v-model="activeCategoryTab"
|
||||
color="primary"
|
||||
class="mb-2"
|
||||
grow
|
||||
<div v-if="user" class="relative min-h-layout">
|
||||
<div class="container mx-auto p-4 sm:p-8">
|
||||
<div class="layout">
|
||||
<div class="sidebar flex flex-col gap-3">
|
||||
<n-card
|
||||
:class="cardClass"
|
||||
:style="cardStyle"
|
||||
:content-style="cardContentStyle"
|
||||
>
|
||||
<v-tab value="all">All</v-tab>
|
||||
<v-tab value="posts">Posts</v-tab>
|
||||
<v-tab value="articles">Articles</v-tab>
|
||||
</v-tabs>
|
||||
|
||||
<v-row>
|
||||
<v-col cols="12" sm="6">
|
||||
<v-checkbox
|
||||
:model-value="includeReplies"
|
||||
label="Include replies"
|
||||
:indeterminate="includeReplies === null"
|
||||
density="compact"
|
||||
prepend-icon="mdi-reply"
|
||||
hide-details
|
||||
class="px-4"
|
||||
@update:model-value="cycleIncludeReplies"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="6">
|
||||
<v-checkbox
|
||||
v-model="mediaOnly"
|
||||
label="Media only"
|
||||
density="compact"
|
||||
hide-details
|
||||
class="px-4"
|
||||
prepend-icon="mdi-attachment"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
<v-checkbox
|
||||
v-model="orderDesc"
|
||||
label="Descending order"
|
||||
density="compact"
|
||||
prepend-icon="mdi-sort"
|
||||
class="px-4"
|
||||
hide-details
|
||||
/>
|
||||
|
||||
<v-divider class="my-1" />
|
||||
|
||||
<v-list-item
|
||||
title="Advanced filters"
|
||||
prepend-icon="mdi-filter-variant"
|
||||
@click="showAdvancedFilters = !showAdvancedFilters"
|
||||
>
|
||||
<template #append>
|
||||
<v-icon>
|
||||
{{
|
||||
showAdvancedFilters ? "mdi-chevron-up" : "mdi-chevron-down"
|
||||
}}
|
||||
</v-icon>
|
||||
</template>
|
||||
</v-list-item>
|
||||
|
||||
<v-expand-transition>
|
||||
<div v-if="showAdvancedFilters" class="my-3 px-4">
|
||||
<v-text-field
|
||||
v-model="queryTerm"
|
||||
hide-details
|
||||
label="Search"
|
||||
placeholder="Search posts"
|
||||
prepend-inner-icon="mdi-magnify"
|
||||
variant="outlined"
|
||||
density="comfortable"
|
||||
class="mb-3"
|
||||
/>
|
||||
|
||||
<v-select
|
||||
v-model="order"
|
||||
hide-details
|
||||
label="Sort by"
|
||||
:items="[
|
||||
{ title: 'Date', value: 'date' },
|
||||
{ title: 'Popularity', value: 'popularity' }
|
||||
]"
|
||||
variant="outlined"
|
||||
density="comfortable"
|
||||
class="mb-3"
|
||||
/>
|
||||
|
||||
<v-row>
|
||||
<v-col cols="12" sm="6">
|
||||
<v-text-field
|
||||
:model-value="periodStartFormatted"
|
||||
hide-details
|
||||
label="From date"
|
||||
prepend-inner-icon="mdi-calendar"
|
||||
variant="outlined"
|
||||
density="comfortable"
|
||||
readonly
|
||||
@click="openDatePicker('start')"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="6">
|
||||
<v-text-field
|
||||
:model-value="periodEndFormatted"
|
||||
hide-details
|
||||
label="To date"
|
||||
prepend-inner-icon="mdi-calendar"
|
||||
variant="outlined"
|
||||
density="comfortable"
|
||||
readonly
|
||||
@click="openDatePicker('end')"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</div>
|
||||
</v-expand-transition>
|
||||
</v-card>
|
||||
|
||||
<post-list :key="filterKey" :params="postListParams" />
|
||||
|
||||
<!-- Date Picker Dialog -->
|
||||
<v-dialog v-model="datePickerDialog" max-width="400">
|
||||
<v-card>
|
||||
<v-card-title>{{
|
||||
datePickerType === "start" ? "From date" : "To date"
|
||||
}}</v-card-title>
|
||||
<v-card-text>
|
||||
<v-date-picker
|
||||
v-model="tempDate"
|
||||
:max="new Date().toISOString().split('T')[0]"
|
||||
/>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-spacer />
|
||||
<v-btn @click="datePickerDialog = false">Cancel</v-btn>
|
||||
<v-btn color="primary" @click="confirmDatePicker">OK</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</div>
|
||||
<div class="sidebar flex flex-col gap-3">
|
||||
<v-card class="w-full">
|
||||
<v-card-text>
|
||||
<div class="flex items-center gap-4 mb-4">
|
||||
<v-avatar size="60" rounded="circle" :image="userPicture" />
|
||||
<n-avatar size="large" round :src="userPicture" />
|
||||
<div>
|
||||
<div class="text-xl font-bold">
|
||||
{{ user.nick || user.name }}
|
||||
</div>
|
||||
<div class="text-body-2 text-medium-emphasis">
|
||||
@{{ user.name }}
|
||||
</div>
|
||||
<div class="text-sm opacity-80">@{{ user.name }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="htmlBio" class="bio-prose" v-html="htmlBio"></div>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
<article
|
||||
v-if="htmlBio"
|
||||
class="bio-prose prose prose-sm dark:prose-invert prose-slate"
|
||||
v-html="htmlBio"
|
||||
></article>
|
||||
</n-card>
|
||||
</div>
|
||||
<div class="main">
|
||||
<!-- Filter Section -->
|
||||
<n-card
|
||||
class="mb-4"
|
||||
:class="cardClass"
|
||||
:style="cardStyle"
|
||||
:content-style="cardContentStyle"
|
||||
>
|
||||
<n-tabs v-model:value="activeCategoryTab" type="segment">
|
||||
<n-tab name="all">All</n-tab>
|
||||
<n-tab name="posts">Posts</n-tab>
|
||||
<n-tab name="articles">Articles</n-tab>
|
||||
</n-tabs>
|
||||
|
||||
<div class="mx-4">
|
||||
<div
|
||||
class="grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-2 mt-4"
|
||||
>
|
||||
<div
|
||||
class="flex items-center gap-2 cursor-pointer"
|
||||
@click="cycleIncludeReplies"
|
||||
>
|
||||
<n-icon :component="Reply" />
|
||||
<n-checkbox
|
||||
:checked="includeReplies !== false"
|
||||
:indeterminate="includeReplies === null"
|
||||
@update:checked="cycleIncludeReplies"
|
||||
>
|
||||
Include replies
|
||||
</n-checkbox>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<n-icon :component="Paperclip" />
|
||||
<n-checkbox v-model:checked="mediaOnly">
|
||||
Media only
|
||||
</n-checkbox>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<n-icon :component="ArrowUpDown" />
|
||||
<n-checkbox v-model:checked="orderDesc">
|
||||
Descending order
|
||||
</n-checkbox>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="flex items-center cursor-pointer mt-4"
|
||||
@click="showAdvancedFilters = !showAdvancedFilters"
|
||||
>
|
||||
<n-icon :component="Filter" />
|
||||
<span class="ml-2 font-medium">Advanced filters</span>
|
||||
<n-icon class="ml-auto">
|
||||
<ChevronDown v-if="!showAdvancedFilters" />
|
||||
<ChevronUp v-else />
|
||||
</n-icon>
|
||||
</div>
|
||||
|
||||
<n-collapse-transition :show="showAdvancedFilters">
|
||||
<div class="mt-4 flex flex-col gap-3">
|
||||
<n-input
|
||||
v-model:value="queryTerm"
|
||||
placeholder="Search posts"
|
||||
>
|
||||
<template #prefix>
|
||||
<n-icon :component="Search" />
|
||||
</template>
|
||||
</n-input>
|
||||
|
||||
<!-- the select only takes the common border radius somehow -->
|
||||
<n-config-provider
|
||||
:theme-overrides="{ common: { borderRadius: '8px' } }"
|
||||
>
|
||||
<n-select
|
||||
v-model:value="order"
|
||||
placeholder="Sort by"
|
||||
:options="[
|
||||
{ label: 'Date', value: 'date' },
|
||||
{ label: 'Popularity', value: 'popularity' }
|
||||
]"
|
||||
/>
|
||||
</n-config-provider>
|
||||
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
|
||||
<n-date-picker
|
||||
v-model:value="periodStart"
|
||||
type="date"
|
||||
placeholder="From date"
|
||||
clearable
|
||||
/>
|
||||
<n-date-picker
|
||||
v-model:value="periodEnd"
|
||||
type="date"
|
||||
placeholder="To date"
|
||||
clearable
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</n-collapse-transition>
|
||||
</div>
|
||||
</n-card>
|
||||
|
||||
<post-list :key="filterKey" :params="postListParams" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</v-container>
|
||||
</div>
|
||||
<div v-else-if="notFound" class="flex justify-center items-center h-full">
|
||||
<v-empty-state
|
||||
icon="mdi-account-off"
|
||||
title="User not found"
|
||||
text="The user profile you're trying to access is not found."
|
||||
/>
|
||||
</div>
|
||||
<div v-else class="flex justify-center items-center h-full">
|
||||
<v-progress-circular indeterminate size="64" color="primary" />
|
||||
</div>
|
||||
<div
|
||||
v-else-if="notFound"
|
||||
class="relative flex justify-center items-center h-full"
|
||||
>
|
||||
<n-empty
|
||||
description="The publisher profile you're trying to access is not found."
|
||||
>
|
||||
<template #icon>
|
||||
<n-icon :component="UserX" />
|
||||
</template>
|
||||
</n-empty>
|
||||
</div>
|
||||
<div v-else class="relative flex justify-center items-center h-full">
|
||||
<n-spin size="large" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from "vue"
|
||||
import { useWindowScroll } from "@vueuse/core"
|
||||
import { useMarkdownProcessor } from "~/composables/useMarkdownProcessor"
|
||||
import type { SnPublisher } from "~/types/api"
|
||||
import type { PostListParams } from "~/composables/usePostList"
|
||||
|
||||
import PostList from "~/components/Post/PostList.vue"
|
||||
import {
|
||||
Reply,
|
||||
Paperclip,
|
||||
ArrowUpDown,
|
||||
Filter,
|
||||
Search,
|
||||
ChevronDown,
|
||||
ChevronUp,
|
||||
UserX
|
||||
} from "lucide-vue-next"
|
||||
|
||||
const route = useRoute()
|
||||
|
||||
@@ -202,7 +184,6 @@ const username = computed(() => {
|
||||
return nameStr
|
||||
})
|
||||
|
||||
// Use useFetch with the correct API URL to avoid router conflicts
|
||||
const apiBase = useSolarNetworkUrl()
|
||||
const apiBaseServer = useSolarNetworkUrl()
|
||||
|
||||
@@ -246,6 +227,44 @@ const userPicture = computed(() => {
|
||||
: undefined
|
||||
})
|
||||
|
||||
const { y: scrollY } = useWindowScroll()
|
||||
const scrollThreshold = 192 // max-h-48 is 12rem = 192px
|
||||
|
||||
const backgroundOpacity = computed(() => {
|
||||
return Math.max(0, Math.min(scrollY.value / scrollThreshold, 1))
|
||||
})
|
||||
|
||||
const headerOpacity = computed(() => {
|
||||
return 1 - backgroundOpacity.value
|
||||
})
|
||||
|
||||
const pageStyle = computed(() => {
|
||||
if (!userBackground.value) return {}
|
||||
return {
|
||||
backgroundImage: `linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.4)), url('${userBackground.value}')`,
|
||||
backgroundSize: "cover",
|
||||
backgroundPosition: "center",
|
||||
backgroundRepeat: "no-repeat",
|
||||
backgroundAttachment: "fixed",
|
||||
opacity: backgroundOpacity.value
|
||||
}
|
||||
})
|
||||
|
||||
const cardClass = computed(() => ({
|
||||
"backdrop-blur-2xl": !!userBackground.value,
|
||||
"shadow-xl": !!userBackground.value
|
||||
}))
|
||||
|
||||
const cardStyle = computed(() =>
|
||||
userBackground.value
|
||||
? "background-color: var(--n-color-modal)"
|
||||
: "background-color: var(--n-color)"
|
||||
)
|
||||
|
||||
const cardContentStyle = computed(() =>
|
||||
userBackground.value ? "background-color: transparent" : ""
|
||||
)
|
||||
|
||||
// Filter state
|
||||
const activeCategoryTab = ref("all")
|
||||
const includeReplies = ref<boolean | null>(null)
|
||||
@@ -253,14 +272,9 @@ const mediaOnly = ref(false)
|
||||
const orderDesc = ref(true)
|
||||
const showAdvancedFilters = ref(false)
|
||||
const queryTerm = ref("")
|
||||
const order = ref<string | undefined>(undefined)
|
||||
const periodStart = ref<number | undefined>(undefined)
|
||||
const periodEnd = ref<number | undefined>(undefined)
|
||||
|
||||
// Date picker dialog
|
||||
const datePickerDialog = ref(false)
|
||||
const datePickerType = ref<"start" | "end">("start")
|
||||
const tempDate = ref<Date | undefined>(undefined)
|
||||
const order = ref<string | null>(null)
|
||||
const periodStart = ref<number | null>(null)
|
||||
const periodEnd = ref<number | null>(null)
|
||||
|
||||
const postListParams = computed<PostListParams>(() => {
|
||||
const params: PostListParams = {
|
||||
@@ -269,74 +283,36 @@ const postListParams = computed<PostListParams>(() => {
|
||||
mediaOnly: mediaOnly.value,
|
||||
orderDesc: orderDesc.value,
|
||||
queryTerm: queryTerm.value || undefined,
|
||||
order: order.value,
|
||||
periodStart: periodStart.value,
|
||||
periodEnd: periodEnd.value
|
||||
order: order.value ?? undefined,
|
||||
periodStart: periodStart.value
|
||||
? Math.floor(periodStart.value / 1000)
|
||||
: undefined,
|
||||
periodEnd: periodEnd.value ? Math.floor(periodEnd.value / 1000) : undefined
|
||||
}
|
||||
|
||||
// Set type based on active tab
|
||||
if (activeCategoryTab.value === "posts") {
|
||||
params.type = 0 // Assuming 0 is for posts
|
||||
params.type = 0
|
||||
} else if (activeCategoryTab.value === "articles") {
|
||||
params.type = 1 // Assuming 1 is for articles
|
||||
params.type = 1
|
||||
}
|
||||
// 'all' means no type filter
|
||||
|
||||
return params
|
||||
})
|
||||
|
||||
const periodStartFormatted = computed(() => {
|
||||
return periodStart.value
|
||||
? new Date(periodStart.value * 1000).toISOString().split("T")[0]
|
||||
: ""
|
||||
})
|
||||
|
||||
const periodEndFormatted = computed(() => {
|
||||
return periodEnd.value
|
||||
? new Date(periodEnd.value * 1000).toISOString().split("T")[0]
|
||||
: ""
|
||||
})
|
||||
|
||||
// Create a key that changes when filters change to force PostList re-mount
|
||||
const filterKey = computed(() => {
|
||||
return JSON.stringify(postListParams.value)
|
||||
})
|
||||
|
||||
const cycleIncludeReplies = () => {
|
||||
if (includeReplies.value === null) {
|
||||
includeReplies.value = false
|
||||
} else if (includeReplies.value === false) {
|
||||
includeReplies.value = true
|
||||
} else if (includeReplies.value === true) {
|
||||
includeReplies.value = false
|
||||
} else {
|
||||
includeReplies.value = null
|
||||
}
|
||||
}
|
||||
|
||||
const openDatePicker = (type: "start" | "end") => {
|
||||
datePickerType.value = type
|
||||
tempDate.value =
|
||||
type === "start"
|
||||
? periodStart.value
|
||||
? new Date(periodStart.value * 1000)
|
||||
: new Date()
|
||||
: periodEnd.value
|
||||
? new Date(periodEnd.value * 1000)
|
||||
: new Date()
|
||||
datePickerDialog.value = true
|
||||
}
|
||||
|
||||
const confirmDatePicker = () => {
|
||||
if (tempDate.value) {
|
||||
const timestamp = Math.floor(tempDate.value.getTime() / 1000)
|
||||
if (datePickerType.value === "start") {
|
||||
periodStart.value = timestamp
|
||||
} else {
|
||||
periodEnd.value = timestamp
|
||||
}
|
||||
}
|
||||
datePickerDialog.value = false
|
||||
}
|
||||
|
||||
definePageMeta({
|
||||
alias: ["/p/:name()"]
|
||||
})
|
||||
@@ -344,12 +320,12 @@ definePageMeta({
|
||||
useHead({
|
||||
title: computed(() => {
|
||||
if (notFound.value) {
|
||||
return "User not found"
|
||||
return "Publisher not found"
|
||||
}
|
||||
if (user.value) {
|
||||
return user.value.nick || user.value.name
|
||||
}
|
||||
return "Loading user..."
|
||||
return "Loading publisher..."
|
||||
}),
|
||||
meta: computed(() => {
|
||||
if (user.value) {
|
||||
@@ -364,6 +340,7 @@ useHead({
|
||||
|
||||
defineOgImage({
|
||||
component: "ImageCard",
|
||||
// @ts-ignore
|
||||
title: computed(() =>
|
||||
user.value ? user.value.nick || user.value.name : "Publisher Profile"
|
||||
),
|
||||
@@ -398,14 +375,12 @@ defineOgImage({
|
||||
|
||||
.sidebar {
|
||||
order: 1;
|
||||
overflow-y: auto;
|
||||
height: auto;
|
||||
max-height: 100vh;
|
||||
}
|
||||
|
||||
@media (min-width: 960px) {
|
||||
.layout {
|
||||
grid-template-columns: 2fr 1fr;
|
||||
grid-template-columns: 1fr 2fr;
|
||||
}
|
||||
|
||||
.main {
|
||||
@@ -420,7 +395,8 @@ defineOgImage({
|
||||
@media (min-width: 1280px) {
|
||||
.sidebar {
|
||||
position: sticky;
|
||||
top: calc(68px + 8px);
|
||||
top: calc(var(--header-height) + 8px);
|
||||
align-self: start;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -99,12 +99,17 @@ export default defineNuxtConfig({
|
||||
borderRadiusSmall: "8px"
|
||||
},
|
||||
Input: {
|
||||
borderRadius: "8px",
|
||||
borderRadiusMedium: "8px",
|
||||
borderRadiusSmall: "4px"
|
||||
borderRadius: "8px"
|
||||
},
|
||||
Select: {
|
||||
borderRadius: "8px"
|
||||
},
|
||||
Dropdown: {
|
||||
borderRadius: "8px"
|
||||
},
|
||||
Button: {
|
||||
borderRadius: "8px",
|
||||
borderRadiusLarge: "12px",
|
||||
borderRadiusMedium: "8px",
|
||||
borderRadiusSmall: "4px"
|
||||
}
|
||||
|
||||
@@ -49,6 +49,8 @@
|
||||
"@types/node": "^24.10.1",
|
||||
"daisyui": "^5.5.5",
|
||||
"naive-ui": "^2.43.2",
|
||||
"tailwindcss": "^4.1.17"
|
||||
"tailwindcss": "^4.1.17",
|
||||
"unplugin-auto-import": "^20.3.0",
|
||||
"unplugin-vue-components": "^30.0.0"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user