保存更多图片元数据并同步更新前端

This commit is contained in:
2026-01-27 13:52:40 +08:00
parent 6dfffe1236
commit 9c2a5d5cd8
11 changed files with 331 additions and 72 deletions

View File

@@ -455,8 +455,7 @@
"200": {
"description": "OK",
"schema": {
"type": "object",
"additionalProperties": true
"$ref": "#/definitions/handlers.ImageMetaResp"
}
}
}
@@ -512,8 +511,7 @@
"200": {
"description": "OK",
"schema": {
"type": "object",
"additionalProperties": true
"$ref": "#/definitions/handlers.ImageMetaResp"
}
}
}
@@ -569,8 +567,7 @@
"200": {
"description": "OK",
"schema": {
"type": "object",
"additionalProperties": true
"$ref": "#/definitions/handlers.ImageMetaResp"
}
}
}
@@ -601,8 +598,7 @@
"schema": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": true
"$ref": "#/definitions/handlers.ImageMetaResp"
}
}
}
@@ -879,6 +875,61 @@
}
}
},
"handlers.ImageMetaResp": {
"type": "object",
"properties": {
"copyright": {
"type": "string"
},
"copyrightlink": {
"type": "string"
},
"date": {
"type": "string"
},
"fullstartdate": {
"type": "string"
},
"hsh": {
"type": "string"
},
"quiz": {
"type": "string"
},
"startdate": {
"type": "string"
},
"title": {
"type": "string"
},
"variants": {
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ImageVariantResp"
}
}
}
},
"handlers.ImageVariantResp": {
"type": "object",
"properties": {
"format": {
"type": "string"
},
"size": {
"type": "integer"
},
"storage_key": {
"type": "string"
},
"url": {
"type": "string"
},
"variant": {
"type": "string"
}
}
},
"handlers.LoginRequest": {
"type": "object",
"required": [

View File

@@ -149,6 +149,11 @@ export interface ImageMeta {
date?: string
title?: string
copyright?: string
copyrightlink?: string // 图片的详细版权链接(指向 Bing 搜索页面)
quiz?: string // 旧字段,保留向后兼容
startdate?: string // 图片的发布开始日期格式YYYYMMDD
fullstartdate?: string // 图片的完整发布时间格式YYYYMMDDHHMM
hsh?: string // 图片的唯一哈希值
url?: string
variant?: string
format?: string

View File

@@ -294,7 +294,7 @@
<div class="bg-white/5 backdrop-blur-sm rounded-xl p-6 border border-white/10">
<p class="text-white/70 mb-4">获取图片的元数据信息(标题、版权、日期等),只返回 JSON 数据不返回图片</p>
<div class="space-y-3">
<div class="space-y-3 mb-6">
<div class="flex items-center gap-3 text-sm">
<code class="text-blue-400 font-mono">/image/today/meta</code>
<span class="text-white/50">-</span>
@@ -316,6 +316,45 @@
<span class="text-white/60">图片列表(支持分页)</span>
</div>
</div>
<!-- 元数据字段说明 -->
<div class="mt-6 pt-6 border-t border-white/10">
<h4 class="text-white/80 font-semibold mb-4">响应字段说明</h4>
<div class="space-y-3 text-sm">
<div class="flex gap-4">
<code class="text-yellow-400 min-w-32">date</code>
<span class="text-white/60">图片日期格式YYYY-MM-DD</span>
</div>
<div class="flex gap-4">
<code class="text-yellow-400 min-w-32">title</code>
<span class="text-white/60">图片标题</span>
</div>
<div class="flex gap-4">
<code class="text-yellow-400 min-w-32">copyright</code>
<span class="text-white/60">版权信息</span>
</div>
<div class="flex gap-4">
<code class="text-yellow-400 min-w-32">copyrightlink</code>
<span class="text-white/60">版权详情链接(指向 Bing 搜索页面)⭐ 新增</span>
</div>
<div class="flex gap-4">
<code class="text-yellow-400 min-w-32">startdate</code>
<span class="text-white/60">发布开始日期格式YYYYMMDD⭐ 新增</span>
</div>
<div class="flex gap-4">
<code class="text-yellow-400 min-w-32">fullstartdate</code>
<span class="text-white/60">完整发布时间格式YYYYMMDDHHMM⭐ 新增</span>
</div>
<div class="flex gap-4">
<code class="text-yellow-400 min-w-32">hsh</code>
<span class="text-white/60">图片唯一哈希值 ⭐ 新增</span>
</div>
<div class="flex gap-4">
<code class="text-yellow-400 min-w-32">quiz</code>
<span class="text-white/60">必应 quiz 链接(已废弃,建议使用 copyrightlink</span>
</div>
</div>
</div>
</div>
</section>

View File

@@ -40,8 +40,8 @@
查看大图
</button>
<button
v-if="todayImage.quiz"
@click="openQuiz(todayImage.quiz)"
v-if="todayImage.copyrightlink"
@click="openCopyrightLink(todayImage.copyrightlink)"
class="px-6 py-3 bg-white/10 backdrop-blur-md text-white rounded-lg font-semibold hover:bg-white/20 transition-all border border-white/30"
>
了解更多
@@ -145,7 +145,7 @@
</router-link>
<a
href="https://github.com"
href="https://github.com/hanxuanyu/BingPaper"
target="_blank"
class="text-white/60 hover:text-white transition-colors text-sm flex items-center gap-2"
>
@@ -200,11 +200,10 @@ const viewImage = (date: string) => {
router.push(`/image/${date}`)
}
// 打开必应 quiz 链接
const openQuiz = (quiz: string) => {
// 拼接完整的必应地址
const bingUrl = `https://www.bing.com${quiz}`
window.open(bingUrl, '_blank')
// 打开版权详情链接
const openCopyrightLink = (link: string) => {
// copyrightlink 是完整的 URL直接打开
window.open(link, '_blank')
}
</script>
@@ -213,6 +212,7 @@ const openQuiz = (quiz: string) => {
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
line-clamp: 2;
overflow: hidden;
}
</style>

View File

@@ -49,10 +49,10 @@
{{ image.copyright }}
</p>
<!-- Quiz 链接 -->
<!-- 版权详情链接 -->
<a
v-if="image.quiz"
:href="getBingQuizUrl(image.quiz)"
v-if="image.copyrightlink"
:href="image.copyrightlink"
target="_blank"
class="inline-flex items-center gap-2 px-4 py-2 bg-white/20 hover:bg-white/30 text-white rounded-lg text-sm font-medium transition-all group"
>
@@ -175,10 +175,7 @@ const getFullImageUrl = () => {
return bingPaperApi.getImageUrlByDate(currentDate.value, 'UHD', 'jpg')
}
// 获取必应 quiz URL
const getBingQuizUrl = (quiz: string) => {
return `https://www.bing.com${quiz}`
}
// copyrightlink 现在是完整的 URL无需额外处理
// 返回首页
const goBack = () => {