init
This commit is contained in:
232
src/views/AssetsView.vue
Normal file
232
src/views/AssetsView.vue
Normal file
@@ -0,0 +1,232 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, computed } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { dataService } from '../services/dataService'
|
||||
import type { Asset } from '@/models/asset'
|
||||
import Button from 'primevue/button'
|
||||
import Skeleton from 'primevue/skeleton'
|
||||
import Dialog from 'primevue/dialog'
|
||||
import Paginator from 'primevue/paginator'
|
||||
|
||||
const router = useRouter()
|
||||
const assets = ref<Asset[]>([])
|
||||
const loading = ref(true)
|
||||
const activeFilter = ref('all')
|
||||
const API_URL = import.meta.env.VITE_API_URL
|
||||
|
||||
const selectedAsset = ref<Asset | null>(null)
|
||||
const isModalVisible = ref(false)
|
||||
|
||||
const first = ref(0)
|
||||
const rows = ref(12)
|
||||
const totalRecords = ref(0)
|
||||
|
||||
const openModal = (asset: Asset) => {
|
||||
selectedAsset.value = asset
|
||||
isModalVisible.value = true
|
||||
}
|
||||
|
||||
const loadAssets = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const response = await dataService.getAssets(rows.value, first.value, activeFilter.value)
|
||||
if (response && response.assets) {
|
||||
assets.value = response.assets
|
||||
totalRecords.value = response.total_count || 0
|
||||
} else {
|
||||
// Fallback for unexpected response structure
|
||||
assets.value = Array.isArray(response) ? response : []
|
||||
totalRecords.value = assets.value.length
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to load assets', e)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadAssets()
|
||||
})
|
||||
|
||||
// Server-side filtering is now used, so we don't need a local filteredAssets computed property
|
||||
// unless we want to do secondary filtering, but usually it's better to let the server handle it.
|
||||
|
||||
const paginatedAssets = computed(() => {
|
||||
// With server-side pagination, assets.value already contains only the current page
|
||||
return assets.value
|
||||
})
|
||||
|
||||
const onPage = (event: any) => {
|
||||
first.value = event.first
|
||||
rows.value = event.rows
|
||||
loadAssets()
|
||||
}
|
||||
|
||||
const handleFilterChange = (filter: string) => {
|
||||
activeFilter.value = filter
|
||||
first.value = 0 // Reset to first page when filter changes
|
||||
loadAssets()
|
||||
}
|
||||
|
||||
const goBack = () => {
|
||||
router.push('/')
|
||||
}
|
||||
|
||||
const formatDate = (dateString: string) => {
|
||||
if (!dateString) return ''
|
||||
return new Intl.DateTimeFormat('en-US', { month: 'short', day: 'numeric', year: 'numeric' }).format(new Date(dateString))
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex h-screen bg-slate-900 overflow-hidden">
|
||||
<!-- Sidebar -->
|
||||
<nav class="glass-panel w-20 m-4 flex flex-col items-center py-6 rounded-3xl z-10">
|
||||
<div class="mb-12 cursor-pointer" @click="goBack">
|
||||
<div
|
||||
class="w-10 h-10 bg-white/10 rounded-xl flex items-center justify-center font-bold text-white text-xl transition-all duration-300 hover:bg-white/20">
|
||||
←
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex-1 flex flex-col gap-6 w-full items-center">
|
||||
<div class="w-12 h-12 flex items-center justify-center rounded-xl cursor-pointer transition-all duration-300 text-slate-400 hover:bg-white/10 hover:text-slate-50"
|
||||
@click="router.push('/')">
|
||||
<span class="text-2xl">🏠</span>
|
||||
</div>
|
||||
<div
|
||||
class="w-12 h-12 flex items-center justify-center rounded-xl cursor-pointer transition-all duration-300 bg-white/10 text-slate-50">
|
||||
<span class="text-2xl">📂</span>
|
||||
</div>
|
||||
<div class="w-12 h-12 flex items-center justify-center rounded-xl cursor-pointer transition-all duration-300 text-slate-400 hover:bg-white/10 hover:text-slate-50"
|
||||
@click="router.push('/characters')">
|
||||
<span class="text-2xl">👥</span>
|
||||
</div>
|
||||
|
||||
<!-- Pagination -->
|
||||
<div v-if="totalRecords > rows" class="mt-auto py-6">
|
||||
<Paginator :first="first" :rows="rows" :totalRecords="totalRecords" @page="onPage" :template="{
|
||||
default: 'FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink'
|
||||
}" class="!bg-transparent !border-none !p-0" :pt="{
|
||||
root: { class: '!bg-transparent' },
|
||||
pcPageButton: {
|
||||
root: ({ context }) => ({
|
||||
class: [
|
||||
'!min-w-[40px] !h-10 !rounded-xl !border-none !transition-all !duration-300 !font-bold',
|
||||
context.active ? '!bg-violet-600 !text-white !shadow-lg' : '!bg-white/5 !text-slate-400 hover:!bg-white/10 hover:!text-slate-50'
|
||||
]
|
||||
})
|
||||
},
|
||||
pcFirstPageButton: { root: { class: '!bg-white/5 !text-slate-400 !border-none !rounded-xl !min-w-[40px] !h-10 hover:!bg-white/10 hover:!text-slate-50 transition-all' } },
|
||||
pcPreviousPageButton: { root: { class: '!bg-white/5 !text-slate-400 !border-none !rounded-xl !min-w-[40px] !h-10 hover:!bg-white/10 hover:!text-slate-50 transition-all' } },
|
||||
pcNextPageButton: { root: { class: '!bg-white/5 !text-slate-400 !border-none !rounded-xl !min-w-[40px] !h-10 hover:!bg-white/10 hover:!text-slate-50 transition-all' } },
|
||||
pcLastPageButton: { root: { class: '!bg-white/5 !text-slate-400 !border-none !rounded-xl !min-w-[40px] !h-10 hover:!bg-white/10 hover:!text-slate-50 transition-all' } }
|
||||
}" />
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- Main Content -->
|
||||
<main class="flex-1 p-8 overflow-y-auto flex flex-col">
|
||||
<!-- Top Bar -->
|
||||
<header class="flex justify-between items-end mb-8">
|
||||
<div>
|
||||
<h1 class="text-4xl font-bold m-0">Assets Library</h1>
|
||||
<p class="mt-2 mb-0 text-slate-400">Manage all your assets</p>
|
||||
</div>
|
||||
|
||||
<div class="glass-panel p-2 flex gap-2 rounded-xl">
|
||||
<Button v-for="filter in ['all', 'image']" :key="filter"
|
||||
:label="filter.charAt(0).toUpperCase() + filter.slice(1)"
|
||||
:class="activeFilter === filter ? 'bg-white/10 text-slate-50' : 'bg-transparent text-slate-400'"
|
||||
class="px-4 py-2 rounded-lg font-medium transition-all duration-300 hover:text-slate-50" text
|
||||
@click="handleFilterChange(filter)" />
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- Loading State -->
|
||||
<div v-if="loading" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6 pb-8">
|
||||
<div v-for="i in 8" :key="i" class="glass-panel rounded-2xl overflow-hidden">
|
||||
<Skeleton height="180px" />
|
||||
<div class="p-5">
|
||||
<Skeleton class="mb-2" />
|
||||
<Skeleton width="60%" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Assets Grid -->
|
||||
<div v-else class="flex-1 flex flex-col">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-6 gap-6 pb-8">
|
||||
<div v-for="asset in paginatedAssets" :key="asset.id" @click="openModal(asset)"
|
||||
class="glass-panel rounded-2xl overflow-hidden transition-all duration-300 cursor-pointer border border-white/5 hover:-translate-y-1 hover:border-white/20 hover:shadow-2xl">
|
||||
<!-- Media Preview -->
|
||||
<div class="h-70 bg-black/30 relative overflow-hidden">
|
||||
<img :src="API_URL + asset.url || 'https://via.placeholder.com/300'" :alt="asset.name"
|
||||
class="w-full h-full object-cover transition-transform duration-500 hover:scale-105" />
|
||||
<div
|
||||
class="absolute top-2.5 right-2.5 bg-black/60 backdrop-blur-sm px-3 py-1 rounded-full text-xs uppercase font-semibold text-white z-10">
|
||||
{{ asset.type }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Asset Info -->
|
||||
<div class="p-5">
|
||||
<div class="flex justify-between items-start mb-2">
|
||||
<h3
|
||||
class="m-0 text-base font-semibold whitespace-nowrap overflow-hidden text-ellipsis flex-1 mr-2">
|
||||
{{ asset.name }}
|
||||
</h3>
|
||||
</div>
|
||||
<div class="flex justify-between items-center text-xs text-slate-400">
|
||||
<span>{{ formatDate(asset.created_at) }}</span>
|
||||
<span v-if="asset.linked_char_id"
|
||||
class="bg-emerald-500/10 text-emerald-400 px-2 py-0.5 rounded">
|
||||
🔗 Linked
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Pagination -->
|
||||
<div v-if="totalRecords > rows" class="mt-auto py-6">
|
||||
<Paginator :first="first" :rows="rows" :totalRecords="totalRecords" @page="onPage" :template="{
|
||||
default: 'FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink'
|
||||
}" class="!bg-transparent !border-none !p-0" :pt="{
|
||||
root: { class: '!bg-transparent' },
|
||||
pcPageButton: {
|
||||
root: ({ context }) => ({
|
||||
class: [
|
||||
'!min-w-[40px] !h-10 !rounded-xl !border-none !transition-all !duration-300 !font-bold',
|
||||
context.active ? '!bg-violet-600 !text-white !shadow-lg' : '!bg-white/5 !text-slate-400 hover:!bg-white/10 hover:!text-slate-50'
|
||||
]
|
||||
})
|
||||
},
|
||||
pcFirstPageButton: { root: { class: '!bg-white/5 !text-slate-400 !border-none !rounded-xl !min-w-[40px] !h-10 hover:!bg-white/10 hover:!text-slate-50 transition-all' } },
|
||||
pcPreviousPageButton: { root: { class: '!bg-white/5 !text-slate-400 !border-none !rounded-xl !min-w-[40px] !h-10 hover:!bg-white/10 hover:!text-slate-50 transition-all' } },
|
||||
pcNextPageButton: { root: { class: '!bg-white/5 !text-slate-400 !border-none !rounded-xl !min-w-[40px] !h-10 hover:!bg-white/10 hover:!text-slate-50 transition-all' } },
|
||||
pcLastPageButton: { root: { class: '!bg-white/5 !text-slate-400 !border-none !rounded-xl !min-w-[40px] !h-10 hover:!bg-white/10 hover:!text-slate-50 transition-all' } }
|
||||
}" />
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<Dialog v-model:visible="isModalVisible" modal dismissableMask header="Asset View"
|
||||
:style="{ width: '90vw', maxWidth: '800px' }" class="glass-panel rounded-2xl">
|
||||
<div v-if="selectedAsset" class="flex flex-col items-center">
|
||||
<img :src="selectedAsset.link ? API_URL + selectedAsset.link : (selectedAsset.url ? API_URL + selectedAsset.url : 'https://via.placeholder.com/800')"
|
||||
:alt="selectedAsset.name" class="max-w-full max-h-[70vh] rounded-xl object-contain shadow-2xl" />
|
||||
<div class="mt-6 text-center">
|
||||
<h2 class="text-2xl font-bold mb-2">{{ selectedAsset.name }}</h2>
|
||||
<p class="text-slate-400">{{ formatDate(selectedAsset.created_at) }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* Additional custom styles if needed */
|
||||
</style>
|
||||
753
src/views/CharacterDetailView.vue
Normal file
753
src/views/CharacterDetailView.vue
Normal file
@@ -0,0 +1,753 @@
|
||||
<script setup>
|
||||
import { ref, onMounted, computed } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { dataService } from '../services/dataService'
|
||||
import { aiService } from '../services/aiService'
|
||||
import Button from 'primevue/button'
|
||||
import Skeleton from 'primevue/skeleton'
|
||||
import Tag from 'primevue/tag'
|
||||
import Dialog from 'primevue/dialog'
|
||||
import Textarea from 'primevue/textarea'
|
||||
import SelectButton from 'primevue/selectbutton'
|
||||
import FileUpload from 'primevue/fileupload'
|
||||
import ProgressBar from 'primevue/progressbar'
|
||||
import Message from 'primevue/message'
|
||||
import ProgressSpinner from 'primevue/progressspinner'
|
||||
import Tabs from 'primevue/tabs'
|
||||
import TabList from 'primevue/tablist'
|
||||
import Tab from 'primevue/tab'
|
||||
import TabPanels from 'primevue/tabpanels'
|
||||
import TabPanel from 'primevue/tabpanel'
|
||||
import Paginator from 'primevue/paginator'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const character = ref(null)
|
||||
const characterAssets = ref([])
|
||||
const assetsTotalRecords = ref(0)
|
||||
const historyGenerations = ref([])
|
||||
const historyTotal = ref(0)
|
||||
const historyRows = ref(10)
|
||||
const historyFirst = ref(0)
|
||||
const loading = ref(true)
|
||||
const API_URL = import.meta.env.VITE_API_URL
|
||||
|
||||
const selectedAsset = ref(null)
|
||||
const isModalVisible = ref(false)
|
||||
|
||||
const openModal = (asset) => {
|
||||
selectedAsset.value = asset
|
||||
isModalVisible.value = true
|
||||
}
|
||||
|
||||
const loadData = async () => {
|
||||
loading.value = true
|
||||
const charId = route.params.id
|
||||
try {
|
||||
const [char, assetsResponse, historyResponse] = await Promise.all([
|
||||
dataService.getCharacterById(charId),
|
||||
dataService.getAssetsByCharacterId(charId, assetsRows.value, assetsFirst.value),
|
||||
aiService.getGenerations(historyRows.value, historyFirst.value, charId)
|
||||
])
|
||||
character.value = char
|
||||
|
||||
if (assetsResponse && assetsResponse.assets) {
|
||||
characterAssets.value = assetsResponse.assets
|
||||
assetsTotalRecords.value = assetsResponse.total_count || 0
|
||||
} else {
|
||||
characterAssets.value = Array.isArray(assetsResponse) ? assetsResponse : []
|
||||
assetsTotalRecords.value = characterAssets.value.length
|
||||
}
|
||||
|
||||
if (historyResponse && historyResponse.generations) {
|
||||
historyGenerations.value = historyResponse.generations
|
||||
historyTotal.value = historyResponse.total_count || 0
|
||||
} else {
|
||||
historyGenerations.value = Array.isArray(historyResponse) ? historyResponse : []
|
||||
historyTotal.value = historyGenerations.value.length
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to load character details', e)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadData()
|
||||
})
|
||||
|
||||
const goBack = () => {
|
||||
router.push('/characters')
|
||||
}
|
||||
|
||||
const loadAssets = async () => {
|
||||
const charId = route.params.id
|
||||
try {
|
||||
const response = await dataService.getAssetsByCharacterId(charId, assetsRows.value, assetsFirst.value)
|
||||
if (response && response.assets) {
|
||||
characterAssets.value = response.assets
|
||||
assetsTotalRecords.value = response.total_count || 0
|
||||
} else {
|
||||
characterAssets.value = Array.isArray(response) ? response : []
|
||||
assetsTotalRecords.value = characterAssets.value.length
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to load assets', e)
|
||||
}
|
||||
return characterAssets.value
|
||||
}
|
||||
const loadHistory = async () => {
|
||||
const charId = route.params.id
|
||||
try {
|
||||
const response = await aiService.getGenerations(historyRows.value, historyFirst.value, charId)
|
||||
if (response && response.generations) {
|
||||
historyGenerations.value = response.generations
|
||||
historyTotal.value = response.total_count || 0
|
||||
} else {
|
||||
historyGenerations.value = Array.isArray(response) ? response : []
|
||||
historyTotal.value = historyGenerations.value.length
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to load history', e)
|
||||
}
|
||||
}
|
||||
|
||||
const onHistoryPage = (event) => {
|
||||
historyFirst.value = event.first
|
||||
historyRows.value = event.rows
|
||||
loadHistory()
|
||||
}
|
||||
|
||||
// Generation State
|
||||
const prompt = ref('')
|
||||
const isGenerating = ref(false)
|
||||
const generationStatus = ref('')
|
||||
const generationProgress = ref(0)
|
||||
const generationSuccess = ref(false)
|
||||
const generatedResult = ref(null)
|
||||
|
||||
// Prompt Assistant state
|
||||
const isImprovingPrompt = ref(false)
|
||||
const previousPrompt = ref('')
|
||||
|
||||
// File Upload state
|
||||
const isUploading = ref(false)
|
||||
const fileInput = ref(null)
|
||||
|
||||
const selectedAssets = ref([])
|
||||
const toggleAssetSelection = (asset) => {
|
||||
const index = selectedAssets.value.findIndex(a => a.id === asset.id)
|
||||
if (index > -1) {
|
||||
selectedAssets.value.splice(index, 1)
|
||||
} else {
|
||||
selectedAssets.value.push(asset)
|
||||
}
|
||||
}
|
||||
|
||||
const quality = ref({
|
||||
key: 'TWOK',
|
||||
value: '2K'
|
||||
})
|
||||
const qualityOptions = ref([{
|
||||
key: 'ONEK',
|
||||
value: '1K'
|
||||
}, {
|
||||
key: 'TWOK',
|
||||
value: '2K'
|
||||
}, {
|
||||
key: 'FOURK',
|
||||
value: '4K'
|
||||
}])
|
||||
const aspectRatio = ref({ key: "NINESIXTEEN", value: "9:16" })
|
||||
const aspectRatioOptions = ref([
|
||||
{ key: "NINESIXTEEN", value: "9:16" },
|
||||
{ key: "FOURTHIREE", value: "4:3" },
|
||||
{ key: "THIRDFOUR", value: "3:4" },
|
||||
{ key: "SIXTEENNINE", value: "16:9" }
|
||||
])
|
||||
|
||||
const assetsFirst = ref(0)
|
||||
const assetsRows = ref(12)
|
||||
const paginatedCharacterAssets = computed(() => {
|
||||
return characterAssets.value
|
||||
})
|
||||
|
||||
const onAssetsPage = (event) => {
|
||||
assetsFirst.value = event.first
|
||||
assetsRows.value = event.rows
|
||||
loadAssets()
|
||||
}
|
||||
|
||||
const pollStatus = async (id) => {
|
||||
let completed = false
|
||||
while (!completed && isGenerating.value) {
|
||||
try {
|
||||
const response = await aiService.getGenerationStatus(id)
|
||||
generationStatus.value = response.status
|
||||
generationProgress.value = response.progress || 0
|
||||
|
||||
if (response.status === 'done') {
|
||||
completed = true
|
||||
generationSuccess.value = true
|
||||
|
||||
// Refresh assets list
|
||||
const assets = await loadAssets()
|
||||
|
||||
// Display created assets from the list (without selecting them)
|
||||
if (response.assets_list && response.assets_list.length > 0) {
|
||||
const resultAssets = assets.filter(a => response.assets_list.includes(a.id))
|
||||
generatedResult.value = {
|
||||
type: 'assets',
|
||||
assets: resultAssets
|
||||
}
|
||||
}
|
||||
|
||||
loadHistory()
|
||||
} else if (response.status === 'failed') {
|
||||
completed = true
|
||||
throw new Error('Generation failed on server')
|
||||
} else {
|
||||
// Wait before next poll
|
||||
await new Promise(resolve => setTimeout(resolve, 2000))
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Polling failed', e)
|
||||
completed = true
|
||||
isGenerating.value = false
|
||||
}
|
||||
}
|
||||
isGenerating.value = false
|
||||
}
|
||||
|
||||
const restoreGeneration = async (gen) => {
|
||||
// 1. Set prompt
|
||||
prompt.value = gen.prompt
|
||||
|
||||
// 2. Set Quality
|
||||
const foundQuality = qualityOptions.value.find(opt => opt.key === gen.quality)
|
||||
if (foundQuality) quality.value = foundQuality
|
||||
|
||||
// 3. Set Aspect Ratio
|
||||
const foundAspect = aspectRatioOptions.value.find(opt => opt.key === gen.aspect_ratio)
|
||||
if (foundAspect) aspectRatio.value = foundAspect
|
||||
|
||||
// 4. Set Result if status is 'done'
|
||||
if (gen.status === 'done') {
|
||||
const assets = characterAssets.value
|
||||
if (gen.assets_list && gen.assets_list.length > 0) {
|
||||
selectedAssets.value = assets.filter(a => gen.assets_list.includes(a.id))
|
||||
generatedResult.value = {
|
||||
type: 'assets',
|
||||
assets: selectedAssets.value
|
||||
}
|
||||
generationSuccess.value = true
|
||||
}
|
||||
} else {
|
||||
generatedResult.value = null
|
||||
generationSuccess.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleImprovePrompt = async () => {
|
||||
if (prompt.value.length <= 10) return
|
||||
|
||||
isImprovingPrompt.value = true
|
||||
try {
|
||||
const linkedAssetIds = selectedAssets.value.map(a => a.id)
|
||||
const response = await aiService.improvePrompt(prompt.value, linkedAssetIds)
|
||||
if (response && response.prompt) {
|
||||
previousPrompt.value = prompt.value
|
||||
prompt.value = response.prompt
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Prompt improvement failed', e)
|
||||
} finally {
|
||||
isImprovingPrompt.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const undoImprovePrompt = () => {
|
||||
if (previousPrompt.value) {
|
||||
const temp = prompt.value
|
||||
prompt.value = previousPrompt.value
|
||||
previousPrompt.value = temp
|
||||
}
|
||||
}
|
||||
|
||||
const triggerFileUpload = () => {
|
||||
if (fileInput.value) fileInput.value.click()
|
||||
}
|
||||
|
||||
const onFileSelected = async (event) => {
|
||||
const file = event.target.files[0]
|
||||
if (!file) return
|
||||
|
||||
isUploading.value = true
|
||||
try {
|
||||
await dataService.uploadAsset(file, route.params.id)
|
||||
await loadAssets()
|
||||
} catch (e) {
|
||||
console.error('Failed to upload asset', e)
|
||||
} finally {
|
||||
isUploading.value = false
|
||||
if (event.target) event.target.value = '' // Clear input
|
||||
}
|
||||
}
|
||||
|
||||
const handleGenerate = async () => {
|
||||
if (!prompt.value.trim()) return
|
||||
|
||||
isGenerating.value = true
|
||||
generationSuccess.value = false
|
||||
generationStatus.value = 'starting'
|
||||
generationProgress.value = 0
|
||||
generatedResult.value = null
|
||||
|
||||
try {
|
||||
const payload = {
|
||||
linked_character_id: character.value?.id,
|
||||
aspect_ratio: aspectRatio.value.key,
|
||||
quality: quality.value.key,
|
||||
prompt: prompt.value,
|
||||
assets_list: selectedAssets.value.map(a => a.id)
|
||||
}
|
||||
|
||||
const response = await aiService.runGeneration(payload)
|
||||
// response is expected to have an 'id' for the generation task
|
||||
if (response && response.id) {
|
||||
pollStatus(response.id)
|
||||
} else {
|
||||
// Fallback if it returns data immediately
|
||||
generatedResult.value = response
|
||||
generationSuccess.value = true
|
||||
isGenerating.value = false
|
||||
}
|
||||
prompt.value = ''
|
||||
} catch (e) {
|
||||
console.error('Generation failed', e)
|
||||
isGenerating.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex h-screen bg-slate-900 overflow-hidden">
|
||||
<nav class="glass-panel w-14 m-2 flex flex-col items-center py-4 rounded-2xl z-10">
|
||||
<div class="mb-6 cursor-pointer" @click="router.push('/')">
|
||||
<div
|
||||
class="w-8 h-8 bg-white/10 rounded-lg flex items-center justify-center font-bold text-white text-lg transition-all duration-300 hover:bg-white/20">
|
||||
←
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex-1 flex flex-col gap-4 w-full items-center">
|
||||
<div class="w-10 h-10 flex items-center justify-center rounded-lg cursor-pointer transition-all duration-300 text-slate-400 hover:bg-white/10 hover:text-slate-50"
|
||||
@click="router.push('/')">
|
||||
<span class="text-xl">🏠</span>
|
||||
</div>
|
||||
<div class="w-10 h-10 flex items-center justify-center rounded-lg cursor-pointer transition-all duration-300 text-slate-400 hover:bg-white/10 hover:text-slate-50"
|
||||
@click="router.push('/assets')">
|
||||
<span class="text-xl">📂</span>
|
||||
</div>
|
||||
<div class="w-10 h-10 flex items-center justify-center rounded-lg cursor-pointer transition-all duration-300 bg-white/10 text-slate-50"
|
||||
@click="router.push('/characters')">
|
||||
<span class="text-xl">👥</span>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main v-if="!loading && character" class="flex-1 p-4 lg:p-6 overflow-y-auto flex flex-col gap-4">
|
||||
<header class="mb-0">
|
||||
<Button label="Back" icon="pi pi-arrow-left" @click="goBack" text
|
||||
class="text-slate-400 hover:text-slate-50 p-1" />
|
||||
</header>
|
||||
|
||||
<div class="glass-panel p-2 lg:p-3 rounded-xl border border-white/5">
|
||||
<div class="flex gap-4 items-center">
|
||||
<div class="w-16 h-16 rounded-full overflow-hidden border border-white/10 flex-shrink-0">
|
||||
<img :src="API_URL + character.avatar_image || 'https://via.placeholder.com/200'"
|
||||
:alt="character.name" class="w-full h-full object-cover" />
|
||||
</div>
|
||||
<div class="flex-1 overflow-hidden">
|
||||
<h1 class="text-xl font-bold m-0 mb-1 leading-tight">{{ character.name }}</h1>
|
||||
<div class="flex gap-2 mb-1">
|
||||
<Tag :value="`ID: ${character.id.substring(0, 8)}`" severity="secondary"
|
||||
class="text-[9px] px-1 py-0" />
|
||||
</div>
|
||||
<p class="text-[11px] leading-tight text-slate-400 max-w-full">
|
||||
{{ character.character_bio }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Tabs value="0" class="glass-panel p-1.5 rounded-xl border border-white/5"
|
||||
style="--p-tabs-tablist-background: transparent !important">
|
||||
<TabList :pt="{
|
||||
root: { class: 'border-none p-0 mb-2 inline-flex' },
|
||||
tab: ({ context }) => ({
|
||||
class: [
|
||||
'flex items-center gap-1.5 px-4 py-2 rounded-lg font-bold transition-all duration-300 border-none outline-none cursor-pointer text-xs',
|
||||
context.active
|
||||
? 'bg-violet-600/20 text-violet-400 shadow-[0_0_20px_rgba(124,58,237,0.1)] border border-violet-500/20'
|
||||
: 'text-slate-500 hover:text-slate-300 !bg-transparent border border-transparent'
|
||||
]
|
||||
}),
|
||||
activeBar: { class: 'hidden' }
|
||||
}">
|
||||
<Tab value="0">
|
||||
<div class="!flex !flex-row !gap-1">
|
||||
<i class="pi pi-sparkles text-[10px]" />
|
||||
<span>Generation</span>
|
||||
</div>
|
||||
</Tab>
|
||||
<Tab value="1">
|
||||
<div class="!flex !flex-row !gap-1">
|
||||
<i class="pi pi-images text-[10px]" />
|
||||
<span>Assets ({{ assetsTotalRecords }})</span>
|
||||
</div>
|
||||
</Tab>
|
||||
<Tab value="2" class="hidden">
|
||||
<div class="!flex !flex-row !gap-1">
|
||||
<i class="pi pi-history text-[10px]" />
|
||||
<span>History ({{ historyTotal }})</span>
|
||||
</div>
|
||||
</Tab>
|
||||
</TabList>
|
||||
|
||||
<TabPanels class="bg-transparent p-0">
|
||||
<TabPanel value="0">
|
||||
<div class="grid grid-cols-1 lg:grid-cols-4 gap-2">
|
||||
<div
|
||||
class="lg:col-span-1 glass-panel p-2 rounded-xl border border-white/5 bg-white/5 flex flex-col gap-3">
|
||||
<div class="flex justify-between items-center flex-col">
|
||||
<h2 class="text-sm font-bold m-0">Settings</h2>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-1.5">
|
||||
<label
|
||||
class="text-slate-400 text-[9px] font-semibold uppercase tracking-wider">Quality</label>
|
||||
<div
|
||||
class="!flex !w-full !justify-between items-center justify-center !bg-slate-900/50 !p-1 gap-1 !rounded-lg !border !border-white/10">
|
||||
<div v-for="option in qualityOptions" :key="option.key"
|
||||
@click="quality = option"
|
||||
class="w-full items-center justify-center justify-items-center !text-center hover:bg-white/5 hover:text-white p-1 hover:rounded-lg"
|
||||
:class="quality.key === option.key ? 'bg-white/9 text-white rounded-lg' : ''">
|
||||
<span class="text-white w-full text-center">{{ option.value }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-1.5">
|
||||
<label
|
||||
class="text-slate-400 text-[9px] font-semibold uppercase tracking-wider">Aspect</label>
|
||||
<div
|
||||
class="!flex !w-full !justify-between items-center justify-center !bg-slate-900/50 !p-1 gap-1 !rounded-lg !border !border-white/10">
|
||||
<div v-for="option in aspectRatioOptions" :key="option.key"
|
||||
@click="aspectRatio = option"
|
||||
class="w-full items-center justify-center justify-items-center !text-center hover:bg-white/5 hover:text-white p-1 hover:rounded-lg"
|
||||
:class="aspectRatio.key === option.key ? 'bg-white/9 text-white rounded-lg' : ''">
|
||||
<span class="text-white w-full text-center">{{ option.value }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-1.5">
|
||||
<label
|
||||
class="text-slate-400 text-[9px] font-semibold uppercase tracking-wider">Description</label>
|
||||
|
||||
<div class="relative w-full">
|
||||
<Textarea v-model="prompt" rows="3" autoResize placeholder="Describe..."
|
||||
class="w-full bg-slate-900 border-white/10 text-white rounded-lg p-2 focus:border-violet-500 transition-all text-xs pr-10" />
|
||||
|
||||
<div class="absolute top-1.5 right-1.5 flex gap-1">
|
||||
<Button v-if="previousPrompt" icon="pi pi-undo"
|
||||
class="!p-1 !w-6 !h-6 !text-[10px] bg-slate-800 hover:bg-slate-700 border-white/10 text-slate-300"
|
||||
@click="undoImprovePrompt" v-tooltip.top="'Rollback'" />
|
||||
|
||||
<Button icon="pi pi-sparkles" :loading="isImprovingPrompt"
|
||||
:disabled="prompt.length <= 10"
|
||||
class="!p-1 !w-6 !h-6 !text-[10px] bg-violet-600/20 hover:bg-violet-600/30 border-violet-500/30 text-violet-400 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
@click="handleImprovePrompt"
|
||||
v-tooltip.top="prompt.length <= 10 ? 'Enter at least 10 characters' : 'Improve prompt'" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="characterAssets.length > 0" class="flex flex-col gap-1.5">
|
||||
<label class="text-slate-400 text-[9px] font-semibold uppercase tracking-wider">Ref
|
||||
Assets ({{ selectedAssets.length }})</label>
|
||||
<div class="grid grid-cols-6 gap-1">
|
||||
<div v-for="asset in characterAssets" :key="asset.id"
|
||||
@click="toggleAssetSelection(asset)"
|
||||
class="relative aspect-[9/16] rounded overflow-hidden cursor-pointer border transition-all duration-200 hover:scale-200 hover:z-10"
|
||||
:class="selectedAssets.some(a => a.id === asset.id) ? 'border-violet-500 ring-1 ring-violet-500/20 shadow-lg' : 'border-white/5 opacity-60 hover:opacity-100 hover:border-white/20'">
|
||||
<img :src="API_URL + asset.url" class="w-full h-full object-cover" />
|
||||
<div v-if="selectedAssets.some(a => a.id === asset.id)"
|
||||
class="absolute inset-0 bg-violet-600/20 flex items-center justify-center">
|
||||
<i class="pi pi-check text-white text-[8px] drop-shadow-md" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Removed Ref Assets section if characterAssets is empty, but it's already conditional -->
|
||||
|
||||
<div class="flex flex-col gap-1.5 mt-auto pt-1.5 border-t border-white/5">
|
||||
<Button :label="isGenerating ? 'Wait...' : `Generate`"
|
||||
:icon="isGenerating ? 'pi pi-spin pi-spinner' : 'pi pi-magic'"
|
||||
:loading="isGenerating" @click="handleGenerate"
|
||||
class="w-full py-2 text-[11px] font-bold bg-gradient-to-r from-violet-600 to-cyan-500 border-none rounded shadow transition-all hover:scale-[1.01] active:scale-[0.99]" />
|
||||
|
||||
<Message v-if="generationSuccess" severity="success" :closable="true"
|
||||
@close="generationSuccess = false">
|
||||
Success!
|
||||
</Message>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="lg:col-span-3 glass-panel p-3 rounded-xl border border-white/5 bg-white/5 min-h-[300px] flex flex-col items-center justify-center text-center relative overflow-hidden">
|
||||
<div v-if="isGenerating" class="flex flex-col items-center gap-3 z-10 w-full px-12">
|
||||
<ProgressSpinner style="width: 40px; height: 40px" strokeWidth="4"
|
||||
animationDuration=".8s" fill="transparent" />
|
||||
<div class="text-center">
|
||||
<h3
|
||||
class="text-lg font-bold mb-0.5 bg-gradient-to-r from-violet-400 to-cyan-400 bg-clip-text text-transparent capitalize">
|
||||
{{ generationStatus || 'Creating...' }}</h3>
|
||||
<p class="text-[10px] text-slate-400">Processing using AI</p>
|
||||
</div>
|
||||
<ProgressBar :value="generationProgress" style="height: 6px; width: 100%"
|
||||
class="rounded-full overflow-hidden !bg-slate-800" :pt="{
|
||||
value: { class: '!bg-gradient-to-r !from-violet-600 !to-cyan-500 !transition-all !duration-500' }
|
||||
}" />
|
||||
<span class="text-[10px] text-slate-500 font-mono">{{ generationProgress }}%</span>
|
||||
</div>
|
||||
|
||||
<div v-else-if="generatedResult"
|
||||
class="w-full h-full flex flex-col gap-3 animate-in fade-in zoom-in duration-300">
|
||||
<div class="flex justify-between items-center mb-1">
|
||||
<h2 class="text-lg font-bold m-0">Result</h2>
|
||||
<div class="flex gap-1">
|
||||
<Button icon="pi pi-download" text class="hover:bg-white/10 p-1 text-xs" />
|
||||
<Button icon="pi pi-share-alt" text class="hover:bg-white/10 p-1 text-xs" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="generatedResult.type === 'assets'"
|
||||
class="grid grid-cols-1 md:grid-cols-2 gap-2 overflow-y-auto">
|
||||
<div v-for="asset in generatedResult.assets" :key="asset.id"
|
||||
class="rounded-xl overflow-hidden border border-white/10 shadow-xl aspect-square bg-black/20">
|
||||
<img :src="API_URL + asset.url" class="w-full h-full object-cover" />
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="generatedResult.type === 'image'"
|
||||
class="flex-1 rounded-xl overflow-hidden border border-white/10 shadow-xl">
|
||||
<img :src="generatedResult.url" class="w-full h-full object-cover" />
|
||||
</div>
|
||||
<div v-else
|
||||
class="flex-1 bg-slate-900/50 p-4 rounded-xl border border-white/10 text-left font-mono text-[11px] leading-tight overflow-y-auto">
|
||||
{{ generatedResult.content || generatedResult }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="flex flex-col items-center gap-2 text-slate-500 opacity-60">
|
||||
<i class="pi pi-image text-4xl" />
|
||||
<p class="text-sm font-medium">Ready</p>
|
||||
</div>
|
||||
|
||||
<!-- Generation History Section -->
|
||||
<div class="w-full mt-6 pt-6 border-t border-white/5 flex flex-col gap-3 relative z-10">
|
||||
<div class="flex justify-between items-center px-1">
|
||||
<h3 class="text-xs font-bold text-slate-400 uppercase tracking-wider">Recent
|
||||
Generations ({{ historyTotal }})</h3>
|
||||
<Button v-if="historyTotal > 0" icon="pi pi-refresh" text
|
||||
class="!p-1 hover:bg-white/5 text-xs text-slate-500" @click="loadHistory" />
|
||||
</div>
|
||||
|
||||
<div v-if="historyGenerations.length === 0"
|
||||
class="py-10 text-center text-slate-600 italic text-[11px]">
|
||||
No previous generations.
|
||||
</div>
|
||||
|
||||
<div v-else
|
||||
class="flex flex-col gap-2 max-h-[400px] overflow-y-auto pr-2 custom-scrollbar">
|
||||
<div v-for="gen in historyGenerations" :key="gen.id"
|
||||
@click="restoreGeneration(gen)"
|
||||
class="glass-panel p-2.5 rounded-xl border border-white/5 flex gap-3 items-center bg-white/[0.02] hover:bg-white/[0.05] transition-all cursor-pointer group active:scale-[0.98]">
|
||||
<div
|
||||
class="w-14 h-14 rounded-lg overflow-hidden border border-white/10 bg-black/20 flex-shrink-0 relative">
|
||||
<img v-if="gen.assets_list && gen.assets_list.length > 0"
|
||||
:src="API_URL + '/assets/' + gen.assets_list[0]"
|
||||
class="w-full h-full object-cover transition-transform group-hover:scale-110" />
|
||||
<div v-else
|
||||
class="w-full h-full flex items-center justify-center text-slate-700">
|
||||
<i class="pi pi-image text-lg" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex-1 min-w-0 flex flex-col gap-1">
|
||||
<div class="flex justify-between items-start gap-2">
|
||||
<p class="text-[11px] text-slate-300 truncate font-medium">{{
|
||||
gen.prompt }}</p>
|
||||
<Tag :value="gen.status"
|
||||
:severity="gen.status === 'done' ? 'success' : (gen.status === 'failed' ? 'danger' : 'warning')"
|
||||
class="text-[8px] px-1 py-0 !h-auto uppercase" />
|
||||
</div>
|
||||
<div class="flex gap-2 text-[9px] text-slate-500 font-mono">
|
||||
<span>{{ new Date(gen.created_at).toLocaleDateString() }}</span>
|
||||
<span>•</span>
|
||||
<span>{{ gen.quality }}</span>
|
||||
<span>•</span>
|
||||
<span>{{ gen.aspect_ratio }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<Button icon="pi pi-chevron-right" text rounded size="small"
|
||||
class="opacity-0 group-hover:opacity-100 transition-opacity text-slate-400 !p-1" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Compact Pagination -->
|
||||
<div v-if="historyTotal > historyRows" class="mt-2 border-t border-white/5 pt-2">
|
||||
<Paginator :first="historyFirst" :rows="historyRows"
|
||||
:totalRecords="historyTotal" @page="onHistoryPage" :template="{
|
||||
default: 'PrevPageLink PageLinks NextPageLink'
|
||||
}" class="!bg-transparent !border-none !p-0 !text-[10px]" :pt="{
|
||||
root: { class: '!p-0' },
|
||||
pcPageButton: { root: ({ context }) => ({ class: ['!min-w-[24px] !h-6 !text-[10px] !rounded-md', context.active ? '!bg-violet-600/20 !text-violet-400' : '!bg-transparent'] }) },
|
||||
pcNextPageButton: { root: { class: '!min-w-[24px] !h-6 !text-[10px]' } },
|
||||
pcPreviousPageButton: { root: { class: '!min-w-[24px] !h-6 !text-[10px]' } }
|
||||
}" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="absolute -bottom-20 -right-20 w-64 h-64 bg-violet-600/10 blur-[100px] rounded-full pointer-events-none">
|
||||
</div>
|
||||
<div
|
||||
class="absolute -top-20 -left-20 w-64 h-64 bg-cyan-600/10 blur-[100px] rounded-full pointer-events-none">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</TabPanel>
|
||||
|
||||
<TabPanel value="1">
|
||||
<div class="glass-panel p-8 rounded-3xl border border-white/5 bg-white/5">
|
||||
<div class="flex justify-between items-center mb-6">
|
||||
<h2 class="text-2xl font-bold m-0">Linked Assets ({{ assetsTotalRecords }})</h2>
|
||||
<div>
|
||||
<input type="file" ref="fileInput" class="hidden" accept="image/*"
|
||||
@change="onFileSelected" />
|
||||
<Button :label="isUploading ? 'Uploading...' : 'Upload Asset'"
|
||||
:icon="isUploading ? 'pi pi-spin pi-spinner' : 'pi pi-upload'"
|
||||
:loading="isUploading" @click="triggerFileUpload"
|
||||
class="!py-2 !px-4 !text-sm font-bold bg-white/5 hover:bg-white/10 border-white/10 text-white rounded-xl transition-all" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="characterAssets.length === 0"
|
||||
class="text-center py-16 text-slate-400 bg-white/[0.02] rounded-2xl">
|
||||
No assets linked to this character.
|
||||
</div>
|
||||
|
||||
<div v-else class="flex-1 flex flex-col">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-6 gap-6">
|
||||
<div v-for="asset in paginatedCharacterAssets" :key="asset.id"
|
||||
@click="openModal(asset)"
|
||||
class="glass-panel rounded-2xl overflow-hidden border border-white/5 transition-all duration-300 cursor-pointer hover:-translate-y-1 hover:border-white/20">
|
||||
<div class="h-70 relative overflow-hidden">
|
||||
<img :src="API_URL + asset.url || 'https://via.placeholder.com/300'"
|
||||
:alt="asset.name" class="w-full h-full object-cover" />
|
||||
<div
|
||||
class="absolute top-2 right-2 bg-black/60 backdrop-blur-sm px-2 py-1 rounded text-xs uppercase text-white">
|
||||
{{ asset.type }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="p-4">
|
||||
<h3
|
||||
class="text-sm font-semibold m-0 whitespace-nowrap overflow-hidden text-ellipsis">
|
||||
{{ asset.name }}
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Pagination -->
|
||||
<div v-if="assetsTotalRecords > assetsRows" class="mt-8">
|
||||
<Paginator :first="assetsFirst" :rows="assetsRows"
|
||||
:totalRecords="assetsTotalRecords" @page="onAssetsPage" :template="{
|
||||
default: 'FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink'
|
||||
}" class="!bg-transparent !border-none !p-0" :pt="{
|
||||
root: { class: '!bg-transparent' },
|
||||
pcPageButton: {
|
||||
root: ({ context }) => ({
|
||||
class: [
|
||||
'!min-w-[40px] !h-10 !rounded-xl !border-none !transition-all !duration-300 !font-bold',
|
||||
context.active ? '!bg-violet-600 !text-white !shadow-lg' : '!bg-white/5 !text-slate-400 hover:!bg-white/10 hover:!text-slate-50'
|
||||
]
|
||||
})
|
||||
},
|
||||
pcFirstPageButton: { root: { class: '!bg-white/5 !text-slate-400 !border-none !rounded-xl !min-w-[40px] !h-10 hover:!bg-white/10 hover:!text-slate-50 transition-all' } },
|
||||
pcPreviousPageButton: { root: { class: '!bg-white/5 !text-slate-400 !border-none !rounded-xl !min-w-[40px] !h-10 hover:!bg-white/10 hover:!text-slate-50 transition-all' } },
|
||||
pcNextPageButton: { root: { class: '!bg-white/5 !text-slate-400 !border-none !rounded-xl !min-w-[40px] !h-10 hover:!bg-white/10 hover:!text-slate-50 transition-all' } },
|
||||
pcLastPageButton: { root: { class: '!bg-white/5 !text-slate-400 !border-none !rounded-xl !min-w-[40px] !h-10 hover:!bg-white/10 hover:!text-slate-50 transition-all' } }
|
||||
}" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</TabPanel>
|
||||
|
||||
</TabPanels>
|
||||
</Tabs>
|
||||
</main>
|
||||
|
||||
<div v-else-if="loading" class="flex-1 p-8 overflow-y-auto flex flex-col gap-8">
|
||||
<Skeleton width="10rem" height="2rem" />
|
||||
<div class="glass-panel p-8 rounded-3xl">
|
||||
<div class="flex gap-8 items-center">
|
||||
<Skeleton shape="circle" size="9.5rem" />
|
||||
<div class="flex-1">
|
||||
<Skeleton width="20rem" height="3rem" class="mb-4" />
|
||||
<Skeleton width="15rem" height="2rem" class="mb-6" />
|
||||
<Skeleton width="100%" height="4rem" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="flex-1 flex items-center justify-center text-slate-400">
|
||||
Character not found.
|
||||
</div>
|
||||
|
||||
<Dialog v-model:visible="isModalVisible" modal dismissableMask header="Asset View"
|
||||
:style="{ width: '90vw', maxWidth: '800px' }" class="glass-panel rounded-2xl">
|
||||
<div v-if="selectedAsset" class="flex flex-col items-center">
|
||||
<img :src="selectedAsset.link ? API_URL + selectedAsset.link : (selectedAsset.url ? API_URL + selectedAsset.url : 'https://via.placeholder.com/800')"
|
||||
:alt="selectedAsset.name" class="max-w-full max-h-[70vh] rounded-xl object-contain shadow-2xl" />
|
||||
<div class="mt-6 text-center">
|
||||
<h2 class="text-2xl font-bold mb-2">{{ selectedAsset.name }}</h2>
|
||||
<p class="text-slate-400">{{ selectedAsset.type }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog>
|
||||
</div>
|
||||
</template>
|
||||
<style scoped>
|
||||
.p-tablist {
|
||||
background: transparent !important;
|
||||
}
|
||||
|
||||
.p-tablist-tab-list {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.p-tabpanels {
|
||||
background: transparent !important;
|
||||
}
|
||||
|
||||
.p-togglebutton-content {
|
||||
padding: 0 !important;
|
||||
}
|
||||
</style>
|
||||
110
src/views/CharactersView.vue
Normal file
110
src/views/CharactersView.vue
Normal file
@@ -0,0 +1,110 @@
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { dataService } from '../services/dataService'
|
||||
import Skeleton from 'primevue/skeleton'
|
||||
|
||||
const router = useRouter()
|
||||
const characters = ref([])
|
||||
const loading = ref(true)
|
||||
const API_URL = import.meta.env.VITE_API_URL
|
||||
|
||||
onMounted(async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
characters.value = await dataService.getCharacters()
|
||||
} catch (e) {
|
||||
console.error('Failed to load characters', e)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
})
|
||||
|
||||
const goBack = () => {
|
||||
router.push('/')
|
||||
}
|
||||
|
||||
const goToDetail = (id) => {
|
||||
router.push(`/characters/${id}`)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex h-screen bg-slate-900 overflow-hidden">
|
||||
<!-- Sidebar -->
|
||||
<nav class="glass-panel w-20 m-4 flex flex-col items-center py-6 rounded-3xl z-10">
|
||||
<div class="mb-12 cursor-pointer" @click="goBack">
|
||||
<div
|
||||
class="w-10 h-10 bg-white/10 rounded-xl flex items-center justify-center font-bold text-white text-xl transition-all duration-300 hover:bg-white/20">
|
||||
←
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex-1 flex flex-col gap-6 w-full items-center">
|
||||
<div class="w-12 h-12 flex items-center justify-center rounded-xl cursor-pointer transition-all duration-300 text-slate-400 hover:bg-white/10 hover:text-slate-50"
|
||||
@click="router.push('/')">
|
||||
<span class="text-2xl">🏠</span>
|
||||
</div>
|
||||
<div class="w-12 h-12 flex items-center justify-center rounded-xl cursor-pointer transition-all duration-300 text-slate-400 hover:bg-white/10 hover:text-slate-50"
|
||||
@click="router.push('/assets')">
|
||||
<span class="text-2xl">📂</span>
|
||||
</div>
|
||||
<div
|
||||
class="w-12 h-12 flex items-center justify-center rounded-xl cursor-pointer transition-all duration-300 bg-white/10 text-slate-50">
|
||||
<span class="text-2xl">👥</span>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- Main Content -->
|
||||
<main class="flex-1 p-8 overflow-y-auto flex flex-col">
|
||||
<!-- Top Bar -->
|
||||
<header class="flex justify-between items-end mb-8">
|
||||
<div>
|
||||
<h1 class="text-4xl font-bold m-0">Characters</h1>
|
||||
<p class="mt-2 mb-0 text-slate-400">Manage your AI personas</p>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- Loading State -->
|
||||
<div v-if="loading" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
<div v-for="i in 6" :key="i" class="glass-panel rounded-2xl p-6 flex items-center gap-6">
|
||||
<Skeleton shape="circle" size="5rem" />
|
||||
<div class="flex-1">
|
||||
<Skeleton class="mb-2" height="1.5rem" />
|
||||
<Skeleton height="1rem" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Characters Grid -->
|
||||
<div v-else class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
<div v-for="char in characters" :key="char.id"
|
||||
class="glass-panel rounded-2xl p-6 flex items-center gap-6 transition-all duration-300 cursor-pointer border border-white/5 hover:-translate-y-1 hover:bg-white/5 hover:border-white/10"
|
||||
@click="goToDetail(char.id)">
|
||||
<div class="w-20 h-20 rounded-full overflow-hidden flex-shrink-0 border-3 border-white/10">
|
||||
<img :src="API_URL + char.avatar_image || 'https://via.placeholder.com/150'" :alt="char.name"
|
||||
class="w-full h-full object-cover" />
|
||||
</div>
|
||||
<div class="flex-1 overflow-hidden">
|
||||
<h3 class="m-0 mb-2 text-xl font-semibold">{{ char.name }}</h3>
|
||||
<p class="m-0 text-sm text-slate-400 line-clamp-2">
|
||||
{{ char.character_bio }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* Line clamp utility for older browsers */
|
||||
.line-clamp-2 {
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
153
src/views/DashboardView.vue
Normal file
153
src/views/DashboardView.vue
Normal file
@@ -0,0 +1,153 @@
|
||||
<script setup>
|
||||
import { useRouter } from 'vue-router'
|
||||
import Button from 'primevue/button'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
const aiModels = [
|
||||
{
|
||||
id: 'chatgpt',
|
||||
name: 'ChatGPT',
|
||||
provider: 'OpenAI',
|
||||
description: 'Advanced conversational AI for coding, writing, and analysis.',
|
||||
icon: '🤖',
|
||||
color: '#10a37f'
|
||||
},
|
||||
{
|
||||
id: 'gemini',
|
||||
name: 'Gemini',
|
||||
provider: 'Google',
|
||||
description: 'Multimodal AI model with reasoning and coding capabilities.',
|
||||
icon: '✨',
|
||||
color: '#4285f4'
|
||||
},
|
||||
{
|
||||
id: 'nana-banana',
|
||||
name: 'Nana Banana',
|
||||
provider: 'Custom',
|
||||
description: 'Specialized creative assistant for unique tasks.',
|
||||
icon: '🍌',
|
||||
color: '#eab308'
|
||||
},
|
||||
{
|
||||
id: 'kling',
|
||||
name: 'Kling',
|
||||
provider: 'Kling AI',
|
||||
description: 'Next-generation video generation and processing.',
|
||||
icon: '🎥',
|
||||
color: '#ef4444'
|
||||
}
|
||||
]
|
||||
|
||||
const selectModel = (id) => {
|
||||
console.log(`Selected model: ${id}`)
|
||||
router.push(`/workspace/${id}`)
|
||||
}
|
||||
|
||||
const handleLogout = () => {
|
||||
localStorage.removeItem('auth_code')
|
||||
router.push('/login')
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex h-screen bg-slate-900 overflow-hidden text-slate-100">
|
||||
<!-- Sidebar -->
|
||||
<nav class="glass-panel w-20 m-4 flex flex-col items-center py-6 rounded-3xl z-10 border border-white/5">
|
||||
<div class="mb-12">
|
||||
<div
|
||||
class="w-10 h-10 bg-gradient-to-br from-violet-600 to-cyan-500 rounded-xl flex items-center justify-center font-bold text-white text-xl shadow-lg shadow-violet-500/20">
|
||||
AI
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex-1 flex flex-col gap-6 w-full items-center">
|
||||
<div
|
||||
class="w-12 h-12 flex items-center justify-center rounded-xl cursor-pointer transition-all duration-300 bg-white/10 text-slate-50 shadow-inner">
|
||||
<span class="text-2xl">🏠</span>
|
||||
</div>
|
||||
<div class="w-12 h-12 flex items-center justify-center rounded-xl cursor-pointer transition-all duration-300 text-slate-400 hover:bg-white/10 hover:text-slate-50"
|
||||
@click="router.push('/assets')">
|
||||
<span class="text-2xl">📂</span>
|
||||
</div>
|
||||
<div class="w-12 h-12 flex items-center justify-center rounded-xl cursor-pointer transition-all duration-300 text-slate-400 hover:bg-white/10 hover:text-slate-50"
|
||||
@click="router.push('/characters')">
|
||||
<span class="text-2xl">👥</span>
|
||||
</div>
|
||||
|
||||
<div class="w-10 h-px bg-white/10 my-2"></div>
|
||||
|
||||
<div v-for="model in aiModels" :key="model.id"
|
||||
class="w-12 h-12 flex items-center justify-center rounded-xl cursor-pointer transition-all duration-300 text-slate-400 hover:bg-white/10"
|
||||
:style="{ '--model-color': model.color }" @click="selectModel(model.id)" :title="model.name">
|
||||
<span class="text-2xl">{{ model.icon }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-auto flex flex-col items-center gap-4">
|
||||
<div @click="handleLogout"
|
||||
class="w-10 h-10 rounded-xl bg-red-500/10 text-red-400 flex items-center justify-center cursor-pointer hover:bg-red-500/20 transition-all"
|
||||
title="Logout">
|
||||
<i class="pi pi-power-off"></i>
|
||||
</div>
|
||||
<div class="w-10 h-10 rounded-full bg-slate-800 border-2 border-violet-600 flex items-center justify-center font-bold text-slate-50 cursor-pointer hover:scale-105 transition-all"
|
||||
title="Profile">
|
||||
U
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- Main Content -->
|
||||
<main class="flex-1 p-8 overflow-y-auto flex flex-col">
|
||||
<!-- Top Bar -->
|
||||
<header class="flex justify-between items-end mb-12">
|
||||
<div>
|
||||
<h1
|
||||
class="text-5xl font-bold m-0 italic tracking-tight bg-gradient-to-r from-white to-slate-500 bg-clip-text text-transparent">
|
||||
Workspace</h1>
|
||||
<p class="mt-2 mb-0 text-slate-400 font-medium tracking-wide">Welcome back to your controlled
|
||||
environment</p>
|
||||
</div>
|
||||
<div>
|
||||
<Button label="New Project" icon="pi pi-plus" class="btn-secondary" outlined />
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- Models Grid -->
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-2 xl:grid-cols-2 gap-8">
|
||||
<div v-for="model in aiModels" :key="model.id"
|
||||
class="glass-panel p-8 relative overflow-hidden cursor-pointer transition-all duration-300 flex flex-col h-60 rounded-2xl border border-white/5 hover:-translate-y-2 hover:border-white/20"
|
||||
@click="selectModel(model.id)" :style="{ '--accent-color': model.color }">
|
||||
<div class="flex justify-between items-start mb-6">
|
||||
<span class="text-5xl">{{ model.icon }}</span>
|
||||
<span
|
||||
class="text-xs px-3 py-1 bg-white/10 rounded-full text-slate-400 font-bold tracking-wider uppercase">
|
||||
{{ model.provider }}
|
||||
</span>
|
||||
</div>
|
||||
<h3 class="text-2xl font-bold mb-2">{{ model.name }}</h3>
|
||||
<p class="text-slate-400 text-sm leading-relaxed mb-auto">
|
||||
{{ model.description }}
|
||||
</p>
|
||||
<div class="mt-6">
|
||||
<button
|
||||
class="bg-transparent border-none font-bold p-0 cursor-pointer transition-all duration-300 flex items-center gap-2 group"
|
||||
:style="{ color: model.color }">
|
||||
Initialize Workspace <i
|
||||
class="pi pi-arrow-right text-xs transition-transform group-hover:translate-x-1"></i>
|
||||
</button>
|
||||
</div>
|
||||
<!-- Glow Effect -->
|
||||
<div class="absolute top-0 right-0 w-38 h-38 opacity-10 transition-opacity duration-300 pointer-events-none blur-3xl"
|
||||
:style="{ background: `radial-gradient(circle, ${model.color} 0%, transparent 70%)` }"></div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.model-nav-item:hover {
|
||||
box-shadow: 0 0 10px var(--model-color);
|
||||
}
|
||||
</style>
|
||||
98
src/views/LoginView.vue
Normal file
98
src/views/LoginView.vue
Normal file
@@ -0,0 +1,98 @@
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import Button from 'primevue/button'
|
||||
import InputText from 'primevue/inputtext'
|
||||
|
||||
const router = useRouter()
|
||||
const code = ref('')
|
||||
const error = ref('')
|
||||
const loading = ref(false)
|
||||
|
||||
const handleLogin = () => {
|
||||
if (!code.value.trim()) {
|
||||
error.value = 'Please enter your access code'
|
||||
return
|
||||
}
|
||||
|
||||
loading.value = true
|
||||
// Simulate a brief delay for feel
|
||||
if (code.value == 'NE_LEZ_SUDA_SUK') {
|
||||
localStorage.setItem('auth_code', code.value.trim())
|
||||
router.push('/')
|
||||
} else {
|
||||
error.value = 'Pshel nah'
|
||||
}
|
||||
loading.value = false
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="h-screen w-full flex items-center justify-center bg-slate-950 overflow-hidden relative">
|
||||
<!-- Animated Background Blur -->
|
||||
<div class="absolute top-1/4 left-1/4 w-96 h-96 bg-violet-600/20 blur-[120px] rounded-full animate-pulse"></div>
|
||||
<div class="absolute bottom-1/4 right-1/4 w-96 h-96 bg-cyan-600/20 blur-[120px] rounded-full animate-pulse"
|
||||
style="animation-delay: 1s;"></div>
|
||||
|
||||
<div
|
||||
class="glass-panel p-10 rounded-3xl border border-white/10 bg-white/5 backdrop-blur-xl w-full max-w-md z-10 flex flex-col items-center gap-8 shadow-2xl">
|
||||
<div class="text-center">
|
||||
<div
|
||||
class="w-16 h-16 bg-gradient-to-tr from-violet-600 to-cyan-500 rounded-2xl flex items-center justify-center text-3xl mb-6 mx-auto shadow-lg shadow-violet-500/20">
|
||||
✨
|
||||
</div>
|
||||
<h1 class="text-3xl font-bold text-white mb-2 tracking-tight">Access Gate</h1>
|
||||
<p class="text-slate-400 text-sm">Please enter your authorized access code</p>
|
||||
</div>
|
||||
|
||||
<div class="w-full flex flex-col gap-4">
|
||||
<div class="flex flex-col gap-1.5">
|
||||
<label class="text-slate-400 text-[10px] font-bold uppercase tracking-widest ml-1">Secure
|
||||
Code</label>
|
||||
<div class="relative">
|
||||
<InputText v-model="code" type="password" placeholder="••••••••"
|
||||
class="w-full !bg-slate-900/50 !border-white/10 !text-white !p-4 !rounded-xl focus:!border-violet-500 !transition-all"
|
||||
@keyup.enter="handleLogin" />
|
||||
<i class="pi pi-lock absolute right-4 top-1/2 -translate-y-1/2 text-slate-500"></i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="error" class="text-red-400 text-xs ml-1 flex items-center gap-1.5 animate-bounce">
|
||||
<i class="pi pi-exclamation-circle"></i>
|
||||
{{ error }}
|
||||
</div>
|
||||
|
||||
<Button label="Initialize Session" icon="pi pi-bolt" :loading="loading" @click="handleLogin"
|
||||
class="w-full !py-4 !rounded-xl !bg-gradient-to-r !from-violet-600 !to-cyan-500 !border-none !font-bold !text-lg !shadow-xl !shadow-violet-900/20 hover:scale-[1.02] active:scale-[0.98] transition-all" />
|
||||
</div>
|
||||
|
||||
<div class="pt-4 border-t border-white/5 w-full text-center">
|
||||
<p class="text-slate-600 text-[10px] uppercase font-bold tracking-widest">Authorized Personnel Only</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.glass-panel {
|
||||
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
|
||||
0%,
|
||||
100% {
|
||||
transform: scale(1);
|
||||
opacity: 0.2;
|
||||
}
|
||||
|
||||
50% {
|
||||
transform: scale(1.1);
|
||||
opacity: 0.3;
|
||||
}
|
||||
}
|
||||
|
||||
.animate-pulse {
|
||||
animation: pulse 8s cubic-bezier(0.4, 0, 0.6, 1) infinite;
|
||||
}
|
||||
</style>
|
||||
215
src/views/WorkspaceView.vue
Normal file
215
src/views/WorkspaceView.vue
Normal file
@@ -0,0 +1,215 @@
|
||||
<script setup>
|
||||
import { ref, onMounted, computed, nextTick } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { aiService } from '../services/aiService'
|
||||
import Button from 'primevue/button'
|
||||
import Textarea from 'primevue/textarea'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const modelId = route.params.id
|
||||
|
||||
// Mock data for models - in a real app this might come from a store or config
|
||||
const models = {
|
||||
'chatgpt': { name: 'ChatGPT', provider: 'OpenAI', icon: '🤖', color: '#10a37f' },
|
||||
'gemini': { name: 'Gemini', provider: 'Google', icon: '✨', color: '#4285f4' },
|
||||
'nana-banana': { name: 'Nana Banana', provider: 'Custom', icon: '🍌', color: '#eab308' },
|
||||
'kling': { name: 'Kling', provider: 'Kling AI', icon: '🎥', color: '#ef4444' }
|
||||
}
|
||||
|
||||
const currentModel = computed(() => models[modelId] || { name: 'Unknown', color: '#888' })
|
||||
|
||||
const messages = ref([
|
||||
{ id: 1, role: 'assistant', content: `Hello! I'm ${currentModel.value.name}. How can I help you today?`, timestamp: new Date() }
|
||||
])
|
||||
|
||||
const userInput = ref('')
|
||||
const isTyping = ref(false)
|
||||
const chatContainer = ref(null)
|
||||
|
||||
const scrollToBottom = async () => {
|
||||
await nextTick()
|
||||
if (chatContainer.value) {
|
||||
chatContainer.value.scrollTop = chatContainer.value.scrollHeight
|
||||
}
|
||||
}
|
||||
|
||||
const sendMessage = async () => {
|
||||
if (!userInput.value.trim()) return
|
||||
|
||||
// Add user message
|
||||
const userMsg = {
|
||||
id: Date.now(),
|
||||
role: 'user',
|
||||
content: userInput.value,
|
||||
timestamp: new Date()
|
||||
}
|
||||
messages.value.push(userMsg)
|
||||
|
||||
const msgContent = userInput.value
|
||||
userInput.value = ''
|
||||
scrollToBottom()
|
||||
|
||||
// Simulate API call/Typing
|
||||
isTyping.value = true
|
||||
|
||||
try {
|
||||
const response = await aiService.sendMessage(modelId, msgContent, messages.value)
|
||||
messages.value.push(response)
|
||||
} catch (error) {
|
||||
console.error('Failed to get response:', error)
|
||||
messages.value.push({
|
||||
id: Date.now(),
|
||||
role: 'system',
|
||||
content: 'Error: Could not connect to AI service.',
|
||||
timestamp: new Date()
|
||||
})
|
||||
} finally {
|
||||
isTyping.value = false
|
||||
scrollToBottom()
|
||||
}
|
||||
}
|
||||
|
||||
const goBack = () => {
|
||||
router.push('/')
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex h-screen bg-slate-900 text-slate-50 overflow-hidden">
|
||||
<!-- Sidebar -->
|
||||
<aside class="glass-panel w-70 m-4 flex flex-col rounded-2xl overflow-hidden">
|
||||
<div class="p-6 border-b border-white/5 flex items-center gap-4">
|
||||
<button @click="goBack"
|
||||
class="bg-white/10 border-none text-slate-50 w-8 h-8 rounded-full cursor-pointer flex items-center justify-center transition-all duration-300 hover:bg-white/20"
|
||||
title="Back to Dashboard">
|
||||
←
|
||||
</button>
|
||||
<div class="flex items-center gap-3">
|
||||
<div class="w-10 h-10 rounded-xl flex items-center justify-center text-xl"
|
||||
:style="{ background: currentModel.color }">
|
||||
{{ currentModel.icon }}
|
||||
</div>
|
||||
<div>
|
||||
<h2 class="text-base m-0">{{ currentModel.name }}</h2>
|
||||
<span class="text-xs text-green-400 flex items-center gap-1">
|
||||
<span class="w-1.5 h-1.5 bg-green-400 rounded-full"></span>
|
||||
Online
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex-1 p-6 overflow-y-auto">
|
||||
<div class="text-xs uppercase tracking-wider text-slate-400 mb-4">History</div>
|
||||
<div class="space-y-1">
|
||||
<div
|
||||
class="flex items-center gap-3 px-4 py-3 rounded-lg cursor-pointer transition-all duration-300 bg-white/10 text-slate-50">
|
||||
<span>💬</span>
|
||||
<span class="text-sm">New Conversation</span>
|
||||
</div>
|
||||
<div
|
||||
class="flex items-center gap-3 px-4 py-3 rounded-lg cursor-pointer transition-all duration-300 text-slate-400 hover:bg-white/5 hover:text-slate-50">
|
||||
<span>📅</span>
|
||||
<span class="text-sm">Previous Session</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="p-4 border-t border-white/5">
|
||||
<button
|
||||
class="w-full bg-transparent border-none text-slate-400 px-3 py-3 cursor-pointer flex items-center gap-3 transition-all duration-300 hover:text-slate-50">
|
||||
<span>⚙️</span>
|
||||
<span>Settings</span>
|
||||
</button>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<!-- Main Chat Area -->
|
||||
<main class="flex-1 flex flex-col relative mr-4 my-4">
|
||||
<div ref="chatContainer" class="flex-1 overflow-y-auto p-8 flex flex-col gap-6 scroll-smooth">
|
||||
<div v-for="msg in messages" :key="msg.id"
|
||||
:class="['flex gap-4 max-w-4/5', msg.role === 'user' ? 'ml-auto flex-row-reverse' : '']">
|
||||
<div v-if="msg.role === 'assistant'"
|
||||
class="w-9 h-9 rounded-full flex items-center justify-center flex-shrink-0 text-base"
|
||||
:style="{ background: currentModel.color }">
|
||||
{{ currentModel.icon }}
|
||||
</div>
|
||||
<div :class="[
|
||||
'px-6 py-4 rounded-xl relative',
|
||||
msg.role === 'user'
|
||||
? 'bg-violet-600 rounded-tr-sm border-none'
|
||||
: 'glass-panel rounded-tl-sm'
|
||||
]">
|
||||
<p class="m-0 leading-relaxed">{{ msg.content }}</p>
|
||||
<span class="text-xs opacity-50 mt-2 block">
|
||||
{{ msg.timestamp.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="isTyping" class="flex gap-4 max-w-4/5">
|
||||
<div class="w-9 h-9 rounded-full flex items-center justify-center flex-shrink-0 text-base"
|
||||
:style="{ background: currentModel.color }">
|
||||
{{ currentModel.icon }}
|
||||
</div>
|
||||
<div class="glass-panel px-5 py-5 flex gap-1 rounded-tl-sm rounded-xl">
|
||||
<span class="w-1.5 h-1.5 bg-white/50 rounded-full animate-bounce"
|
||||
style="animation-delay: -0.32s;"></span>
|
||||
<span class="w-1.5 h-1.5 bg-white/50 rounded-full animate-bounce"
|
||||
style="animation-delay: -0.16s;"></span>
|
||||
<span class="w-1.5 h-1.5 bg-white/50 rounded-full animate-bounce"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="glass-panel mx-8 mb-8 p-2 rounded-2xl">
|
||||
<div class="flex items-end gap-2 bg-black/20 rounded-xl p-2">
|
||||
<Textarea v-model="userInput" @keydown.enter.prevent="sendMessage" placeholder="Type a message..."
|
||||
rows="1" auto-resize
|
||||
class="flex-1 bg-transparent border-none p-3 text-slate-50 resize-none max-h-30 focus:outline-none focus:shadow-none" />
|
||||
<Button @click="sendMessage" :disabled="!userInput.trim()"
|
||||
class="bg-violet-600 text-white border-none w-10 h-10 rounded-lg flex items-center justify-center cursor-pointer transition-all duration-300 hover:bg-violet-700 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
icon="pi pi-send" text />
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* Custom scrollbar */
|
||||
::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
@apply bg-white/10 rounded;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
@apply bg-white/20;
|
||||
}
|
||||
|
||||
/* Typing animation */
|
||||
@keyframes bounce {
|
||||
|
||||
0%,
|
||||
80%,
|
||||
100% {
|
||||
transform: scale(0);
|
||||
}
|
||||
|
||||
40% {
|
||||
transform: scale(1);
|
||||
}
|
||||
}
|
||||
|
||||
.animate-bounce {
|
||||
animation: bounce 1.4s infinite ease-in-out both;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user