update article.ts
This commit is contained in:
4
components.d.ts
vendored
4
components.d.ts
vendored
@@ -21,11 +21,15 @@ declare module 'vue' {
|
||||
DictModal: typeof import('./src/components/Toolbar/DictModal.vue')['default']
|
||||
EditAbleText: typeof import('./src/components/EditAbleText.vue')['default']
|
||||
ElInput: typeof import('element-plus/es')['ElInput']
|
||||
ElInputNumber: typeof import('element-plus/es')['ElInputNumber']
|
||||
ElOption: typeof import('element-plus/es')['ElOption']
|
||||
ElProgress: typeof import('element-plus/es')['ElProgress']
|
||||
ElRadio: typeof import('element-plus/es')['ElRadio']
|
||||
ElRadioButton: typeof import('element-plus/es')['ElRadioButton']
|
||||
ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
|
||||
ElSelect: typeof import('element-plus/es')['ElSelect']
|
||||
ElSlider: typeof import('element-plus/es')['ElSlider']
|
||||
ElSwitch: typeof import('element-plus/es')['ElSwitch']
|
||||
FeedbackModal: typeof import('./src/components/Toolbar/FeedbackModal.vue')['default']
|
||||
Fireworks: typeof import('./src/components/Fireworks.vue')['default']
|
||||
Footer: typeof import('./src/components/Practice/Footer.vue')['default']
|
||||
|
||||
1299
pnpm-lock.yaml
generated
1299
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -7,8 +7,8 @@ import {
|
||||
getNetworkTranslate,
|
||||
getSentenceAllText,
|
||||
getSentenceAllTranslateText,
|
||||
updateLocalSentenceTranslate,
|
||||
updateSections
|
||||
renewSectionTranslates,
|
||||
renewSectionTexts
|
||||
} from "@/hooks/translate.ts";
|
||||
import * as copy from "copy-to-clipboard";
|
||||
import {getSplitTranslateText} from "@/hooks/article.ts";
|
||||
@@ -26,17 +26,18 @@ interface IProps {
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<IProps>(), {
|
||||
article: () => cloneDeep(DefaultArticle)
|
||||
article: () => DefaultArticle
|
||||
})
|
||||
|
||||
const base = useBaseStore()
|
||||
let article = $ref<Article>(props.article)
|
||||
let article = $ref<Article>(cloneDeep(props.article))
|
||||
let networkTranslateEngine = $ref('baidu')
|
||||
let progress = $ref(0)
|
||||
const TranslateEngineOptions = [
|
||||
{value: 'baidu', label: '百度'},
|
||||
{value: 'youdao', label: '有道'},
|
||||
]
|
||||
|
||||
const emit = defineEmits([
|
||||
'update:modelValue',
|
||||
'close',
|
||||
@@ -63,7 +64,7 @@ watch(() => props.article, n => {
|
||||
}
|
||||
}
|
||||
}
|
||||
updateSentenceTranslate()
|
||||
renewSections()
|
||||
}
|
||||
})
|
||||
|
||||
@@ -74,7 +75,7 @@ async function startNetworkTranslate() {
|
||||
if (!article.text.trim()) {
|
||||
return ElMessage.error('请填写正文!')
|
||||
}
|
||||
updateSections(article)
|
||||
renewSectionTexts(article)
|
||||
article.textNetworkTranslate = ''
|
||||
//注意!!!
|
||||
//这里需要用异步,因为watch了article.networkTranslate,改变networkTranslate了之后,会重新设置article.sections
|
||||
@@ -96,22 +97,23 @@ function saveSentenceTranslate(sentence: Sentence, val: string) {
|
||||
if (article.useTranslateType === TranslateType.network) {
|
||||
article.textNetworkTranslate = getSentenceAllTranslateText(article)
|
||||
}
|
||||
renewSections()
|
||||
}
|
||||
|
||||
function saveSentenceText(sentence: Sentence, val: string) {
|
||||
sentence.text = val
|
||||
article.text = getSentenceAllText(article)
|
||||
updateSentenceTranslate()
|
||||
renewSections()
|
||||
}
|
||||
|
||||
function updateSentenceTranslate() {
|
||||
function renewSections() {
|
||||
if (article.text.trim()) {
|
||||
updateSections(article)
|
||||
renewSectionTexts(article)
|
||||
if (article.useTranslateType === TranslateType.custom) {
|
||||
updateLocalSentenceTranslate(article, article.textCustomTranslate)
|
||||
renewSectionTranslates(article, article.textCustomTranslate)
|
||||
}
|
||||
if (article.useTranslateType === TranslateType.network) {
|
||||
updateLocalSentenceTranslate(article, article.textNetworkTranslate)
|
||||
renewSectionTranslates(article, article.textNetworkTranslate)
|
||||
}
|
||||
} else {
|
||||
article.sections = []
|
||||
@@ -132,14 +134,18 @@ function onPaste(event: ClipboardEvent) {
|
||||
// @ts-ignore
|
||||
let paste = (event.clipboardData || window.clipboardData).getData("text");
|
||||
return MessageBox.confirm(
|
||||
'是否需要进行自动分句',
|
||||
'是否需要自动分句',
|
||||
'提示',
|
||||
() => {
|
||||
let r = getSplitTranslateText(paste)
|
||||
if (r) appendTranslate(r)
|
||||
if (r) {
|
||||
appendTranslate(r)
|
||||
renewSections()
|
||||
}
|
||||
},
|
||||
() => {
|
||||
appendTranslate(paste)
|
||||
renewSections()
|
||||
},
|
||||
{
|
||||
confirmButtonText: '需要',
|
||||
@@ -234,38 +240,34 @@ function save(option: 'save' | 'next', mute: boolean = false) {
|
||||
saveTemp()
|
||||
}
|
||||
|
||||
watch(() => article.textCustomTranslate, (str: string) => {
|
||||
updateSentenceTranslate()
|
||||
})
|
||||
|
||||
watch(() => article.textNetworkTranslate, (str: string) => {
|
||||
updateSentenceTranslate()
|
||||
})
|
||||
|
||||
watch(() => article.useTranslateType, () => {
|
||||
function changeTranslateType() {
|
||||
if (article.text.trim()) {
|
||||
if (article.useTranslateType === TranslateType.custom) {
|
||||
if (article.textCustomTranslate.trim()) {
|
||||
updateLocalSentenceTranslate(article, article.textCustomTranslate)
|
||||
renewSectionTranslates(article, article.textCustomTranslate)
|
||||
} else {
|
||||
updateSections(article)
|
||||
renewSectionTexts(article)
|
||||
}
|
||||
}
|
||||
if (article.useTranslateType === TranslateType.network) {
|
||||
if (article.textNetworkTranslate.trim()) {
|
||||
updateLocalSentenceTranslate(article, article.textNetworkTranslate)
|
||||
renewSectionTranslates(article, article.textNetworkTranslate)
|
||||
} else {
|
||||
updateSections(article)
|
||||
renewSectionTexts(article)
|
||||
}
|
||||
}
|
||||
if (article.useTranslateType === TranslateType.none) {
|
||||
updateSections(article)
|
||||
renewSectionTexts(article)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function selectArticle(item: Article) {
|
||||
article = cloneDeep(item)
|
||||
if (!article?.sections?.length){
|
||||
renewSections()
|
||||
}
|
||||
console.log('article', article)
|
||||
}
|
||||
|
||||
function add() {
|
||||
@@ -319,7 +321,7 @@ function add() {
|
||||
<div class="label">正文:</div>
|
||||
<textarea
|
||||
v-model="article.text"
|
||||
@input="updateSentenceTranslate"
|
||||
@input="renewSections"
|
||||
:readonly="![100,0].includes(progress)"
|
||||
type="textarea"
|
||||
class="base-textarea"
|
||||
@@ -333,7 +335,10 @@ function add() {
|
||||
<div class="item">
|
||||
<div class="label">
|
||||
<span>标题:</span>
|
||||
<el-radio-group v-model="article.useTranslateType">
|
||||
<el-radio-group
|
||||
v-model="article.useTranslateType"
|
||||
@change="changeTranslateType"
|
||||
>
|
||||
<el-radio-button :label="TranslateType.custom">本地翻译</el-radio-button>
|
||||
<el-radio-button :label="TranslateType.network">网络翻译</el-radio-button>
|
||||
<el-radio-button :label="TranslateType.none">不需要翻译</el-radio-button>
|
||||
@@ -379,6 +384,7 @@ function add() {
|
||||
<textarea
|
||||
v-if="article.useTranslateType === TranslateType.custom"
|
||||
v-model="article.textCustomTranslate"
|
||||
@input="renewSections"
|
||||
:readonly="![100,0].includes(progress)"
|
||||
@blur="onBlur"
|
||||
@focus="onFocus"
|
||||
@@ -390,6 +396,7 @@ function add() {
|
||||
<textarea
|
||||
v-if="article.useTranslateType === TranslateType.network"
|
||||
v-model="article.textNetworkTranslate"
|
||||
@input="renewSections"
|
||||
@blur="onBlur"
|
||||
@focus="onFocus"
|
||||
type="textarea"
|
||||
@@ -554,6 +561,10 @@ function add() {
|
||||
.sentence {
|
||||
margin-bottom: 20rem;
|
||||
|
||||
&:last-child{
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.text {
|
||||
font-size: 18rem;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ onMounted(() => {
|
||||
|
||||
<template>
|
||||
<div id="BatchAddArticle">
|
||||
<AddArticle2/>
|
||||
<AddArticle2/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -37,6 +37,5 @@ onMounted(() => {
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
color: black;
|
||||
|
||||
}
|
||||
</style>
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
getNetworkTranslate,
|
||||
getSentenceAllText,
|
||||
getSentenceAllTranslateText,
|
||||
updateLocalSentenceTranslate, updateSections
|
||||
renewSectionTranslates, renewSectionTexts
|
||||
} from "@/hooks/translate.ts";
|
||||
import * as copy from "copy-to-clipboard";
|
||||
import {getSplitTranslateText, splitEnArticle} from "@/hooks/article.ts";
|
||||
@@ -78,7 +78,7 @@ async function startNetworkTranslate() {
|
||||
if (!article.text.trim()) {
|
||||
return ElMessage.error('请填写正文!')
|
||||
}
|
||||
updateSections(article)
|
||||
renewSectionTexts(article)
|
||||
article.textNetworkTranslate = ''
|
||||
//注意!!!
|
||||
//这里需要用异步,因为watch了article.networkTranslate,改变networkTranslate了之后,会重新设置article.sections
|
||||
@@ -110,12 +110,12 @@ function saveSentenceText(sentence: Sentence, val: string) {
|
||||
|
||||
function updateSentenceTranslate() {
|
||||
if (article.text.trim()) {
|
||||
updateSections(article)
|
||||
renewSectionTexts(article)
|
||||
if (article.useTranslateType === TranslateType.custom) {
|
||||
updateLocalSentenceTranslate(article, article.textCustomTranslate)
|
||||
renewSectionTranslates(article, article.textCustomTranslate)
|
||||
}
|
||||
if (article.useTranslateType === TranslateType.network) {
|
||||
updateLocalSentenceTranslate(article, article.textNetworkTranslate)
|
||||
renewSectionTranslates(article, article.textNetworkTranslate)
|
||||
}
|
||||
} else {
|
||||
article.sections = []
|
||||
@@ -220,20 +220,20 @@ watch(() => article.useTranslateType, () => {
|
||||
if (article.text.trim()) {
|
||||
if (article.useTranslateType === TranslateType.custom) {
|
||||
if (article.textCustomTranslate.trim()) {
|
||||
updateLocalSentenceTranslate(article, article.textCustomTranslate)
|
||||
renewSectionTranslates(article, article.textCustomTranslate)
|
||||
} else {
|
||||
updateSections(article)
|
||||
renewSectionTexts(article)
|
||||
}
|
||||
}
|
||||
if (article.useTranslateType === TranslateType.network) {
|
||||
if (article.textNetworkTranslate.trim()) {
|
||||
updateLocalSentenceTranslate(article, article.textNetworkTranslate)
|
||||
renewSectionTranslates(article, article.textNetworkTranslate)
|
||||
} else {
|
||||
updateSections(article)
|
||||
renewSectionTexts(article)
|
||||
}
|
||||
}
|
||||
if (article.useTranslateType === TranslateType.none) {
|
||||
updateSections(article)
|
||||
renewSectionTexts(article)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -16,7 +16,7 @@ import {Article, DefaultArticle, TranslateType} from "@/types.ts";
|
||||
import AddArticle from "@/components/Practice/AddArticle.vue";
|
||||
import {useStartKeyboardEventListener} from "@/hooks/event.ts";
|
||||
import {useRuntimeStore} from "@/stores/runtime.ts";
|
||||
import {updateLocalSentenceTranslate, updateSections} from "@/hooks/translate.ts";
|
||||
import {renewSectionTranslates, renewSectionTexts} from "@/hooks/translate.ts";
|
||||
import BaseButton from "@/components/BaseButton.vue";
|
||||
import {MessageBox} from "@/utils/MessageBox.tsx";
|
||||
|
||||
@@ -68,14 +68,14 @@ function getCurrentPractice() {
|
||||
articleData.article = tempArticle
|
||||
} else {
|
||||
if (tempArticle.useTranslateType === TranslateType.none) {
|
||||
updateSections(tempArticle)
|
||||
renewSectionTexts(tempArticle)
|
||||
articleData.article = tempArticle
|
||||
} else {
|
||||
if (tempArticle.useTranslateType === TranslateType.custom) {
|
||||
if (tempArticle.textCustomTranslate.trim()) {
|
||||
if (tempArticle.textCustomTranslateIsFormat) {
|
||||
updateSections(tempArticle)
|
||||
updateLocalSentenceTranslate(tempArticle, tempArticle.textCustomTranslate)
|
||||
renewSectionTexts(tempArticle)
|
||||
renewSectionTranslates(tempArticle, tempArticle.textCustomTranslate)
|
||||
articleData.article = tempArticle
|
||||
} else {
|
||||
//说明有本地翻译,但是没格式化成一行一行的
|
||||
@@ -86,7 +86,7 @@ function getCurrentPractice() {
|
||||
showEditArticle = true
|
||||
},
|
||||
() => {
|
||||
updateSections(tempArticle)
|
||||
renewSectionTexts(tempArticle)
|
||||
tempArticle.useTranslateType = TranslateType.none
|
||||
store.currentDict.articles[store.currentDict.chapterIndex] = articleData.article = tempArticle
|
||||
},
|
||||
@@ -105,7 +105,7 @@ function getCurrentPractice() {
|
||||
showEditArticle = true
|
||||
},
|
||||
() => {
|
||||
updateSections(tempArticle)
|
||||
renewSectionTexts(tempArticle)
|
||||
tempArticle.useTranslateType = TranslateType.none
|
||||
store.currentDict.articles[store.currentDict.chapterIndex] = articleData.article = tempArticle
|
||||
},
|
||||
@@ -117,8 +117,8 @@ function getCurrentPractice() {
|
||||
}
|
||||
|
||||
if (tempArticle.useTranslateType === TranslateType.network) {
|
||||
updateSections(tempArticle)
|
||||
updateLocalSentenceTranslate(tempArticle, tempArticle.textNetworkTranslate)
|
||||
renewSectionTexts(tempArticle)
|
||||
renewSectionTranslates(tempArticle, tempArticle.textNetworkTranslate)
|
||||
store.currentDict.articles[store.currentDict.chapterIndex] = articleData.article = tempArticle
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,33 +30,15 @@ export const EnKeyboardMap: KeyboardMap = {
|
||||
}
|
||||
|
||||
export function splitEnArticle(text: string): { sections: Sentence[][], newText: string } {
|
||||
console.time()
|
||||
// console.log(text)
|
||||
// console.time()
|
||||
let keyboardMap = EnKeyboardMap
|
||||
// text = "On Jan. 20, former Sen. Barack Obama became the 44th President of the U.S. Millions attended the Inauguration. It was Sunday? I never get up early on Sundays! I sometimes stay in bed until lunchtime. Last Sunday I got up very late. I looked out of the window. It was dark outside. 'What a day!' I thought. 'It's raining again.' Just then, the telephone rang. It was my aunt Lucy. 'I've just arrived by train,' she said. 'I'm coming to see you.'\n 'But I'm still having breakfast,' I said\n 'What are you doing?' she asked.\n 'I'm having breakfast,' I repeated.\n 'Dear me,' she said. 'Do you always get up so late? It's one o'clock'"
|
||||
// text = "Mr.James Scott has a garage in Silbury and now he has just bought another garage in Pinhurst. Pinhurst is only five miles from Silbury, but Mr. Scott cannot get a telephone for his new garage, so he has just bought twelve pigeons. Yesterday, a pigeon carried the first message from Pinhurst to Silbury. The bird covered the distance in three minutes. Up to now, Mr.Scott has sent a great many requests for spare parts and other urgent messages from one garage to the other. In this way, he has begun his own private 'telephone' service."
|
||||
// text = "How does the older investor differ in his approach to investment from the younger investor?\nThere is no shortage of tipsters around offering 'get-rich-quick' opportunities. But if you are a serious private investor, leave the Las Vegas mentality to those with money to fritter. The serious investor needs a proper 'portfolio' -- a well-planned selection of investments, with a definite structure and a clear aim. But exactly how does a newcomer to the stock market go about achieving that?\nWell, if you go to five reputable stock brokers and ask them what you should do with your money, you're likely to get five different answers, -- even if you give all the relevant information about your age age, family, finances and what you want from your investments. Moral? There is no one 'right' way to structure a portfolio. However, there are undoubtedly some wrong ways, and you can be sure that none of our five advisers would have suggested sinking all (or perhaps any) of your money into Periwigs*.\nSo what should you do? We'll assume that you have sorted out the basics -- like mortgages, pensions, insurance and access to sufficient cash reserves. You should then establish your own individual aims. These are partly a matter of personal circumstances, partly a matter of psychology.\nFor instance, if you are older you have less time to recover from any major losses, and you may well wish to boost your pension income. So preserving your capital and generating extra income are your main priorities. In this case, you'd probably construct a portfolio with some shares (but not high risk ones), along with gilts, cash deposits, and perhaps convertibles or the income shares of split capital investment trusts.\nIf you are younger, and in a solid financial position, you may decide to take an aggressive approach -- but only if you're blessed with a sanguine disposition and won't suffer sleepless nights over share prices. If portfolio, alongside your more pedestrian in vestments. Once you have decided on your investment aims, you can then decide where to put your money. The golden rule here is spread your risk -- if you put all of your money into Periwigs International, you're setting yourself up as a hostage to fortune.\n*'Periwigs' is the name of a fictitious company.\nINVESTOR'S CHRONICLE, March 23 1990"
|
||||
|
||||
//去除头和尾部的空格
|
||||
text = text.trim()
|
||||
// text = text.replaceAll(`‘`, '"')
|
||||
// text = text.replaceAll(`’`, '"')
|
||||
// text = text.replaceAll(`“`, '"')
|
||||
// text = text.replaceAll(`”`, '"')
|
||||
// 替换所有单引号为双引号
|
||||
// text = text.replaceAll(`'`, '"')
|
||||
// 将缩写词的双引号替换回单引号
|
||||
// text = text.replaceAll(`"t`, `'t`)
|
||||
// text = text.replaceAll(`"s`, `'s`)
|
||||
// text = text.replaceAll(`"S`, `'S`)
|
||||
// text = text.replaceAll(`"m`, `'m`)
|
||||
// text = text.replaceAll(`"d`, `'d`)
|
||||
// text = text.replaceAll(`"ve`, `'ve`)
|
||||
// text = text.replaceAll(`"re`, `'re`)
|
||||
// text = text.replaceAll(`"clock`, `'clock`)
|
||||
// console.log('splitEnArticle', text)
|
||||
|
||||
let sections: Sentence[][] = []
|
||||
text && text.split('\n').map((rowSection, i) => {
|
||||
text && text.trim().split('\n').map((rowSection, i) => {
|
||||
let section: Sentence[] = []
|
||||
sections.push(section)
|
||||
rowSection = rowSection.trim()
|
||||
@@ -66,7 +48,8 @@ export function splitEnArticle(text: string): { sections: Sentence[][], newText:
|
||||
// console.log('--')
|
||||
sentences.map(sentenceRow => {
|
||||
let sentence: Sentence = {
|
||||
text: sentenceRow.text,
|
||||
//他没有空格,导致修改一行一行的数据时,汇总时全没有空格了,库无法正常断句
|
||||
text: sentenceRow.text + ' ',
|
||||
// text: '',
|
||||
translate: '',
|
||||
words: []
|
||||
|
||||
@@ -4,7 +4,7 @@ import {axiosInstance} from "@/utils/http.ts";
|
||||
import {getSplitTranslateText, splitEnArticle} from "@/hooks/article.ts";
|
||||
import {Translator} from "@opentranslate/translator/src/translator.ts";
|
||||
|
||||
export function updateLocalSentenceTranslate(article: Article, translate: string) {
|
||||
export function renewSectionTranslates(article: Article, translate: string) {
|
||||
if (translate.trim()) {
|
||||
let articleTranslate = translate.split('\n')
|
||||
// console.log('articleTranslate', articleTranslate)
|
||||
@@ -63,7 +63,7 @@ export async function getNetworkTranslate(
|
||||
progressCb?: (val: number) => void
|
||||
) {
|
||||
if (article.textNetworkTranslate) {
|
||||
updateLocalSentenceTranslate(article, article.textNetworkTranslate)
|
||||
renewSectionTranslates(article, article.textNetworkTranslate)
|
||||
} else {
|
||||
let translator: Translator
|
||||
if (translateEngine === TranslateEngine.Baidu) {
|
||||
@@ -190,7 +190,7 @@ export async function getNetworkTranslate(
|
||||
}
|
||||
}
|
||||
|
||||
export function updateSections(article: Article) {
|
||||
export function renewSectionTexts(article: Article) {
|
||||
let {newText, sections} = splitEnArticle(article.text)
|
||||
article.text = newText
|
||||
article.sections = sections
|
||||
@@ -204,19 +204,19 @@ export function test(article: Article) {
|
||||
} else {
|
||||
if (article.useTranslateType !== undefined) {
|
||||
if (article.useTranslateType) {
|
||||
updateLocalSentenceTranslate(article, article.textCustomTranslate)
|
||||
renewSectionTranslates(article, article.textCustomTranslate)
|
||||
} else {
|
||||
updateLocalSentenceTranslate(article, article.textNetworkTranslate)
|
||||
renewSectionTranslates(article, article.textNetworkTranslate)
|
||||
}
|
||||
} else {
|
||||
// article.sections = splitEnArticle(article.article)
|
||||
if (article.textCustomTranslate) {
|
||||
article.textCustomTranslate = getSplitTranslateText(article.textCustomTranslate)
|
||||
updateLocalSentenceTranslate(article, article.textCustomTranslate)
|
||||
renewSectionTranslates(article, article.textCustomTranslate)
|
||||
article.useTranslateType = TranslateType.custom
|
||||
} else {
|
||||
article.textNetworkTranslate = getSplitTranslateText(article.textNetworkTranslate)
|
||||
updateLocalSentenceTranslate(article, article.textCustomTranslate)
|
||||
renewSectionTranslates(article, article.textCustomTranslate)
|
||||
article.useTranslateType = TranslateType.network
|
||||
}
|
||||
}
|
||||
|
||||
256
src/types.ts
256
src/types.ts
@@ -1,17 +1,17 @@
|
||||
import {v4 as uuidv4} from 'uuid';
|
||||
|
||||
export type Word = {
|
||||
"name": string,
|
||||
"usphone": string,
|
||||
"ukphone": string,
|
||||
"trans": string[]
|
||||
"name": string,
|
||||
"usphone": string,
|
||||
"ukphone": string,
|
||||
"trans": string[]
|
||||
}
|
||||
|
||||
export const DefaultWord: Word = {
|
||||
name: '',
|
||||
usphone: '',
|
||||
ukphone: '',
|
||||
trans: []
|
||||
name: '',
|
||||
usphone: '',
|
||||
ukphone: '',
|
||||
trans: []
|
||||
}
|
||||
|
||||
export const SaveDictKey = 'typing-word-dict'
|
||||
@@ -26,184 +26,186 @@ export type LanguageCategoryType = 'en' | 'ja' | 'de' | 'code'
|
||||
|
||||
|
||||
export type DictionaryResource = {
|
||||
id: string
|
||||
name: string
|
||||
description: string
|
||||
category: string
|
||||
tags: string[]
|
||||
url: string
|
||||
length: number
|
||||
language: LanguageType
|
||||
languageCategory: LanguageCategoryType
|
||||
//override default pronunciation when not undefined
|
||||
defaultPronIndex?: number
|
||||
id: string
|
||||
name: string
|
||||
description: string
|
||||
category: string
|
||||
tags: string[]
|
||||
url: string
|
||||
length: number
|
||||
language: LanguageType
|
||||
languageCategory: LanguageCategoryType
|
||||
//override default pronunciation when not undefined
|
||||
defaultPronIndex?: number
|
||||
}
|
||||
|
||||
export type Dictionary = {
|
||||
id: string
|
||||
name: string
|
||||
description: string
|
||||
category: string
|
||||
tags: string[]
|
||||
url: string
|
||||
length: number
|
||||
language: LanguageType
|
||||
languageCategory: LanguageCategoryType
|
||||
// calculated in the store
|
||||
chapterCount: number
|
||||
//override default pronunciation when not undefined
|
||||
defaultPronIndex?: number
|
||||
id: string
|
||||
name: string
|
||||
description: string
|
||||
category: string
|
||||
tags: string[]
|
||||
url: string
|
||||
length: number
|
||||
language: LanguageType
|
||||
languageCategory: LanguageCategoryType
|
||||
// calculated in the store
|
||||
chapterCount: number
|
||||
//override default pronunciation when not undefined
|
||||
defaultPronIndex?: number
|
||||
}
|
||||
|
||||
export type PronunciationConfig = {
|
||||
name: string
|
||||
pron: PronunciationType
|
||||
name: string
|
||||
pron: PronunciationType
|
||||
}
|
||||
|
||||
export type LanguagePronunciationMapConfig = {
|
||||
defaultPronIndex: number
|
||||
pronunciation: PronunciationConfig[]
|
||||
defaultPronIndex: number
|
||||
pronunciation: PronunciationConfig[]
|
||||
}
|
||||
|
||||
export type LanguagePronunciationMap = {
|
||||
[key in LanguageType]: LanguagePronunciationMapConfig
|
||||
[key in LanguageType]: LanguagePronunciationMapConfig
|
||||
}
|
||||
|
||||
export type SoundResource = {
|
||||
key: string
|
||||
name: string
|
||||
filename: string
|
||||
key: string
|
||||
name: string
|
||||
filename: string
|
||||
}
|
||||
|
||||
export interface DictJson {
|
||||
description: string,
|
||||
category: string,
|
||||
tags: string[],
|
||||
url: string,
|
||||
length: number,
|
||||
language: string,
|
||||
languageCategory: string,
|
||||
description: string,
|
||||
category: string,
|
||||
tags: string[],
|
||||
url: string,
|
||||
length: number,
|
||||
language: string,
|
||||
languageCategory: string,
|
||||
}
|
||||
|
||||
export enum DictType {
|
||||
newDict = 'newDict',
|
||||
skipDict = 'skipDict',
|
||||
wrongDict = 'wrongDict',
|
||||
publicDict = 'publicDict',
|
||||
customDict = 'customDict',
|
||||
publicArticle = 'publicArticle',
|
||||
customArticle = 'customArticle'
|
||||
newDict = 'newDict',
|
||||
skipDict = 'skipDict',
|
||||
wrongDict = 'wrongDict',
|
||||
publicDict = 'publicDict',
|
||||
customDict = 'customDict',
|
||||
publicArticle = 'publicArticle',
|
||||
customArticle = 'customArticle'
|
||||
}
|
||||
|
||||
export const DefaultArticleWord: ArticleWord = {
|
||||
name: '',
|
||||
usphone: '',
|
||||
ukphone: '',
|
||||
trans: [],
|
||||
nextSpace: true,
|
||||
isSymbol: false,
|
||||
symbolPosition: ''
|
||||
name: '',
|
||||
usphone: '',
|
||||
ukphone: '',
|
||||
trans: [],
|
||||
nextSpace: true,
|
||||
isSymbol: false,
|
||||
symbolPosition: ''
|
||||
}
|
||||
|
||||
export interface ArticleWord extends Word {
|
||||
nextSpace: boolean,
|
||||
isSymbol: boolean,
|
||||
symbolPosition: 'start' | 'end' | '',
|
||||
nextSpace: boolean,
|
||||
isSymbol: boolean,
|
||||
symbolPosition: 'start' | 'end' | '',
|
||||
}
|
||||
|
||||
export interface Sentence {
|
||||
text: string,
|
||||
translate: string,
|
||||
words: ArticleWord[]
|
||||
text: string,
|
||||
translate: string,
|
||||
words: ArticleWord[]
|
||||
}
|
||||
|
||||
export enum TranslateType {
|
||||
custom = 'custom',
|
||||
network = 'network',
|
||||
none = 'none'
|
||||
custom = 'custom',
|
||||
network = 'network',
|
||||
none = 'none'
|
||||
}
|
||||
|
||||
export interface Article {
|
||||
id: string,
|
||||
title: string,
|
||||
titleTranslate: string,
|
||||
text: string,
|
||||
textCustomTranslate: string,
|
||||
textCustomTranslateIsFormat: boolean,//翻译是否格式化
|
||||
textNetworkTranslate: string,
|
||||
newWords: Word[],
|
||||
textAllWords: string[],
|
||||
sections: Sentence[][],
|
||||
useTranslateType: TranslateType
|
||||
id: string,
|
||||
title: string,
|
||||
titleTranslate: string,
|
||||
text: string,
|
||||
textFormat: string,
|
||||
textCustomTranslate: string,
|
||||
textCustomTranslateIsFormat: boolean,//翻译是否格式化
|
||||
textNetworkTranslate: string,
|
||||
newWords: Word[],
|
||||
textAllWords: string[],
|
||||
sections: Sentence[][],
|
||||
useTranslateType: TranslateType
|
||||
}
|
||||
|
||||
export const DefaultArticle: Article = {
|
||||
// id: uuidv4(),
|
||||
id: '',
|
||||
title: '',
|
||||
titleTranslate: '',
|
||||
text: '',
|
||||
textCustomTranslate: '',
|
||||
textNetworkTranslate: '',
|
||||
textCustomTranslateIsFormat: false,
|
||||
newWords: [],
|
||||
textAllWords: [],
|
||||
sections: [],
|
||||
useTranslateType: TranslateType.network
|
||||
// id: uuidv4(),
|
||||
id: '',
|
||||
title: '',
|
||||
titleTranslate: '',
|
||||
text: '',
|
||||
textFormat: '',
|
||||
textCustomTranslate: '',
|
||||
textNetworkTranslate: '',
|
||||
textCustomTranslateIsFormat: false,
|
||||
newWords: [],
|
||||
textAllWords: [],
|
||||
sections: [],
|
||||
useTranslateType: TranslateType.network
|
||||
}
|
||||
|
||||
export interface Dict {
|
||||
name: string,
|
||||
sort: Sort,
|
||||
type: DictType,
|
||||
originWords: Word[],//原始单词
|
||||
words: Word[],
|
||||
chapterWordNumber: number,//章节单词数量
|
||||
chapterWords: Word[][],
|
||||
articles: Article[],
|
||||
chapterIndex: number,
|
||||
chapterWordIndex: number,
|
||||
statistics: Statistics[],
|
||||
url: string,
|
||||
name: string,
|
||||
sort: Sort,
|
||||
type: DictType,
|
||||
originWords: Word[],//原始单词
|
||||
words: Word[],
|
||||
chapterWordNumber: number,//章节单词数量
|
||||
chapterWords: Word[][],
|
||||
articles: Article[],
|
||||
chapterIndex: number,
|
||||
chapterWordIndex: number,
|
||||
statistics: Statistics[],
|
||||
url: string,
|
||||
}
|
||||
|
||||
export interface Statistics {
|
||||
startDate: number,//开始日期
|
||||
endDate: number//结束日期
|
||||
spend: number,//花费时间
|
||||
total: number//单词数量
|
||||
wrongWordNumber: number//错误数
|
||||
correctRate: number//正确率
|
||||
startDate: number,//开始日期
|
||||
endDate: number//结束日期
|
||||
spend: number,//花费时间
|
||||
total: number//单词数量
|
||||
wrongWordNumber: number//错误数
|
||||
correctRate: number//正确率
|
||||
}
|
||||
|
||||
export interface DisplayStatistics extends Statistics {
|
||||
wrongWords: Word[]
|
||||
wrongWords: Word[]
|
||||
}
|
||||
|
||||
export const DefaultDisplayStatistics: DisplayStatistics = {
|
||||
startDate: Date.now(),
|
||||
endDate: -1,
|
||||
spend: -1,
|
||||
total: -1,
|
||||
correctRate: -1,
|
||||
wrongWordNumber: -1,
|
||||
wrongWords: [],
|
||||
startDate: Date.now(),
|
||||
endDate: -1,
|
||||
spend: -1,
|
||||
total: -1,
|
||||
correctRate: -1,
|
||||
wrongWordNumber: -1,
|
||||
wrongWords: [],
|
||||
}
|
||||
|
||||
export enum Sort {
|
||||
normal = 0,
|
||||
random = 1,
|
||||
reverse = 2
|
||||
normal = 0,
|
||||
random = 1,
|
||||
reverse = 2
|
||||
}
|
||||
|
||||
|
||||
export const ShortKeyMap = {
|
||||
Show: 'Escape',
|
||||
Ignore: 'Tab',
|
||||
Remove: '`',
|
||||
Collect: 'Enter',
|
||||
Show: 'Escape',
|
||||
Ignore: 'Tab',
|
||||
Remove: '`',
|
||||
Collect: 'Enter',
|
||||
}
|
||||
|
||||
export enum TranslateEngine {
|
||||
Baidu = 0,
|
||||
Baidu = 0,
|
||||
}
|
||||
Reference in New Issue
Block a user