LaiTool V3.0.1-preview.5
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
show-trigger
|
||||
@collapse="collapsed = true"
|
||||
@expand="collapsed = false"
|
||||
style="position: relative"
|
||||
>
|
||||
<n-menu
|
||||
:collapsed="collapsed"
|
||||
@@ -18,7 +19,8 @@
|
||||
:options="menuOptions"
|
||||
:render-icon="renderMenuIcon"
|
||||
:expand-icon="expandIcon"
|
||||
/>
|
||||
>
|
||||
</n-menu>
|
||||
</n-layout-sider>
|
||||
<n-layout-content content-style="padding: 20px 5px 5px 20px; height:100%">
|
||||
<!-- <Setting></Setting> -->
|
||||
@@ -52,7 +54,7 @@ import {
|
||||
DuplicateOutline,
|
||||
GridOutline,
|
||||
RadioOutline,
|
||||
BookOutline,
|
||||
BookOutline
|
||||
} from '@vicons/ionicons5'
|
||||
import CheckMachineId from '../Components/CheckMachineId.vue'
|
||||
import { DEFINE_STRING } from '../../../../define/define_string'
|
||||
@@ -242,7 +244,8 @@ export default defineComponent({
|
||||
{
|
||||
to: {
|
||||
name: 'gptCopywriting'
|
||||
}
|
||||
},
|
||||
class: 'router-link-a'
|
||||
},
|
||||
{
|
||||
default: () => '文案处理'
|
||||
@@ -382,6 +385,36 @@ export default defineComponent({
|
||||
// ]
|
||||
|
||||
// },
|
||||
{
|
||||
label: () =>
|
||||
h(
|
||||
RouterLink,
|
||||
{
|
||||
to: {
|
||||
name: 'lai_api'
|
||||
}
|
||||
},
|
||||
{
|
||||
default: () => 'API服务'
|
||||
}
|
||||
),
|
||||
key: 'lai_api'
|
||||
},
|
||||
{
|
||||
label: () =>
|
||||
h(
|
||||
RouterLink,
|
||||
{
|
||||
to: {
|
||||
name: 'TTS_Services'
|
||||
}
|
||||
},
|
||||
{
|
||||
default: () => '语音服务'
|
||||
}
|
||||
),
|
||||
key: 'TTS_Services'
|
||||
},
|
||||
{
|
||||
label: '设置',
|
||||
key: 'setting',
|
||||
@@ -453,39 +486,13 @@ export default defineComponent({
|
||||
key: 'mj_setting'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: () =>
|
||||
h(
|
||||
RouterLink,
|
||||
{
|
||||
to: {
|
||||
name: 'lai_api'
|
||||
}
|
||||
},
|
||||
{
|
||||
default: () => 'API服务'
|
||||
}
|
||||
),
|
||||
key: 'lai_api'
|
||||
},
|
||||
{
|
||||
label: () =>
|
||||
h(
|
||||
RouterLink,
|
||||
{
|
||||
to: {
|
||||
name: 'TTS_Services'
|
||||
}
|
||||
},
|
||||
{
|
||||
default: () => '语音服务'
|
||||
}
|
||||
),
|
||||
key: 'TTS_Services'
|
||||
}
|
||||
]
|
||||
|
||||
function renderIcon(icon) {
|
||||
return () => h(NIcon, null, { default: () => h(icon) })
|
||||
}
|
||||
|
||||
return {
|
||||
renderMenuIcon,
|
||||
menuOptions,
|
||||
|
||||
@@ -185,7 +185,9 @@ export default defineComponent({
|
||||
chinese_prompt: characterData.value.chinese_prompt,
|
||||
prompt: characterData.value.prompt,
|
||||
image_url: characterData.value.image_url,
|
||||
show_image: characterData.value.show_image,
|
||||
show_image: characterData.value.show_image
|
||||
? characterData.value.show_image.split('?t')[0]
|
||||
: null,
|
||||
cref_cw: characterData.value.cref_cw,
|
||||
lora: characterData.value.lora,
|
||||
lora_weight: characterData.value.lora_weight
|
||||
@@ -194,6 +196,9 @@ export default defineComponent({
|
||||
characterData.value['children'] = children
|
||||
console.log(characterData.value)
|
||||
characterData.value['type'] = 'character_main'
|
||||
characterData.value['show_image'] = characterData.value.show_image
|
||||
? characterData.value.show_image.split('?t')[0]
|
||||
: null
|
||||
// 开始保存
|
||||
await window.mj.SaveTagPropertyData(
|
||||
[JSON.stringify(characterData.value), 'character_tags'],
|
||||
|
||||
@@ -26,11 +26,6 @@
|
||||
<n-form-item label="语调">
|
||||
<n-input-number v-model:value="settingStore.ttsSetting.edgeTTS.pitch" :min="0" :max="100" />
|
||||
</n-form-item>
|
||||
<n-form-item label="生成SRT">
|
||||
<n-checkbox v-model:checked="settingStore.ttsSetting.edgeTTS.saveSubtitles">
|
||||
复选框
|
||||
</n-checkbox>
|
||||
</n-form-item>
|
||||
</n-form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
<template>
|
||||
<div id="tts-history">
|
||||
<n-data-table
|
||||
remote
|
||||
ref="table"
|
||||
:columns="columns"
|
||||
:data="data"
|
||||
:loading="loading"
|
||||
:pagination="pagination"
|
||||
:row-key="rowKey"
|
||||
@update:page="handlePageChange"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted, defineComponent, onUnmounted, toRaw, reactive, h } from 'vue'
|
||||
import { useMessage, NDataTable } from 'naive-ui'
|
||||
import TTSHistoryAction from './TTSHistoryAction.vue'
|
||||
import TTSHistoryShowPath from './TTSHistoryShowPath.vue'
|
||||
|
||||
let props = defineProps({
|
||||
height: {
|
||||
type: Number,
|
||||
default: 0
|
||||
}
|
||||
})
|
||||
let height = ref(props.height)
|
||||
let data = ref([])
|
||||
let message = useMessage()
|
||||
let loading = ref(false)
|
||||
let rowKey = (rowData) => {
|
||||
return rowData.id
|
||||
}
|
||||
const pagination = reactive({
|
||||
page: 0,
|
||||
pageCount: 0,
|
||||
pageSize: 20,
|
||||
prefix({ itemCount }) {
|
||||
return `Total is ${itemCount}.`
|
||||
}
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
// 加载的时候设置高度和滚动条
|
||||
let div = document.getElementById('tts-history')
|
||||
div.style.height = height.value - 70 + 'px'
|
||||
div.style.overflow = 'auto'
|
||||
await GetTTSHistoryData(pagination.page)
|
||||
})
|
||||
|
||||
async function GetTTSHistoryData(currentPage) {
|
||||
// 这边加载数据
|
||||
if (!loading.value) {
|
||||
let res = await window.tts.GetTTSHistoryData({
|
||||
page: currentPage,
|
||||
pageSize: pagination.pageSize
|
||||
})
|
||||
if (res.code == 0) {
|
||||
message.error(res.message)
|
||||
return
|
||||
}
|
||||
data.value = res.data.ttsList
|
||||
pagination.page = currentPage
|
||||
pagination.pageCount = Math.ceil(res.data.ttsCount / pagination.pageSize)
|
||||
pagination.itemCount = res.data.ttsCount
|
||||
}
|
||||
}
|
||||
|
||||
async function handlePageChange(currentPage) {
|
||||
await GetTTSHistoryData(currentPage)
|
||||
}
|
||||
|
||||
async function handleUpdateRow(row, index) {
|
||||
if (row == null) {
|
||||
debugger
|
||||
// data.value.splice(index, 1)
|
||||
// 直接重新加载吧
|
||||
await GetTTSHistoryData(pagination.page)
|
||||
} else {
|
||||
data.value[index] = row
|
||||
}
|
||||
}
|
||||
|
||||
let columns = ref([
|
||||
{
|
||||
title: 'No.',
|
||||
key: 'no',
|
||||
width: 80
|
||||
},
|
||||
{
|
||||
title: '名字',
|
||||
key: 'name',
|
||||
width: 250
|
||||
},
|
||||
{
|
||||
title: '配音地址',
|
||||
key: 'ttsPath',
|
||||
render(row, index) {
|
||||
return h(TTSHistoryShowPath, {
|
||||
text: row.ttsPath
|
||||
})
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '字幕地址',
|
||||
key: 'srtPath',
|
||||
render(row, index) {
|
||||
return h(
|
||||
'div',
|
||||
{
|
||||
className: 'tts-path',
|
||||
onClick: () => {
|
||||
window.system.OpenFile(row.srtPath)
|
||||
}
|
||||
},
|
||||
row.srtPath
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
key: 'createTime',
|
||||
width: 200,
|
||||
render(row, index) {
|
||||
return h('span', row.createTime.toLocaleString())
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
fixed: 'right',
|
||||
key: 'action',
|
||||
width: 280,
|
||||
render(row, index) {
|
||||
return h(TTSHistoryAction, {
|
||||
row: row,
|
||||
index: index,
|
||||
onUpdateRow: (data, dataIndex) => handleUpdateRow(data, dataIndex)
|
||||
})
|
||||
}
|
||||
}
|
||||
])
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.tts-path {
|
||||
overflow: hidden;
|
||||
max-width: 300px;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
cursor: pointer;
|
||||
}
|
||||
.tts-path:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,74 @@
|
||||
<template>
|
||||
<n-button
|
||||
:color="softwareStore.SoftColor.BROWN_YELLOW"
|
||||
size="small"
|
||||
style="margin-right: 5px"
|
||||
@click="GenerateSrt"
|
||||
>生成字幕</n-button
|
||||
>
|
||||
<n-button
|
||||
:color="softwareStore.SoftColor.BROWN_YELLOW"
|
||||
size="small"
|
||||
style="margin-right: 5px"
|
||||
@click="OpenFolder"
|
||||
>打开文件夹</n-button
|
||||
>
|
||||
<n-button type="error" size="small" style="margin-right: 5px" @click="DeleteTTSHistory"
|
||||
>删除</n-button
|
||||
>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { useMessage, NButton } from 'naive-ui'
|
||||
import { useSoftwareStore } from '../../../../stores/software'
|
||||
let message = useMessage()
|
||||
let softwareStore = useSoftwareStore()
|
||||
let props = defineProps({
|
||||
row: undefined,
|
||||
index: undefined
|
||||
})
|
||||
const emit = defineEmits(['update-row'])
|
||||
|
||||
// 调用生成SRT的方法
|
||||
async function GenerateSrt() {
|
||||
let res = await window.tts.GenerateSrt(props.row.id)
|
||||
if (res.code == 0) {
|
||||
message.error(res.message)
|
||||
return
|
||||
} else {
|
||||
// 这边要处理返回的数据
|
||||
emit('update-row', res.data, props.index)
|
||||
message.success(res.message)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开对应的文件夹
|
||||
*/
|
||||
async function OpenFolder() {
|
||||
let res = await window.system.OpenFolder({
|
||||
folderPath: props.row.ttsPath,
|
||||
baseProject: false,
|
||||
dirFloder: true
|
||||
})
|
||||
if (res.code == 0) {
|
||||
message.error(res.message)
|
||||
}
|
||||
}
|
||||
|
||||
// 调用删除数据的方法
|
||||
async function DeleteTTSHistory() {
|
||||
softwareStore.spin.spinning = true
|
||||
softwareStore.spin.tip = '删除中...'
|
||||
let res = await window.tts.DeleteTTSHistory(props.row.id)
|
||||
if (res.code == 0) {
|
||||
message.error(res.message)
|
||||
} else {
|
||||
// 这边要处理返回的数据
|
||||
emit('update-row', null, props.index)
|
||||
message.success(res.message)
|
||||
}
|
||||
softwareStore.spin.spinning = false
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,35 @@
|
||||
<template>
|
||||
<n-popover trigger="hover">
|
||||
<template #trigger>
|
||||
<div @click="Click" class="show-text-ellipsis">{{ text }}</div>
|
||||
</template>
|
||||
<span>{{ text }}</span>
|
||||
</n-popover>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { NPopover } from 'naive-ui'
|
||||
let props = defineProps({
|
||||
text: undefined
|
||||
})
|
||||
let text = ref(props.text)
|
||||
|
||||
function Click() {
|
||||
// window.open(text.value)
|
||||
window.system.OpenFile(text.value)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.show-text-ellipsis {
|
||||
overflow: hidden;
|
||||
max-width: 300px;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
cursor: pointer;
|
||||
}
|
||||
.show-text-ellipsis:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
</style>
|
||||
@@ -103,6 +103,7 @@ import { useSoftwareStore } from '../../../../stores/software'
|
||||
import { AddCircleOutline } from '@vicons/ionicons5'
|
||||
import InputDialogContent from '../Original/Components/InputDialogContent.vue'
|
||||
import { useSettingStore } from '../../../../stores/setting'
|
||||
import TTSHistory from './TTSHistory.vue'
|
||||
|
||||
export default defineComponent({
|
||||
components: {
|
||||
@@ -116,7 +117,8 @@ export default defineComponent({
|
||||
NPopover,
|
||||
AddCircleOutline,
|
||||
NIcon,
|
||||
InputDialogContent
|
||||
InputDialogContent,
|
||||
TTSHistory
|
||||
},
|
||||
|
||||
setup() {
|
||||
@@ -259,6 +261,7 @@ export default defineComponent({
|
||||
softwareStore.spin.spinning = true
|
||||
softwareStore.spin.tip = '正在合成音频,请稍等...'
|
||||
|
||||
// 保存配置信息
|
||||
let saveRes = await window.tts.SaveTTSConfig(toRaw(settingStore.ttsSetting))
|
||||
if (saveRes.code == 0) {
|
||||
softwareStore.spin.spinning = false
|
||||
@@ -266,16 +269,32 @@ export default defineComponent({
|
||||
return
|
||||
}
|
||||
|
||||
// 开始真正的合成音频
|
||||
let generateRes = await window.tts.GenerateAudio(text.value)
|
||||
if (generateRes.code == 0) {
|
||||
softwareStore.spin.spinning = false
|
||||
message.error(generateRes.message)
|
||||
return
|
||||
}
|
||||
audioUrl.value = generateRes.data
|
||||
debugger
|
||||
audioUrl.value = generateRes.mp3Path
|
||||
softwareStore.spin.spinning = false
|
||||
}
|
||||
|
||||
// 显示配音的历史记录
|
||||
function ShowHistory() {
|
||||
let dialogWidth = window.innerWidth * 0.8
|
||||
let dialogHeight = window.innerHeight * 0.9
|
||||
dialog.create({
|
||||
title: '配音历史记录',
|
||||
showIcon: false,
|
||||
closeOnEsc: false,
|
||||
content: () => h(TTSHistory, { height: dialogHeight }),
|
||||
style: `width : ${dialogWidth}px; min-height : ${dialogHeight}px;matgin-right: 0px`,
|
||||
maskClosable: false
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
text,
|
||||
azurettsRef,
|
||||
@@ -284,6 +303,7 @@ export default defineComponent({
|
||||
writeSetting,
|
||||
softwareStore,
|
||||
ModifySplitChar,
|
||||
ShowHistory,
|
||||
SaveTTSConfig,
|
||||
FormatWord,
|
||||
ClearText,
|
||||
|
||||
Reference in New Issue
Block a user