save
This commit is contained in:
@@ -6,10 +6,11 @@ import {useEsc} from "@/hooks/event.ts";
|
||||
import {$ref} from "vue/macros";
|
||||
import BaseButton from "@/components/BaseButton.vue";
|
||||
|
||||
interface IProps {
|
||||
export interface ModalProps {
|
||||
modelValue?: boolean,
|
||||
showClose?: boolean,
|
||||
title?: string,
|
||||
content?: string,
|
||||
fullScreen?: boolean;
|
||||
padding?: boolean
|
||||
footer?: boolean
|
||||
@@ -18,7 +19,7 @@ interface IProps {
|
||||
cancelButtonText?: string
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<IProps>(), {
|
||||
const props = withDefaults(defineProps<ModalProps>(), {
|
||||
modelValue: undefined,
|
||||
showClose: true,
|
||||
fullScreen: false,
|
||||
@@ -56,7 +57,6 @@ function close() {
|
||||
setTimeout(() => {
|
||||
emit('update:modelValue', false)
|
||||
emit('close')
|
||||
emit('cancel')
|
||||
visible = false
|
||||
resolve(true)
|
||||
}, closeTime)
|
||||
@@ -81,6 +81,16 @@ onMounted(() => {
|
||||
|
||||
useEsc(close, () => props.modelValue)
|
||||
|
||||
async function ok() {
|
||||
await close()
|
||||
emit('ok')
|
||||
}
|
||||
|
||||
async function cancel() {
|
||||
await close()
|
||||
emit('cancel')
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -89,12 +99,13 @@ useEsc(close, () => props.modelValue)
|
||||
<div class="modal-mask"
|
||||
ref="maskRef"
|
||||
v-if="!fullScreen"
|
||||
@click="close"></div>
|
||||
@click.stop="close"></div>
|
||||
<div class="modal"
|
||||
ref="modalRef"
|
||||
:class="[
|
||||
fullScreen?'full':'window'
|
||||
]"
|
||||
@click.stop="null"
|
||||
>
|
||||
<div class="modal-header" v-if="header">
|
||||
<div class="title">{{ props.title }}</div>
|
||||
@@ -108,13 +119,14 @@ useEsc(close, () => props.modelValue)
|
||||
</div>
|
||||
<div class="modal-body" :class="{padding}">
|
||||
<slot></slot>
|
||||
<div v-if="content" class="content">{{ content }}</div>
|
||||
</div>
|
||||
<div class="modal-footer" v-if="footer">
|
||||
<div class="left">
|
||||
</div>
|
||||
<div class="right">
|
||||
<BaseButton type="link" @click="close">取消</BaseButton>
|
||||
<BaseButton @click="emit('ok'),close()">确定</BaseButton>
|
||||
<BaseButton type="link" @click="cancel">{{ cancelButtonText }}</BaseButton>
|
||||
<BaseButton @click="ok">{{ confirmButtonText }}</BaseButton>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -252,6 +264,12 @@ $header-height: 60rem;
|
||||
&.padding {
|
||||
padding: 4rem 24rem 24rem;
|
||||
}
|
||||
|
||||
.content {
|
||||
width: 350rem;
|
||||
color: black;
|
||||
padding: 4rem 24rem 24rem;
|
||||
}
|
||||
}
|
||||
|
||||
.modal-footer {
|
||||
|
||||
@@ -135,16 +135,21 @@ function onPaste(event: ClipboardEvent) {
|
||||
event.preventDefault()
|
||||
// @ts-ignore
|
||||
let paste = (event.clipboardData || window.clipboardData).getData("text");
|
||||
ElMessageBox.confirm('', '是否需要进行自动分句?', {
|
||||
confirmButtonText: '需要',
|
||||
cancelButtonText: '关闭',
|
||||
type: 'warning',
|
||||
}).then(() => {
|
||||
let r = getSplitTranslateText(paste)
|
||||
if (r) appendTranslate(r)
|
||||
}).catch(() => {
|
||||
appendTranslate(paste)
|
||||
})
|
||||
return MessageBox.confirm(
|
||||
'是否需要进行自动分句',
|
||||
'提示',
|
||||
() => {
|
||||
let r = getSplitTranslateText(paste)
|
||||
if (r) appendTranslate(r)
|
||||
},
|
||||
() => {
|
||||
appendTranslate(paste)
|
||||
},
|
||||
{
|
||||
confirmButtonText: '需要',
|
||||
cancelButtonText: '关闭',
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
function onBlur() {
|
||||
@@ -174,37 +179,29 @@ function save() {
|
||||
|
||||
if (article.useTranslateType === TranslateType.network) {
|
||||
if (!article.textNetworkTranslate.trim()) {
|
||||
// MessageBox.confirm(
|
||||
// '您选择了“网络翻译”,但译文内容却为空白,是否修改为“不需要翻译”并保存?',
|
||||
// '提示',
|
||||
// () => {
|
||||
// // article.useTranslateType = TranslateType.none
|
||||
// // saveTemp()
|
||||
// },
|
||||
// () => void 0,
|
||||
// )
|
||||
// return
|
||||
return ElMessageBox.confirm('您选择了“网络翻译”,但译文内容却为空白,是否修改为“不需要翻译”并保存?', '提示', {
|
||||
confirmButtonText: '确认',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}).then(() => {
|
||||
article.useTranslateType = TranslateType.none
|
||||
saveTemp()
|
||||
}).catch(() => void 0)
|
||||
return MessageBox.confirm(
|
||||
'您选择了“网络翻译”,但译文内容却为空白,是否修改为“不需要翻译”并保存?',
|
||||
'提示',
|
||||
() => {
|
||||
article.useTranslateType = TranslateType.none
|
||||
saveTemp()
|
||||
},
|
||||
() => void 0,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (article.useTranslateType === TranslateType.custom) {
|
||||
if (!article.textCustomTranslate.trim()) {
|
||||
return ElMessageBox.confirm('您选择了“本地翻译”,但译文内容却为空白,是否修改为“不需要翻译”并保存?', '提示', {
|
||||
confirmButtonText: '确认',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}).then(() => {
|
||||
article.useTranslateType = TranslateType.none
|
||||
saveTemp()
|
||||
}).catch(() => void 0)
|
||||
return MessageBox.confirm(
|
||||
'您选择了“本地翻译”,但译文内容却为空白,是否修改为“不需要翻译”并保存?',
|
||||
'提示',
|
||||
() => {
|
||||
article.useTranslateType = TranslateType.none
|
||||
saveTemp()
|
||||
},
|
||||
() => void 0,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,7 +243,6 @@ watch(() => article.useTranslateType, () => {
|
||||
<template>
|
||||
<Modal
|
||||
:model-value="props.modelValue"
|
||||
@close="emit('update:modelValue')"
|
||||
:full-screen="true"
|
||||
>
|
||||
<div class="add-article" @click.stop="null">
|
||||
|
||||
@@ -38,13 +38,6 @@ onUnmounted(() => {
|
||||
|
||||
<template>
|
||||
<div class="footer" :class="!settingStore.showToolbar && 'hide'">
|
||||
<Tooltip :title="settingStore.showToolbar?'收起':'展开'">
|
||||
<Icon icon="icon-park-outline:down"
|
||||
@click="settingStore.showToolbar = !settingStore.showToolbar"
|
||||
class="arrow"
|
||||
:class="!settingStore.showToolbar && 'down'"
|
||||
width="24" color="#999"/>
|
||||
</Tooltip>
|
||||
<div class="bottom">
|
||||
<el-progress :percentage="progress"
|
||||
:stroke-width="8"
|
||||
@@ -99,25 +92,10 @@ onUnmounted(() => {
|
||||
margin-bottom: -90rem;
|
||||
margin-top: 65rem;
|
||||
|
||||
.arrow {
|
||||
transform: translate3d(-50%, -220%, 0) rotate(180deg);
|
||||
}
|
||||
|
||||
.progress {
|
||||
bottom: calc(100% + 30rem);
|
||||
}
|
||||
}
|
||||
|
||||
.arrow {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 50%;
|
||||
cursor: pointer;
|
||||
transition: all .3s;
|
||||
transform: translate3d(-50%, -100%, 0) rotate(0);
|
||||
padding: 5rem;
|
||||
}
|
||||
|
||||
.bottom {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
@@ -146,7 +124,6 @@ onUnmounted(() => {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.progress {
|
||||
|
||||
@@ -59,7 +59,7 @@ watch(() => store.load, n => {
|
||||
|
||||
function getCurrentPractice() {
|
||||
if (store.isArticle) {
|
||||
// return
|
||||
return
|
||||
let tempArticle = {...DefaultArticle, ...store.currentDict.articles[store.currentDict.chapterIndex]}
|
||||
console.log('article', tempArticle)
|
||||
if (tempArticle.sections.length) {
|
||||
@@ -77,33 +77,40 @@ function getCurrentPractice() {
|
||||
articleData.article = tempArticle
|
||||
} else {
|
||||
//说明有本地翻译,但是没格式化成一行一行的
|
||||
ElMessageBox.confirm('', '检测到存在本地翻译,但未格式化,是否进行编辑?', {
|
||||
confirmButtonText: '去编辑',
|
||||
cancelButtonText: '不需要翻译',
|
||||
type: 'warning',
|
||||
}).then(() => {
|
||||
editArticle = tempArticle
|
||||
showEditArticle = true
|
||||
}).catch(() => {
|
||||
updateSections(tempArticle)
|
||||
tempArticle.useTranslateType = TranslateType.none
|
||||
articleData.article = tempArticle
|
||||
})
|
||||
MessageBox.confirm('检测到存在本地翻译,但未格式化,是否进行编辑?',
|
||||
'提示',
|
||||
() => {
|
||||
editArticle = tempArticle
|
||||
showEditArticle = true
|
||||
},
|
||||
() => {
|
||||
updateSections(tempArticle)
|
||||
tempArticle.useTranslateType = TranslateType.none
|
||||
articleData.article = tempArticle
|
||||
},
|
||||
{
|
||||
confirmButtonText: '去编辑',
|
||||
cancelButtonText: '不需要翻译',
|
||||
})
|
||||
}
|
||||
} else {
|
||||
//没有本地翻译
|
||||
ElMessageBox.confirm('', '没有本地翻译,是否进行编辑?', {
|
||||
confirmButtonText: '去编辑',
|
||||
cancelButtonText: '不需要翻译',
|
||||
type: 'warning',
|
||||
}).then(() => {
|
||||
editArticle = tempArticle
|
||||
showEditArticle = true
|
||||
}).catch(() => {
|
||||
updateSections(tempArticle)
|
||||
tempArticle.useTranslateType = TranslateType.none
|
||||
articleData.article = tempArticle
|
||||
})
|
||||
MessageBox.confirm(
|
||||
'没有本地翻译,是否进行编辑?',
|
||||
'提示',
|
||||
() => {
|
||||
editArticle = tempArticle
|
||||
showEditArticle = true
|
||||
},
|
||||
() => {
|
||||
updateSections(tempArticle)
|
||||
tempArticle.useTranslateType = TranslateType.none
|
||||
articleData.article = tempArticle
|
||||
},
|
||||
{
|
||||
confirmButtonText: '去编辑',
|
||||
cancelButtonText: '不需要翻译',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,7 +174,7 @@ function test() {
|
||||
<template>
|
||||
<div class="practice">
|
||||
<Toolbar/>
|
||||
<!-- <BaseButton @click="test">test</BaseButton>-->
|
||||
<!-- <BaseButton @click="test">test</BaseButton>-->
|
||||
|
||||
<TypeArticle
|
||||
v-if="store.isArticle"
|
||||
|
||||
Reference in New Issue
Block a user