Files
ONE/frontend/src/components/RightRail.vue
T
Sakurasan bc1b0ccce3 交互:表情面板 + 短文快发盒 + 双 UI 手机导航重做 + 社交链接与统计脚本接入
评论表情
- 发布 / 回复 / 编辑三处输入框挂上表情面板(EmojiPicker + emoji.js):
  「表情 / 颜文字」两个 tab,光标处插入(insertAtCursor,未聚焦追加到
  末尾),面板自己管点外 / Esc 收起
- 操作钮 ✎ ✕ ↩ 圆图标改文字钮(回复 / 编辑 / 删除),删除悬停给红,
  补 focus-visible;编辑态去掉「正在改定此评:」交给 placeholder

双 UI 手机导航(参考 innei.in 的底部胶囊 + 上拉菜单)
- 余白:顶栏手机端整条退场,底部悬浮 dock(品牌 + NavBurger 汉堡),
  点开上拉毛玻璃菜单:mono 序号 01-05 + 中文大字 + 英文小字,当前项
  强调色 + 左缘短杠,逐项错峰 45ms 入场;dock 在菜单之下原位变 ✕
- classic:顶栏 brand 居中(三列网格)+ NavBurger + 下拉纸片;下滑隐藏
  上滑唤回——上滑要累计 40px 才算数(页面高度稳定时浏览器会回弹几十
  像素,那种「假上滑」不拉回顶栏);首页 .sticky-head 用 var(--topbar-h)
  跟随顶栏一起滑
- NavBurger 两套 UI 共用;经典手机 FAB 避开右下角主题浮钮

sticky 失效修复
- body overflow-x:hidden 把 body 变成滚动容器,页内所有 position:sticky
  全部失明(首页筛选条吸顶从来没生效过)→ 改 overflow-x:clip,
  只裁剪不建滚动容器
- 余白手机端 .article-layout 裸 1fr 的自动最小尺寸是 min-content,
  长 token 把整列顶到 592px 横向溢出 → minmax(0,1fr) + overflow-wrap

短文快发盒(QuickShort,Twitter 式)
- 时间线顶部内联发布盒:头像 + 输入框 + 发布(Ctrl/⌘+Enter),手机收进
  右下角 FAB + 上拉 sheet;只有管理员会话在场才渲染(/api/admin/me
  探测),发布走真实 createPost(kind:short)——标题 / slug / 阅读时长
  后端自动生成。读者社交登录是阶段二产物,后端就绪前访客无法登录,
  所以天然只有站主可见;要放开给读者发,换探测和发布接口即可
- 经典 FAB 避开右下角主题浮钮(bottom 72),余白贴安全区(bottom 20)

社交链接 + 统计脚本接入
- Settings 的 social_links 前台两处渲染:经典左栏「常读标签」区域改为
  「社交账号」图标行(url 域名推导图标:GitHub / Telegram / X / 邮箱
  信封,认不出显示名称文字),右栏卡片下方 Twitter 式页脚小字区三排
  (导航行 / 社交图标行 / 项目源码 + 版权行)——项目源码是固定入口
  (本站 git remote),与版权同为固定元素,后台配置挤不掉
- Settings 加 custom_js:后台贴完整 <script> 片段(GA / Plausible /
  Umami),DOMParser 解析后逐个重建 script 节点插进 head(innerHTML
  塞的 script 不会执行);公开页每页注入一次,/admin 不注入;
  站主自己的代码不做清洗(洗 JS 只会把统计脚本洗坏)
- 订阅卡删掉:RSS 入口在页脚小字里,一张卡只为一个链接不值得

杂项
- vite dev 加 --host:手机连局域网直接评审
- 评论 mock 的状态浮层窄屏上移,给底部 dock 让位
- 经典页脚在 12px 页边距下的排版对齐

验证
- 后端 go test 全绿;前端构建通过
- 浏览器逐状态过目:双 UI × 亮暗 × 桌面/手机;表情插入 / 短文发布真实
  入库(测试内容已删)/ dock 与 sheet 开合 / FAB 与主题浮钮不重叠 /
  顶栏隐藏与筛选条跟随同步
2026-09-27 03:35:28 +08:00

272 lines
6.8 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup>
import { computed, onMounted, ref } from 'vue'
import { publicApi } from '../api'
import { site } from '../site'
import { socialIcon } from '../socialIcons'
import { relativeDate } from '../utils'
// vivid 是单栏布局,右栏整体不渲染(省掉 latest/tags 两次请求)。
const isVivid = computed(() => site.ui_id === 'vivid')
// 项目源码仓库是固定入口(本站 git remote),不来自后台配置 —— 和版权一样
// 固定渲染在自己的那排;后台填的社交账号单独一排,URL 撞车的去重。
const PROJECT_REPO = 'https://git.gopher.ink/mirrors2/ONE'
// 社交 / 源码链接(后台「高级 → 社交链接」填写);url 必填,空的丢弃。
// 有图标的(按域名推导)渲染成单色图标,认不出的显示名称文字。
const social = computed(() => (site.social_links || []).filter((s) => s && s.url && s.url !== PROJECT_REPO))
const links = [
{ to: '/', label: '首页' },
{ to: '/archive', label: '归档' },
{ to: '/tags', label: '标签' },
{ to: '/projects', label: '作品' },
{ to: '/about', label: '关于' }
]
const latest = ref([])
const tags = ref([])
onMounted(async () => {
if (isVivid.value) return
try {
const [posts, tagData] = await Promise.all([publicApi.latest(), publicApi.tags()])
latest.value = posts.items || []
tags.value = (tagData.tags || []).slice(0, 12)
} catch (e) {
latest.value = []
tags.value = []
}
})
</script>
<template>
<aside v-if="!isVivid" class="rail-right">
<section class="card">
<p class="eyebrow">关于这里</p>
<p class="bio">{{ site.author_bio || site.site_desc }}</p>
<RouterLink to="/about" class="more">了解更多 →</RouterLink>
</section>
<section v-if="latest.length" class="card">
<p class="eyebrow">最近更新</p>
<ul class="list">
<li v-for="p in latest" :key="p.id">
<RouterLink :to="`/post/${p.slug}`" class="row">
<span class="title">
{{ p.kind === 'short' ? '短文' : p.title || '无题' }}
<span v-if="p.kind === 'short'" class="badge">短</span>
</span>
<span class="date">{{ relativeDate(p.published_at) }}</span>
</RouterLink>
</li>
</ul>
</section>
<section v-if="tags.length" class="card">
<p class="eyebrow">标签</p>
<div class="tags">
<RouterLink v-for="t in tags" :key="t.id" :to="`/tag/${t.slug}`" class="tag-chip">
{{ t.name }}<span class="count"> {{ t.count }}</span>
</RouterLink>
</div>
</section>
<!-- 订阅卡删掉了:RSS 入口在下方页脚小字里,一张卡片只为一个链接不值得 -->
<!-- 页脚信息(Twitter 式:右栏卡片下方的小字区)。通栏 ClassicFoot
已删:右栏在窄屏会堆到信息流下方,卡片之后正好接页脚小字,
所有宽度都不缺位。 -->
<footer class="rail-foot">
<nav class="foot-links" aria-label="页脚导航">
<template v-for="(l, i) in links" :key="l.to">
<span v-if="i" class="dot">·</span>
<RouterLink :to="l.to">{{ l.label }}</RouterLink>
</template>
<span class="dot">·</span>
<a href="/rss.xml">RSS</a>
</nav>
<!-- 后台填的社交账号:单独一排 -->
<div v-if="social.length" class="social-row">
<a
v-for="s in social"
:key="s.label + s.url"
class="social-icon"
:href="s.url"
:title="s.label"
:aria-label="s.label"
:target="s.url.startsWith('http') ? '_blank' : undefined"
:rel="s.url.startsWith('http') ? 'noopener' : undefined"
>
<svg v-if="socialIcon(s.url)" viewBox="0 0 24 24" aria-hidden="true"><path :d="socialIcon(s.url)" /></svg>
<span v-else>{{ s.label }}</span>
</a>
</div>
<!-- 项目信息:固定的源码图标 + 版权,永远在 -->
<div class="foot-meta">
<a class="social-icon" :href="PROJECT_REPO" title="项目源码" aria-label="项目源码" target="_blank" rel="noopener">
<svg viewBox="0 0 24 24" aria-hidden="true"><path :d="socialIcon(PROJECT_REPO)" /></svg>
</a>
<span class="copyright">
{{ site.footer_note }}<template v-if="site.icp"> · {{ site.icp }}</template>
</span>
</div>
</footer>
</aside>
</template>
<style scoped>
.rail-right {
position: sticky;
top: 0;
align-self: start;
padding: 28px 0 40px;
display: flex;
flex-direction: column;
gap: 16px;
}
.card {
border: 1px solid var(--line);
border-radius: 4px;
background: var(--card);
padding: 16px 18px;
}
.bio {
margin: 8px 0 10px;
font-size: 13.5px;
line-height: 1.85;
color: var(--ink-soft);
}
.more {
font-size: 13px;
color: var(--accent);
}
.list {
list-style: none;
margin: 8px 0 0;
padding: 0;
}
.row {
display: block;
padding: 7px 0;
border-bottom: 1px dashed var(--line-soft);
}
.list li:last-child .row {
border-bottom: 0;
}
.title {
display: block;
font-size: 14px;
line-height: 1.7;
}
.badge {
display: inline-block;
margin-left: 5px;
padding: 0 5px;
border: 1px solid var(--line);
border-radius: 2px;
font-size: 11px;
color: var(--muted);
vertical-align: 1px;
}
.date {
font-size: 12px;
color: var(--faint);
}
.tags {
display: flex;
flex-wrap: wrap;
gap: 6px;
margin-top: 10px;
}
.count {
color: var(--faint);
font-size: 11px;
}
/* 页脚小字区:无卡片边框,Twitter 式侧栏页脚。classic 的页脚信息只在这里
出现(通栏 ClassicFoot 已删):右栏在窄屏会堆到信息流下方,卡片之后
正好接页脚小字,所有宽度都不缺位。 */
.rail-foot {
padding: 4px 6px 0;
font-size: 12px;
line-height: 1.9;
color: var(--faint);
}
.foot-links a {
color: var(--faint);
transition: color 0.15s;
}
.foot-links a:hover {
color: var(--accent);
}
.dot {
margin: 0 4px;
opacity: 0.6;
}
/* 图标 + 版权同排:源码等入口是单色小图标,hover 才亮成强调色 */
.social-row {
display: flex;
flex-wrap: wrap;
gap: 4px;
margin-top: 2px;
}
.foot-meta {
display: flex;
align-items: center;
gap: 8px;
/* 项目信息行和上面的社交账号排拉开一截:它们是两类信息 */
margin-top: 16px;
}
.social-icon {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 22px;
height: 22px;
padding: 0 3px;
border-radius: 6px;
color: var(--faint);
font-size: 12px;
transition: color 0.15s;
}
.social-icon:hover {
color: var(--accent);
}
.social-icon svg {
width: 16px;
height: 16px;
fill: currentColor;
}
.copyright {
color: var(--faint);
}
/* 窄屏:底部留白加高,右下角浮动主题钮压不到页脚小字 */
@media (max-width: 780px) {
.rail-right {
padding-bottom: 96px;
}
}
</style>