|
|
@ -21,8 +21,6 @@ const state = reactive({ |
|
|
const loading = ref(true) |
|
|
const loading = ref(true) |
|
|
const saving = ref(false) |
|
|
const saving = ref(false) |
|
|
const postsNav = ref<PostRow[]>([]) |
|
|
const postsNav = ref<PostRow[]>([]) |
|
|
const jumpIdRaw = ref('') |
|
|
|
|
|
const toast = useToast() |
|
|
|
|
|
|
|
|
|
|
|
const currentNumericId = computed(() => Number.parseInt(id.value, 10)) |
|
|
const currentNumericId = computed(() => Number.parseInt(id.value, 10)) |
|
|
|
|
|
|
|
|
@ -52,6 +50,18 @@ const publicPostHref = computed(() => { |
|
|
return `/@${ps}/posts/${encodeURIComponent(state.slug)}` |
|
|
return `/@${ps}/posts/${encodeURIComponent(state.slug)}` |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
/** 公开文跳站点详情,否则进编辑页 */ |
|
|
|
|
|
function navTargetHref(p: PostRow | null) { |
|
|
|
|
|
if (!p) { |
|
|
|
|
|
return '' |
|
|
|
|
|
} |
|
|
|
|
|
const ps = user.value?.publicSlug |
|
|
|
|
|
if (p.visibility === 'public' && ps) { |
|
|
|
|
|
return `/@${ps}/posts/${encodeURIComponent(p.slug)}` |
|
|
|
|
|
} |
|
|
|
|
|
return `/me/posts/${p.id}` |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
async function load() { |
|
|
async function load() { |
|
|
loading.value = true |
|
|
loading.value = true |
|
|
try { |
|
|
try { |
|
|
@ -79,18 +89,6 @@ async function loadPostNav() { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function goJumpId() { |
|
|
|
|
|
const n = Number.parseInt(jumpIdRaw.value.trim(), 10) |
|
|
|
|
|
if (!Number.isFinite(n) || n < 1) { |
|
|
|
|
|
toast.add({ title: '请输入有效的文章 ID', color: 'error' }) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
if (n === currentNumericId.value) { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
void navigateTo(`/me/posts/${n}`) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => { |
|
|
onMounted(() => { |
|
|
void refreshAuth(true) |
|
|
void refreshAuth(true) |
|
|
void loadPostNav() |
|
|
void loadPostNav() |
|
|
@ -147,13 +145,11 @@ const shareUrl = computed(() => { |
|
|
<UButton |
|
|
<UButton |
|
|
v-if="publicPostHref" |
|
|
v-if="publicPostHref" |
|
|
:to="publicPostHref" |
|
|
:to="publicPostHref" |
|
|
target="_blank" |
|
|
|
|
|
rel="noopener noreferrer" |
|
|
|
|
|
variant="soft" |
|
|
variant="soft" |
|
|
color="neutral" |
|
|
color="neutral" |
|
|
size="sm" |
|
|
size="sm" |
|
|
> |
|
|
> |
|
|
公开页 |
|
|
详情 |
|
|
</UButton> |
|
|
</UButton> |
|
|
<UButton to="/me/posts" variant="ghost" color="neutral" size="sm"> |
|
|
<UButton to="/me/posts" variant="ghost" color="neutral" size="sm"> |
|
|
返回列表 |
|
|
返回列表 |
|
|
@ -165,7 +161,7 @@ const shareUrl = computed(() => { |
|
|
<div class="flex flex-wrap items-center gap-2"> |
|
|
<div class="flex flex-wrap items-center gap-2"> |
|
|
<UButton |
|
|
<UButton |
|
|
v-if="newerPost" |
|
|
v-if="newerPost" |
|
|
:to="`/me/posts/${newerPost.id}`" |
|
|
:to="navTargetHref(newerPost)" |
|
|
variant="soft" |
|
|
variant="soft" |
|
|
color="neutral" |
|
|
color="neutral" |
|
|
size="sm" |
|
|
size="sm" |
|
|
@ -185,7 +181,7 @@ const shareUrl = computed(() => { |
|
|
</UButton> |
|
|
</UButton> |
|
|
<UButton |
|
|
<UButton |
|
|
v-if="olderPost" |
|
|
v-if="olderPost" |
|
|
:to="`/me/posts/${olderPost.id}`" |
|
|
:to="navTargetHref(olderPost)" |
|
|
variant="soft" |
|
|
variant="soft" |
|
|
color="neutral" |
|
|
color="neutral" |
|
|
size="sm" |
|
|
size="sm" |
|
|
@ -203,23 +199,9 @@ const shareUrl = computed(() => { |
|
|
> |
|
|
> |
|
|
较旧 |
|
|
较旧 |
|
|
</UButton> |
|
|
</UButton> |
|
|
<div class="flex flex-1 flex-wrap items-center gap-2 min-w-[12rem] justify-end"> |
|
|
|
|
|
<UInput |
|
|
|
|
|
v-model="jumpIdRaw" |
|
|
|
|
|
type="text" |
|
|
|
|
|
size="sm" |
|
|
|
|
|
placeholder="文章 ID" |
|
|
|
|
|
class="w-28" |
|
|
|
|
|
autocomplete="off" |
|
|
|
|
|
@keydown.enter.prevent="goJumpId" |
|
|
|
|
|
/> |
|
|
|
|
|
<UButton size="sm" color="neutral" @click="goJumpId"> |
|
|
|
|
|
跳转 |
|
|
|
|
|
</UButton> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
</div> |
|
|
<p v-if="newerPost || olderPost" class="text-xs text-muted mt-2"> |
|
|
<p v-if="newerPost || olderPost" class="text-xs text-muted mt-2"> |
|
|
顺序与列表一致:最新在上(<code class="text-xs">/me/posts</code>)。 |
|
|
顺序与列表一致(最新在上)。公开文章打开站点详情,其余进入对应编辑页。 |
|
|
</p> |
|
|
</p> |
|
|
</UCard> |
|
|
</UCard> |
|
|
|
|
|
|
|
|
|