1135 lines
38 KiB
Vue
1135 lines
38 KiB
Vue
<script setup lang="ts">
|
||
import { getMachineId, licenseHeaders } from '@/tools/license/license';
|
||
|
||
const models = ref<{ id: string; i2i: boolean; custom?: boolean }[]>([]);
|
||
const model = ref(''); // 打开页面默认选中列表第一个模型
|
||
const prompt = ref('');
|
||
const loading = ref(false);
|
||
const error = ref('');
|
||
const resultUrl = ref('');
|
||
const promptEn = ref(''); // 中文提示词自动转英文后的实际发送内容
|
||
|
||
// ---------- 自定义提供商(KEY 只存本机浏览器 localStorage) ----------
|
||
const PROVIDER_KEY = 'it-tools-ai-provider';
|
||
const provider = ref<{ base_url: string; api_key: string; models: string[] }>({ base_url: '', api_key: '', models: [] });
|
||
const provOpen = ref(false);
|
||
const provBusy = ref(false);
|
||
const provErr = ref('');
|
||
const manualModel = ref('');
|
||
|
||
function loadProvider() {
|
||
try {
|
||
const raw = localStorage.getItem(PROVIDER_KEY);
|
||
if (raw) {
|
||
const p = JSON.parse(raw);
|
||
provider.value = {
|
||
base_url: typeof p.base_url === 'string' ? p.base_url : '',
|
||
api_key: typeof p.api_key === 'string' ? p.api_key : '',
|
||
models: Array.isArray(p.models) ? p.models.map((x: any) => String(x)) : [],
|
||
};
|
||
}
|
||
} catch { /* ignore */ }
|
||
}
|
||
function saveProvider() {
|
||
try { localStorage.setItem(PROVIDER_KEY, JSON.stringify(provider.value)); } catch { /* ignore */ }
|
||
}
|
||
watch(provider, saveProvider, { deep: true });
|
||
|
||
const hasCreds = computed(() => !!(provider.value.base_url.trim() && provider.value.api_key.trim()));
|
||
|
||
async function connectProvider() {
|
||
provErr.value = '';
|
||
if (!hasCreds.value) { provErr.value = '请填写接口地址和 API KEY'; return; }
|
||
provBusy.value = true;
|
||
try {
|
||
const res = await fetch('/relay/ai/custom-models', {
|
||
method: 'POST',
|
||
headers: { 'Content-Type': 'application/json' },
|
||
body: JSON.stringify({
|
||
machine: getMachineId(),
|
||
base_url: provider.value.base_url.trim(),
|
||
api_key: provider.value.api_key.trim(),
|
||
}),
|
||
});
|
||
const j = await res.json().catch(() => ({}));
|
||
if (j.code === 200 && Array.isArray(j.data) && j.data.length) {
|
||
provider.value.models = j.data.map((x: any) => String(x));
|
||
saveProvider();
|
||
mergeModels();
|
||
if (!models.value.some((m) => m.id === model.value) && provider.value.models.length) {
|
||
model.value = provider.value.models[0];
|
||
}
|
||
} else {
|
||
provErr.value = j.message || '连接失败';
|
||
}
|
||
} catch (e: any) {
|
||
provErr.value = String(e?.message || e);
|
||
} finally {
|
||
provBusy.value = false;
|
||
}
|
||
}
|
||
function addManualModel() {
|
||
const v = manualModel.value.trim();
|
||
if (!v) return;
|
||
if (!provider.value.models.includes(v)) provider.value.models.push(v);
|
||
manualModel.value = '';
|
||
saveProvider();
|
||
mergeModels();
|
||
}
|
||
function removeProviderModel(m: string) {
|
||
provider.value.models = provider.value.models.filter((x) => x !== m);
|
||
saveProvider();
|
||
mergeModels();
|
||
}
|
||
function clearProvider() {
|
||
provider.value = { base_url: '', api_key: '', models: [] };
|
||
provErr.value = '';
|
||
saveProvider();
|
||
mergeModels();
|
||
}
|
||
|
||
// 站内模型 + 用户自填模型合并(自定义款 custom=true 排后面)
|
||
let inhouseModels: { id: string; i2i: boolean }[] = [];
|
||
function mergeModels() {
|
||
const inhouse = inhouseModels.map((m) => ({ ...m, custom: false }));
|
||
const mine = provider.value.models.map((id) => ({ id, i2i: false, custom: true }));
|
||
models.value = [...inhouse, ...mine];
|
||
if (!model.value && models.value.length) model.value = models.value[0].id;
|
||
}
|
||
|
||
// ---------- 生成历史(服务端落盘,点缩略图回看/下载) ----------
|
||
const history = ref<{ id: string; at: number; model: string; prompt: string; img_url: string }[]>([]);
|
||
async function loadHistory() {
|
||
try {
|
||
const res = await fetch(`/relay/ai/img-history?machine=${encodeURIComponent(getMachineId())}`);
|
||
const j = await res.json();
|
||
if (j.code === 200 && Array.isArray(j.data)) history.value = j.data;
|
||
} catch { /* ignore */ }
|
||
}
|
||
function openHist(it: any) {
|
||
resultUrl.value = it.img_url || '';
|
||
error.value = '';
|
||
promptEn.value = '';
|
||
}
|
||
|
||
// 宽高比
|
||
type Ratio = { label: string; w: number; h: number; sw: number; sh: number };
|
||
const RATIOS: Ratio[] = [
|
||
{ label: '默认', w: 1024, h: 1024, sw: 26, sh: 26 },
|
||
{ label: '1:1', w: 1024, h: 1024, sw: 26, sh: 26 },
|
||
{ label: '3:2', w: 1152, h: 768, sw: 30, sh: 20 },
|
||
{ label: '2:3', w: 768, h: 1152, sw: 20, sh: 30 },
|
||
{ label: '9:16', w: 720, h: 1280, sw: 15, sh: 27 },
|
||
{ label: '16:9', w: 1280, h: 720, sw: 30, sh: 17 },
|
||
{ label: '3:4', w: 768, h: 1024, sw: 21, sh: 28 },
|
||
{ label: '4:3', w: 1024, h: 768, sw: 28, sh: 21 },
|
||
{ label: '21:9', w: 1344, h: 576, sw: 32, sh: 14 },
|
||
{ label: '9:21', w: 576, h: 1344, sw: 14, sh: 32 },
|
||
];
|
||
const ratio = ref('默认');
|
||
const ratioObj = computed(() => RATIOS.find(r => r.label === ratio.value) || RATIOS[0]);
|
||
|
||
// 示例提示词(按自媒体平台分组;点标签填入完整提示词)
|
||
const EXAMPLE_GROUPS = [
|
||
{ k: '通用', items: [
|
||
{ n: '电影感人像', p: '电影感人像,柔和侧光,浅景深,35mm 胶片质感,戏剧性光影,细节丰富' },
|
||
{ n: '奇幻风景', p: '奇幻风景,漂浮的岛屿与瀑布,魔幻光线,超广角,史诗感,细节丰富' },
|
||
{ n: '赛博朋克城市', p: '赛博朋克城市夜景,霓虹灯,雨后街道反光,未来感,高细节' },
|
||
{ n: '动漫角色', p: '动漫角色立绘,大眼睛,鲜艳色彩,干净线条,动漫风格,白底' },
|
||
{ n: '产品摄影', p: '产品摄影,纯白背景,柔和打光,高清晰度,商业级,居中构图' },
|
||
{ n: '油画风格', p: '油画风格,厚涂笔触,丰富色彩,印象派,艺术感,画布质感' },
|
||
{ n: '人形机器人', p: '2026 热门人形机器人展台,银白机身与蓝色光带,展会级布光,科技感,横版封面留白' },
|
||
{ n: '智能眼镜', p: '智能眼镜悬浮展示,镜片反射数据光效,极简灰白背景,后屏幕时代概念,横版构图' },
|
||
{ n: '芯片晶圆', p: 'AI 芯片晶圆微距特写,电路纹理与彩虹衍射光,深色背景,硬核科技感,横版头图' },
|
||
{ n: '情绪治愈', p: '暖阳窗边治愈系场景,猫咪与热茶毛毯,柔焦光晕,情绪价值氛围,横版构图' },
|
||
{ n: 'AI陪伴玩具', p: '呆萌 AI 陪伴玩具插画,发光眼睛与毛绒质感,糖果配色,情绪消费概念,横版留白' },
|
||
{ n: '脑机接口', p: '脑机接口科技概念,人脑轮廓与神经触点光丝,深蓝渐变,前沿感,横版文章配图' },
|
||
{ n: '低碳出行', p: '新能源汽车与充电桩场景,清晨柔光,绿色环保调,生活方式封面,横版构图' },
|
||
{ n: '露营户外', p: '山间露营帐篷与篝火,黄昏暖光,户外生活感,治愈色温,横版构图' },
|
||
]},
|
||
{ k: '自媒体', items: [
|
||
{ n: '好物开箱', p: '好物开箱场景,纸箱与产品陈列,暖光木质桌面,种草图,横版构图' },
|
||
{ n: '性价比对比', p: '三款同类产品并排对比摆拍,纯白背景,柔光,测评感,横版构图' },
|
||
{ n: '家居神器', p: '高颜值家居小神器摆拍,ins 风布景,自然光,种草构图,横版' },
|
||
{ n: '数码平铺', p: '数码配件平铺摆拍,数据线耳机充电宝,科技灰背景,俯拍横版,整齐治愈' },
|
||
{ n: '测评天平', p: '产品测评天平对比概念,左右分屏清晰构图,横版头图,信息感' },
|
||
{ n: '拆箱瞬间', p: '双手拆快递开箱瞬间,期待感,暖调生活化,浅景深,横版构图' },
|
||
{ n: '耳机开箱', p: '无线耳机开箱特写,充电盒与耳机悬浮,冷光科技背景,产品细节丰富,横版构图' },
|
||
{ n: '手机上手', p: '新机上手体验,手持手机侧光特写,金属边框质感,深色背景,高清晰,横版' },
|
||
{ n: '电竞外设', p: '电竞外设全家福,键鼠耳机 RGB 灯效,暗黑桌面战备感,炫酷构图,横版' },
|
||
{ n: '智能穿戴', p: '智能手表细节特写,表盘 UI 点亮,腕上佩戴视角,柔光质感,竖版构图' },
|
||
{ n: '智能体矩阵', p: '多个 AI 智能体光点组成矩阵网络,中心主脑发光,深蓝科技底色,横版构图' },
|
||
{ n: '机器人交互', p: '人类与白色机器人握手交互,未来实验室背景,干净冷光,信任氛围,横版' },
|
||
{ n: '对话气泡', p: 'AI 对话气泡与输入光标概念视觉,霓虹渐变描边,深色背景,智能感,横版留白' },
|
||
{ n: '数字员工', p: '数字人主播与全息工牌概念,虚拟办公场景,青蓝光效,未来职业感,竖版构图' },
|
||
{ n: '悬浮都市', p: '悬浮飞行都市夜景,飞行器穿梭楼宇间,霓虹光轨,赛博蓝紫色调,横版构图' },
|
||
{ n: '全息操作', p: '工程师全息投影操作界面,悬浮数据面板环绕,暗室蓝光,未来科技感,横版' },
|
||
{ n: '太空舱', p: '太空舱舷窗望向地球,宇航员剪影,静谧深蓝,沉浸氛围,电影感,横版构图' },
|
||
{ n: '光速穿梭', p: '光速隧道穿梭视觉,粒子光束向心汇聚,速度感拉满,深空蓝紫渐变,横版头图' },
|
||
{ n: '短剧霸总', p: '都市短剧霸总场景,西装男主雨夜对峙,电影感打光,戏剧张力,竖版构图' },
|
||
{ n: '古装穿越', p: '古装穿越短剧剧照,红衣仗剑立于宫墙下,电影级质感,光影层次,竖版构图' },
|
||
{ n: '悬疑剧情', p: '悬疑短剧氛围特写,暗巷回头眼神特写,冷暖对比光,紧张感,竖版构图' },
|
||
{ n: '都市情感', p: '都市情感短剧雨夜拥吻,霓虹倒影街道,唯美电影感,浅景深,竖版构图' },
|
||
{ n: 'AI办公智能体', p: 'AI 办公智能体自动干活概念,悬浮任务卡片与文档表格,办公桌虚化,横版头图留白' },
|
||
{ n: 'Token囤货', p: 'Token 词元囤货概念,金币与数据方块堆叠,红金促销配色,双11 热点,横版构图' },
|
||
{ n: 'AI导购比价', p: 'AI 购物助手比价界面概念,对话气泡与购物车,明快电商配色,横版头图留白' },
|
||
{ n: '具身智能', p: '具身智能机械臂精细操作,金属关节与伺服光效,实验室冷光,硬核科技,横版构图' },
|
||
{ n: '演唱会神器', p: '演唱会手机拍摄视角,舞台光束与人群剪影,暗光高感,追星氛围,竖版构图' },
|
||
{ n: '情绪价值', p: '都市青年治愈系独处场景,暖光小店与手冲咖啡,松弛感,日系清透,竖版构图' },
|
||
{ n: '后屏幕交互', p: '无屏幕手势交互概念,悬浮光影界面环绕,暗室蓝光,未来感,竖版构图' },
|
||
{ n: '科普热词', p: '年度十大科普热词云图,关键词漂浮排布,蓝紫渐变光效,知识感,横版头图留白' },
|
||
]},
|
||
{ k: '电商', items: [
|
||
{ n: '商品主图', p: '电商商品主图,单品居中悬浮,纯白背景,商业打光,高清晰,细节丰富' },
|
||
{ n: '大促Banner', p: '电商大促 banner 背景,红金配色,光效与丝带,左侧留白排版区,横版构图' },
|
||
{ n: '秒杀氛围', p: '限时秒杀视觉,倒计时钟与聚光灯,红黑撞色,冲击力构图,横版' },
|
||
{ n: '买赠活动', p: '买一送一促销插画,礼盒与促销标签,活泼配色,电商活动图,横版留白' },
|
||
{ n: '新品首发', p: '新品发布海报感,聚光灯下的产品,高级渐变背景,横版构图,质感高级' },
|
||
{ n: '直播带货', p: '直播间场景概念,主播手持产品展示,暖光氛围灯,竖版构图,热闹感' },
|
||
{ n: '红包优惠券', p: '优惠券红包雨插画,喜庆红色,扁平风格,节日促销氛围,横版 banner' },
|
||
{ n: '礼盒包装', p: '产品精致包装盒摆拍,丝带与贺卡,礼品质感,柔光,横版构图' },
|
||
{ n: '购物概念', p: '购物车与优惠标签插画,红橙促销配色,扁平风格,横版头图留白' },
|
||
{ n: '折扣爆炸贴', p: '爆炸贴折扣标签与产品,促销感,醒目黄红配色,横版构图,高对比' },
|
||
{ n: '双12年终', p: '双12年终盛典视觉,红金渐变光效与丝带,横版 banner,左侧留白排版区' },
|
||
{ n: '虚拟试衣', p: '虚拟试衣间概念,模特与全息服装切换光效,时尚科技感,竖版构图,干净背景' },
|
||
{ n: '国补换新', p: '家电以旧换新国补场景,冰箱洗衣机整齐陈列,红色补贴标签,横版留白' },
|
||
{ n: '囤货清单', p: '大促囤货清单手账风,勾选列表与购物袋插画,暖橙配色,横版头图' },
|
||
{ n: '直播秒杀', p: '直播秒杀倒计时界面,主播手势与价格标签,红紫霓虹,竖版构图,紧张感' },
|
||
{ n: '情绪好物', p: '情绪价值好物摆拍,香薰与毛绒玩偶,奶油色系,治愈种草感,横版构图' },
|
||
{ n: '年货节', p: '年货节喜庆场景,礼盒灯笼与祥云元素,中国红金配色,横版 banner 留白' },
|
||
{ n: '跨境出海', p: '跨境电商全球物流概念,地球与包裹航线光轨,深蓝科技底,横版头图' },
|
||
]},
|
||
{ k: '软件类', items: [
|
||
{ n: '办公桌面', p: '极简办公桌面俯拍,笔记本电脑与咖啡,冷灰调,软件推荐文章封面,横版留白排版' },
|
||
{ n: '效率概念', p: '效率工具概念插画,齿轮与程序窗口组合,扁平风格,科技蓝橙配色,横版头图' },
|
||
{ n: 'AI概念', p: 'AI人工智能概念图,发光大脑与数据流,深蓝科技感,软件文章封面,右侧留白' },
|
||
{ n: '键盘特写', p: '机械键盘特写,RGB 灯效,暗调背景,程序员氛围感,横版构图,高细节' },
|
||
{ n: '数据看板', p: '数据看板 UI 概念插画,图表与卡片悬浮,SaaS 风格,蓝紫渐变,横版头图留白' },
|
||
{ n: '安全盾牌', p: '网络安全概念插画,盾牌与挂锁,深色背景,科技光效,横版文章配图' },
|
||
{ n: '多设备协同', p: '电脑手机平板多设备协同场景,纯白背景,产品渲染质感,横版构图' },
|
||
{ n: '程序员场景', p: '程序员工作场景,双屏代码界面,暗调霓虹光,科技感,横版封面,高细节' },
|
||
{ n: '手持APP', p: '手持手机展示应用界面,干净背景,柔和光线,APP 推荐封面,竖版构图,高清晰' },
|
||
{ n: '悬浮展示', p: '手机悬浮展示,应用图标元素环绕,渐变背景,科技感,竖版构图' },
|
||
{ n: '街头刷机', p: '年轻人街头刷手机,生活化场景,自然光,日系清新,竖版构图' },
|
||
{ n: '界面概念', p: '手机 APP 界面卡片悬浮概念图,扁平插画,清新配色,竖版留白排版' },
|
||
{ n: '手机摄影', p: '手机拍照场景,取景框构图,户外自然光,通透感,竖版构图' },
|
||
{ n: '游戏娱乐', p: '手机游戏娱乐场景,霓虹光效与手指触屏,动感冲击,竖版高饱和' },
|
||
{ n: '通勤办公', p: '地铁通勤用手机办公,纪实感,冷色调,竖版构图,电影感' },
|
||
{ n: '助手拟人', p: '卡通手机助手拟人插画,微笑表情,马卡龙配色,竖版白底,可爱治愈' },
|
||
{ n: '智能体办公', p: 'AI 智能体自动办公概念,任务卡片流水线与机器人图标,蓝橙配色,横版头图留白' },
|
||
{ n: '大模型对话', p: '大模型对话终端界面概念,代码流与回复气泡,暗色 IDE 风格,横版构图' },
|
||
{ n: '开源生态', p: '开源代码协作概念,分支节点与齿轮网络,绿色科技光效,横版文章配图' },
|
||
{ n: '机器人编程', p: '机器人编程调试场景,屏幕代码与机械臂,工程师视角,暗调霓虹,横版构图' },
|
||
{ n: '词元Token', p: 'Token 词元可视化,文字方块粒子流汇入芯片,蓝紫渐变,前沿感,横版头图留白' },
|
||
{ n: '语音助手', p: '语音助手声波可视化,麦克风与光圈涟漪,深色背景,智能交互感,横版构图' },
|
||
{ n: '云同步', p: '多端云同步概念,云朵与数据流连线各设备,清爽蓝白配色,横版文章配图' },
|
||
{ n: '无代码搭建', p: '无代码拖拽建站概念,积木模块拼装界面,明亮配色,效率感,横版头图留白' },
|
||
]},
|
||
];
|
||
const exGroup = ref('通用');
|
||
const curExamples = computed(() => (EXAMPLE_GROUPS.find(g => g.k === exGroup.value) || EXAMPLE_GROUPS[0]).items);
|
||
const exScroll = ref<HTMLElement | null>(null); // 示例词区域(词多时内滚动)
|
||
watch(exGroup, async () => {
|
||
await nextTick();
|
||
if (exScroll.value) exScroll.value.scrollTop = 0; // 切组回到顶部
|
||
});
|
||
|
||
const canGen = computed(() => !!prompt.value.trim());
|
||
|
||
// ---------- 内置免费额度(机器每日次数 + 上游真实免费池;北京时间 0 点重置) ----------
|
||
const quota = ref<{
|
||
authorized: boolean; limit: number; used: number; remaining: number;
|
||
upstream?: string; upstream_daily?: number | null; upstream_used?: number | null;
|
||
upstream_remaining?: number | null; upstream_note?: string; cf_daily?: number;
|
||
} | null>(null);
|
||
const quotaText = computed(() => {
|
||
const q = quota.value;
|
||
if (!q) return '内置免费 · 有每日次数限制';
|
||
if (!q.authorized && q.remaining <= 0) return `内置免费 · 每日${q.limit}次 · 今日已用完`;
|
||
const me = q.authorized ? '已授权' : `免费${q.limit}次·剩${q.remaining}`;
|
||
if (q.upstream === 'pollinations') return `${me} · Pollinations按Key余额`;
|
||
if (q.upstream === 'cloudflare') {
|
||
if ((q.upstream_remaining ?? 1) <= 0) return 'CF免费池已用完 · 08:00重置';
|
||
return `${me} · CF池剩${q.upstream_remaining}/${q.upstream_daily}张`;
|
||
}
|
||
return q.authorized ? '已授权' : `内置免费 · 每日${q.limit}次 · 今日剩${q.remaining}次`;
|
||
});
|
||
const quotaOut = computed(() => {
|
||
const q = quota.value;
|
||
if (!q) return false;
|
||
if (q.upstream === 'cloudflare' && (q.upstream_remaining ?? 1) <= 0) return true;
|
||
return !q.authorized && q.remaining <= 0;
|
||
});
|
||
const quotaTip = computed(() => quota.value?.upstream_note || '内置免费额度说明');
|
||
// 模型下拉后缀:把各上游的真实免费配额实际写出来
|
||
function upSuffix(id: string) {
|
||
if (id.startsWith('pollinations')) return '(按Key余额)';
|
||
return `(CF ${quota.value?.cf_daily ?? 173}张/日)`;
|
||
}
|
||
async function loadQuota() {
|
||
try {
|
||
const res = await fetch('/relay/ai/quota', {
|
||
method: 'POST',
|
||
headers: { 'Content-Type': 'application/json' },
|
||
body: JSON.stringify({ machine: getMachineId(), model: model.value }),
|
||
});
|
||
const j = await res.json();
|
||
if (j.code === 200 && j.data) quota.value = j.data;
|
||
} catch { /* ignore */ }
|
||
}
|
||
// 切换模型 → 上游不同,额度说明跟着换
|
||
watch(model, () => loadQuota());
|
||
|
||
onMounted(async () => {
|
||
loadProvider();
|
||
loadHistory();
|
||
loadQuota();
|
||
try {
|
||
const res = await fetch('/relay/ai/image-models');
|
||
const j = await res.json();
|
||
if (j.code === 200 && Array.isArray(j.data) && j.data.length) {
|
||
inhouseModels = j.data;
|
||
mergeModels();
|
||
if (!model.value || !models.value.some((m: any) => m.id === model.value)) {
|
||
// 默认选中列表第一个模型
|
||
model.value = j.data[0].id;
|
||
}
|
||
} else {
|
||
mergeModels();
|
||
}
|
||
}
|
||
catch { mergeModels(); /* 模型列表加载失败则用默认 */ }
|
||
});
|
||
|
||
function b64DataUrl(b64: string) {
|
||
let mime = 'image/png';
|
||
if (b64.startsWith('/9j/')) mime = 'image/jpeg';
|
||
else if (b64.startsWith('UklGR')) mime = 'image/webp';
|
||
return `data:${mime};base64,${b64}`;
|
||
}
|
||
|
||
// 站内历史文件下载带 ?dl=1(触发 attachment);dataUrl/外链原样
|
||
const dlHref = computed(() => {
|
||
const u = resultUrl.value;
|
||
if (!u) return '#';
|
||
return u.startsWith('/relay/ai/img/') ? u + '?dl=1' : u;
|
||
});
|
||
|
||
async function generate() {
|
||
if (loading.value || !canGen.value) return;
|
||
loading.value = true;
|
||
error.value = '';
|
||
resultUrl.value = '';
|
||
promptEn.value = '';
|
||
try {
|
||
const r = ratioObj.value;
|
||
const body: any = {
|
||
machine: getMachineId(),
|
||
prompt: prompt.value.trim(),
|
||
model: model.value,
|
||
width: r.w,
|
||
height: r.h,
|
||
};
|
||
const isMine = provider.value.models.includes(model.value);
|
||
if (isMine) {
|
||
if (!hasCreds.value) throw new Error('已选自定义模型:请先在「我的提供商」填写接口地址和 API KEY');
|
||
body.provider = { base_url: provider.value.base_url.trim(), api_key: provider.value.api_key.trim() };
|
||
}
|
||
const res = await fetch('/relay/ai/gen-image', {
|
||
method: 'POST',
|
||
headers: { 'Content-Type': 'application/json', ...licenseHeaders('ai-gen') },
|
||
body: JSON.stringify(body),
|
||
});
|
||
const j = await res.json().catch(() => ({}));
|
||
if (!res.ok || j.code !== 200) throw new Error(j.message || `HTTP ${res.status}`);
|
||
const dataUrl = j.data.b64 ? b64DataUrl(j.data.b64) : '';
|
||
resultUrl.value = j.data.img_url || dataUrl || j.data.url;
|
||
promptEn.value = j.data.prompt_en || ''; // 后端已把中文转英文再发送
|
||
loadHistory();
|
||
loadQuota(); // 生成后刷新当日剩余次数
|
||
}
|
||
catch (e: any) {
|
||
error.value = String(e?.message || e);
|
||
}
|
||
finally {
|
||
loading.value = false;
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<template>
|
||
<div class="gen-root">
|
||
<div class="gen-body">
|
||
<!-- 左侧控制面板 -->
|
||
<div class="gen-ctrl">
|
||
<!-- 模型 -->
|
||
<div class="gen-sec">
|
||
<div class="gen-h" :title="quotaTip">模型 <span class="gen-quota" :class="{ out: quotaOut }">{{ quotaText }}</span></div>
|
||
<select v-model="model" class="gen-model-sel">
|
||
<optgroup label="站内免费模型">
|
||
<option v-for="m in models.filter(x => !x.custom)" :key="m.id" :value="m.id">{{ m.id }}{{ upSuffix(m.id) }}</option>
|
||
</optgroup>
|
||
<optgroup v-if="models.some(x => x.custom)" label="我的模型">
|
||
<option v-for="m in models.filter(x => x.custom)" :key="m.id" :value="m.id">{{ m.id }}(我的)</option>
|
||
</optgroup>
|
||
<option v-if="!models.length" value="">选择模型…</option>
|
||
</select>
|
||
<div class="gen-pills">
|
||
<button
|
||
v-for="m in models"
|
||
:key="m.id"
|
||
class="gen-pill"
|
||
:class="{ on: model === m.id, mine: m.custom }"
|
||
@click="model = m.id"
|
||
>
|
||
{{ m.id }}
|
||
</button>
|
||
</div>
|
||
|
||
<!-- 自定义提供商:KEY 只存本机 -->
|
||
<div class="prov">
|
||
<button type="button" class="prov-toggle" @click="provOpen = !provOpen">
|
||
<span>{{ hasCreds ? '✓ 我的提供商已配置' : '或使用自己的提供商 / API KEY' }}</span>
|
||
<span class="prov-caret">{{ provOpen ? '▾' : '▸' }}</span>
|
||
</button>
|
||
<div v-show="provOpen" class="prov-form">
|
||
<input v-model="provider.base_url" class="prov-input" placeholder="接口地址(OpenAI 兼容,如 https://api.openai.com/v1)" spellcheck="false" />
|
||
<input v-model="provider.api_key" class="prov-input" type="password" placeholder="API KEY(仅保存在本机浏览器)" spellcheck="false" autocomplete="off" />
|
||
<div class="prov-actions">
|
||
<button type="button" class="prov-btn prov-primary" :disabled="provBusy" @click="connectProvider">
|
||
{{ provBusy ? '⏳ 连接中…' : '🔌 连接并拉取模型' }}
|
||
</button>
|
||
<button type="button" class="prov-btn" @click="saveProvider">💾 保存到本地</button>
|
||
<button v-if="provider.base_url || provider.api_key || provider.models.length" type="button" class="prov-btn prov-danger" @click="clearProvider">清除</button>
|
||
</div>
|
||
<div v-if="provErr" class="prov-err">⚠️ {{ provErr }}</div>
|
||
<div class="prov-hint">接口地址与 KEY 只保存在你的浏览器(localStorage),生成时临时发给服务器转发,不入库、不落盘。</div>
|
||
<div v-if="provider.models.length" class="prov-models">
|
||
<span v-for="m in provider.models" :key="m" class="prov-tag">
|
||
{{ m }}
|
||
<i title="移除" @click="removeProviderModel(m)">×</i>
|
||
</span>
|
||
</div>
|
||
<div class="prov-manual">
|
||
<input v-model="manualModel" class="prov-input" placeholder="手动输入模型名,回车添加" @keyup.enter="addManualModel" />
|
||
<button type="button" class="prov-btn" @click="addManualModel">添加</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 提示词 -->
|
||
<div class="gen-sec gen-grow">
|
||
<div class="gen-h">提示词</div>
|
||
<textarea
|
||
v-model="prompt"
|
||
class="gen-prompt"
|
||
maxlength="1000"
|
||
placeholder="描述你想生成的图像,例如:一只戴帽子的柴犬,卡通风格,可爱 / 赛博朋克城市夜景,霓虹灯"
|
||
/>
|
||
<div class="gen-count">{{ prompt.length }}/1000</div>
|
||
</div>
|
||
|
||
<!-- 示例 + 宽高比 并排(压缩纵向高度,自适应一屏) -->
|
||
<div class="gen-row">
|
||
<div class="gen-sec">
|
||
<div class="gen-ex-tabs">
|
||
<button
|
||
v-for="g in EXAMPLE_GROUPS"
|
||
:key="g.k"
|
||
class="gen-ex-tab"
|
||
:class="{ on: exGroup === g.k }"
|
||
@click="exGroup = g.k"
|
||
>{{ g.k }}</button>
|
||
<span class="gen-ex-hint">点词即填提示词</span>
|
||
</div>
|
||
<div ref="exScroll" class="gen-examples">
|
||
<button v-for="ex in curExamples" :key="ex.n" class="gen-example" @click="prompt = ex.p">{{ ex.n }}</button>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="gen-sec">
|
||
<div class="gen-h">宽高比</div>
|
||
<div class="gen-ratios">
|
||
<button
|
||
v-for="r in RATIOS"
|
||
:key="r.label"
|
||
class="gen-ratio"
|
||
:class="{ on: ratio === r.label }"
|
||
@click="ratio = r.label"
|
||
>
|
||
<span class="gen-rshape" :style="{ width: r.sw + 'px', height: r.sh + 'px' }" />
|
||
<span class="gen-rl">{{ r.label }}</span>
|
||
</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<button class="gen-go" :disabled="loading || !canGen" @click="generate()">
|
||
{{ loading ? '⏳ 生成中…' : '🎨 生成图片' }}
|
||
</button>
|
||
</div>
|
||
|
||
<!-- 中间结果(占满剩余空间) -->
|
||
<div class="gen-result">
|
||
<div v-if="error" class="gen-err">⚠️ {{ error }}</div>
|
||
<div v-else-if="resultUrl" class="gen-img-box">
|
||
<img :src="resultUrl" alt="生成结果">
|
||
<div class="gen-img-acts">
|
||
<a class="gen-dl" :href="dlHref" target="_blank" rel="noopener" download>⬇ 下载图片</a>
|
||
<a class="gen-dl" :href="resultUrl" target="_blank" rel="noopener">🔗 新窗口打开</a>
|
||
<span v-if="promptEn" class="gen-tr" :title="promptEn">🌐 已自动转英文发送(悬停查看)</span>
|
||
</div>
|
||
</div>
|
||
<div v-else-if="loading" class="gen-empty">
|
||
<n-spin size="large" />
|
||
<p>AI 正在生成图片,请稍候…</p>
|
||
</div>
|
||
<div v-else class="gen-empty">生成的图片会显示在这里</div>
|
||
</div>
|
||
|
||
<!-- 右侧历史:50×50 缩略图竖排 -->
|
||
<div class="gen-hist">
|
||
<div class="hist-t">历史<em v-if="history.length">{{ history.length }}</em></div>
|
||
<div v-if="history.length" class="hist-list">
|
||
<img
|
||
v-for="it in history"
|
||
:key="it.id"
|
||
:src="it.img_url"
|
||
:title="it.prompt"
|
||
:class="{ on: resultUrl === it.img_url }"
|
||
@click="openHist(it)"
|
||
/>
|
||
</div>
|
||
<div v-else class="hist-empty">还没有<br>生成记录</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
|
||
<style scoped lang="less">
|
||
.gen-root {
|
||
display: flex;
|
||
flex-direction: column;
|
||
// 锁定为视口内可用高度:页面级(n-scrollbar)不再出现滚动条
|
||
// 196 = 顶栏 59 + 工具头 93 + 内容容器偏移 44(四档窗口实测恒定)
|
||
height: calc(100vh - 196px);
|
||
|
||
@media (max-width: 900px) {
|
||
// 窄屏纵向堆叠,恢复常规页面滚动
|
||
height: auto;
|
||
}
|
||
}
|
||
|
||
// 占满屏幕:控制面板 + 结果区填满可视高度 + 右侧历史列
|
||
.gen-body {
|
||
display: flex;
|
||
gap: 10px;
|
||
align-items: stretch;
|
||
flex: 1;
|
||
min-height: 0;
|
||
|
||
@media (max-width: 900px) {
|
||
flex-direction: column;
|
||
flex: none;
|
||
min-height: auto;
|
||
}
|
||
}
|
||
|
||
.gen-ctrl {
|
||
width: 560px;
|
||
flex-shrink: 0;
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 10px;
|
||
// 超高时列内滚动兜底(正常窗口一屏放得下,不出滚动条)
|
||
min-height: 0;
|
||
overflow-y: auto;
|
||
|
||
@media (max-width: 900px) {
|
||
width: 100%;
|
||
overflow: visible;
|
||
}
|
||
}
|
||
|
||
// 示例与宽高比并排一行,省一截纵向空间
|
||
.gen-row {
|
||
display: flex;
|
||
gap: 10px;
|
||
|
||
.gen-sec {
|
||
flex: 1;
|
||
min-width: 0;
|
||
}
|
||
|
||
@media (max-width: 900px) {
|
||
flex-direction: column;
|
||
gap: 10px;
|
||
}
|
||
}
|
||
|
||
.gen-sec {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 6px;
|
||
}
|
||
|
||
.gen-grow {
|
||
flex: 1;
|
||
min-height: 0;
|
||
}
|
||
|
||
.gen-h {
|
||
font-size: 14px;
|
||
font-weight: 800;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
gap: 8px;
|
||
}
|
||
|
||
.gen-quota {
|
||
font-size: 11px;
|
||
font-weight: 500;
|
||
color: rgba(128, 128, 128, 0.95);
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.gen-quota.out {
|
||
color: #d03050;
|
||
}
|
||
|
||
.gen-model-sel {
|
||
padding: 9px 10px;
|
||
border: 1px solid rgba(128, 128, 128, 0.3);
|
||
border-radius: 8px;
|
||
font-size: 13.5px;
|
||
background: #fff;
|
||
outline: none;
|
||
|
||
&:focus {
|
||
border-color: #0ea5a0;
|
||
}
|
||
}
|
||
|
||
.gen-pills {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
gap: 6px;
|
||
|
||
.gen-pill {
|
||
padding: 5px 10px;
|
||
border-radius: 999px;
|
||
border: 1px solid rgba(128, 128, 128, 0.28);
|
||
background: rgba(128, 128, 128, 0.05);
|
||
font-size: 12px;
|
||
cursor: pointer;
|
||
transition: all 0.15s;
|
||
|
||
&.on {
|
||
background: rgba(14, 165, 160, 0.15);
|
||
border-color: #0ea5a0;
|
||
color: #0e8b87;
|
||
font-weight: 700;
|
||
}
|
||
|
||
// 用户自填的模型
|
||
&.mine {
|
||
border-style: dashed;
|
||
border-color: #9b6cff;
|
||
color: #7c4dff;
|
||
}
|
||
|
||
&.mine.on {
|
||
background: #9b6cff;
|
||
border-style: solid;
|
||
border-color: #9b6cff;
|
||
color: #fff;
|
||
}
|
||
}
|
||
}
|
||
|
||
/* ---- 自定义提供商 ---- */
|
||
.prov {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 7px;
|
||
margin-top: 4px;
|
||
padding-top: 10px;
|
||
border-top: 1px dashed rgba(128, 128, 128, 0.3);
|
||
}
|
||
|
||
.prov-toggle {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
width: 100%;
|
||
padding: 8px 11px;
|
||
border: 1px solid rgba(128, 128, 128, 0.3);
|
||
border-radius: 8px;
|
||
background: rgba(128, 128, 128, 0.05);
|
||
font-size: 13px;
|
||
font-weight: 600;
|
||
color: inherit;
|
||
cursor: pointer;
|
||
transition: all 0.15s;
|
||
|
||
&:hover {
|
||
border-color: #0ea5a0;
|
||
color: #0e8b87;
|
||
}
|
||
}
|
||
|
||
.prov-caret {
|
||
font-size: 11px;
|
||
opacity: 0.6;
|
||
}
|
||
|
||
.prov-form {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 8px;
|
||
}
|
||
|
||
.prov-input {
|
||
width: 100%;
|
||
box-sizing: border-box;
|
||
padding: 9px 11px;
|
||
border: 1px solid rgba(128, 128, 128, 0.3);
|
||
border-radius: 8px;
|
||
font-size: 13px;
|
||
background: #fff;
|
||
outline: none;
|
||
font-family: inherit;
|
||
|
||
&:focus {
|
||
border-color: #0ea5a0;
|
||
}
|
||
}
|
||
|
||
.prov-actions {
|
||
display: flex;
|
||
gap: 7px;
|
||
flex-wrap: wrap;
|
||
}
|
||
|
||
.prov-btn {
|
||
padding: 7px 12px;
|
||
border: 1px solid rgba(128, 128, 128, 0.3);
|
||
border-radius: 8px;
|
||
background: #fff;
|
||
font-size: 12.5px;
|
||
font-weight: 600;
|
||
color: inherit;
|
||
cursor: pointer;
|
||
transition: all 0.15s;
|
||
|
||
&:hover:not(:disabled) {
|
||
border-color: #0ea5a0;
|
||
color: #0e8b87;
|
||
}
|
||
|
||
&:disabled {
|
||
opacity: 0.55;
|
||
cursor: not-allowed;
|
||
}
|
||
}
|
||
|
||
.prov-primary {
|
||
background: linear-gradient(48deg, #0e9384, #14b8a6);
|
||
border: none;
|
||
color: #fff;
|
||
|
||
&:hover:not(:disabled) {
|
||
opacity: 0.88;
|
||
color: #fff;
|
||
}
|
||
}
|
||
|
||
.prov-danger:hover:not(:disabled) {
|
||
border-color: #d03050;
|
||
color: #d03050;
|
||
}
|
||
|
||
.prov-hint {
|
||
font-size: 11.5px;
|
||
line-height: 1.6;
|
||
opacity: 0.6;
|
||
}
|
||
|
||
.prov-err {
|
||
font-size: 12.5px;
|
||
color: #d03050;
|
||
word-break: break-all;
|
||
}
|
||
|
||
.prov-models {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
gap: 6px;
|
||
}
|
||
|
||
.prov-tag {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
gap: 6px;
|
||
padding: 3px 9px;
|
||
border-radius: 999px;
|
||
border: 1px dashed #9b6cff;
|
||
background: rgba(155, 108, 255, 0.08);
|
||
color: #7c4dff;
|
||
font-size: 12px;
|
||
|
||
i {
|
||
font-style: normal;
|
||
cursor: pointer;
|
||
font-size: 14px;
|
||
line-height: 1;
|
||
opacity: 0.6;
|
||
|
||
&:hover {
|
||
opacity: 1;
|
||
color: #d03050;
|
||
}
|
||
}
|
||
}
|
||
|
||
.prov-manual {
|
||
display: flex;
|
||
gap: 7px;
|
||
|
||
.prov-input {
|
||
flex: 1;
|
||
min-width: 0;
|
||
}
|
||
}
|
||
|
||
.gen-prompt {
|
||
width: 100%;
|
||
flex: 1;
|
||
min-height: 96px;
|
||
resize: vertical;
|
||
padding: 12px 14px;
|
||
border: 1px solid rgba(128, 128, 128, 0.3);
|
||
border-radius: 10px;
|
||
font-size: 15px;
|
||
line-height: 1.7;
|
||
outline: none;
|
||
box-sizing: border-box;
|
||
font-family: inherit;
|
||
|
||
&:focus {
|
||
border-color: #0ea5a0;
|
||
}
|
||
}
|
||
|
||
.gen-count {
|
||
text-align: right;
|
||
font-size: 11.5px;
|
||
opacity: 0.5;
|
||
}
|
||
|
||
// 选项卡(按组切换示例提示词,下划线式,整行替代原「尝试这些示例」标题行)
|
||
.gen-ex-tabs {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 2px;
|
||
border-bottom: 1px solid rgba(128, 128, 128, 0.22);
|
||
margin-bottom: 8px;
|
||
|
||
.gen-ex-tab {
|
||
font-size: 12.5px;
|
||
font-weight: 600;
|
||
padding: 4px 14px;
|
||
background: transparent;
|
||
border: none;
|
||
border-bottom: 2px solid transparent;
|
||
margin-bottom: -1px;
|
||
color: #666;
|
||
cursor: pointer;
|
||
white-space: nowrap;
|
||
transition: color 0.15s;
|
||
|
||
&:hover {
|
||
color: #0e8b87;
|
||
}
|
||
|
||
&.on {
|
||
color: #0e8b87;
|
||
font-weight: 800;
|
||
border-bottom-color: #0ea5a0;
|
||
}
|
||
}
|
||
|
||
.gen-ex-hint {
|
||
margin-left: auto;
|
||
font-size: 11px;
|
||
color: rgba(128, 128, 128, 0.75);
|
||
white-space: nowrap;
|
||
}
|
||
}
|
||
|
||
.gen-examples {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
gap: 6px;
|
||
max-height: 172px; /* 词多时在本区域内滚动查看(放得下则不出现滚动条) */
|
||
overflow-y: auto;
|
||
overscroll-behavior: contain;
|
||
padding-right: 6px;
|
||
scrollbar-width: thin;
|
||
scrollbar-color: rgba(128, 128, 128, 0.4) transparent;
|
||
|
||
&::-webkit-scrollbar {
|
||
width: 6px;
|
||
}
|
||
|
||
&::-webkit-scrollbar-thumb {
|
||
background: rgba(128, 128, 128, 0.4);
|
||
border-radius: 3px;
|
||
}
|
||
|
||
&::-webkit-scrollbar-track {
|
||
background: transparent;
|
||
}
|
||
|
||
.gen-example {
|
||
padding: 6px 11px;
|
||
border-radius: 999px;
|
||
border: 1px solid rgba(128, 128, 128, 0.28);
|
||
background: #fff;
|
||
font-size: 13px;
|
||
cursor: pointer;
|
||
transition: all 0.15s;
|
||
|
||
&:hover {
|
||
border-color: #0ea5a0;
|
||
color: #0e8b87;
|
||
}
|
||
}
|
||
}
|
||
|
||
.gen-ratios {
|
||
display: grid;
|
||
grid-template-columns: repeat(5, 1fr);
|
||
gap: 7px;
|
||
|
||
.gen-ratio {
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
gap: 5px;
|
||
padding: 7px 3px;
|
||
border: 1px solid rgba(128, 128, 128, 0.28);
|
||
border-radius: 9px;
|
||
background: #fff;
|
||
cursor: pointer;
|
||
transition: all 0.15s;
|
||
|
||
&.on {
|
||
background: rgba(14, 165, 160, 0.12);
|
||
border-color: #0ea5a0;
|
||
}
|
||
|
||
.gen-rshape {
|
||
background: #0ea5a0;
|
||
border-radius: 3px;
|
||
opacity: 0.75;
|
||
}
|
||
|
||
.gen-rl {
|
||
font-size: 11.5px;
|
||
opacity: 0.8;
|
||
}
|
||
}
|
||
}
|
||
|
||
.gen-go {
|
||
padding: 11px;
|
||
border: none;
|
||
border-radius: 10px;
|
||
background: linear-gradient(48deg, #0e9384, #14b8a6);
|
||
color: #fff;
|
||
font-size: 16px;
|
||
font-weight: 700;
|
||
cursor: pointer;
|
||
transition: opacity 0.15s;
|
||
|
||
&:disabled {
|
||
opacity: 0.5;
|
||
cursor: not-allowed;
|
||
}
|
||
}
|
||
|
||
.gen-err {
|
||
max-width: 520px;
|
||
padding: 20px 28px;
|
||
border: 1px solid rgba(208, 48, 80, 0.45);
|
||
border-radius: 12px;
|
||
background: rgba(208, 48, 80, 0.08);
|
||
color: #d03050;
|
||
font-size: 15px;
|
||
line-height: 1.8;
|
||
text-align: center;
|
||
word-break: break-all;
|
||
}
|
||
|
||
// 结果区:占满剩余宽度与全部高度
|
||
.gen-result {
|
||
flex: 1;
|
||
min-width: 0;
|
||
border: 1px solid rgba(128, 128, 128, 0.25);
|
||
border-radius: 12px;
|
||
background: rgba(128, 128, 128, 0.04);
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
padding: 20px;
|
||
overflow: auto;
|
||
}
|
||
|
||
.gen-img-box {
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
gap: 14px;
|
||
max-width: 100%;
|
||
|
||
img {
|
||
max-width: 100%;
|
||
max-height: calc(100vh - 320px);
|
||
border-radius: 10px;
|
||
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
|
||
}
|
||
|
||
.gen-img-acts {
|
||
display: flex;
|
||
gap: 12px;
|
||
align-items: center;
|
||
flex-wrap: wrap;
|
||
}
|
||
|
||
.gen-tr {
|
||
font-size: 11px;
|
||
color: var(--muted);
|
||
cursor: help;
|
||
margin-left: auto;
|
||
white-space: nowrap;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
max-width: 60%;
|
||
}
|
||
|
||
.gen-dl {
|
||
padding: 9px 18px;
|
||
border-radius: 8px;
|
||
background: rgba(14, 165, 160, 0.12);
|
||
color: #0e8b87;
|
||
font-size: 14px;
|
||
font-weight: 600;
|
||
text-decoration: none;
|
||
}
|
||
}
|
||
|
||
.gen-empty {
|
||
text-align: center;
|
||
opacity: 0.5;
|
||
font-size: 14.5px;
|
||
|
||
p {
|
||
margin-top: 14px;
|
||
}
|
||
}
|
||
|
||
// 右侧历史:50×50 缩略图竖排
|
||
.gen-hist {
|
||
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;
|
||
|
||
.hist-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;
|
||
}
|
||
}
|
||
|
||
.hist-list {
|
||
flex: 1;
|
||
overflow-y: auto;
|
||
overflow-x: hidden;
|
||
padding: 9px 13px 12px;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
gap: 8px;
|
||
|
||
img {
|
||
width: 50px;
|
||
height: 50px;
|
||
object-fit: cover;
|
||
border-radius: 7px;
|
||
border: 2px solid transparent;
|
||
cursor: pointer;
|
||
background: #fff;
|
||
box-shadow: 0 1px 5px rgba(0, 0, 0, 0.1);
|
||
transition: all 0.15s;
|
||
display: block;
|
||
|
||
&:hover {
|
||
border-color: #0ea5a0;
|
||
transform: translateY(-1px);
|
||
}
|
||
|
||
&.on {
|
||
border-color: #0ea5a0;
|
||
box-shadow: 0 2px 8px rgba(14, 165, 160, 0.35);
|
||
}
|
||
}
|
||
}
|
||
|
||
.hist-empty {
|
||
font-size: 11px;
|
||
text-align: center;
|
||
opacity: 0.45;
|
||
padding: 16px 4px;
|
||
line-height: 1.6;
|
||
}
|
||
|
||
@media (max-width: 900px) {
|
||
flex: none;
|
||
width: 100%;
|
||
flex-direction: row;
|
||
align-items: center;
|
||
|
||
.hist-t {
|
||
border-bottom: none;
|
||
border-right: 1px solid rgba(128, 128, 128, 0.18);
|
||
padding: 8px 10px;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.hist-list {
|
||
flex-direction: row;
|
||
overflow-x: auto;
|
||
overflow-y: hidden;
|
||
padding: 8px;
|
||
}
|
||
}
|
||
}
|
||
</style>
|