Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions components/Main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,23 @@
</el-row>


<!-- 视频字幕翻译 -->
<el-row v-if="config.on" class="margin-bottom margin-left-2em margin-top-1em">
<el-col :span="20" class="lightblue rounded-corner">
<el-tooltip class="box-item" effect="dark"
content="在 YouTube 等平台上,开启原生字幕后自动翻译并以双语形式叠加显示(需先在视频播放器中开启字幕)"
placement="top-start" :show-after="500">
<span class="popup-text popup-vertical-left">
视频字幕翻译
<el-icon class="icon-margin"><ChatDotRound /></el-icon>
</span>
</el-tooltip>
</el-col>
<el-col :span="4" class="flex-end">
<el-switch v-model="config.enableVideoSubtitle" inline-prompt active-text="开" inactive-text="关" />
</el-col>
</el-row>

<!-- 划词翻译模式选择 -->
<el-row v-if="config.on" class="margin-bottom margin-left-2em margin-top-1em">
<el-col :span="14" class="lightblue rounded-corner">
Expand Down
6 changes: 5 additions & 1 deletion entrypoints/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import { mountSelectionTranslator, unmountSelectionTranslator } from "@/entrypoi
import { cancelAllTranslations, translateText } from "@/entrypoints/utils/translateApi";
import { createApp } from 'vue';
import TranslationStatus from '@/components/TranslationStatus.vue';
import { mountNewApiComponent } from "@/entrypoints/utils/newApi";
import { mountNewApiComponent } from "@/entrypoints/utils/newApi"
import { initVideoSubtitle } from "@/entrypoints/video/manager";

export default defineContentScript({
matches: ['<all_urls>'], // 匹配所有页面
Expand Down Expand Up @@ -55,6 +56,9 @@ export default defineContentScript({

mountNewApiComponent();

// 初始化视频字幕翻译(在支持的平台上注入拦截脚本)
initVideoSubtitle();

cache.cleaner(); // 检测是否清理缓存

// background.ts
Expand Down
2 changes: 2 additions & 0 deletions entrypoints/utils/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export class Config {
translationStatus: boolean; // 是否启用全文翻译进度面板
inputBoxTranslationTrigger: string; // 输入框翻译触发方式
inputBoxTranslationTarget: string; // 输入框翻译目标语言
enableVideoSubtitle: boolean; // 是否启用视频字幕翻译

constructor() {
this.on = true;
Expand Down Expand Up @@ -98,6 +99,7 @@ export class Config {
this.translationStatus = true; // 默认启用翻译进度面板
this.inputBoxTranslationTrigger = 'disabled'; // 默认关闭输入框翻译
this.inputBoxTranslationTarget = 'en'; // 默认翻译成英文
this.enableVideoSubtitle = true; // 默认启用视频字幕翻译
}
}

Expand Down
Loading