fix(display): 隐藏调试标识 + 积分榜显示单位 logo
- TopBar 的「实例 N · 屏 N」只在该窗口确实处于调试态时渲染:非 windowed(kiosk)不显示, 窗口化下按 F11 全屏也不显示(同时监听 fullscreenchange,与 App.vue 口径一致) - 积分榜与团体奖牌榜的队名左侧渲染单位 logo:数据本来就下发了(dto/standings.go 的 LogoPath),只是页面没画。图标 1em 随行字号浮动、object-fit:contain,行高不会被撑开; 无 logo 不占位,加载失败 visibility:hidden 保留占位避免队名跳动,@load 会复原 - resolveAssetUrl(路径归一化)从 admin 目录收敛到 web/src/shared/asset.ts, 管理端与大屏共用一份;原 image-path 测试随之迁到 shared/tests 未做(需服务端 DTO 支持,本次未授权):分项成绩页与个人榜的单位列同样没有 logoPath 字段, 所以那两个页面仍无法显示单位 logo。 自检:vue-tsc + pnpm build 通过;前端 node --test 69/69。
This commit is contained in:
1 parent
407abec3b0
commit
6f47849e1e
7 files changed
+79
-5
No files matched your search
@@ -3,8 +3,8 @@ import { computed, onBeforeUnmount, ref, watch } from 'vue'
|
||||
import MxIcon from '../MxIcon.vue'
|
||||
import { adminApi } from '../../api/client'
|
||||
import { useToastStore } from '../../stores/toast'
|
||||
import { resolveAssetUrl } from '@/shared'
|
||||
import { describeError } from './systemApi'
|
||||
import { resolveAssetUrl } from './imagePath'
|
||||
|
||||
/**
|
||||
* 图片字段:文本框(可手填 / 粘贴路径)+ 上传按钮 + 缩略图预览。
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
/**
|
||||
* 图片路径解析(供 <img src> 使用)。
|
||||
*
|
||||
* 上传接口返回的路径本就带 `/uploads/` 前缀,这里主要兼容手填的历史值:
|
||||
* 绝对地址(http/https)、内联数据(data:)与已带前导斜杠的路径原样使用,
|
||||
* 其余相对路径补一个 `/`,否则浏览器会相对当前路由解析(如 `/admin/logos/x.png`)。
|
||||
*/
|
||||
export function resolveAssetUrl(value: string | null | undefined): string {
|
||||
const path = (value ?? '').trim()
|
||||
if (path === '') return ''
|
||||
if (path.startsWith('/') || path.startsWith('data:') || /^https?:\/\//i.test(path)) return path
|
||||
return `/${path}`
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
import { test } from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { resolveAssetUrl } from '../components/system/imagePath'
|
||||
|
||||
// 服务端上传接口返回的路径已带 /uploads/ 前缀,这里主要保证手填的历史值也能加载。
|
||||
test('resolveAssetUrl 原样保留已带前缀的路径与绝对地址', () => {
|
||||
assert.equal(resolveAssetUrl('/uploads/a.png'), '/uploads/a.png')
|
||||
assert.equal(resolveAssetUrl('https://cdn.example.com/a.png'), 'https://cdn.example.com/a.png')
|
||||
assert.equal(resolveAssetUrl('HTTP://cdn.example.com/a.png'), 'HTTP://cdn.example.com/a.png')
|
||||
assert.equal(resolveAssetUrl('data:image/png;base64,AAAA'), 'data:image/png;base64,AAAA')
|
||||
})
|
||||
|
||||
test('resolveAssetUrl 给相对路径补上前导斜杠', () => {
|
||||
assert.equal(resolveAssetUrl('uploads/a.png'), '/uploads/a.png')
|
||||
assert.equal(resolveAssetUrl('logos/team1.png'), '/logos/team1.png')
|
||||
assert.equal(resolveAssetUrl(' logos/team1.png '), '/logos/team1.png')
|
||||
})
|
||||
|
||||
// 空值必须返回空串:调用方据此判断「不渲染缩略图」,而不是给出一个坏掉的 <img src>。
|
||||
test('resolveAssetUrl 对空值返回空串', () => {
|
||||
assert.equal(resolveAssetUrl(null), '')
|
||||
assert.equal(resolveAssetUrl(undefined), '')
|
||||
assert.equal(resolveAssetUrl(' '), '')
|
||||
})
|
||||
Reference in new issue
Block a user