🐛 Fix bugs

This commit is contained in:
2025-11-29 23:43:00 +08:00
parent 72ca5e9b77
commit 2c395e36d3
6 changed files with 49 additions and 44 deletions

View File

@@ -29,7 +29,7 @@
<audio
v-else-if="itemType == 'audio'"
class="w-full h-auto"
class="w-full"
:src="remoteSource"
controls
/>

View File

@@ -31,8 +31,7 @@
</n-carousel>
</div>
<!-- Mixed content: vertical scrollable -->
<div v-else class="space-y-4 max-h-96 overflow-y-auto">
<div v-else class="space-y-4 flex flex-col">
<attachment-item
v-for="attachment in attachments"
:key="attachment.id"

View File

@@ -1,5 +1,5 @@
<template>
<div class="flex flex-col gap-2">
<div class="flex flex-col gap-3">
<pub-select v-model:value="publisher" />
<n-input
v-model:value="content"
@@ -8,11 +8,11 @@
@keydown.meta.enter.exact="submit"
@keydown.ctrl.enter.exact="submit"
/>
<div class="flex justify-between">
<div class="flex justify-end">
<n-button type="primary" :loading="submitting" @click="submit">
Post
<template #icon>
<span class="mdi mdi-send"></span>
<n-icon :component="SendIcon" />
</template>
</n-button>
</div>
@@ -20,8 +20,9 @@
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { useSolarNetwork } from '~/composables/useSolarNetwork'
import { SendIcon } from "lucide-vue-next"
import { ref } from "vue"
import { useSolarNetwork } from "~/composables/useSolarNetwork"
// Interface for uploaded files in the editor
interface UploadedFile {
@@ -30,10 +31,10 @@ interface UploadedFile {
type: string
}
const emits = defineEmits(['posted'])
const emits = defineEmits(["posted"])
const publisher = ref<string | undefined>()
const content = ref('')
const content = ref("")
const fileList = ref<UploadedFile[]>([])
@@ -43,21 +44,21 @@ async function submit() {
submitting.value = true
const api = useSolarNetwork()
await api(`/sphere/posts?pub=${publisher.value}`, {
method: 'POST',
method: "POST",
headers: {
'content-type': 'application/json',
"content-type": "application/json"
},
body: JSON.stringify({
content: content.value,
attachments: fileList.value
.filter((e) => e.url != null)
.map((e) => e.url!.split('/').reverse()[0]),
}),
.map((e) => e.url!.split("/").reverse()[0])
})
})
submitting.value = false
content.value = ''
content.value = ""
fileList.value = []
emits('posted')
emits("posted")
}
</script>

View File

@@ -11,55 +11,61 @@
</template>
<script setup lang="ts">
import { usePubStore } from '~/stores/pub'
import { watch, h } from 'vue'
import type { SelectRenderLabel, SelectRenderTag } from 'naive-ui'
import { usePubStore } from "~/stores/pub"
import { watch, h } from "vue"
import type { SelectRenderLabel, SelectRenderTag } from "naive-ui"
import type { SnPublisher } from "~/types/api"
const pubStore = usePubStore()
const apiBase = useSolarNetworkUrl()
const props = defineProps<{ value: string | undefined }>()
const emits = defineEmits(['update:value'])
const emits = defineEmits(["update:value"])
const renderLabel: SelectRenderLabel = (option) => {
return h('div', { class: 'flex items-center' }, [
return h("div", { class: "flex items-center" }, [
h(NAvatar, {
src: option.picture ? `${apiBase.value}/drive/files/${option.picture.id}` : undefined,
size: 'small',
class: 'mr-2'
src: (option.value as SnPublisher)!.picture?.id
? `${apiBase}/drive/files/${(option.value as SnPublisher)!.picture!.id}`
: undefined,
size: "small",
class: "mr-2"
}),
h('div', null, [
h('div', null, option.nick as string),
h('div', { class: 'text-xs text-gray-500' }, `@${option.name as string}`)
h("div", null, [
h("div", null, option.nick as string),
h("div", { class: "text-xs opacity-80" }, `@${option.name as string}`)
])
])
}
const renderTag: SelectRenderTag = ({ option }) => {
return h(
'div',
"div",
{
class: 'flex items-center'
class: "flex items-center"
},
[
h(NAvatar, {
src: option.picture ? `${apiBase.value}/drive/files/${option.picture.id}` : undefined,
size: 'small',
class: 'mr-2'
src: (option.value as SnPublisher)!.picture?.id
? `${apiBase}/drive/files/${
(option.value as SnPublisher)!.picture!.id
}`
: undefined,
size: "small",
class: "mr-2"
}),
option.nick as string
]
)
}
watch(
pubStore,
(value) => {
if (!props.value && value.publishers) {
emits('update:value', pubStore.publishers[0]?.name)
emits("update:value", pubStore.publishers[0]?.name)
}
},
{ deep: true, immediate: true },
{ deep: true, immediate: true }
)
</script>