feat(admin): 跳转规范化、侧栏子分类与归类管理
- 条目保存时规范化 href(裸域名补 https,拒绝 javascript:/data: 等协议),详情按钮按解析结果置灰/跳转
- settings.sidebar 增加 hidden_groups / shown_groups / group_order,侧栏 Tab 支持分组显隐与排序
- 新增 PATCH /api/categories/{id} 与「归类」Tab:编辑类型/标题/图标/色条/条数;改类型自动迁移条目与首页卡片
- 测试 54 passed(href 规范化 3 例、分类更新 3 例)
This commit is contained in:
@@ -13,6 +13,7 @@ import {
|
||||
} from '@stash/ui'
|
||||
import { useEffect, useState } from 'react'
|
||||
import type { ItemDetailModel } from '../../data/detail'
|
||||
import { resolveHref } from '../../data/detail'
|
||||
import type { RelatedItem } from '../../data/types'
|
||||
import { RelatedList } from './RelatedList'
|
||||
|
||||
@@ -49,6 +50,8 @@ export function ItemDetailView({
|
||||
}: ItemDetailViewProps) {
|
||||
const [views, setViews] = useState(model.views)
|
||||
const [likes, setLikes] = useState(model.likes)
|
||||
// 历史数据可能是裸域名或占位符 #;统一解析成可跳转地址后再渲染
|
||||
const jumpHref = resolveHref(model.href)
|
||||
const [liked, setLiked] = useState(() => {
|
||||
try {
|
||||
return window.localStorage.getItem(`stash-liked:${itemKey}`) === '1'
|
||||
@@ -202,14 +205,14 @@ export function ItemDetailView({
|
||||
/>
|
||||
</Space>
|
||||
|
||||
{/* 占位数据没有真实地址时,按钮置灰而不是打开空白页 */}
|
||||
{model.href === '#' ? (
|
||||
<button type="button" className="item-jump" disabled title="暂无跳转地址">
|
||||
{/* 没有真实地址(空 / # / 不安全协议)时置灰,避免打开错误页面 */}
|
||||
{jumpHref === undefined ? (
|
||||
<button type="button" className="item-jump" disabled title="暂无跳转地址,可在编辑里添加">
|
||||
跳转到
|
||||
<Icon name="a-external_link_line1" />
|
||||
</button>
|
||||
) : (
|
||||
<a className="item-jump" href={model.href} target="_blank" rel="noreferrer">
|
||||
<a className="item-jump" href={jumpHref} target="_blank" rel="noreferrer">
|
||||
跳转到
|
||||
<Icon name="a-external_link_line1" />
|
||||
</a>
|
||||
|
||||
Reference in New Issue
Block a user