feat: 每个工具页新增「问AI」按钮
- 左上角绿色胶囊按钮, 点击弹窗显示该工具 使用方法/特色亮点/小提示 - 新端点 POST /relay/ai/tool-help (免费, 不做授权检查), mimo-v2.6-flash - 前端 markdown-it 渲染(html:false防注入), 按path缓存, 失败可重试, 加载动画 - About 功能介绍新增「问AI 按钮」条目 验证: 端点直测7.3s结构化返回 ✓; 4工具页均有按钮 ✓; 弹窗三节渲染无报错 ✓ CHANGELOG记录
This commit is contained in:
1 parent
38caff5d82
commit
01fecba91b
4 files changed
+215
No files matched your search
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. See [standa
|
||||
|
||||
## Version 2026.10.12-it-tools-pro
|
||||
|
||||
### 🤖 每个工具页新增「问AI」按钮
|
||||
- 位置:工具页**左上角**(标题左侧),绿色胶囊按钮「🤖 问AI」
|
||||
- 点击**弹出窗口**,AI 即时生成该工具的三节说明:**使用方法**(3-5 步编号)/ **特色亮点**(3-4 点)/ **小提示**(1 条)
|
||||
- 新端点 `POST /relay/ai/tool-help`,**免费开放**(不在 PROTECTED_TOOLS、不做授权检查),走 mimo-v2.6-flash,90s 超时
|
||||
- 前端 `markdown-it` 渲染(`html:false` 防注入),按 path 缓存内容,切换回来不重复请求;失败可重试;带加载动画
|
||||
- 验证:端点直测 7.3s 返回结构化 Markdown ✓;4 个工具页(翻译/JSON/OCR/印章)均有按钮 ✓;弹窗加载→三节渲染、控制台无报错 ✓;视觉排版清晰 ✓
|
||||
|
||||
### 📖 新功能介绍页同步更新
|
||||
- **修正 AI 客服介绍**:去掉已移除的「模型可选」→「模型固定不开选择」
|
||||
- **新增「首页资讯」分组 4 条**:每日资讯 5 列 / 最热股票实时刷新 / 自选股 / 首页推荐与全部工具(此前介绍页完全未提及)
|
||||
|
||||
Vendored
+1
@@ -184,6 +184,7 @@ declare module '@vue/runtime-core' {
|
||||
NLayout: typeof import('naive-ui')['NLayout']
|
||||
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
|
||||
NMenu: typeof import('naive-ui')['NMenu']
|
||||
NModal: typeof import('naive-ui')['NModal']
|
||||
NProgress: typeof import('naive-ui')['NProgress']
|
||||
NScrollbar: typeof import('naive-ui')['NScrollbar']
|
||||
NSlider: typeof import('naive-ui')['NSlider']
|
||||
|
||||
@@ -46,6 +46,55 @@ const isWide = computed(() => WIDE_TOOLS.has(route.path));
|
||||
const i18nKey = computed<string>(() => route.path.trim().replace('/', ''));
|
||||
const toolTitle = computed<string>(() => t(`tools.${i18nKey.value}.title`, String(route.meta.name)));
|
||||
const toolDescription = computed<string>(() => t(`tools.${i18nKey.value}.description`, String(route.meta.description)));
|
||||
|
||||
// ===== 「问AI」按钮:弹窗展示当前工具的用法与特色 =====
|
||||
import MarkdownIt from 'markdown-it';
|
||||
const mdRenderer = new MarkdownIt({ html: false, linkify: true, breaks: true });
|
||||
|
||||
const showAiHelp = ref(false);
|
||||
const aiHelpCache = ref<Record<string, string>>({}); // 按 path 缓存,切换回来不重复请求
|
||||
const aiHelpLoading = ref(false);
|
||||
const aiHelpErr = ref('');
|
||||
|
||||
const aiHelpHtml = computed(() => {
|
||||
const src = aiHelpCache.value[route.path] || '';
|
||||
return src ? mdRenderer.render(src) : '';
|
||||
});
|
||||
|
||||
async function askAiHelp() {
|
||||
showAiHelp.value = true;
|
||||
if (aiHelpCache.value[route.path] || aiHelpLoading.value) return;
|
||||
aiHelpLoading.value = true;
|
||||
aiHelpErr.value = '';
|
||||
try {
|
||||
const res = await fetch('/relay/ai/tool-help', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
name: toolTitle.value,
|
||||
description: toolDescription.value,
|
||||
path: route.path,
|
||||
}),
|
||||
});
|
||||
const j = await res.json().catch(() => ({}));
|
||||
if (!res.ok || j.code !== 200) throw new Error(j.message || `HTTP ${res.status}`);
|
||||
aiHelpCache.value = { ...aiHelpCache.value, [route.path]: String(j.data?.reply || '') };
|
||||
}
|
||||
catch (e: any) {
|
||||
aiHelpErr.value = String(e?.message || e);
|
||||
}
|
||||
finally {
|
||||
aiHelpLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function retryAiHelp() {
|
||||
const next = { ...aiHelpCache.value };
|
||||
delete next[route.path];
|
||||
aiHelpCache.value = next;
|
||||
aiHelpErr.value = '';
|
||||
askAiHelp();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -53,6 +102,9 @@ const toolDescription = computed<string>(() => t(`tools.${i18nKey.value}.descrip
|
||||
<div class="tool-layout" :class="{ wide: isWide }">
|
||||
<div class="tool-header">
|
||||
<div flex flex-nowrap items-center gap-12px>
|
||||
<button class="ask-ai-btn" title="问 AI:本工具的用法与特色" @click="askAiHelp">
|
||||
🤖 问AI
|
||||
</button>
|
||||
<n-h1 m-0>
|
||||
{{ toolTitle }}
|
||||
</n-h1>
|
||||
@@ -68,6 +120,28 @@ const toolDescription = computed<string>(() => t(`tools.${i18nKey.value}.descrip
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 问AI 弹窗:当前工具的用法与特色 -->
|
||||
<n-modal
|
||||
v-model:show="showAiHelp"
|
||||
preset="card"
|
||||
class="ai-help-modal"
|
||||
:title="`🤖 问AI · ${toolTitle}`"
|
||||
:style="{ width: 'min(680px, 94vw)' }"
|
||||
>
|
||||
<div class="ai-help-box">
|
||||
<div v-if="aiHelpLoading" class="ai-help-state">
|
||||
<span class="ai-help-dots"><i /><i /><i /></span>
|
||||
AI 正在整理这个工具的用法…
|
||||
</div>
|
||||
<div v-else-if="aiHelpErr" class="ai-help-state err">
|
||||
⚠️ {{ aiHelpErr }}
|
||||
<button class="ai-help-retry" @click="retryAiHelp">重试</button>
|
||||
</div>
|
||||
<div v-else-if="aiHelpHtml" class="ai-help-body" v-html="aiHelpHtml" />
|
||||
<div v-else class="ai-help-state">暂无内容</div>
|
||||
</div>
|
||||
</n-modal>
|
||||
|
||||
<div class="tool-content" :class="{ wide: isWide }">
|
||||
<slot />
|
||||
</div>
|
||||
@@ -152,3 +226,135 @@ const toolDescription = computed<string>(() => t(`tools.${i18nKey.value}.descrip
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="less" scoped>
|
||||
// 「问AI」按钮 —— 工具页左上角
|
||||
.ask-ai-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
padding: 6px 14px;
|
||||
border: 1px solid rgba(24, 160, 88, 0.45);
|
||||
border-radius: 999px;
|
||||
background: rgba(24, 160, 88, 0.1);
|
||||
color: #18a058;
|
||||
font-size: 14.5px;
|
||||
font-weight: 600;
|
||||
flex-shrink: 0;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s;
|
||||
|
||||
&:hover {
|
||||
background: #18a058;
|
||||
color: #fff;
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 4px 12px rgba(24, 160, 88, 0.3);
|
||||
}
|
||||
}
|
||||
|
||||
// 问AI 弹窗
|
||||
.ai-help-box {
|
||||
min-height: 170px;
|
||||
}
|
||||
|
||||
.ai-help-state {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 26px 4px;
|
||||
font-size: 15px;
|
||||
opacity: 0.75;
|
||||
|
||||
&.err {
|
||||
color: #d03050;
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.ai-help-dots {
|
||||
display: inline-flex;
|
||||
gap: 5px;
|
||||
|
||||
i {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: #18a058;
|
||||
animation: aihelp-blink 1.2s infinite ease-in-out;
|
||||
|
||||
&:nth-child(2) {
|
||||
animation-delay: 0.2s;
|
||||
}
|
||||
|
||||
&:nth-child(3) {
|
||||
animation-delay: 0.4s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes aihelp-blink {
|
||||
0%,
|
||||
80%,
|
||||
100% {
|
||||
opacity: 0.25;
|
||||
transform: scale(0.8);
|
||||
}
|
||||
|
||||
40% {
|
||||
opacity: 1;
|
||||
transform: scale(1);
|
||||
}
|
||||
}
|
||||
|
||||
.ai-help-retry {
|
||||
margin-left: 4px;
|
||||
padding: 4px 12px;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
background: #d03050;
|
||||
color: #fff;
|
||||
font-size: 13.5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.ai-help-body {
|
||||
font-size: 15px;
|
||||
line-height: 1.75;
|
||||
color: rgba(0, 0, 0, 0.85);
|
||||
|
||||
:deep(h3) {
|
||||
margin: 14px 0 8px;
|
||||
font-size: 16.5px;
|
||||
color: #18a058;
|
||||
|
||||
&:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(ol),
|
||||
:deep(ul) {
|
||||
margin: 0 0 10px;
|
||||
padding-left: 22px;
|
||||
}
|
||||
|
||||
:deep(li) {
|
||||
margin: 5px 0;
|
||||
}
|
||||
|
||||
:deep(p) {
|
||||
margin: 8px 0;
|
||||
}
|
||||
|
||||
:deep(code) {
|
||||
padding: 1px 6px;
|
||||
border-radius: 4px;
|
||||
background: rgba(0, 0, 0, 0.06);
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
:deep(strong) {
|
||||
color: #18a058;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -20,6 +20,7 @@ const groups: { title: string; items: Item[] }[] = [
|
||||
{ name: '截图理解(AI 看图)', icon: '看', desc: '截图/票据/合同/报错图丢进去 AI 读懂并提取关键信息(多模态),金额日期编号原样保留,5 个预设问题', tag: '全新' },
|
||||
{ name: '视频字幕 AI', icon: '幕', desc: 'Whisper 本地转录生成 SRT、AI 一键翻译英日文、时间轴预览、SRT 下载,与视频工具箱联动', tag: '全新' },
|
||||
{ name: 'AI 修图', icon: '修', desc: '去水印/修复(涂抹智能填充)、抠图去背景、4x 超分辨率、人脸修复,本地 AI 模型 10 秒级出图', tag: '全新' },
|
||||
{ name: '问AI 按钮', icon: '问', desc: '每个工具页左上角都有「🤖 问AI」,点击弹窗即可看到该工具的使用方法、特色亮点与小提示,无需翻文档,按工具缓存不重复请求', tag: '全新' },
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user