feat: 第二梯队AI功能落地 — 文案工具箱(改写/降AIGC/标题/小红书/朋友圈5场景) & 截图理解(qwen多模态看图) & 视频字幕AI(Whisper本地转录SRT+AI翻译英日文), relay四接口, 受控授权, 全链路实测通过
This commit is contained in:
1 parent
b5a933600b
commit
6d1f0f80cb
11 files changed
+1221
-1
No files matched your search
Vendored
+3
@@ -62,6 +62,7 @@ declare module '@vue/runtime-core' {
|
||||
ColoredCard: typeof import('./src/components/ColoredCard.vue')['default']
|
||||
CommandPalette: typeof import('./src/modules/command-palette/command-palette.vue')['default']
|
||||
CommandPaletteOption: typeof import('./src/modules/command-palette/components/command-palette-option.vue')['default']
|
||||
Copywriting: typeof import('./src/tools/copywriting/copywriting.vue')['default']
|
||||
CrontabGenerator: typeof import('./src/tools/crontab-generator/crontab-generator.vue')['default']
|
||||
CSelect: typeof import('./src/ui/c-select/c-select.vue')['default']
|
||||
'CSelect.demo': typeof import('./src/ui/c-select/c-select.demo.vue')['default']
|
||||
@@ -213,6 +214,7 @@ declare module '@vue/runtime-core' {
|
||||
RouterView: typeof import('vue-router')['RouterView']
|
||||
RsaKeyPairGenerator: typeof import('./src/tools/rsa-key-pair-generator/rsa-key-pair-generator.vue')['default']
|
||||
SafelinkDecoder: typeof import('./src/tools/safelink-decoder/safelink-decoder.vue')['default']
|
||||
ScreenshotQa: typeof import('./src/tools/screenshot-qa/screenshot-qa.vue')['default']
|
||||
SealMaker: typeof import('./src/tools/seal-maker/seal-maker.vue')['default']
|
||||
SignaturePad: typeof import('./src/tools/signature-pad/signature-pad.vue')['default']
|
||||
SiteBookmarks: typeof import('./src/tools/site-bookmarks/site-bookmarks.vue')['default']
|
||||
@@ -244,6 +246,7 @@ declare module '@vue/runtime-core' {
|
||||
'UserCenter.page': typeof import('./src/pages/UserCenter.page.vue')['default']
|
||||
UserMenu: typeof import('./src/components/UserMenu.vue')['default']
|
||||
UuidGenerator: typeof import('./src/tools/uuid-generator/uuid-generator.vue')['default']
|
||||
VideoSubtitle: typeof import('./src/tools/video-subtitle/video-subtitle.vue')['default']
|
||||
VideoTools: typeof import('./src/tools/video-tools/video-tools.vue')['default']
|
||||
WifiQrCodeGenerator: typeof import('./src/tools/wifi-qr-code-generator/wifi-qr-code-generator.vue')['default']
|
||||
XmlFormatter: typeof import('./src/tools/xml-formatter/xml-formatter.vue')['default']
|
||||
|
||||
@@ -44,7 +44,7 @@ AUTH_PASS = os.environ.get("AUTH_PASS", "")
|
||||
PROJECT_NAME = os.environ.get("PROJECT_NAME", "IT-Tools")
|
||||
TRIAL_FILE = os.environ.get("TRIAL_FILE", "/app/data/trials.json")
|
||||
TRIAL_MS = int(os.environ.get("TRIAL_MS_MIN", "30")) * 60 * 1000
|
||||
PROTECTED_TOOLS = {"translator", "image-ocr", "pdf-ocr", "ai-retouch", "label-designer", "doc-convert", "image-tools", "pdf-tools", "video-tools", "audio-tools", "text-to-image", "ai-image-tools", "ai-chat"}
|
||||
PROTECTED_TOOLS = {"translator", "image-ocr", "pdf-ocr", "ai-retouch", "label-designer", "doc-convert", "image-tools", "pdf-tools", "video-tools", "audio-tools", "text-to-image", "ai-image-tools", "ai-chat", "copywriting", "screenshot-qa", "video-subtitle"}
|
||||
MACHINE_RE = re.compile(r"^\d{10,16}$")
|
||||
|
||||
# verify() messages that unconditionally block activation
|
||||
@@ -1527,6 +1527,154 @@ class Handler(BaseHTTPRequestHandler):
|
||||
except Exception as e: # noqa: BLE001
|
||||
self._reply(500, json.dumps({"code": 500, "message": f"放大失败: {e}"}, ensure_ascii=False).encode(), "application/json")
|
||||
|
||||
# ---------- 共用 LLM 调用 ----------
|
||||
def _llm_chat(self, messages: list) -> str:
|
||||
key = os.environ.get("NEWAPI_KEY", "")
|
||||
upstream = os.environ.get("NEWAPI_URL", "http://192.168.68.19:3099/v1/chat/completions")
|
||||
model = os.environ.get("NEWAPI_MODEL", "qwen3.8-flash")
|
||||
if not key:
|
||||
raise RuntimeError("AI 服务未配置")
|
||||
body = json.dumps({"model": model, "messages": messages, "temperature": 0.7, "max_tokens": 4096}).encode()
|
||||
req = request.Request(upstream, data=body, headers={"Content-Type": "application/json", "Authorization": "Bearer " + key})
|
||||
resp = request.urlopen(req, timeout=180)
|
||||
data = json.loads(resp.read())
|
||||
if "error" in data:
|
||||
raise RuntimeError(data["error"].get("message", "upstream error"))
|
||||
return data["choices"][0]["message"]["content"]
|
||||
|
||||
# ---------- 文案工具箱 ----------
|
||||
COPY_SCENES = {
|
||||
"rewrite": "你是一名资深中文编辑。请改写用户提供的文字,保持原意但改变表达方式和句式结构,语言自然流畅,直接输出改写后的正文,不要解释。",
|
||||
"deaigc": "你是消除 AI 腔调的中文改写专家。把用户提供的文字改写得更像真人手写:加入口语化表达、长短句交错、具体细节,降低 AI 生成痕迹(避免排比、避免'首先其次最后'式结构、避免空洞套话),保持原意,直接输出改写后的正文。",
|
||||
"titles": "你是爆款标题专家。根据用户提供的主题,生成 10 个吸引点击的中文标题,要求:每行一个、不超过 30 字、风格多样(悬念/数字/痛点/对比/好奇),直接输出标题列表,不要其他文字。",
|
||||
"xhs": "你是小红书文案高手。根据用户提供的主题写一篇小红书笔记:开头抓人(1-2 句)、正文分段带 emoji、结尾加 5-8 个话题标签(#开头)。总字数 300-600 字,语气亲切接地气,直接输出笔记内容。",
|
||||
"moments": "你是朋友圈文案高手。根据用户提供的主题写 3 条不同风格的微信朋友圈短文案:一条文艺、一条幽默、一条简洁有梗,每条不超过 60 字、可带 1-2 个 emoji,直接输出 3 条文案(每条一行)。",
|
||||
}
|
||||
|
||||
def _handle_copy(self):
|
||||
payload = self._read_payload()
|
||||
machine = str(payload.get("machine") or "")
|
||||
if check(machine, "copywriting") != 200:
|
||||
self._reply(403, json.dumps({"code": 403, "message": "需要授权或免费试用已结束"}, ensure_ascii=False).encode("utf-8"), "application/json")
|
||||
return
|
||||
scene = str(payload.get("scene") or "")
|
||||
if scene not in self.COPY_SCENES:
|
||||
self._reply(400, json.dumps({"code": 400, "message": "无效的场景"}, ensure_ascii=False).encode(), "application/json")
|
||||
return
|
||||
text = str(payload.get("text") or "").strip()[:8000]
|
||||
if not text:
|
||||
self._reply(400, json.dumps({"code": 400, "message": "请输入内容"}, ensure_ascii=False).encode(), "application/json")
|
||||
return
|
||||
try:
|
||||
reply = self._llm_chat([
|
||||
{"role": "system", "content": self.COPY_SCENES[scene]},
|
||||
{"role": "user", "content": text},
|
||||
])
|
||||
log_usage(machine, "copywriting")
|
||||
self._reply(200, json.dumps({"code": 200, "message": "ok", "data": {"reply": reply}}, ensure_ascii=False).encode("utf-8"), "application/json")
|
||||
except Exception as e: # noqa: BLE001
|
||||
self._reply(502, json.dumps({"code": 502, "message": f"AI 服务异常: {e}"}, ensure_ascii=False).encode(), "application/json")
|
||||
|
||||
# ---------- 截图理解 ----------
|
||||
def _handle_vision(self):
|
||||
payload = self._read_payload()
|
||||
machine = str(payload.get("machine") or "")
|
||||
if check(machine, "screenshot-qa") != 200:
|
||||
self._reply(403, json.dumps({"code": 403, "message": "需要授权或免费试用已结束"}, ensure_ascii=False).encode("utf-8"), "application/json")
|
||||
return
|
||||
b64 = str(payload.get("image") or "")
|
||||
question = str(payload.get("question") or "").strip()[:1000] or "提取图片中的所有文字和关键信息,结构化整理输出。"
|
||||
if not b64:
|
||||
self._reply(400, json.dumps({"code": 400, "message": "未收到图片"}, ensure_ascii=False).encode(), "application/json")
|
||||
return
|
||||
if len(b64) > 20 * 1024 * 1024:
|
||||
self._reply(413, json.dumps({"code": 413, "message": "图片过大(≤15MB)"}, ensure_ascii=False).encode(), "application/json")
|
||||
return
|
||||
try:
|
||||
reply = self._llm_chat([
|
||||
{"role": "system", "content": "你是截图理解助手,能看懂图片内容(截图、票据、合同、表格、报错)。用中文简洁准确地回答,涉及金额/日期/编号等关键信息必须原样保留。"},
|
||||
{"role": "user", "content": [
|
||||
{"type": "text", "text": question},
|
||||
{"type": "image_url", "image_url": {"url": "data:image/png;base64," + b64}},
|
||||
]},
|
||||
])
|
||||
log_usage(machine, "screenshot-qa")
|
||||
self._reply(200, json.dumps({"code": 200, "message": "ok", "data": {"reply": reply}}, ensure_ascii=False).encode("utf-8"), "application/json")
|
||||
except Exception as e: # noqa: BLE001
|
||||
self._reply(502, json.dumps({"code": 502, "message": f"AI 服务异常: {e}"}, ensure_ascii=False).encode(), "application/json")
|
||||
|
||||
# ---------- 视频字幕:转录 + 翻译 ----------
|
||||
def _handle_subtitle(self):
|
||||
machine = self.headers.get("X-Machine-Id", "")
|
||||
if check(machine, "video-subtitle") != 200:
|
||||
self._reply(403, json.dumps({"code": 403, "message": "需要授权或免费试用已结束"}, ensure_ascii=False).encode("utf-8"), "application/json")
|
||||
return
|
||||
try:
|
||||
ctype = self.headers.get("Content-Type", "")
|
||||
length = int(self.headers.get("Content-Length") or 0)
|
||||
if length > 500 * 1024 * 1024:
|
||||
self._reply(413, json.dumps({"code": 413, "message": "视频超过 500MB 限制"}, ensure_ascii=False).encode(), "application/json")
|
||||
return
|
||||
raw = self.rfile.read(length) if length else b""
|
||||
if not raw:
|
||||
self._reply(400, json.dumps({"code": 400, "message": "未收到视频数据"}, ensure_ascii=False).encode(), "application/json")
|
||||
return
|
||||
import cgi as _cgi
|
||||
import audio_ops
|
||||
wd = "/tmp/sub-" + uuid.uuid4().hex[:12]
|
||||
os.makedirs(wd, exist_ok=True)
|
||||
video_bytes = raw
|
||||
if "multipart" in ctype:
|
||||
env = {"REQUEST_METHOD": "POST", "CONTENT_TYPE": ctype, "CONTENT_LENGTH": str(length)}
|
||||
fs = _cgi.FieldStorage(fp=__import__("io").BytesIO(raw), environ=env, keep_blank_values=True)
|
||||
fitem = fs["file"] if "file" in fs.keys() else None
|
||||
if fitem is not None and fitem.filename:
|
||||
video_bytes = fitem.file.read()
|
||||
vin = os.path.join(wd, "in.mp4")
|
||||
with open(vin, "wb") as f:
|
||||
f.write(video_bytes)
|
||||
wav = os.path.join(wd, "audio.wav")
|
||||
r = subprocess.run(
|
||||
["ffmpeg", "-y", "-i", vin, "-vn", "-ac", "1", "-ar", "16000", wav],
|
||||
capture_output=True, timeout=600,
|
||||
)
|
||||
if r.returncode != 0 or not os.path.exists(wav):
|
||||
shutil.rmtree(wd, ignore_errors=True)
|
||||
self._reply(400, json.dumps({"code": 400, "message": "视频无音轨或格式不支持"}, ensure_ascii=False).encode(), "application/json")
|
||||
return
|
||||
q = parse.parse_qs(parse.urlparse(self.path).query)
|
||||
lang = (q.get("lang") or [""])[0]
|
||||
result = audio_ops.run_asr(wav, lang)
|
||||
shutil.rmtree(wd, ignore_errors=True)
|
||||
log_usage(machine, "video-subtitle")
|
||||
self._reply(200, json.dumps({"code": 200, "message": "ok", "data": result}, ensure_ascii=False).encode("utf-8"), "application/json")
|
||||
except Exception as e: # noqa: BLE001
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
self._reply(500, json.dumps({"code": 500, "message": f"字幕生成失败: {e}"}, ensure_ascii=False).encode(), "application/json")
|
||||
|
||||
def _handle_translate_srt(self):
|
||||
payload = self._read_payload()
|
||||
machine = str(payload.get("machine") or "")
|
||||
if check(machine, "video-subtitle") != 200:
|
||||
self._reply(403, json.dumps({"code": 403, "message": "需要授权或免费试用已结束"}, ensure_ascii=False).encode("utf-8"), "application/json")
|
||||
return
|
||||
srt = str(payload.get("srt") or "").strip()
|
||||
target = str(payload.get("target") or "en")
|
||||
if not srt or len(srt) > 60000:
|
||||
self._reply(400, json.dumps({"code": 400, "message": "字幕内容无效"}, ensure_ascii=False).encode(), "application/json")
|
||||
return
|
||||
tname = "英文" if target == "en" else "日文" if target == "ja" else "英文"
|
||||
try:
|
||||
reply = self._llm_chat([
|
||||
{"role": "system", "content": f"你是专业字幕翻译。把用户提供的 SRT 字幕翻译成{tname}:保留序号、时间轴和空行结构完全不变,只翻译每条字幕的文字部分;译文保持口语化、简洁(每行尽量不超过原长的 1.3 倍)。只输出翻译后的 SRT,不要解释。"},
|
||||
{"role": "user", "content": srt},
|
||||
])
|
||||
log_usage(machine, "video-subtitle")
|
||||
self._reply(200, json.dumps({"code": 200, "message": "ok", "data": {"reply": reply}}, ensure_ascii=False).encode("utf-8"), "application/json")
|
||||
except Exception as e: # noqa: BLE001
|
||||
self._reply(502, json.dumps({"code": 502, "message": f"翻译失败: {e}"}, ensure_ascii=False).encode(), "application/json")
|
||||
|
||||
# ---------- AI 问答 ----------
|
||||
def _handle_aichat(self):
|
||||
payload = self._read_payload()
|
||||
@@ -1826,6 +1974,18 @@ class Handler(BaseHTTPRequestHandler):
|
||||
if parsed.path == "/ai/chat":
|
||||
self._handle_aichat()
|
||||
return
|
||||
if parsed.path == "/ai/copy":
|
||||
self._handle_copy()
|
||||
return
|
||||
if parsed.path == "/ai/vision":
|
||||
self._handle_vision()
|
||||
return
|
||||
if parsed.path == "/subtitle":
|
||||
self._handle_subtitle()
|
||||
return
|
||||
if parsed.path == "/ai/translate-srt":
|
||||
self._handle_translate_srt()
|
||||
return
|
||||
if parsed.path == "/convert":
|
||||
self._handle_convert()
|
||||
return
|
||||
|
||||
@@ -20,6 +20,9 @@ const NEW_FEATURES = [
|
||||
{ path: '/user-center', icon: '👤', name: '用户中心', desc: '收藏/记录云端同步,换电脑登录即恢复,授权跟随账号' },
|
||||
{ path: '/ai-image-lab', icon: '🪄', name: 'AI 图片实验室', desc: '智能抠图去背景、AI 无损放大变清晰、一键证件照' },
|
||||
{ path: '/ai-chat', icon: '🤖', name: 'AI 问答', desc: '报错解读、文案写作、代码问题随口问,支持多轮对话' },
|
||||
{ path: '/copywriting', icon: '✍️', name: '文案工具箱', desc: '一键改写、降 AIGC 率、爆款标题、小红书/朋友圈文案' },
|
||||
{ path: '/screenshot-qa', icon: '👁️', name: '截图理解', desc: '丢张截图/票据/报错图,AI 读懂并提取关键信息' },
|
||||
{ path: '/video-subtitle', icon: '🎬', name: '视频字幕 AI', desc: 'Whisper 自动生成 SRT + AI 翻译英日文' },
|
||||
];
|
||||
import { config } from '@/config';
|
||||
|
||||
|
||||
@@ -0,0 +1,251 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { useHead } from '@vueuse/head';
|
||||
import { getMachineId } from '@/tools/license/license';
|
||||
import { useGenHistory } from '@/tools/gen-history/gen-history';
|
||||
|
||||
useHead({ title: '文案工具箱 - IT-TOOLS-PRO' });
|
||||
const genHist = useGenHistory('copywriting');
|
||||
|
||||
const SCENES = [
|
||||
{ key: 'rewrite', icon: '✍️', name: '一键改写', hint: '粘贴原文,保留原意换个说法', ph: '粘贴需要改写的正文…' },
|
||||
{ key: 'deaigc', icon: '🧑💻', name: '降 AIGC 率', hint: '去掉 AI 腔,改得像真人手写', ph: '粘贴 AI 生成的正文…' },
|
||||
{ key: 'titles', icon: '🔥', name: '标题生成', hint: '输入主题,产出 10 个爆款标题', ph: '输入文章主题,如:办公室久坐腰痛怎么办…' },
|
||||
{ key: 'xhs', icon: '📕', name: '小红书文案', hint: '完整笔记:正文+emoji+话题标签', ph: '输入笔记主题,如:平价通勤包包推荐…' },
|
||||
{ key: 'moments', icon: '💬', name: '朋友圈文案', hint: '3 条不同风格任选', ph: '输入想发的内容,如:周末爬山看日落…' },
|
||||
] as const;
|
||||
|
||||
const scene = ref<(typeof SCENES)[number]['key']>('rewrite');
|
||||
const input = ref('');
|
||||
const output = ref('');
|
||||
const busy = ref(false);
|
||||
const error = ref('');
|
||||
const copied = ref(false);
|
||||
|
||||
const cur = () => SCENES.find(s => s.key === scene.value)!;
|
||||
|
||||
async function run() {
|
||||
if (!input.value.trim() || busy.value) {
|
||||
return;
|
||||
}
|
||||
busy.value = true;
|
||||
error.value = '';
|
||||
output.value = '';
|
||||
try {
|
||||
const res = await fetch('/relay/ai/copy', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ machine: getMachineId(), scene: scene.value, text: input.value }),
|
||||
});
|
||||
const j = await res.json().catch(() => ({}));
|
||||
if (!res.ok || j.code !== 200) {
|
||||
throw new Error(j.message || `HTTP ${res.status}`);
|
||||
}
|
||||
output.value = j.data.reply;
|
||||
genHist.add({ title: `${cur().name}: ${input.value.slice(0, 20)}`, detail: `${j.data.reply.length} 字` });
|
||||
}
|
||||
catch (e: any) {
|
||||
error.value = String(e?.message || e);
|
||||
}
|
||||
finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function copyOut() {
|
||||
await navigator.clipboard.writeText(output.value);
|
||||
copied.value = true;
|
||||
setTimeout(() => (copied.value = false), 1500);
|
||||
}
|
||||
|
||||
function switchScene(k: (typeof SCENES)[number]['key']) {
|
||||
scene.value = k;
|
||||
output.value = '';
|
||||
error.value = '';
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="cw-root">
|
||||
<div class="cw-tabs">
|
||||
<button v-for="s in SCENES" :key="s.key" class="cw-tab" :class="{ on: scene === s.key }" @click="switchScene(s.key)">
|
||||
{{ s.icon }} {{ s.name }}
|
||||
</button>
|
||||
<span class="cw-note">{{ cur().hint }}</span>
|
||||
</div>
|
||||
|
||||
<div class="cw-cols">
|
||||
<div class="cw-left">
|
||||
<div class="cw-sec">输入</div>
|
||||
<textarea v-model="input" class="cw-input" :placeholder="cur().ph" rows="12" />
|
||||
<button class="cw-go" :disabled="busy || !input.trim()" @click="run()">
|
||||
{{ busy ? '⏳ AI 生成中…' : `🚀 ${cur().name}` }}
|
||||
</button>
|
||||
<div v-if="error" class="cw-error">⚠️ {{ error }}</div>
|
||||
</div>
|
||||
<div class="cw-right">
|
||||
<div class="cw-sec">
|
||||
生成结果
|
||||
<span v-if="output" class="cw-actions">
|
||||
<button class="cw-mini" @click="copyOut">{{ copied ? '✓ 已复制' : '📋 复制' }}</button>
|
||||
<button class="cw-mini" @click="output = ''">清空</button>
|
||||
</span>
|
||||
</div>
|
||||
<div class="cw-out">
|
||||
<pre v-if="output" class="cw-text">{{ output }}</pre>
|
||||
<div v-else class="cw-empty">左侧输入后点生成,结果出现在这里</div>
|
||||
</div>
|
||||
<GenHistory tool="copywriting" label="文案记录" class="mt-10px" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.cw-root {
|
||||
padding-bottom: 16px;
|
||||
}
|
||||
|
||||
.cw-tabs {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.cw-tab {
|
||||
border: 1px solid rgba(128, 128, 128, 0.3);
|
||||
background: #fff;
|
||||
border-radius: 999px;
|
||||
padding: 8px 16px;
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
transition: all 0.14s;
|
||||
|
||||
&.on {
|
||||
background: #e60012;
|
||||
border-color: #e60012;
|
||||
color: #fff;
|
||||
font-weight: 700;
|
||||
}
|
||||
}
|
||||
|
||||
.cw-note {
|
||||
margin-left: auto;
|
||||
font-size: 11.5px;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.cw-cols {
|
||||
display: flex;
|
||||
gap: 14px;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.cw-left,
|
||||
.cw-right {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
border: 1px solid rgba(128, 128, 128, 0.2);
|
||||
border-radius: 12px;
|
||||
padding: 14px;
|
||||
}
|
||||
|
||||
.cw-sec {
|
||||
font-size: 12.5px;
|
||||
font-weight: 700;
|
||||
opacity: 0.75;
|
||||
margin-bottom: 8px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.cw-actions {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.cw-mini {
|
||||
border: 1px solid rgba(128, 128, 128, 0.3);
|
||||
background: #fff;
|
||||
border-radius: 6px;
|
||||
padding: 3px 10px;
|
||||
font-size: 11.5px;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
border-color: #18a058;
|
||||
color: #18a058;
|
||||
}
|
||||
}
|
||||
|
||||
.cw-input {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
resize: vertical;
|
||||
border: 1px solid rgba(128, 128, 128, 0.35);
|
||||
border-radius: 10px;
|
||||
padding: 11px 13px;
|
||||
font-size: 13.5px;
|
||||
font-family: inherit;
|
||||
line-height: 1.7;
|
||||
outline: none;
|
||||
|
||||
&:focus {
|
||||
border-color: #e60012;
|
||||
}
|
||||
}
|
||||
|
||||
.cw-go {
|
||||
width: 100%;
|
||||
margin-top: 12px;
|
||||
border: none;
|
||||
background: #e60012;
|
||||
color: #fff;
|
||||
border-radius: 9px;
|
||||
padding: 11px;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
background: #c50010;
|
||||
}
|
||||
}
|
||||
|
||||
.cw-error {
|
||||
color: #d03050;
|
||||
font-size: 12.5px;
|
||||
margin-top: 9px;
|
||||
}
|
||||
|
||||
.cw-out {
|
||||
min-height: 340px;
|
||||
background: rgba(128, 128, 128, 0.05);
|
||||
border-radius: 10px;
|
||||
padding: 14px;
|
||||
}
|
||||
|
||||
.cw-text {
|
||||
margin: 0;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
font-family: inherit;
|
||||
font-size: 13.5px;
|
||||
line-height: 1.8;
|
||||
}
|
||||
|
||||
.cw-empty {
|
||||
font-size: 13px;
|
||||
opacity: 0.45;
|
||||
text-align: center;
|
||||
padding: 60px 0;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,11 @@
|
||||
import { Pencil } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: '文案工具箱',
|
||||
path: '/copywriting',
|
||||
description: 'AI 一键改写、降 AIGC 率、爆款标题、小红书/朋友圈文案',
|
||||
keywords: ['copy', 'rewrite', 'title', 'xiaohongshu', '文案', '改写', '标题', '小红书', '朋友圈', 'AIGC'],
|
||||
component: () => import('./copywriting.vue'),
|
||||
icon: Pencil,
|
||||
});
|
||||
@@ -90,6 +90,9 @@ import { tool as zhConvert } from './zh-convert';
|
||||
import { tool as pinyinConverter } from './pinyin-converter';
|
||||
import { tool as aiImageLab } from './ai-image-lab';
|
||||
import { tool as aiChat } from './ai-chat';
|
||||
import { tool as copywriting } from './copywriting';
|
||||
import { tool as screenshotQa } from './screenshot-qa';
|
||||
import { tool as videoSubtitle } from './video-subtitle';
|
||||
import { tool as docConvert } from './doc-convert';
|
||||
import { tool as aiRetouch } from './ai-retouch';
|
||||
import { tool as wifiQrCodeGenerator } from './wifi-qr-code-generator';
|
||||
@@ -209,6 +212,9 @@ export const toolsByCategory: ToolCategory[] = [
|
||||
pinyinConverter,
|
||||
aiImageLab,
|
||||
aiChat,
|
||||
copywriting,
|
||||
screenshotQa,
|
||||
videoSubtitle,
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -19,6 +19,9 @@ export const PROTECTED_TOOLS: Record<string, string> = {
|
||||
'/text-to-image': '文字生成图片',
|
||||
'/ai-image-lab': 'AI图片实验室',
|
||||
'/ai-chat': 'AI问答',
|
||||
'/copywriting': '文案工具箱',
|
||||
'/screenshot-qa': '截图理解',
|
||||
'/video-subtitle': '视频字幕AI',
|
||||
};
|
||||
|
||||
export const TRIAL_MS = 30 * 60 * 1000; // 每个功能免费 30 分钟
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import { Eye } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: '截图理解',
|
||||
path: '/screenshot-qa',
|
||||
description: 'AI 看图说话:截图/票据/合同/报错图,读懂并提取关键信息',
|
||||
keywords: ['vision', 'screenshot', 'ocr', 'ai', '截图', '看图', '识别', '票据', '合同'],
|
||||
component: () => import('./screenshot-qa.vue'),
|
||||
icon: Eye,
|
||||
});
|
||||
@@ -0,0 +1,322 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { useHead } from '@vueuse/head';
|
||||
import { getMachineId } from '@/tools/license/license';
|
||||
import { useGenHistory } from '@/tools/gen-history/gen-history';
|
||||
|
||||
useHead({ title: '截图理解 - IT-TOOLS-PRO' });
|
||||
const genHist = useGenHistory('screenshot-qa');
|
||||
|
||||
const QUESTIONS = [
|
||||
'提取图片中的所有文字,结构化整理',
|
||||
'图里写了什么关键信息?(金额/日期/编号)',
|
||||
'这是什么报错?原因和解决办法是什么?',
|
||||
'把表格内容转成 Markdown 表格',
|
||||
'用三句话总结这张图的内容',
|
||||
];
|
||||
|
||||
const srcUrl = ref('');
|
||||
const file = ref<File | null>(null);
|
||||
const question = ref(QUESTIONS[0]);
|
||||
const output = ref('');
|
||||
const busy = ref(false);
|
||||
const error = ref('');
|
||||
const fileInput = ref<HTMLInputElement>();
|
||||
|
||||
function pick() {
|
||||
fileInput.value?.click();
|
||||
}
|
||||
|
||||
function onInput(e: Event) {
|
||||
const input = e.target as HTMLInputElement;
|
||||
setFile(input.files?.[0] ?? null);
|
||||
input.value = '';
|
||||
}
|
||||
|
||||
function onDrop(e: DragEvent) {
|
||||
setFile(e.dataTransfer?.files?.[0] ?? null);
|
||||
}
|
||||
|
||||
function setFile(f: File | null) {
|
||||
if (srcUrl.value) {
|
||||
URL.revokeObjectURL(srcUrl.value);
|
||||
}
|
||||
file.value = f;
|
||||
srcUrl.value = f ? URL.createObjectURL(f) : '';
|
||||
output.value = '';
|
||||
error.value = '';
|
||||
}
|
||||
|
||||
async function ask() {
|
||||
if (!file.value || busy.value) {
|
||||
error.value = '请先上传截图/图片';
|
||||
return;
|
||||
}
|
||||
busy.value = true;
|
||||
error.value = '';
|
||||
try {
|
||||
const b64 = await new Promise<string>((resolve, reject) => {
|
||||
const r = new FileReader();
|
||||
r.onload = () => resolve(String(r.result).split(',')[1]);
|
||||
r.onerror = () => reject(new Error('读取图片失败'));
|
||||
r.readAsDataURL(file.value!);
|
||||
});
|
||||
const res = await fetch('/relay/ai/vision', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ machine: getMachineId(), image: b64, question: question.value }),
|
||||
});
|
||||
const j = await res.json().catch(() => ({}));
|
||||
if (!res.ok || j.code !== 200) {
|
||||
throw new Error(j.message || `HTTP ${res.status}`);
|
||||
}
|
||||
output.value = j.data.reply;
|
||||
genHist.add({ title: `截图理解: ${question.value.slice(0, 16)}`, detail: file.value.name });
|
||||
}
|
||||
catch (e: any) {
|
||||
error.value = String(e?.message || e);
|
||||
}
|
||||
finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function copyOut() {
|
||||
await navigator.clipboard.writeText(output.value);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="sq-root">
|
||||
<div class="sq-head">
|
||||
<div>
|
||||
<div class="sq-title">👁️ 截图理解 · AI 看图说话</div>
|
||||
<div class="sq-sub">丢一张截图 / 票据 / 合同 / 报错图,AI 直接读懂并回答——金额日期编号原样保留</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="sq-cols">
|
||||
<div class="sq-left">
|
||||
<input ref="fileInput" type="file" hidden accept="image/*" @change="onInput">
|
||||
<div class="sq-drop" @click="pick" @dragover.prevent @drop.prevent="onDrop">
|
||||
<template v-if="!file">
|
||||
<div class="sq-drop-hint">📁 点击或拖入截图<br><span>PNG / JPG / WebP · ≤15MB</span></div>
|
||||
</template>
|
||||
<img v-else :src="srcUrl" class="sq-thumb" alt="preview">
|
||||
</div>
|
||||
<div class="sq-sec">问它什么</div>
|
||||
<div class="sq-chips">
|
||||
<button v-for="q in QUESTIONS" :key="q" class="sq-chip" :class="{ on: question === q }" @click="question = q">
|
||||
{{ q.length > 16 ? q.slice(0, 16) + '…' : q }}
|
||||
</button>
|
||||
</div>
|
||||
<textarea v-model="question" class="sq-input" rows="3" placeholder="或直接输入你的问题…" />
|
||||
<button class="sq-go" :disabled="busy || !file" @click="ask()">
|
||||
{{ busy ? '⏳ AI 正在看图…' : '👁️ 让 AI 看图回答' }}
|
||||
</button>
|
||||
<div v-if="error" class="sq-error">⚠️ {{ error }}</div>
|
||||
</div>
|
||||
|
||||
<div class="sq-right">
|
||||
<div class="sq-sec">
|
||||
AI 回答
|
||||
<button v-if="output" class="sq-mini" @click="copyOut()">📋 复制</button>
|
||||
</div>
|
||||
<div class="sq-out">
|
||||
<pre v-if="output" class="sq-text">{{ output }}</pre>
|
||||
<div v-else class="sq-empty">上传截图并提问,AI 的回答在这里</div>
|
||||
</div>
|
||||
<GenHistory tool="screenshot-qa" label="看图记录" class="mt-10px" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.sq-root {
|
||||
padding-bottom: 16px;
|
||||
}
|
||||
|
||||
.sq-head {
|
||||
margin-bottom: 14px;
|
||||
|
||||
.sq-title {
|
||||
font-size: 17px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.sq-sub {
|
||||
font-size: 12.5px;
|
||||
opacity: 0.55;
|
||||
margin-top: 3px;
|
||||
}
|
||||
}
|
||||
|
||||
.sq-cols {
|
||||
display: flex;
|
||||
gap: 14px;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.sq-left {
|
||||
width: 400px;
|
||||
flex-shrink: 0;
|
||||
border: 1px solid rgba(128, 128, 128, 0.2);
|
||||
border-radius: 12px;
|
||||
padding: 14px;
|
||||
}
|
||||
|
||||
.sq-right {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
border: 1px solid rgba(128, 128, 128, 0.2);
|
||||
border-radius: 12px;
|
||||
padding: 14px;
|
||||
}
|
||||
|
||||
.sq-drop {
|
||||
border: 1.5px dashed rgba(128, 128, 128, 0.4);
|
||||
border-radius: 10px;
|
||||
padding: 16px;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
margin-bottom: 12px;
|
||||
transition: border-color 0.15s;
|
||||
|
||||
&:hover {
|
||||
border-color: #2563eb;
|
||||
}
|
||||
|
||||
.sq-drop-hint {
|
||||
font-size: 13.5px;
|
||||
font-weight: 600;
|
||||
line-height: 1.7;
|
||||
|
||||
span {
|
||||
font-size: 11.5px;
|
||||
font-weight: 400;
|
||||
opacity: 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
.sq-thumb {
|
||||
max-width: 100%;
|
||||
max-height: 260px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.sq-sec {
|
||||
font-size: 12.5px;
|
||||
font-weight: 700;
|
||||
opacity: 0.75;
|
||||
margin: 8px 0;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.sq-chips {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.sq-chip {
|
||||
border: 1px solid rgba(128, 128, 128, 0.3);
|
||||
background: #fff;
|
||||
border-radius: 999px;
|
||||
padding: 4px 11px;
|
||||
font-size: 11.5px;
|
||||
cursor: pointer;
|
||||
|
||||
&.on {
|
||||
background: rgba(37, 99, 235, 0.1);
|
||||
border-color: #2563eb;
|
||||
color: #2563eb;
|
||||
font-weight: 700;
|
||||
}
|
||||
}
|
||||
|
||||
.sq-input {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
resize: vertical;
|
||||
border: 1px solid rgba(128, 128, 128, 0.35);
|
||||
border-radius: 9px;
|
||||
padding: 9px 11px;
|
||||
font-size: 13px;
|
||||
font-family: inherit;
|
||||
outline: none;
|
||||
|
||||
&:focus {
|
||||
border-color: #2563eb;
|
||||
}
|
||||
}
|
||||
|
||||
.sq-go {
|
||||
width: 100%;
|
||||
margin-top: 11px;
|
||||
border: none;
|
||||
background: #2563eb;
|
||||
color: #fff;
|
||||
border-radius: 9px;
|
||||
padding: 11px;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
background: #1d4ed8;
|
||||
}
|
||||
}
|
||||
|
||||
.sq-error {
|
||||
color: #d03050;
|
||||
font-size: 12.5px;
|
||||
margin-top: 9px;
|
||||
}
|
||||
|
||||
.sq-mini {
|
||||
border: 1px solid rgba(128, 128, 128, 0.3);
|
||||
background: #fff;
|
||||
border-radius: 6px;
|
||||
padding: 3px 10px;
|
||||
font-size: 11.5px;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
border-color: #18a058;
|
||||
color: #18a058;
|
||||
}
|
||||
}
|
||||
|
||||
.sq-out {
|
||||
min-height: 400px;
|
||||
background: rgba(128, 128, 128, 0.05);
|
||||
border-radius: 10px;
|
||||
padding: 14px;
|
||||
}
|
||||
|
||||
.sq-text {
|
||||
margin: 0;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
font-family: inherit;
|
||||
font-size: 13.5px;
|
||||
line-height: 1.8;
|
||||
}
|
||||
|
||||
.sq-empty {
|
||||
font-size: 13px;
|
||||
opacity: 0.45;
|
||||
text-align: center;
|
||||
padding: 70px 0;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,11 @@
|
||||
import { PlayerPlay } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: '视频字幕 AI',
|
||||
path: '/video-subtitle',
|
||||
description: 'Whisper 自动生成 SRT 字幕 + AI 翻译成英文/日文',
|
||||
keywords: ['subtitle', 'srt', 'whisper', 'asr', '字幕', '转录', '翻译', '视频'],
|
||||
component: () => import('./video-subtitle.vue'),
|
||||
icon: PlayerPlay,
|
||||
});
|
||||
@@ -0,0 +1,439 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue';
|
||||
import { useHead } from '@vueuse/head';
|
||||
import { getMachineId, licenseHeaders } from '@/tools/license/license';
|
||||
import { useGenHistory } from '@/tools/gen-history/gen-history';
|
||||
|
||||
useHead({ title: '视频字幕 AI - IT-TOOLS-PRO' });
|
||||
const genHist = useGenHistory('video-subtitle');
|
||||
|
||||
interface Seg {
|
||||
start: number;
|
||||
end: number;
|
||||
text: string;
|
||||
}
|
||||
|
||||
const file = ref<File | null>(null);
|
||||
const busy = ref(false);
|
||||
const busyMsg = ref('');
|
||||
const error = ref('');
|
||||
const segs = ref<Seg[]>([]);
|
||||
const lang = ref('');
|
||||
const fileInput = ref<HTMLInputElement>();
|
||||
const translating = ref(false);
|
||||
const translated = ref('');
|
||||
|
||||
function fmt(t: number) {
|
||||
const h = Math.floor(t / 3600);
|
||||
const m = Math.floor((t % 3600) / 60);
|
||||
const s = Math.floor(t % 60);
|
||||
const ms = Math.round((t % 1) * 1000);
|
||||
return `${String(h).padStart(2, '0')}:${String(m).padStart(2, '0')}:${String(s).padStart(2, '0')},${String(ms).padStart(3, '0')}`;
|
||||
}
|
||||
|
||||
const srt = computed(() =>
|
||||
segs.value.map((s, i) => `${i + 1}\n${fmt(s.start)} --> ${fmt(s.end)}\n${s.text}\n`).join('\n'),
|
||||
);
|
||||
|
||||
function pick() {
|
||||
fileInput.value?.click();
|
||||
}
|
||||
|
||||
function onInput(e: Event) {
|
||||
const input = e.target as HTMLInputElement;
|
||||
file.value = input.files?.[0] ?? null;
|
||||
input.value = '';
|
||||
segs.value = [];
|
||||
translated.value = '';
|
||||
error.value = '';
|
||||
}
|
||||
|
||||
async function transcribe() {
|
||||
if (!file.value || busy.value) {
|
||||
error.value = '请先选择视频文件';
|
||||
return;
|
||||
}
|
||||
busy.value = true;
|
||||
error.value = '';
|
||||
translated.value = '';
|
||||
busyMsg.value = '上传并提取音轨中…(长视频需要一些时间)';
|
||||
try {
|
||||
const fd = new FormData();
|
||||
fd.append('file', file.value);
|
||||
const res = await fetch(`/relay/subtitle?lang=`, {
|
||||
method: 'POST',
|
||||
body: fd,
|
||||
headers: licenseHeaders('video-subtitle'),
|
||||
});
|
||||
busyMsg.value = 'AI 转录中…';
|
||||
const j = await res.json().catch(() => ({}));
|
||||
if (!res.ok || j.code !== 200) {
|
||||
throw new Error(j.message || `HTTP ${res.status}`);
|
||||
}
|
||||
segs.value = j.data.segments || [];
|
||||
lang.value = `${j.data.language}(${j.data.probability})`;
|
||||
if (!segs.value.length) {
|
||||
throw new Error('未识别到语音内容');
|
||||
}
|
||||
genHist.add({ title: `字幕转录: ${file.value.name}`, detail: `${segs.value.length} 条 · 语言 ${j.data.language}` });
|
||||
}
|
||||
catch (e: any) {
|
||||
error.value = String(e?.message || e);
|
||||
}
|
||||
finally {
|
||||
busy.value = false;
|
||||
busyMsg.value = '';
|
||||
}
|
||||
}
|
||||
|
||||
async function translate(target: string) {
|
||||
if (!srt.value || translating.value) {
|
||||
return;
|
||||
}
|
||||
translating.value = true;
|
||||
error.value = '';
|
||||
try {
|
||||
const res = await fetch('/relay/ai/translate-srt', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ machine: getMachineId(), srt: srt.value, target }),
|
||||
});
|
||||
const j = await res.json().catch(() => ({}));
|
||||
if (!res.ok || j.code !== 200) {
|
||||
throw new Error(j.message || `HTTP ${res.status}`);
|
||||
}
|
||||
translated.value = j.data.reply;
|
||||
genHist.add({ title: `字幕翻译→${target === 'en' ? '英文' : '日文'}`, detail: `${j.data.reply.length} 字` });
|
||||
}
|
||||
catch (e: any) {
|
||||
error.value = String(e?.message || e);
|
||||
}
|
||||
finally {
|
||||
translating.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function download(content: string, name: string) {
|
||||
const blob = new Blob([content], { type: 'text/plain;charset=utf-8' });
|
||||
const a = document.createElement('a');
|
||||
a.href = URL.createObjectURL(blob);
|
||||
a.download = name;
|
||||
a.click();
|
||||
URL.revokeObjectURL(a.href);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="vs-root">
|
||||
<div class="vs-head">
|
||||
<div>
|
||||
<div class="vs-title">🎬 视频字幕 AI</div>
|
||||
<div class="vs-sub">本地 Whisper 语音识别 → 自动生成 SRT 字幕 → AI 一键翻译成英文/日文,与视频工具箱联动成完整链路</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="vs-cols">
|
||||
<div class="vs-left">
|
||||
<input ref="fileInput" type="file" hidden accept="video/*,.mp4,.mkv,.mov,.webm,.avi" @change="onInput">
|
||||
<div class="vs-drop" @click="pick">
|
||||
<template v-if="!file">
|
||||
<div class="vs-drop-hint">📁 选择视频文件<br><span>MP4 / MOV / MKV / WebM · ≤500MB</span></div>
|
||||
</template>
|
||||
<div v-else class="vs-file">
|
||||
🎥 {{ file.name }}
|
||||
<span class="vs-size">({{ (file.size / 1024 / 1024).toFixed(1) }} MB)</span>
|
||||
<a href="javascript:;" class="vs-clear" @click.stop="file = null; segs = []">✕</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="vs-sec">语言识别</div>
|
||||
<div class="vs-chips">
|
||||
<button class="vs-chip on">自动检测{{ lang ? ` · 已识别 ${lang}` : '' }}</button>
|
||||
</div>
|
||||
|
||||
<button class="vs-go" :disabled="busy || !file" @click="transcribe()">
|
||||
{{ busy ? `⏳ ${busyMsg}` : '🎙️ 生成字幕' }}
|
||||
</button>
|
||||
|
||||
<template v-if="segs.length">
|
||||
<div class="vs-sec">翻译</div>
|
||||
<div class="vs-chips">
|
||||
<button class="vs-chip" :disabled="translating" @click="translate('en')">
|
||||
{{ translating ? '⏳ 翻译中…' : '🇬🇧 翻译成英文' }}
|
||||
</button>
|
||||
<button class="vs-chip" :disabled="translating" @click="translate('ja')">
|
||||
🇯🇵 翻译成日文
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div v-if="error" class="vs-error">⚠️ {{ error }}</div>
|
||||
<div class="vs-hint">💡 需要带语音的视频;无声/纯音乐视频会提示无语音。转录完全本地进行,视频不离开服务器。</div>
|
||||
</div>
|
||||
|
||||
<div class="vs-right">
|
||||
<div class="vs-sec">
|
||||
转录结果 · {{ segs.length }} 条
|
||||
<span v-if="segs.length" class="vs-actions">
|
||||
<button class="vs-mini" @click="download(srt, 'subtitles.srt')">⬇ 下载 SRT</button>
|
||||
<button class="vs-mini" @click="navigator.clipboard.writeText(srt)">📋 复制</button>
|
||||
</span>
|
||||
</div>
|
||||
<div class="vs-out">
|
||||
<div v-if="!segs.length" class="vs-empty">选择视频点「生成字幕」,时间轴预览在这里</div>
|
||||
<template v-else>
|
||||
<div v-for="(s, i) in segs" :key="i" class="vs-seg">
|
||||
<span class="vs-time">{{ fmt(s.start).slice(3, 11) }}</span>
|
||||
<span class="vs-text">{{ s.text }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<template v-if="translated">
|
||||
<div class="vs-sec">
|
||||
译文字幕
|
||||
<span class="vs-actions">
|
||||
<button class="vs-mini" @click="download(translated, 'subtitles-translated.srt')">⬇ 下载译文 SRT</button>
|
||||
<button class="vs-mini" @click="navigator.clipboard.writeText(translated)">📋 复制</button>
|
||||
</span>
|
||||
</div>
|
||||
<div class="vs-out vs-out-tr">
|
||||
<pre class="vs-srt">{{ translated }}</pre>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<GenHistory tool="video-subtitle" label="字幕记录" class="mt-10px" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.vs-root {
|
||||
padding-bottom: 16px;
|
||||
}
|
||||
|
||||
.vs-head {
|
||||
margin-bottom: 14px;
|
||||
|
||||
.vs-title {
|
||||
font-size: 17px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.vs-sub {
|
||||
font-size: 12.5px;
|
||||
opacity: 0.55;
|
||||
margin-top: 3px;
|
||||
}
|
||||
}
|
||||
|
||||
.vs-cols {
|
||||
display: flex;
|
||||
gap: 14px;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.vs-left {
|
||||
width: 380px;
|
||||
flex-shrink: 0;
|
||||
border: 1px solid rgba(128, 128, 128, 0.2);
|
||||
border-radius: 12px;
|
||||
padding: 14px;
|
||||
}
|
||||
|
||||
.vs-right {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.vs-drop {
|
||||
border: 1.5px dashed rgba(128, 128, 128, 0.4);
|
||||
border-radius: 10px;
|
||||
padding: 18px 12px;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
margin-bottom: 12px;
|
||||
transition: border-color 0.15s;
|
||||
|
||||
&:hover {
|
||||
border-color: #7c3aed;
|
||||
}
|
||||
|
||||
.vs-drop-hint {
|
||||
font-size: 13.5px;
|
||||
font-weight: 600;
|
||||
line-height: 1.7;
|
||||
|
||||
span {
|
||||
font-size: 11.5px;
|
||||
font-weight: 400;
|
||||
opacity: 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
.vs-file {
|
||||
font-size: 12.5px;
|
||||
font-weight: 600;
|
||||
word-break: break-all;
|
||||
|
||||
.vs-size {
|
||||
font-weight: 400;
|
||||
opacity: 0.55;
|
||||
}
|
||||
|
||||
.vs-clear {
|
||||
color: #d03050;
|
||||
margin-left: 8px;
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.vs-sec {
|
||||
font-size: 12.5px;
|
||||
font-weight: 700;
|
||||
opacity: 0.75;
|
||||
margin: 10px 0 7px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.vs-chips {
|
||||
display: flex;
|
||||
gap: 7px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.vs-chip {
|
||||
border: 1px solid rgba(128, 128, 128, 0.3);
|
||||
background: #fff;
|
||||
border-radius: 999px;
|
||||
padding: 6px 14px;
|
||||
font-size: 12.5px;
|
||||
cursor: pointer;
|
||||
|
||||
&.on {
|
||||
background: rgba(124, 58, 237, 0.1);
|
||||
border-color: #7c3aed;
|
||||
color: #7c3aed;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.55;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
.vs-go {
|
||||
width: 100%;
|
||||
margin-top: 13px;
|
||||
border: none;
|
||||
background: #7c3aed;
|
||||
color: #fff;
|
||||
border-radius: 9px;
|
||||
padding: 11px;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
line-height: 1.5;
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
background: #6d28d9;
|
||||
}
|
||||
}
|
||||
|
||||
.vs-error {
|
||||
color: #d03050;
|
||||
font-size: 12.5px;
|
||||
margin-top: 9px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.vs-hint {
|
||||
font-size: 11.5px;
|
||||
opacity: 0.5;
|
||||
line-height: 1.7;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.vs-actions {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.vs-mini {
|
||||
border: 1px solid rgba(128, 128, 128, 0.3);
|
||||
background: #fff;
|
||||
border-radius: 6px;
|
||||
padding: 3px 10px;
|
||||
font-size: 11.5px;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
border-color: #18a058;
|
||||
color: #18a058;
|
||||
}
|
||||
}
|
||||
|
||||
.vs-out {
|
||||
background: rgba(128, 128, 128, 0.05);
|
||||
border: 1px solid rgba(128, 128, 128, 0.15);
|
||||
border-radius: 10px;
|
||||
padding: 10px 12px;
|
||||
max-height: 420px;
|
||||
overflow-y: auto;
|
||||
margin-bottom: 12px;
|
||||
|
||||
&.vs-out-tr {
|
||||
max-height: 300px;
|
||||
}
|
||||
|
||||
.vs-empty {
|
||||
font-size: 13px;
|
||||
opacity: 0.45;
|
||||
text-align: center;
|
||||
padding: 60px 0;
|
||||
}
|
||||
}
|
||||
|
||||
.vs-seg {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
padding: 5px 2px;
|
||||
border-bottom: 1px dashed rgba(128, 128, 128, 0.15);
|
||||
font-size: 13px;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.vs-time {
|
||||
color: #7c3aed;
|
||||
font-family: monospace;
|
||||
font-size: 12px;
|
||||
flex-shrink: 0;
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
.vs-text {
|
||||
line-height: 1.6;
|
||||
}
|
||||
}
|
||||
|
||||
.vs-srt {
|
||||
margin: 0;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
font-family: inherit;
|
||||
font-size: 12.5px;
|
||||
line-height: 1.7;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user