- 所有功能历史最多显示100条:relay img-history vis[:150]→[:100]、mcp-usage 流水 LIMIT 300→100 - 前端三处兜底:loadImgHist/ai-gen/poster slice(0,100) - 上轮遗留收口:后台文件管理全量视图/50条分页/100x100缩略图/下载/三类删除、图片历史铁规则 ImgHist 共享层接入7工具 - Home NEW_FEATURES 与 README 同步
172 lines
3.5 KiB
Vue
172 lines
3.5 KiB
Vue
<script setup lang="ts">
|
|
import { onMounted, ref } from 'vue';
|
|
import { loadImgHist, type HistItem } from './img-hist';
|
|
|
|
/**
|
|
* 图片历史右栏(铁规则统一实现):
|
|
* 50×50 缩略图右侧竖排、点击查看大图、按本人隔离(登录=账号/未登录=机器码)。
|
|
* 父级把本组件放在布局最右侧即可;生成成功后调用父组件暴露的 reload()。
|
|
*/
|
|
const props = withDefaults(defineProps<{ kind: string; label?: string }>(), {
|
|
label: '历史',
|
|
});
|
|
|
|
const items = ref<HistItem[]>([]);
|
|
const viewUrl = ref('');
|
|
|
|
async function reload() {
|
|
items.value = await loadImgHist(props.kind);
|
|
}
|
|
|
|
defineExpose({ reload });
|
|
onMounted(reload);
|
|
</script>
|
|
|
|
<template>
|
|
<aside class="ih">
|
|
<div class="ih-t">
|
|
{{ label }}<em v-if="items.length">{{ items.length }}</em>
|
|
</div>
|
|
<div v-if="items.length" class="ih-list">
|
|
<img
|
|
v-for="it in items"
|
|
:key="it.id"
|
|
:src="it.img_url"
|
|
:title="it.prompt || '点击查看大图'"
|
|
class="ih-thumb"
|
|
@click="viewUrl = it.img_url"
|
|
>
|
|
</div>
|
|
<div v-else class="ih-empty">
|
|
还没有<br>生成记录
|
|
</div>
|
|
</aside>
|
|
|
|
<div v-if="viewUrl" class="ih-view" @click="viewUrl = ''">
|
|
<img :src="viewUrl" alt="历史图片">
|
|
<span class="ih-view-tip">点击任意处关闭</span>
|
|
</div>
|
|
</template>
|
|
|
|
<style scoped lang="less">
|
|
.ih {
|
|
flex: 0 0 76px;
|
|
width: 76px;
|
|
border: 1px solid rgba(128, 128, 128, 0.25);
|
|
border-radius: 12px;
|
|
background: rgba(128, 128, 128, 0.04);
|
|
display: flex;
|
|
flex-direction: column;
|
|
overflow: hidden;
|
|
align-self: flex-start;
|
|
max-height: calc(100vh - 230px);
|
|
|
|
.ih-t {
|
|
font-size: 11.5px;
|
|
font-weight: 700;
|
|
text-align: center;
|
|
padding: 9px 4px 7px;
|
|
border-bottom: 1px solid rgba(128, 128, 128, 0.18);
|
|
opacity: 0.75;
|
|
flex-shrink: 0;
|
|
|
|
em {
|
|
font-style: normal;
|
|
color: #0ea5a0;
|
|
margin-left: 4px;
|
|
}
|
|
}
|
|
|
|
.ih-list {
|
|
flex: 1;
|
|
overflow-y: auto;
|
|
overflow-x: hidden;
|
|
padding: 9px 13px 12px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
gap: 8px;
|
|
}
|
|
|
|
.ih-thumb {
|
|
width: 50px;
|
|
height: 50px;
|
|
object-fit: cover;
|
|
border-radius: 7px;
|
|
border: 2px solid transparent;
|
|
cursor: zoom-in;
|
|
background: #fff;
|
|
box-shadow: 0 1px 5px rgba(0, 0, 0, 0.1);
|
|
transition: all 0.15s;
|
|
display: block;
|
|
flex-shrink: 0;
|
|
|
|
&:hover {
|
|
border-color: #0ea5a0;
|
|
transform: translateY(-1px);
|
|
}
|
|
}
|
|
|
|
.ih-empty {
|
|
font-size: 11px;
|
|
text-align: center;
|
|
opacity: 0.45;
|
|
padding: 16px 4px;
|
|
line-height: 1.6;
|
|
}
|
|
}
|
|
|
|
.ih-view {
|
|
position: fixed;
|
|
inset: 0;
|
|
z-index: 9999;
|
|
background: rgba(0, 0, 0, 0.86);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
cursor: zoom-out;
|
|
|
|
img {
|
|
max-width: 92vw;
|
|
max-height: 88vh;
|
|
object-fit: contain;
|
|
border-radius: 8px;
|
|
box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
|
|
}
|
|
|
|
.ih-view-tip {
|
|
position: absolute;
|
|
bottom: 26px;
|
|
left: 0;
|
|
right: 0;
|
|
text-align: center;
|
|
color: rgba(255, 255, 255, 0.65);
|
|
font-size: 12px;
|
|
}
|
|
}
|
|
|
|
@media (max-width: 900px) {
|
|
.ih {
|
|
flex: none;
|
|
width: 100%;
|
|
flex-direction: row;
|
|
align-items: center;
|
|
max-height: none;
|
|
|
|
.ih-t {
|
|
border-bottom: none;
|
|
border-right: 1px solid rgba(128, 128, 128, 0.18);
|
|
padding: 8px 10px;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.ih-list {
|
|
flex-direction: row;
|
|
overflow-x: auto;
|
|
overflow-y: hidden;
|
|
padding: 8px;
|
|
}
|
|
}
|
|
}
|
|
</style>
|