Skip to content

Commit

Permalink
chore(toolbox): 调整翻译界面
Browse files Browse the repository at this point in the history
  • Loading branch information
mark9804 committed Jun 21, 2024
1 parent 931febe commit 2e3b99a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ import { halfToFull, translate } from '../../public/helper/getTranslation';
import { useMainStore } from '../store/mainStore';
import { Title } from '../types/FileContent';
import { DropdownMixedOption } from 'naive-ui/es/dropdown/src/interface';
import { Key } from 'naive-ui/es/menu/src/interface';
const props = defineProps({
index: [Number, String],
Expand Down Expand Up @@ -209,7 +208,7 @@ function handleChangeLanguage(key: string) {
referenceTitle.value = targetLanguage;
}
function getReferenceTextByKey(key: Key | undefined) {
function getReferenceTextByKey(key: string | number | undefined) {
if (key) {
return Reflect.get(
props.content as object,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,11 @@
></n-input>
</div>
<div class="trans">
<n-space>
<n-button type="info" @click="sendResetLive2dSignal"
>重置 Live2D 状态
</n-button>
<n-button type="info" @click="sendRefreshPlayerSignal"
>刷新播放器</n-button
>
<n-space :size="4">
<n-space vertical>
<n-space>
<n-button type="info" @click="sendRefreshPlayerSignal"
>刷新播放器</n-button
>
<n-tooltip>
<template #trigger>
<n-button type="info" @click="addTag()"> 插入等待时长</n-button>
Expand Down Expand Up @@ -79,40 +76,42 @@
></template
>
</n-input-number>
<n-dropdown
trigger="hover"
:options="langSelect"
@select="
{
config.setTargetLang($event as Language);
}
"
>
<n-tooltip>
<template #trigger>
<n-button secondary type="info">
{{ langHash[config.getTargetLang] }}
</n-button>
</template>
<span> 选择需要翻译的语言 </span>
</n-tooltip>
</n-dropdown>
</n-space>
<n-space>
<n-button @click="acceptHandle" type="info">接受机翻</n-button>
<n-button @click="handleFormalizePunctuation" type="info">
规范符号
</n-button>
<!-- <n-button @click="translateHandle(true)" type="info"
>重新翻译</n-button
> -->
<n-button
@click="handleLLMTranslateRequest(2)"
type="info"
quaternary
:loading="llmLoading"
>
帮帮我,GPT 先生
</n-button>
</n-space>
<n-dropdown
trigger="hover"
:options="langSelect"
@select="
{
config.setTargetLang($event as Language);
}
"
>
<n-tooltip>
<template #trigger>
<n-button secondary type="info">
{{ langHash[config.getTargetLang] }}
</n-button>
</template>
<span> 选择需要翻译的语言 </span>
</n-tooltip>
</n-dropdown>
<n-button @click="acceptHandle" type="info">接受机翻</n-button>
<n-button @click="handleFormalizePunctuation" type="info">
规范符号
</n-button>
<!-- <n-button @click="translateHandle(true)" type="info"
>重新翻译</n-button
> -->
<n-button
@click="handleLLMTranslateRequest(2)"
type="info"
quaternary
:loading="llmLoading"
>
帮帮我,GPT 先生
</n-button>
</n-space>
</div>
<div class="textLine">
Expand Down Expand Up @@ -178,7 +177,7 @@
@click="handleGotoPrevLineRequest"
>上一句
</n-button>
<span style="color: lightgray"
<span class="text-gray-300"
>当前位置: {{ completion.completed }} /
{{ completion.fullLength }}</span
>
Expand All @@ -189,7 +188,7 @@

<script setup lang="ts">
import { computed, ref, watch } from "vue";
import { halfToFull, translate } from "../../public/helper/getTranslation";
import { halfToFull } from "../../public/helper/getTranslation";
import { formalizeQuotation } from "../../public/helper/quotation";
import eventBus from "../eventsSystem/eventBus";
import { useGlobalConfig } from "../store/configStore";
Expand All @@ -215,15 +214,6 @@ const langHash = {
TextTw: "繁中",
};
const translateHash = {
TextJp: "ja",
TextEn: "en",
ScriptKr: "ko",
TextTh: "th",
TextCn: "zh-CHS",
TextTw: "zh-CHT",
};
const langSelect = [
{ label: "简体中文", key: "TextCn" },
{ label: "繁体中文", key: "TextTw" },
Expand All @@ -245,7 +235,7 @@ const translateHandle = (force = false) => {
const text = currentText.value
?.replaceAll("#n", "[#n]")
?.replaceAll(/\[.*?\]/g, "");
handleLLMTranslateRequest(0)
handleLLMTranslateRequest(0);
// translate(
// text,
// translateHash[config.getLanguage],
Expand Down Expand Up @@ -430,10 +420,6 @@ function addTag() {
sentence;
}
function sendResetLive2dSignal() {
eventBus.emit("resetLive2d");
}
function sendRefreshPlayerSignal() {
eventBus.emit("refreshPlayer");
}
Expand Down

0 comments on commit 2e3b99a

Please sign in to comment.