mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-24 16:13:54 +08:00
feat: 新增替换词管理功能
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<el-header class="header">
|
||||
<div class="header-container">
|
||||
<!-- 左侧元素 -->
|
||||
<div class="header-left" @click="goHome">
|
||||
<div class="header-left" @click="handleRouter('home')">
|
||||
<img loading="lazy" alt="" src="@/assets/xiaozhi-logo.png" class="logo-img" />
|
||||
<img loading="lazy" alt="" :src="xiaozhiAiIcon" class="brand-img" />
|
||||
</div>
|
||||
@@ -14,7 +14,7 @@
|
||||
$route.path === '/home' ||
|
||||
$route.path === '/role-config' ||
|
||||
$route.path === '/device-management',
|
||||
}" @click="goHome">
|
||||
}" @click="handleRouter('home')">
|
||||
<img loading="lazy" alt="" src="@/assets/header/robot.png" :style="{
|
||||
filter:
|
||||
$route.path === '/home' ||
|
||||
@@ -27,7 +27,7 @@
|
||||
</div>
|
||||
<!-- 普通用户显示音色克隆 -->
|
||||
<div v-if="!userInfo.superAdmin && featureStatus.voiceClone" class="equipment-management"
|
||||
:class="{ 'active-tab': $route.path === '/voice-clone-management' }" @click="goVoiceCloneManagement">
|
||||
:class="{ 'active-tab': $route.path === '/voice-clone-management' }" @click="handleRouter('voiceCloneManagement')">
|
||||
<img loading="lazy" alt="" src="@/assets/header/voice.png" :style="{
|
||||
filter:
|
||||
$route.path === '/voice-clone-management'
|
||||
@@ -55,17 +55,17 @@
|
||||
<i class="el-icon-arrow-down el-icon--right" :class="{ 'rotate-down': voiceCloneDropdownVisible }"></i>
|
||||
</span>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item @click.native="goVoiceCloneManagement">
|
||||
<el-dropdown-item @click.native="handleRouter('voiceCloneManagement')">
|
||||
{{ $t("header.voiceCloneManagement") }}
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item @click.native="goVoiceResourceManagement">
|
||||
<el-dropdown-item @click.native="handleRouter('voiceResourceManagement')">
|
||||
{{ $t("header.voiceResourceManagement") }}
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
|
||||
<div v-if="userInfo.superAdmin" class="equipment-management" :class="{ 'active-tab': $route.path === '/model-config' }"
|
||||
@click="goModelConfig">
|
||||
@click="handleRouter('modelConfig')">
|
||||
<img loading="lazy" alt="" src="@/assets/header/model_config.png" :style="{
|
||||
filter:
|
||||
$route.path === '/model-config' ? 'brightness(0) invert(1)' : 'None',
|
||||
@@ -74,7 +74,7 @@
|
||||
</div>
|
||||
<div v-if="featureStatus.knowledgeBase" class="equipment-management"
|
||||
:class="{ 'active-tab': $route.path === '/knowledge-base-management' || $route.path === '/knowledge-file-upload' }"
|
||||
@click="goKnowledgeBaseManagement">
|
||||
@click="handleRouter('knowledgeBaseManagement')">
|
||||
<img loading="lazy" alt="" src="@/assets/header/knowledge_base.png" :style="{
|
||||
filter:
|
||||
$route.path === '/knowledge-base-management' || $route.path === '/knowledge-file-upload' ? 'brightness(0) invert(1)' : 'None',
|
||||
@@ -110,28 +110,31 @@
|
||||
<i class="el-icon-arrow-down el-icon--right" :class="{ 'rotate-down': paramDropdownVisible }"></i>
|
||||
</span>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item @click.native="goParamManagement">
|
||||
<el-dropdown-item @click.native="handleRouter('paramManagement')">
|
||||
{{ $t("header.paramManagement") }}
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item @click.native="goUserManagement">
|
||||
<el-dropdown-item @click.native="handleRouter('userManagement')">
|
||||
{{ $t("header.userManagement") }}
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item @click.native="goOtaManagement">
|
||||
<el-dropdown-item @click.native="handleRouter('otaManagement')">
|
||||
{{ $t("header.otaManagement") }}
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item @click.native="goDictManagement">
|
||||
<el-dropdown-item @click.native="handleRouter('dictManagement')">
|
||||
{{ $t("header.dictManagement") }}
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item @click.native="goProviderManagement">
|
||||
<el-dropdown-item @click.native="handleRouter('providerManagement')">
|
||||
{{ $t("header.providerManagement") }}
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item @click.native="goAgentTemplateManagement">
|
||||
<el-dropdown-item @click.native="handleRouter('agentTemplate')">
|
||||
{{ $t("header.agentTemplate") }}
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item @click.native="goServerSideManagement">
|
||||
<el-dropdown-item @click.native="handleRouter('replacementWordManagement')">
|
||||
{{ $t("header.replacementWordManagement") }}
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item @click.native="handleRouter('serverSideManagement')">
|
||||
{{ $t("header.serverSideManagement") }}
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item @click.native="goFeatureManagement">
|
||||
<el-dropdown-item @click.native="handleRouter('featureManagement')">
|
||||
{{ $t("header.featureManagement") }}
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
@@ -220,6 +223,23 @@ export default {
|
||||
label: "label",
|
||||
children: "children",
|
||||
},
|
||||
// 跳转页面配置
|
||||
routerPaths: {
|
||||
home: "/home",
|
||||
modelConfig: "/model-config",
|
||||
knowledgeBaseManagement: "/knowledge-base-management",
|
||||
voiceCloneManagement: "/voice-clone-management",
|
||||
voiceResourceManagement: "/voice-resource-management",
|
||||
paramManagement: "/params-management",
|
||||
userManagement: "/user-management",
|
||||
otaManagement: "/ota-management",
|
||||
dictManagement: "/dict-management",
|
||||
providerManagement: "/provider-management",
|
||||
agentTemplate: "/agent-template-management",
|
||||
replacementWordManagement: "/replacement-word-management",
|
||||
serverSideManagement: "/server-side-management",
|
||||
featureManagement: "/feature-management",
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -331,49 +351,8 @@ export default {
|
||||
window.removeEventListener("resize", this.checkScreenSize);
|
||||
},
|
||||
methods: {
|
||||
goHome() {
|
||||
// 跳转到首页
|
||||
this.$router.push("/home");
|
||||
},
|
||||
goUserManagement() {
|
||||
this.$router.push("/user-management");
|
||||
},
|
||||
goModelConfig() {
|
||||
this.$router.push("/model-config");
|
||||
},
|
||||
goKnowledgeBaseManagement() {
|
||||
this.$router.push("/knowledge-base-management");
|
||||
},
|
||||
goVoiceCloneManagement() {
|
||||
this.$router.push("/voice-clone-management");
|
||||
},
|
||||
goParamManagement() {
|
||||
this.$router.push("/params-management");
|
||||
},
|
||||
goOtaManagement() {
|
||||
this.$router.push("/ota-management");
|
||||
},
|
||||
goDictManagement() {
|
||||
this.$router.push("/dict-management");
|
||||
},
|
||||
goProviderManagement() {
|
||||
this.$router.push("/provider-management");
|
||||
},
|
||||
goServerSideManagement() {
|
||||
this.$router.push("/server-side-management");
|
||||
},
|
||||
|
||||
// 跳转到音色资源管理
|
||||
goVoiceResourceManagement() {
|
||||
this.$router.push("/voice-resource-management");
|
||||
},
|
||||
// 添加默认角色模板管理导航方法
|
||||
goAgentTemplateManagement() {
|
||||
this.$router.push("/agent-template-management");
|
||||
},
|
||||
// 跳转到功能管理
|
||||
goFeatureManagement() {
|
||||
this.$router.push("/feature-management");
|
||||
handleRouter(type) {
|
||||
this.$router.push(this.routerPaths[type]);
|
||||
},
|
||||
// 加载功能状态
|
||||
async loadFeatureStatus() {
|
||||
|
||||
@@ -0,0 +1,494 @@
|
||||
<template>
|
||||
<el-dialog :title="title" :visible.sync="visible" width="700px" class="param-dialog-wrapper" :append-to-body="true"
|
||||
:close-on-click-modal="false" :key="dialogKey" custom-class="custom-param-dialog" :show-close="false">
|
||||
<div class="dialog-container">
|
||||
<div class="dialog-header">
|
||||
<h2 class="dialog-title">{{ title }}</h2>
|
||||
<button class="custom-close-btn" @click="cancel">
|
||||
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M13 1L1 13M1 1L13 13" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<el-form :model="localForm" :rules="rules" ref="form" label-width="auto" label-position="left" class="param-form">
|
||||
<el-form-item :label="$t('replacementDialog.fileName')" prop="fileName" class="form-item">
|
||||
<el-input v-model="localForm.fileName" :placeholder="$t('replacementDialog.fileNamePlaceholder')"
|
||||
class="custom-input" @input="clearFieldError('fileName')"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item :label="$t('replacementDialog.content')" prop="content" class="form-item content-item">
|
||||
<div class="content-wrapper">
|
||||
<el-input
|
||||
type="textarea"
|
||||
v-model="localForm.content"
|
||||
:placeholder="$t('replacementDialog.contentPlaceholder')"
|
||||
:rows="8"
|
||||
class="custom-textarea"
|
||||
@input="clearFieldError('content')"
|
||||
></el-input>
|
||||
<p class="format-tip">{{ $t('replacementDialog.formatTip') }}</p>
|
||||
<div class="upload-section">
|
||||
<el-upload
|
||||
class="upload-btn"
|
||||
action=""
|
||||
:auto-upload="false"
|
||||
:show-file-list="false"
|
||||
accept=".txt"
|
||||
:on-change="handleFileChange"
|
||||
>
|
||||
<el-button size="small" type="primary" class="upload-file-btn">
|
||||
<div class="upload-file-content">
|
||||
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg" style="margin-right: 4px;">
|
||||
<path d="M7 1V13M1 7H13" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
|
||||
</svg>
|
||||
<div>
|
||||
<p>{{ $t('replacementDialog.clickUploadTip') }}</p>
|
||||
<p>{{ $t('replacementDialog.uploadCoverTip') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</el-button>
|
||||
</el-upload>
|
||||
<span class="word-count">{{ wordCount }}{{ $t('replacementDialog.wordCountUnit') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<div class="dialog-footer">
|
||||
<el-button type="primary" @click="submit" class="save-btn" :loading="saving" :disabled="saving">
|
||||
{{ $t('replacementDialog.save') }}
|
||||
</el-button>
|
||||
<el-button @click="cancel" class="cancel-btn">
|
||||
{{ $t('replacementDialog.cancel') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
title: {
|
||||
type: String,
|
||||
default: '新增替换词'
|
||||
},
|
||||
visible: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
form: {
|
||||
type: Object,
|
||||
default: () => ({
|
||||
id: undefined,
|
||||
fileName: '',
|
||||
content: ''
|
||||
})
|
||||
}
|
||||
},
|
||||
data() {
|
||||
const validateContent = (rule, value, callback) => {
|
||||
if (!value || !value.trim()) {
|
||||
callback(new Error(this.$t('replacementDialog.requiredContent')));
|
||||
return;
|
||||
}
|
||||
const lines = this.getValidLines(value);
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const pipeCount = (lines[i].match(/\|/g) || []).length;
|
||||
if (pipeCount !== 1) {
|
||||
callback(new Error(this.$t('replacementDialog.invalidPipeCount', { line: i + 1 })));
|
||||
return;
|
||||
}
|
||||
const parts = lines[i].split('|');
|
||||
if (!parts[0] || !parts[0].trim()) {
|
||||
callback(new Error(this.$t('replacementDialog.emptyOriginal', { line: i + 1 })));
|
||||
return;
|
||||
}
|
||||
if (!parts[1] || !parts[1].trim()) {
|
||||
callback(new Error(this.$t('replacementDialog.emptyReplacement', { line: i + 1 })));
|
||||
return;
|
||||
}
|
||||
const specialCharRegex = /[!@#$%^&*()_+=\[\]{};':"\\<>?\/`~]/;
|
||||
if (specialCharRegex.test(parts[0])) {
|
||||
callback(new Error(this.$t('replacementDialog.invalidOriginalChar', { line: i + 1 })));
|
||||
return;
|
||||
}
|
||||
if (specialCharRegex.test(parts[1])) {
|
||||
callback(new Error(this.$t('replacementDialog.invalidReplacementChar', { line: i + 1 })));
|
||||
return;
|
||||
}
|
||||
}
|
||||
callback();
|
||||
};
|
||||
|
||||
return {
|
||||
dialogKey: Date.now(),
|
||||
saving: false,
|
||||
localForm: {
|
||||
id: undefined,
|
||||
fileName: '',
|
||||
content: ''
|
||||
},
|
||||
rules: {
|
||||
fileName: [
|
||||
{ required: true, message: this.$t('replacementDialog.requiredFileName'), trigger: "blur" }
|
||||
],
|
||||
content: [
|
||||
{ required: true, validator: validateContent, trigger: "blur" }
|
||||
]
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
wordCount() {
|
||||
if (!this.localForm.content) return 0;
|
||||
const contentStr = Array.isArray(this.localForm.content)
|
||||
? this.localForm.content.join('\n')
|
||||
: this.localForm.content;
|
||||
if (!contentStr.trim()) {
|
||||
return 0;
|
||||
}
|
||||
const lines = this.getValidLines();
|
||||
return lines.filter(line => line.includes('|')).length;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getValidLines() {
|
||||
if (!this.localForm.content) return [];
|
||||
const contentStr = Array.isArray(this.localForm.content)
|
||||
? this.localForm.content.join('\n')
|
||||
: this.localForm.content;
|
||||
return contentStr.split(/\r?\n/).filter(line => line.trim());
|
||||
},
|
||||
|
||||
clearFieldError(field) {
|
||||
if (this.$refs.form) {
|
||||
this.$refs.form.clearValidate(field);
|
||||
}
|
||||
},
|
||||
|
||||
handleFileChange(file) {
|
||||
if (!file) return;
|
||||
|
||||
const rawFile = file.raw;
|
||||
if (!rawFile) return;
|
||||
|
||||
const reader = new FileReader();
|
||||
reader.onload = (e) => {
|
||||
const content = e.target.result;
|
||||
this.localForm.content = content;
|
||||
this.$nextTick(() => {
|
||||
if (this.$refs.form) {
|
||||
this.$refs.form.clearValidate('content');
|
||||
}
|
||||
});
|
||||
};
|
||||
reader.onerror = () => {
|
||||
this.$message.error(this.$t('replacementDialog.readFileError'));
|
||||
};
|
||||
reader.readAsText(rawFile);
|
||||
},
|
||||
|
||||
submit() {
|
||||
this.$refs.form.validate((valid) => {
|
||||
if (valid) {
|
||||
const submitData = {
|
||||
id: this.localForm.id,
|
||||
fileName: this.localForm.fileName,
|
||||
content: this.getValidLines()
|
||||
};
|
||||
this.saving = true;
|
||||
this.$emit('submit', submitData);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
cancel() {
|
||||
this.saving = false;
|
||||
this.dialogKey = Date.now();
|
||||
this.$emit('cancel');
|
||||
},
|
||||
|
||||
resetSaving() {
|
||||
this.saving = false;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
visible(newVal) {
|
||||
if (newVal) {
|
||||
this.localForm.id = this.form.id;
|
||||
this.localForm.fileName = this.form.fileName || '';
|
||||
const contentData = this.form.content;
|
||||
this.localForm.content = Array.isArray(contentData) ? contentData.join('\n') : (contentData || '');
|
||||
this.$nextTick(() => {
|
||||
if (this.$refs.form) {
|
||||
this.$refs.form.clearValidate();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.saving = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.custom-param-dialog {
|
||||
border-radius: 16px !important;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15) !important;
|
||||
border: none !important;
|
||||
|
||||
.el-dialog__header {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.el-dialog__body {
|
||||
padding: 0 !important;
|
||||
border-radius: 16px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.param-dialog-wrapper {
|
||||
.dialog-container {
|
||||
padding: 24px 32px;
|
||||
background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
|
||||
}
|
||||
|
||||
.dialog-header {
|
||||
position: relative;
|
||||
margin-bottom: 24px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.dialog-title {
|
||||
font-size: 20px;
|
||||
color: #1e293b;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.custom-close-btn {
|
||||
position: absolute;
|
||||
top: -8px;
|
||||
right: -8px;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 50%;
|
||||
border: none;
|
||||
background: #f1f5f9;
|
||||
color: #64748b;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0;
|
||||
outline: none;
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
|
||||
&:hover {
|
||||
color: #ffffff;
|
||||
background: #ef4444;
|
||||
transform: rotate(90deg);
|
||||
box-shadow: 0 4px 6px rgba(239, 68, 68, 0.2);
|
||||
}
|
||||
|
||||
svg {
|
||||
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
}
|
||||
|
||||
.param-form {
|
||||
.form-item {
|
||||
margin-bottom: 20px;
|
||||
|
||||
:deep(.el-form-item__label) {
|
||||
color: #475569;
|
||||
font-weight: 500;
|
||||
padding-right: 12px;
|
||||
text-align: right;
|
||||
font-size: 14px;
|
||||
letter-spacing: 0.2px;
|
||||
}
|
||||
}
|
||||
|
||||
.content-item {
|
||||
:deep(.el-form-item__content) {
|
||||
line-height: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.custom-input {
|
||||
:deep(.el-input__inner) {
|
||||
background-color: #ffffff;
|
||||
border-radius: 8px;
|
||||
border: 1px solid #e2e8f0;
|
||||
height: 42px;
|
||||
padding: 0 14px;
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
font-size: 14px;
|
||||
color: #334155;
|
||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||
|
||||
&:focus {
|
||||
border-color: #3b82f6;
|
||||
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
&::placeholder {
|
||||
color: #94a3b8;
|
||||
font-weight: 400;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.content-wrapper {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.custom-textarea {
|
||||
:deep(.el-textarea__inner) {
|
||||
background-color: #ffffff;
|
||||
border-radius: 8px;
|
||||
border: 1px solid #e2e8f0;
|
||||
padding: 12px 14px;
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
font-size: 14px;
|
||||
color: #334155;
|
||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||
line-height: 1.8;
|
||||
resize: none;
|
||||
white-space: pre;
|
||||
overflow-x: auto;
|
||||
word-wrap: normal;
|
||||
|
||||
&:focus {
|
||||
border-color: #3b82f6;
|
||||
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
&::placeholder {
|
||||
color: #94a3b8;
|
||||
font-weight: 400;
|
||||
}
|
||||
}
|
||||
}
|
||||
.format-tip {
|
||||
font-size: 12px;
|
||||
color: #5778ff;
|
||||
}
|
||||
|
||||
.upload-section {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.upload-btn {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.upload-file-btn {
|
||||
background: #3b82f6;
|
||||
border-color: #3b82f6;
|
||||
border-radius: 6px;
|
||||
font-size: 13px;
|
||||
padding: 8px 16px;
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
.upload-file-content {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
> div {
|
||||
text-align: left;
|
||||
> p {
|
||||
margin: 4px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: #2563eb;
|
||||
border-color: #2563eb;
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
}
|
||||
|
||||
.word-count {
|
||||
font-size: 13px;
|
||||
color: #64748b;
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
|
||||
.dialog-footer {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
padding: 16px 0 0;
|
||||
margin-top: 16px;
|
||||
|
||||
.save-btn {
|
||||
width: 120px;
|
||||
height: 42px;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
border-radius: 8px;
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
background: #3b82f6;
|
||||
color: white;
|
||||
border: none;
|
||||
letter-spacing: 0.5px;
|
||||
box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
|
||||
|
||||
&:hover {
|
||||
background: #2563eb;
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 4px 6px rgba(59, 130, 246, 0.3);
|
||||
}
|
||||
|
||||
&:active {
|
||||
transform: translateY(0);
|
||||
box-shadow: 0 2px 3px rgba(59, 130, 246, 0.2);
|
||||
}
|
||||
}
|
||||
|
||||
.cancel-btn {
|
||||
width: 120px;
|
||||
height: 42px;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
border-radius: 8px;
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
background: #ffffff;
|
||||
color: #64748b;
|
||||
border: 1px solid #e2e8f0;
|
||||
margin-left: 16px;
|
||||
letter-spacing: 0.5px;
|
||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||
|
||||
&:hover {
|
||||
background: #f8fafc;
|
||||
color: #475569;
|
||||
border-color: #cbd5e1;
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
&:active {
|
||||
transform: translateY(0);
|
||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -57,9 +57,32 @@
|
||||
class="tts-slider"
|
||||
/>
|
||||
<span class="slider-hint">{{ $t('roleConfig.pitchHint') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
||||
</el-form>
|
||||
<!-- 关联替换词 -->
|
||||
<div>
|
||||
<h4 class="replacement-label">
|
||||
{{ $t('roleConfig.replacementWordLabel') }}
|
||||
<el-tooltip popper-class="tts-tooltip" :content="$t('roleConfig.replacementWordTip')" effect="light" placement="top">
|
||||
<i class="el-icon-question"></i>
|
||||
</el-tooltip>
|
||||
</h4>
|
||||
<el-select
|
||||
v-model="replacementWordIds"
|
||||
multiple
|
||||
:placeholder="$t('replacementDialog.selectPlaceholder')"
|
||||
class="replacement-word-select"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in replacementWordList"
|
||||
:key="item.id"
|
||||
:label="item.fileName"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="drawer-footer">
|
||||
@@ -70,6 +93,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import correctWord from '@/apis/module/correctWord';
|
||||
|
||||
export default {
|
||||
name: 'TtsAdvancedSettings',
|
||||
props: {
|
||||
@@ -84,15 +109,21 @@ export default {
|
||||
speed: 0,
|
||||
pitch: 0
|
||||
})
|
||||
}
|
||||
},
|
||||
checkedReplacementWordIds: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
localSettings: {
|
||||
volume: 0,
|
||||
speed: 0,
|
||||
pitch: 0
|
||||
}
|
||||
pitch: 0,
|
||||
},
|
||||
replacementWordIds: [],
|
||||
replacementWordList: []
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -110,6 +141,8 @@ export default {
|
||||
if (newVal) {
|
||||
// 当抽屉打开时,复制当前设置到本地
|
||||
this.localSettings = { ...this.settings };
|
||||
this.replacementWordIds = [...this.checkedReplacementWordIds];
|
||||
this.fetchReplacementWordList();
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -123,11 +156,22 @@ export default {
|
||||
},
|
||||
handleSave() {
|
||||
// 保存设置并关闭
|
||||
this.$emit('save', { ...this.localSettings });
|
||||
this.$emit('save', { ...this.localSettings, replacementWordIds: this.replacementWordIds });
|
||||
this.handleClose();
|
||||
},
|
||||
formatTooltip(val) {
|
||||
return `${val}%`;
|
||||
},
|
||||
fetchReplacementWordList() {
|
||||
correctWord.selectAll(({ data }) => {
|
||||
if (data.code === 0) {
|
||||
this.replacementWordList = data.data;
|
||||
}
|
||||
});
|
||||
},
|
||||
getTagName(id) {
|
||||
const item = this.replacementWordList.find(item => item.id === id);
|
||||
return item ? item.fileName : '';
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -224,6 +268,30 @@ export default {
|
||||
::v-deep .el-form-item {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
.replacement-label i {
|
||||
margin-left: 4px;
|
||||
color: #909399;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
}
|
||||
.replacement-label i:hover {
|
||||
color: #409eff;
|
||||
}
|
||||
.replacement-word-select ::v-deep .el-tag {
|
||||
background: #e6ebff;
|
||||
color: #5778ff;
|
||||
border-radius: 8px;
|
||||
font-size: 12px;
|
||||
font-weight: normal;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.replacement-word-select ::v-deep .el-tag__close {
|
||||
color: #5778ff;
|
||||
}
|
||||
.replacement-word-select ::v-deep .el-icon-close {
|
||||
background: #fff;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style>
|
||||
@@ -237,4 +305,45 @@ export default {
|
||||
flex-direction: column;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.replacement-word-select {
|
||||
width: 100%;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.replacement-label {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.selected-tags {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.replacement-tag {
|
||||
background-color: #409eff;
|
||||
border-color: #409eff;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.tts-tooltip {
|
||||
max-height: 60vh !important;
|
||||
max-width: 400px !important;
|
||||
overflow-y: auto !important;
|
||||
scrollbar-width: thin;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.tts-tooltip .popper__arrow {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.tts-tooltip[x-placement^="top"] .popper__arrow {
|
||||
border-top-color: transparent !important;
|
||||
}
|
||||
|
||||
.tts-tooltip[x-placement^="bottom"] .popper__arrow {
|
||||
border-bottom-color: transparent !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user