Browse Source

feat(posts): writing-first layout and markdown editor on edit page

Made-with: Cursor
main
npmrun 11 hours ago
parent
commit
63ac857c73
  1. 89
      app/pages/me/posts/[id].vue

89
app/pages/me/posts/[id].vue

@ -76,52 +76,75 @@ const shareUrl = computed(() => {
</script> </script>
<template> <template>
<UContainer class="py-8 max-w-3xl space-y-4"> <UContainer class="py-8 max-w-6xl space-y-6">
<div class="flex justify-between"> <div class="flex flex-wrap items-center justify-between gap-3">
<h1 class="text-2xl font-semibold"> <h1 class="text-2xl font-semibold tracking-tight">
编辑文章 编辑文章
</h1> </h1>
<UButton to="/me/posts" variant="ghost" color="neutral"> <UButton to="/me/posts" variant="ghost" color="neutral">
返回列表 返回列表
</UButton> </UButton>
</div> </div>
<div v-if="loading" class="text-muted"> <div v-if="loading" class="text-muted">
加载中 加载中
</div> </div>
<template v-else> <template v-else>
<UAlert <UForm :state="state" class="space-y-6" @submit.prevent="save">
v-if="shareUrl" <UCard :ui="{ body: 'p-4 sm:p-6' }">
title="仅链接分享" <PostBodyMarkdownEditor v-model="state.bodyMarkdown" />
:description="shareUrl" <UFormField label="正文" name="bodyMarkdown" required class="sr-only" />
/> </UCard>
<UForm :state="state" class="space-y-4" @submit.prevent="save">
<UFormField label="标题" name="title" required> <UCard :ui="{ body: 'p-4 sm:p-6 space-y-4' }">
<UInput v-model="state.title" /> <UCollapsible :unmount-on-hide="false">
</UFormField> <UButton
<UFormField label="slug" name="slug" required> type="button"
<UInput v-model="state.slug" /> color="neutral"
</UFormField> variant="subtle"
<UFormField label="摘要" name="excerpt" required> block
<UInput v-model="state.excerpt" /> class="justify-between font-medium"
</UFormField> label="文章设置"
<UFormField label="正文" name="bodyMarkdown" required> trailing
<UTextarea v-model="state.bodyMarkdown" :rows="16" class="w-full font-mono text-sm" /> trailing-icon="i-lucide-chevron-down"
</UFormField> />
<UFormField label="可见性" name="visibility"> <template #content>
<USelect <div class="pt-4 space-y-4 border-t border-default mt-4">
v-model="state.visibility" <UAlert
:items="[ v-if="shareUrl"
{ label: '私密', value: 'private' }, title="仅链接分享"
{ label: '公开', value: 'public' }, :description="shareUrl"
{ label: '仅链接', value: 'unlisted' }, />
]" <UFormField label="标题" name="title" required>
/> <UInput v-model="state.title" />
</UFormField> </UFormField>
<div class="flex gap-2"> <UFormField label="slug" name="slug" required>
<UInput v-model="state.slug" />
</UFormField>
<UFormField label="摘要" name="excerpt" required>
<UInput v-model="state.excerpt" />
</UFormField>
<UFormField label="可见性" name="visibility">
<USelect
v-model="state.visibility"
:items="[
{ label: '私密', value: 'private' },
{ label: '公开', value: 'public' },
{ label: '仅链接', value: 'unlisted' },
]"
/>
</UFormField>
</div>
</template>
</UCollapsible>
</UCard>
<div class="flex flex-wrap gap-2">
<UButton type="submit" :loading="saving"> <UButton type="submit" :loading="saving">
保存 保存
</UButton> </UButton>
<UButton color="error" variant="soft" @click="remove"> <UButton color="error" variant="soft" type="button" @click="remove">
删除 删除
</UButton> </UButton>
</div> </div>

Loading…
Cancel
Save