mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-28 04:59:52 +01:00
Merge branch 'xinnan-tech:main' into main
This commit is contained in:
commit
5ca83b2558
44 changed files with 2506 additions and 345 deletions
|
|
@ -74,8 +74,16 @@ public interface Constant {
|
|||
*/
|
||||
String ORDER = "order";
|
||||
|
||||
/**
|
||||
* 请求头授权标识
|
||||
*/
|
||||
String AUTHORIZATION = "Authorization";
|
||||
|
||||
/**
|
||||
* 服务器密钥
|
||||
*/
|
||||
String SERVER_SECRET = "server.secret";
|
||||
|
||||
/**
|
||||
* 路径分割符
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -43,4 +43,12 @@ public interface ErrorCode {
|
|||
int PASSWORD_WEAK_ERROR = 10031;
|
||||
int DEL_MYSELF_ERROR = 10032;
|
||||
int DEVICE_CAPTCHA_ERROR = 10033;
|
||||
|
||||
// 参数校验相关错误码
|
||||
int PARAM_VALUE_NULL = 10034;
|
||||
int PARAM_TYPE_NULL = 10035;
|
||||
int PARAM_TYPE_INVALID = 10036;
|
||||
int PARAM_NUMBER_INVALID = 10037;
|
||||
int PARAM_BOOLEAN_INVALID = 10038;
|
||||
int PARAM_ARRAY_INVALID = 10039;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
package xiaozhi.modules.sys.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.DependsOn;
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import xiaozhi.modules.sys.service.SysParamsService;
|
||||
|
||||
@Configuration
|
||||
@DependsOn("liquibase")
|
||||
public class SystemInitConfig {
|
||||
|
||||
@Autowired
|
||||
private SysParamsService sysParamsService;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
sysParamsService.initServerSecret();
|
||||
}
|
||||
}
|
||||
|
|
@ -84,7 +84,7 @@ public class AdminController {
|
|||
@Operation(summary = "批量修改用户状态")
|
||||
@RequiresPermissions("sys:role:superAdmin")
|
||||
@Parameter(name = "status", description = "用户状态", required = true)
|
||||
public Result<Void> changeStatus(@PathVariable Integer status, @RequestBody Long[] userIds) {
|
||||
public Result<Void> changeStatus(@PathVariable Integer status, @RequestBody String[] userIds) {
|
||||
sysUserService.changeStatus(status, userIds);
|
||||
return new Result<Void>();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,110 @@
|
|||
package xiaozhi.modules.sys.controller;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import xiaozhi.common.annotation.LogOperation;
|
||||
import xiaozhi.common.constant.Constant;
|
||||
import xiaozhi.common.page.PageData;
|
||||
import xiaozhi.common.utils.Result;
|
||||
import xiaozhi.common.validator.AssertUtils;
|
||||
import xiaozhi.common.validator.ValidatorUtils;
|
||||
import xiaozhi.common.validator.group.AddGroup;
|
||||
import xiaozhi.common.validator.group.DefaultGroup;
|
||||
import xiaozhi.common.validator.group.UpdateGroup;
|
||||
import xiaozhi.modules.sys.dto.SysParamsDTO;
|
||||
import xiaozhi.modules.sys.service.SysParamsService;
|
||||
|
||||
/**
|
||||
* 参数管理
|
||||
*
|
||||
* @author Mark sunlightcs@gmail.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("admin/params")
|
||||
@Tag(name = "参数管理")
|
||||
@AllArgsConstructor
|
||||
public class SysParamsController {
|
||||
private final SysParamsService sysParamsService;
|
||||
|
||||
@GetMapping("page")
|
||||
@Operation(summary = "分页")
|
||||
@Parameters({
|
||||
@Parameter(name = Constant.PAGE, description = "当前页码,从1开始", in = ParameterIn.QUERY, required = true, ref = "int"),
|
||||
@Parameter(name = Constant.LIMIT, description = "每页显示记录数", in = ParameterIn.QUERY, required = true, ref = "int"),
|
||||
@Parameter(name = Constant.ORDER_FIELD, description = "排序字段", in = ParameterIn.QUERY, ref = "String"),
|
||||
@Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)", in = ParameterIn.QUERY, ref = "String"),
|
||||
@Parameter(name = "paramCode", description = "参数编码", in = ParameterIn.QUERY, ref = "String")
|
||||
})
|
||||
@RequiresPermissions("sys:role:superAdmin")
|
||||
public Result<PageData<SysParamsDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params) {
|
||||
PageData<SysParamsDTO> page = sysParamsService.page(params);
|
||||
|
||||
return new Result<PageData<SysParamsDTO>>().ok(page);
|
||||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
@Operation(summary = "信息")
|
||||
@RequiresPermissions("sys:role:superAdmin")
|
||||
public Result<SysParamsDTO> get(@PathVariable("id") Long id) {
|
||||
SysParamsDTO data = sysParamsService.get(id);
|
||||
|
||||
return new Result<SysParamsDTO>().ok(data);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Operation(summary = "保存")
|
||||
@LogOperation("保存")
|
||||
@RequiresPermissions("sys:role:superAdmin")
|
||||
public Result<Void> save(@RequestBody SysParamsDTO dto) {
|
||||
// 效验数据
|
||||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
|
||||
|
||||
sysParamsService.save(dto);
|
||||
|
||||
return new Result<Void>();
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Operation(summary = "修改")
|
||||
@LogOperation("修改")
|
||||
@RequiresPermissions("sys:role:superAdmin")
|
||||
public Result<Void> update(@RequestBody SysParamsDTO dto) {
|
||||
// 效验数据
|
||||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
|
||||
|
||||
sysParamsService.update(dto);
|
||||
|
||||
return new Result<Void>();
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@Operation(summary = "删除")
|
||||
@LogOperation("删除")
|
||||
@RequiresPermissions("sys:role:superAdmin")
|
||||
public Result<Void> delete(@RequestBody Long[] ids) {
|
||||
// 效验数据
|
||||
AssertUtils.isArrayEmpty(ids, "id");
|
||||
|
||||
sysParamsService.delete(ids);
|
||||
|
||||
return new Result<Void>();
|
||||
}
|
||||
}
|
||||
|
|
@ -10,6 +10,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
|||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Null;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import lombok.Data;
|
||||
import xiaozhi.common.utils.DateUtils;
|
||||
import xiaozhi.common.validator.group.AddGroup;
|
||||
|
|
@ -36,6 +37,11 @@ public class SysParamsDTO implements Serializable {
|
|||
@NotBlank(message = "{sysparams.paramvalue.require}", groups = DefaultGroup.class)
|
||||
private String paramValue;
|
||||
|
||||
@Schema(description = "值类型")
|
||||
@NotBlank(message = "{sysparams.valuetype.require}", groups = DefaultGroup.class)
|
||||
@Pattern(regexp = "^(string|number|boolean|array)$", message = "{sysparams.valuetype.pattern}", groups = DefaultGroup.class)
|
||||
private String valueType;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,10 @@ public class SysParamsEntity extends BaseEntity {
|
|||
* 参数值
|
||||
*/
|
||||
private String paramValue;
|
||||
/**
|
||||
* 值类型:string-字符串,number-数字,boolean-布尔,array-数组
|
||||
*/
|
||||
private String valueType;
|
||||
/**
|
||||
* 类型 0:系统参数 1:非系统参数
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -29,8 +29,9 @@ public interface SysParamsService extends BaseService<SysParamsEntity> {
|
|||
* 根据参数编码,获取参数的value值
|
||||
*
|
||||
* @param paramCode 参数编码
|
||||
* @param fromCache 是否从缓存中获取
|
||||
*/
|
||||
String getValue(String paramCode);
|
||||
String getValue(String paramCode, Boolean fromCache);
|
||||
|
||||
/**
|
||||
* 根据参数编码,获取value的Object对象
|
||||
|
|
@ -47,4 +48,9 @@ public interface SysParamsService extends BaseService<SysParamsEntity> {
|
|||
* @param paramValue 参数值
|
||||
*/
|
||||
int updateValueByCode(String paramCode, String paramValue);
|
||||
|
||||
/**
|
||||
* 初始化服务器密钥
|
||||
*/
|
||||
void initServerSecret();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,5 +64,5 @@ public interface SysUserService extends BaseService<SysUserEntity> {
|
|||
* @param status 用户状态
|
||||
* @param userIds 用户ID数组
|
||||
*/
|
||||
void changeStatus(Integer status, Long[] userIds);
|
||||
void changeStatus(Integer status, String[] userIds);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package xiaozhi.modules.sys.service.impl;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
@ -69,6 +70,8 @@ public class SysParamsServiceImpl extends BaseServiceImpl<SysParamsDao, SysParam
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void save(SysParamsDTO dto) {
|
||||
validateParamValue(dto);
|
||||
|
||||
SysParamsEntity entity = ConvertUtils.sourceToTarget(dto, SysParamsEntity.class);
|
||||
insert(entity);
|
||||
|
||||
|
|
@ -78,12 +81,55 @@ public class SysParamsServiceImpl extends BaseServiceImpl<SysParamsDao, SysParam
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(SysParamsDTO dto) {
|
||||
validateParamValue(dto);
|
||||
|
||||
SysParamsEntity entity = ConvertUtils.sourceToTarget(dto, SysParamsEntity.class);
|
||||
updateById(entity);
|
||||
|
||||
sysParamsRedis.set(entity.getParamCode(), entity.getParamValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验参数值类型
|
||||
*/
|
||||
private void validateParamValue(SysParamsDTO dto) {
|
||||
if (dto == null) {
|
||||
throw new RenException(ErrorCode.PARAM_VALUE_NULL);
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(dto.getParamValue())) {
|
||||
throw new RenException(ErrorCode.PARAM_VALUE_NULL);
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(dto.getValueType())) {
|
||||
throw new RenException(ErrorCode.PARAM_TYPE_NULL);
|
||||
}
|
||||
|
||||
String valueType = dto.getValueType().toLowerCase();
|
||||
String paramValue = dto.getParamValue();
|
||||
|
||||
switch (valueType) {
|
||||
case "string":
|
||||
break;
|
||||
case "array":
|
||||
break;
|
||||
case "number":
|
||||
try {
|
||||
Double.parseDouble(paramValue);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new RenException(ErrorCode.PARAM_NUMBER_INVALID);
|
||||
}
|
||||
break;
|
||||
case "boolean":
|
||||
if (!"true".equalsIgnoreCase(paramValue) && !"false".equalsIgnoreCase(paramValue)) {
|
||||
throw new RenException(ErrorCode.PARAM_BOOLEAN_INVALID);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new RenException(ErrorCode.PARAM_TYPE_INVALID);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(Long[] ids) {
|
||||
|
|
@ -97,19 +143,24 @@ public class SysParamsServiceImpl extends BaseServiceImpl<SysParamsDao, SysParam
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getValue(String paramCode) {
|
||||
String paramValue = sysParamsRedis.get(paramCode);
|
||||
if (paramValue == null) {
|
||||
paramValue = baseDao.getValueByCode(paramCode);
|
||||
public String getValue(String paramCode, Boolean fromCache) {
|
||||
String paramValue = null;
|
||||
if (fromCache) {
|
||||
paramValue = sysParamsRedis.get(paramCode);
|
||||
if (paramValue == null) {
|
||||
paramValue = baseDao.getValueByCode(paramCode);
|
||||
|
||||
sysParamsRedis.set(paramCode, paramValue);
|
||||
sysParamsRedis.set(paramCode, paramValue);
|
||||
}
|
||||
} else {
|
||||
paramValue = baseDao.getValueByCode(paramCode);
|
||||
}
|
||||
return paramValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getValueObject(String paramCode, Class<T> clazz) {
|
||||
String paramValue = getValue(paramCode);
|
||||
String paramValue = getValue(paramCode, true);
|
||||
if (StringUtils.isNotBlank(paramValue)) {
|
||||
return JsonUtils.parseObject(paramValue, clazz);
|
||||
}
|
||||
|
|
@ -129,4 +180,13 @@ public class SysParamsServiceImpl extends BaseServiceImpl<SysParamsDao, SysParam
|
|||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initServerSecret() {
|
||||
// 获取服务器密钥
|
||||
String secretParam = getValue(Constant.SERVER_SECRET, false);
|
||||
if (StringUtils.isBlank(secretParam) || "null".equals(secretParam)) {
|
||||
String newSecret = UUID.randomUUID().toString();
|
||||
updateValueByCode(Constant.SERVER_SECRET, newSecret);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -197,10 +197,10 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
|
|||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void changeStatus(Integer status, Long[] userIds) {
|
||||
for (Long userId : userIds) {
|
||||
public void changeStatus(Integer status, String[] userIds) {
|
||||
for (String userId : userIds) {
|
||||
SysUserEntity entity = new SysUserEntity();
|
||||
entity.setId(userId);
|
||||
entity.setId(Long.parseLong(userId));
|
||||
entity.setStatus(status);
|
||||
updateById(entity);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,11 +82,11 @@ public class TimbreController {
|
|||
return new Result<>();
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
@DeleteMapping
|
||||
@Operation(summary = "音色删除")
|
||||
@RequiresPermissions("sys:role:superAdmin")
|
||||
public Result<Void> delete(@PathVariable String id) {
|
||||
timbreService.delete(new String[] { id });
|
||||
public Result<Void> delete(@RequestBody String[] ids) {
|
||||
timbreService.delete(ids);
|
||||
return new Result<>();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import lombok.Data;
|
|||
@Data
|
||||
public class TimbreDetailsVO implements Serializable {
|
||||
@Schema(description = "音色id")
|
||||
private Long id;
|
||||
private String id;
|
||||
|
||||
@Schema(description = "语言")
|
||||
private String languages;
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@
|
|||
DELETE FROM `ai_model_config`;
|
||||
|
||||
-- VAD模型配置
|
||||
INSERT INTO `ai_model_config` VALUES ('VAD_SileroVAD', 'VAD', 'SileroVAD', '语音活动检测', 1, 1, '{\"model_dir\": \"models/snakers4_silero-vad\", \"threshold\": 0.5, \"min_silence_duration_ms\": 700}', NULL, NULL, 0, NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `ai_model_config` VALUES ('VAD_SileroVAD', 'VAD', 'SileroVAD', '语音活动检测', 1, 1, '{\"type\": \"silero\", \"model_dir\": \"models/snakers4_silero-vad\", \"threshold\": 0.5, \"min_silence_duration_ms\": 700}', NULL, NULL, 0, NULL, NULL, NULL, NULL);
|
||||
|
||||
-- ASR模型配置
|
||||
INSERT INTO `ai_model_config` VALUES ('ASR_FunASR', 'ASR', 'FunASR', 'FunASR语音识别', 1, 1, '{\"model_dir\": \"models/SenseVoiceSmall\", \"output_dir\": \"tmp/\"}', NULL, NULL, 0, NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `ai_model_config` VALUES ('ASR_SherpaASR', 'ASR', 'SherpaASR', 'Sherpa语音识别', 1, 0, '{\"model_dir\": \"models/sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17\", \"output_dir\": \"tmp/\"}', NULL, NULL, 0, NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `ai_model_config` VALUES ('ASR_DoubaoASR', 'ASR', 'DoubaoASR', '豆包语音识别', 1, 0, '{\"appid\": \"\", \"access_token\": \"\", \"cluster\": \"volcengine_input_common\", \"output_dir\": \"tmp/\"}', NULL, NULL, 0, NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `ai_model_config` VALUES ('ASR_FunASR', 'ASR', 'FunASR', 'FunASR语音识别', 1, 1, '{\"type\": \"fun_local\", \"model_dir\": \"models/SenseVoiceSmall\", \"output_dir\": \"tmp/\"}', NULL, NULL, 0, NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `ai_model_config` VALUES ('ASR_SherpaASR', 'ASR', 'SherpaASR', 'Sherpa语音识别', 1, 0, '{\"type\": \"sherpa_onnx_local\", \"model_dir\": \"models/sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17\", \"output_dir\": \"tmp/\"}', NULL, NULL, 0, NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `ai_model_config` VALUES ('ASR_DoubaoASR', 'ASR', 'DoubaoASR', '豆包语音识别', 1, 0, '{\"type\": \"doubao\", \"appid\": \"\", \"access_token\": \"\", \"cluster\": \"volcengine_input_common\", \"output_dir\": \"tmp/\"}', NULL, NULL, 0, NULL, NULL, NULL, NULL);
|
||||
|
||||
-- LLM模型配置
|
||||
INSERT INTO `ai_model_config` VALUES ('LLM_AliLLM', 'LLM', 'AliLLM', '通义千问', 1, 0, '{\"type\": \"openai\", \"base_url\": \"https://dashscope.aliyuncs.com/compatible-mode/v1\", \"model_name\": \"qwen-turbo\", \"api_key\": \"\", \"temperature\": 0.7, \"max_tokens\": 500, \"top_p\": 1, \"top_k\": 50, \"frequency_penalty\": 0}', NULL, NULL, 0, NULL, NULL, NULL, NULL);
|
||||
|
|
@ -4,12 +4,12 @@
|
|||
DELETE FROM `ai_model_provider`;
|
||||
INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `fields`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES
|
||||
-- VAD模型供应器
|
||||
('SYSTEM_VAD_SileroVAD', 'VAD', 'SileroVAD', 'SileroVAD语音活动检测', '[{"key":"threshold","label":"检测阈值","type":"number"},{"key":"model_dir","label":"模型目录","type":"string"},{"key":"min_silence_duration_ms","label":"最小静音时长","type":"number"}]', 1, 1, NOW(), 1, NOW()),
|
||||
('SYSTEM_VAD_SileroVAD', 'VAD', 'silero', 'SileroVAD语音活动检测', '[{"key":"threshold","label":"检测阈值","type":"number"},{"key":"model_dir","label":"模型目录","type":"string"},{"key":"min_silence_duration_ms","label":"最小静音时长","type":"number"}]', 1, 1, NOW(), 1, NOW()),
|
||||
|
||||
-- ASR模型供应器
|
||||
('SYSTEM_ASR_FunASR', 'ASR', 'FunASR', 'FunASR语音识别', '[{"key":"model_dir","label":"模型目录","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"}]', 1, 1, NOW(), 1, NOW()),
|
||||
('SYSTEM_ASR_SherpaASR', 'ASR', 'SherpaASR', 'SherpaASR语音识别', '[{"key":"model_dir","label":"模型目录","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"}]', 2, 1, NOW(), 1, NOW()),
|
||||
('SYSTEM_ASR_DoubaoASR', 'ASR', 'DoubaoASR', '火山引擎语音识别', '[{"key":"appid","label":"应用ID","type":"string"},{"key":"access_token","label":"访问令牌","type":"string"},{"key":"cluster","label":"集群","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"}]', 3, 1, NOW(), 1, NOW()),
|
||||
('SYSTEM_ASR_FunASR', 'ASR', 'fun_local', 'FunASR语音识别', '[{"key":"model_dir","label":"模型目录","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"}]', 1, 1, NOW(), 1, NOW()),
|
||||
('SYSTEM_ASR_SherpaASR', 'ASR', 'sherpa_onnx_local', 'SherpaASR语音识别', '[{"key":"model_dir","label":"模型目录","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"}]', 2, 1, NOW(), 1, NOW()),
|
||||
('SYSTEM_ASR_DoubaoASR', 'ASR', 'doubao', '火山引擎语音识别', '[{"key":"appid","label":"应用ID","type":"string"},{"key":"access_token","label":"访问令牌","type":"string"},{"key":"cluster","label":"集群","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"}]', 3, 1, NOW(), 1, NOW()),
|
||||
|
||||
-- LLM模型供应器
|
||||
('SYSTEM_LLM_openai', 'LLM', 'openai', 'OpenAI接口', '[{"key":"base_url","label":"基础URL","type":"string"},{"key":"model_name","label":"模型名称","type":"string"},{"key":"api_key","label":"API密钥","type":"string"},{"key":"temperature","label":"温度","type":"number"},{"key":"max_tokens","label":"最大令牌数","type":"number"},{"key":"top_p","label":"top_p值","type":"number"},{"key":"top_k","label":"top_k值","type":"number"},{"key":"frequency_penalty","label":"频率惩罚","type":"number"}]', 1, 1, NOW(), 1, NOW()),
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
-- 本文件用于初始化系统参数数据,无需手动执行,在项目启动时会自动执行
|
||||
-- --------------------------------------------------------
|
||||
-- 初始化参数管理配置
|
||||
DROP TABLE IF EXISTS sys_params;
|
||||
-- 参数管理
|
||||
create table sys_params
|
||||
(
|
||||
id bigint NOT NULL COMMENT 'id',
|
||||
param_code varchar(100) COMMENT '参数编码',
|
||||
param_value varchar(2000) COMMENT '参数值',
|
||||
value_type varchar(20) default 'string' COMMENT '值类型:string-字符串,number-数字,boolean-布尔,array-数组',
|
||||
param_type tinyint unsigned default 1 COMMENT '类型 0:系统参数 1:非系统参数',
|
||||
remark varchar(200) COMMENT '备注',
|
||||
creator bigint COMMENT '创建者',
|
||||
create_date datetime COMMENT '创建时间',
|
||||
updater bigint COMMENT '更新者',
|
||||
update_date datetime COMMENT '更新时间',
|
||||
primary key (id),
|
||||
unique key uk_param_code (param_code)
|
||||
)ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4 COMMENT='参数管理';
|
||||
|
||||
-- 服务器配置
|
||||
INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (100, 'server.ip', '0.0.0.0', 'string', 1, '服务器监听IP地址');
|
||||
INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (101, 'server.port', '8000', 'number', 1, '服务器监听端口');
|
||||
INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (102, 'server.secret', 'null', 'string', 1, '服务器密钥');
|
||||
INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (201, 'log.log_format', '<green>{time:YYMMDD HH:mm:ss}</green>[{version}_{selected_module}][<light-blue>{extra[tag]}</light-blue>]-<level>{level}</level>-<light-green>{message}</light-green>', 'string', 1, '控制台日志格式');
|
||||
INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (202, 'log.log_format_file', '{time:YYYY-MM-DD HH:mm:ss} - {version}_{selected_module} - {name} - {level} - {extra[tag]} - {message}', 'string', 1, '文件日志格式');
|
||||
INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (203, 'log.log_level', 'INFO', 'string', 1, '日志级别');
|
||||
INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (204, 'log.log_dir', 'tmp', 'string', 1, '日志目录');
|
||||
INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (205, 'log.log_file', 'server.log', 'string', 1, '日志文件名');
|
||||
INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (206, 'log.data_dir', 'data', 'string', 1, '数据目录');
|
||||
INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (301, 'delete_audio', 'true', 'boolean', 1, '是否删除使用后的音频文件');
|
||||
INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (302, 'close_connection_no_voice_time', '120', 'number', 1, '无语音输入断开连接时间(秒)');
|
||||
INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (303, 'tts_timeout', '10', 'number', 1, 'TTS请求超时时间(秒)');
|
||||
INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (304, 'enable_wakeup_words_response_cache', 'true', 'boolean', 1, '是否开启唤醒词加速');
|
||||
INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (305, 'enable_greeting', 'true', 'boolean', 1, '是否开启开场回复');
|
||||
INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (306, 'enable_stop_tts_notify', 'false', 'boolean', 1, '是否开启结束提示音');
|
||||
INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (307, 'stop_tts_notify_voice', 'config/assets/tts_notify.mp3', 'string', 1, '结束提示音文件路径');
|
||||
INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (308, 'exit_commands', '退出;关闭', 'array', 1, '退出命令列表');
|
||||
INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (309, 'xiaozhi', '{
|
||||
"type": "hello",
|
||||
"version": 1,
|
||||
"transport": "websocket",
|
||||
"audio_params": {
|
||||
"format": "opus",
|
||||
"sample_rate": 16000,
|
||||
"channels": 1,
|
||||
"frame_duration": 60
|
||||
}
|
||||
}', 'string', 1, '小智类型');
|
||||
INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (310, 'wakeup_words', '你好小智;你好小志;小爱同学;你好小鑫;你好小新;小美同学;小龙小龙;喵喵同学;小滨小滨;小冰小冰', 'array', 1, '唤醒词列表,用于识别唤醒词');
|
||||
INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (400, 'plugin.weather.api_key', 'a861d0d5e7bf4ee1a83d9a9e4f96d4da', 'string', 1, '天气插件API密钥');
|
||||
INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (401, 'plugin.weather.default_location', '广州', 'string', 1, '天气插件默认城市');
|
||||
INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (410, 'plugin.news.default_rss_url', 'https://www.chinanews.com.cn/rss/society.xml', 'string', 1, '新闻插件默认RSS地址');
|
||||
INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (411, 'plugin.news.category_urls', '{"society":"https://www.chinanews.com.cn/rss/society.xml","world":"https://www.chinanews.com.cn/rss/world.xml","finance":"https://www.chinanews.com.cn/rss/finance.xml"}', 'string', 1, '新闻插件分类RSS地址');
|
||||
INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (421, 'plugin.home_assistant.devices', '客厅,玩具灯,switch.cuco_cn_460494544_cp1_on_p_2_1;卧室,台灯,switch.iot_cn_831898993_socn1_on_p_2_1', 'array', 1, 'Home Assistant设备列表');
|
||||
INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (422, 'plugin.home_assistant.base_url', 'http://homeassistant.local:8123', 'string', 1, 'Home Assistant服务器地址');
|
||||
INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (423, 'plugin.home_assistant.api_key', '你的home assistant api访问令牌', 'string', 1, 'Home Assistant API密钥');
|
||||
INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (430, 'plugin.music.music_dir', './music', 'string', 1, '音乐文件存放路径');
|
||||
INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (431, 'plugin.music.music_ext', 'mp3;wav;p3', 'array', 1, '音乐文件类型');
|
||||
INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (432, 'plugin.music.refresh_time', '300', 'number', 1, '音乐列表刷新间隔(秒)');
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
-- 初始化智能体模板数据
|
||||
DELETE FROM `ai_agent_template`;
|
||||
INSERT INTO `ai_agent_template` VALUES ('9406648b5cc5fde1b8aa335b6f8b4f76', '小智', '湾湾小何', 'ASR_FunASR', 'VAD_SileroVAD', 'LLM_ChatGLMLLM', 'TTS_EdgeTTS', 'TTS_EdgeTTS0001', 'Memory_nomem', 'Intent_function_call', '[角色设定]
|
||||
我是{{assistant_name}},来自中国台湾省的00后女生。讲话超级机车,"真的假的啦"这样的台湾腔,喜欢用"笑死""是在哈喽"等流行梗,但会偷偷研究男友的编程书籍。
|
||||
我是{{assistant_name}},来自中国台湾省的00后女生。讲话超级机车,"真的假的啦"这样的台湾腔,喜欢用"笑死"、"哈喽"等流行梗,但会偷偷研究男友的编程书籍。
|
||||
[核心特征]
|
||||
- 讲话像连珠炮,但会突然冒出超温柔语气
|
||||
- 用梗密度高
|
||||
|
|
@ -16,13 +16,6 @@ databaseChangeLog:
|
|||
- sqlFile:
|
||||
encoding: utf8
|
||||
path: classpath:db/changelog/202503141346.sql
|
||||
- changeSet:
|
||||
id: 2025_model_provider
|
||||
author: John
|
||||
changes:
|
||||
- sqlFile:
|
||||
encoding: utf8
|
||||
path: classpath:db/changelog/2025_model_provider.sql
|
||||
- changeSet:
|
||||
id: 2025_tts_voive
|
||||
author: John
|
||||
|
|
@ -31,16 +24,30 @@ databaseChangeLog:
|
|||
encoding: utf8
|
||||
path: classpath:db/changelog/2025_tts_voive.sql
|
||||
- changeSet:
|
||||
id: 2025_model_config
|
||||
id: 202504082210
|
||||
author: John
|
||||
changes:
|
||||
- sqlFile:
|
||||
encoding: utf8
|
||||
path: classpath:db/changelog/2025_model_config.sql
|
||||
path: classpath:db/changelog/202504082210.sql
|
||||
- changeSet:
|
||||
id: 202504061512
|
||||
id: 202504082211
|
||||
author: John
|
||||
changes:
|
||||
- sqlFile:
|
||||
encoding: utf8
|
||||
path: classpath:db/changelog/202504061512.sql
|
||||
path: classpath:db/changelog/202504082211.sql
|
||||
- changeSet:
|
||||
id: 202504092313
|
||||
author: John
|
||||
changes:
|
||||
- sqlFile:
|
||||
encoding: utf8
|
||||
path: classpath:db/changelog/202504092313.sql
|
||||
- changeSet:
|
||||
id: 202504092335
|
||||
author: John
|
||||
changes:
|
||||
- sqlFile:
|
||||
encoding: utf8
|
||||
path: classpath:db/changelog/202504092335.sql
|
||||
|
|
@ -34,3 +34,9 @@
|
|||
10031=\u5F31\u5BC6\u7801
|
||||
10032=\u5220\u9664\u672C\u6570\u636E\u5F02\u5E38
|
||||
10033=\u8BBE\u5907\u9A8C\u8BC1\u7801\u9519\u8BEF
|
||||
10034=\u53C2\u6570\u503C\u4E0D\u80FD\u4E3A\u7A7A
|
||||
10035=\u53C2\u6570\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A
|
||||
10036=\u4E0D\u652F\u6301\u7684\u53C2\u6570\u7C7B\u578B
|
||||
10037=\u53C2\u6570\u503C\u5FC5\u987B\u662F\u6709\u6548\u7684\u6570\u5B57
|
||||
10038=\u53C2\u6570\u503C\u5FC5\u987B\u662Ftrue\u6216false
|
||||
10039=\u53C2\u6570\u503C\u5FC5\u987B\u662F\u6709\u6548\u7684JSON\u6570\u7EC4\u683C\u5F0F
|
||||
|
|
|
|||
|
|
@ -32,4 +32,11 @@
|
|||
10030=The password is less than {0} digits.
|
||||
10031=The password must consist of numbers, uppercase and lowercase letters, and special characters at the same time
|
||||
10032=Exception in deleting this data
|
||||
10033=Device verification code error
|
||||
10033=Device verification code error
|
||||
|
||||
10034=Parameter value cannot be empty
|
||||
10035=Parameter type cannot be empty
|
||||
10036=Unsupported parameter type
|
||||
10037=Parameter value must be a valid number
|
||||
10038=Parameter value must be true or false
|
||||
10039=Parameter value must be a valid JSON array format
|
||||
|
|
@ -32,4 +32,11 @@
|
|||
10030=\u5BC6\u7801\u957F\u5EA6\u4E0D\u8DB3{0}\u4F4D
|
||||
10031=\u5BC6\u7801\u5FC5\u987B\u540C\u65F6\u5305\u542B\u6570\u5B57\u3001\u5927\u5C0F\u5B57\u6BCD\u548C\u7279\u6B8A\u5B57\u7B26\u7EC4\u6210
|
||||
10032=\u5220\u9664\u672C\u6570\u636E\u5F02\u5E38
|
||||
10033=\u8BBE\u5907\u9A8C\u8BC1\u7801\u9519\u8BEF
|
||||
10033=\u8BBE\u5907\u9A8C\u8BC1\u7801\u9519\u8BEF
|
||||
|
||||
10034=\u53C2\u6570\u503C\u4E0D\u80FD\u4E3A\u7A7A
|
||||
10035=\u53C2\u6570\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A
|
||||
10036=\u4E0D\u652F\u6301\u7684\u53C2\u6570\u7C7B\u578B
|
||||
10037=\u53C2\u6570\u503C\u5FC5\u987B\u662F\u6709\u6548\u7684\u6570\u5B57
|
||||
10038=\u53C2\u6570\u503C\u5FC5\u987B\u662Ftrue\u6216false
|
||||
10039=\u53C2\u6570\u503C\u5FC5\u987B\u662F\u6709\u6548\u7684JSON\u6570\u7EC4\u683C\u5F0F
|
||||
|
|
@ -32,4 +32,11 @@
|
|||
10030=\u5BC6\u78BC\u9577\u5EA6\u4E0D\u8DB3{0}\u4F4D
|
||||
10031=\u5BC6\u78BC\u5FC5\u9808\u540C\u6642\u5305\u542B\u6578\u5B57\u3001\u5927\u5C0F\u5B57\u6BCD\u548C\u7279\u6B8A\u5B57\u7B26\u7D44\u6210
|
||||
10032=\u522A\u9664\u6B64\u6578\u64DA\u7570\u5E38
|
||||
10033=\u8A2D\u5099\u9A57\u8B49\u78BC\u932F\u8AA4
|
||||
10033=\u8A2D\u5099\u9A57\u8B49\u78BC\u932F\u8AA4
|
||||
|
||||
10034=\u53C3\u6578\u503C\u4E0D\u80FD\u70BA\u7A7A
|
||||
10035=\u53C3\u6578\u985E\u578B\u4E0D\u80FD\u70BA\u7A7A
|
||||
10036=\u4E0D\u652F\u63F4\u7684\u53C3\u6578\u985E\u578B
|
||||
10037=\u53C3\u6578\u503C\u5FC5\u9808\u662F\u6709\u6548\u7684\u6578\u5B57
|
||||
10038=\u53C3\u6578\u503C\u5FC5\u9808\u662Ftrue\u6216false
|
||||
10039=\u53C3\u6578\u503C\u5FC5\u9808\u662F\u6709\u6548\u7684JSON\u6578\u7D44\u683C\u5F0F
|
||||
|
|
@ -12,6 +12,8 @@ sysdict.label.require=\u5B57\u5178\u6807\u7B7E\u4E0D\u80FD\u4E3A\u7A7A
|
|||
|
||||
sysparams.paramcode.require=\u53C2\u6570\u7F16\u7801\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysparams.paramvalue.require=\u53C2\u6570\u503C\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysparams.valuetype.require=\u503C\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysparams.valuetype.pattern=\u503C\u7C7B\u578B\u5FC5\u987B\u662F string\u3001number\u3001boolean \u6216 array
|
||||
|
||||
sysuser.username.require=\u7528\u6237\u540D\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysuser.password.require=\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ sysdict.label.require=Dictionary tag cannot be empty
|
|||
|
||||
sysparams.paramcode.require=Parameter encoding cannot be empty
|
||||
sysparams.paramvalue.require=Parameter values cannot be empty
|
||||
sysparams.valuetype.require=Value type cannot be empty
|
||||
sysparams.valuetype.pattern=Value type must be string, number, boolean or array
|
||||
|
||||
sysuser.username.require=The username cannot be empty
|
||||
sysuser.password.require=The password cannot be empty
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ sysdict.label.require=\u5B57\u5178\u6807\u7B7E\u4E0D\u80FD\u4E3A\u7A7A
|
|||
|
||||
sysparams.paramcode.require=\u53C2\u6570\u7F16\u7801\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysparams.paramvalue.require=\u53C2\u6570\u503C\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysparams.valuetype.require=\u503C\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysparams.valuetype.pattern=\u503C\u7C7B\u578B\u5FC5\u987B\u662F string\u3001number\u3001boolean \u6216 array
|
||||
|
||||
sysuser.username.require=\u7528\u6237\u540D\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysuser.password.require=\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
|
|
|||
|
|
@ -10,8 +10,10 @@ sysdict.type.require=\u5B57\u5178\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A
|
|||
sysdict.name.require=\u5B57\u5178\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysdict.label.require=\u5B57\u5178\u6807\u7B7E\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
||||
sysparams.paramcode.require=\u53C2\u6570\u7F16\u7801\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysparams.paramvalue.require=\u53C2\u6570\u503C\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysparams.paramcode.require=\u53C3\u6578\u7DE8\u78BC\u4E0D\u80FD\u70BA\u7A7A
|
||||
sysparams.paramvalue.require=\u53C3\u6578\u503C\u4E0D\u80FD\u70BA\u7A7A
|
||||
sysparams.valuetype.require=\u503C\u985E\u578B\u4E0D\u80FD\u70BA\u7A7A
|
||||
sysparams.valuetype.pattern=\u503C\u985E\u578B\u5FC5\u9808\u662F string\u3001number\u3001boolean \u6216 array
|
||||
|
||||
sysuser.username.require=\u7528\u6237\u540D\u4E0D\u80FD\u4E3A\u7A7A
|
||||
sysuser.password.require=\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import admin from './module/admin.js'
|
|||
import agent from './module/agent.js'
|
||||
import device from './module/device.js'
|
||||
import model from './module/model.js'
|
||||
import timbre from "./module/timbre.js"
|
||||
import user from './module/user.js'
|
||||
|
||||
/**
|
||||
|
|
@ -29,4 +30,5 @@ export default {
|
|||
agent,
|
||||
device,
|
||||
model,
|
||||
timbre,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,6 +56,89 @@ export default {
|
|||
this.resetUserPassword(id, callback)
|
||||
})
|
||||
}).send()
|
||||
}
|
||||
},
|
||||
getParamsList(params, callback) {
|
||||
const queryParams = new URLSearchParams({
|
||||
page: params.page,
|
||||
limit: params.limit
|
||||
}).toString();
|
||||
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/admin/params/page?${queryParams}`)
|
||||
.method('GET')
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime()
|
||||
callback(res)
|
||||
})
|
||||
.fail((err) => {
|
||||
console.error('获取参数列表失败:', err)
|
||||
RequestService.reAjaxFun(() => {
|
||||
this.getParamsList(params, callback)
|
||||
})
|
||||
}).send()
|
||||
},
|
||||
addParam(data, callback) {
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/admin/params`)
|
||||
.method('POST')
|
||||
.data(data)
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime()
|
||||
callback(res)
|
||||
})
|
||||
.fail((err) => {
|
||||
console.error('添加参数失败:', err)
|
||||
RequestService.reAjaxFun(() => {
|
||||
this.addParam(data, callback)
|
||||
})
|
||||
}).send()
|
||||
},
|
||||
updateParam(data, callback) {
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/admin/params`)
|
||||
.method('PUT')
|
||||
.data(data)
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime()
|
||||
callback(res)
|
||||
})
|
||||
.fail((err) => {
|
||||
console.error('更新参数失败:', err)
|
||||
RequestService.reAjaxFun(() => {
|
||||
this.updateParam(data, callback)
|
||||
})
|
||||
}).send()
|
||||
},
|
||||
deleteParam(id, callback) {
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/admin/params`)
|
||||
.method('DELETE')
|
||||
.data({ ids: [id] })
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime()
|
||||
callback(res)
|
||||
})
|
||||
.fail((err) => {
|
||||
console.error('删除参数失败:', err)
|
||||
RequestService.reAjaxFun(() => {
|
||||
this.deleteParam(id, callback)
|
||||
})
|
||||
}).send()
|
||||
},
|
||||
batchDeleteParams(ids, callback) {
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/admin/params`)
|
||||
.method('DELETE')
|
||||
.data({ ids })
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime()
|
||||
callback(res)
|
||||
})
|
||||
.fail((err) => {
|
||||
console.error('批量删除参数失败:', err)
|
||||
RequestService.reAjaxFun(() => {
|
||||
this.batchDeleteParams(ids, callback)
|
||||
})
|
||||
}).send()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -159,5 +159,23 @@ export default {
|
|||
})
|
||||
}).send()
|
||||
},
|
||||
|
||||
// 更新模型配置
|
||||
updateModel(params, callback) {
|
||||
const { modelType, provideCode, id, formData } = params;
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/models/${modelType}/${provideCode}/${id}`)
|
||||
.method('PUT')
|
||||
.data(formData)
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime();
|
||||
callback(res);
|
||||
})
|
||||
.fail((err) => {
|
||||
console.error('更新模型失败:', err);
|
||||
this.$message.error(err.msg || '更新模型失败');
|
||||
RequestService.reAjaxFun(() => {
|
||||
this.updateModel(params, callback);
|
||||
});
|
||||
}).send();
|
||||
},
|
||||
}
|
||||
|
|
|
|||
102
main/manager-web/src/apis/module/timbre.js
Normal file
102
main/manager-web/src/apis/module/timbre.js
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
// timbre.js
|
||||
import {getServiceUrl} from '../api';
|
||||
import RequestService from '../httpRequest';
|
||||
|
||||
export default {
|
||||
/**
|
||||
* 获取音色数据
|
||||
*/
|
||||
getVoiceList(params, callback) {
|
||||
const queryParams = new URLSearchParams({
|
||||
ttsModelId: params.ttsModelId,
|
||||
page: params.page || 1,
|
||||
limit: params.limit || 10,
|
||||
name: params.name || ''
|
||||
}).toString();
|
||||
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/ttsVoice?${queryParams}`)
|
||||
.method('GET')
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime();
|
||||
callback(res.data || []);
|
||||
})
|
||||
.fail((err) => {
|
||||
console.error('获取音色列表失败:', err);
|
||||
RequestService.reAjaxFun(() => {
|
||||
this.getVoiceList(params, callback);
|
||||
});
|
||||
}).send();
|
||||
},
|
||||
/**
|
||||
* 音色保存
|
||||
*/
|
||||
saveVoice(params, callback) {
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/ttsVoice`)
|
||||
.method('POST')
|
||||
.data(JSON.stringify({
|
||||
languages: params.languageType,
|
||||
name: params.voiceName,
|
||||
remark: params.remark,
|
||||
sort: params.sort,
|
||||
ttsModelId: params.ttsModelId,
|
||||
ttsVoice: params.voiceCode,
|
||||
voiceDemo: params.voiceDemo || ''
|
||||
}))
|
||||
.success((res) => {
|
||||
callback(res.data);
|
||||
})
|
||||
.fail((err) => {
|
||||
console.error('保存音色失败:', err);
|
||||
RequestService.reAjaxFun(() => {
|
||||
this.saveVoice(params, callback);
|
||||
});
|
||||
}).send();
|
||||
},
|
||||
/**
|
||||
* 音色删除
|
||||
*/
|
||||
deleteVoice(id, callback) {
|
||||
console.log('尝试删除音色,ID:', id);
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/ttsVoice`)
|
||||
.method('DELETE')
|
||||
.data({ ids: [id] })
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime()
|
||||
callback(res);
|
||||
})
|
||||
.fail((err) => {
|
||||
console.error('删除音色失败:', err);
|
||||
RequestService.reAjaxFun(() => {
|
||||
this.deleteVoice(id, callback);
|
||||
});
|
||||
}).send();
|
||||
},
|
||||
/**
|
||||
* 音色修改
|
||||
*/
|
||||
updateVoice(params, callback) {
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/ttsVoice/${params.id}`)
|
||||
.method('PUT')
|
||||
.data(JSON.stringify({
|
||||
languages: params.languageType,
|
||||
name: params.voiceName,
|
||||
remark: params.remark,
|
||||
ttsModelId: params.ttsModelId,
|
||||
ttsVoice: params.voiceCode,
|
||||
voiceDemo: params.voiceDemo || ''
|
||||
}))
|
||||
.success((res) => {
|
||||
callback(res.data);
|
||||
})
|
||||
.fail((err) => {
|
||||
console.error('修改音色失败:', err);
|
||||
RequestService.reAjaxFun(() => {
|
||||
this.updateVoice(params, callback);
|
||||
});
|
||||
}).send();
|
||||
}
|
||||
}
|
||||
BIN
main/manager-web/src/assets/header/param_management.png
Normal file
BIN
main/manager-web/src/assets/header/param_management.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.7 KiB |
|
|
@ -1,12 +1,12 @@
|
|||
<template>
|
||||
<el-dialog :visible.sync="visible" width="975px" center custom-class="custom-dialog" :show-close="false"
|
||||
<el-dialog :visible="dialogVisible" @update:visible="handleVisibleChange" width="975px" center custom-class="custom-dialog" :show-close="false"
|
||||
class="center-dialog">
|
||||
<div style="margin: 0 18px; text-align: left; padding: 10px; border-radius: 10px;">
|
||||
<div style="font-size: 30px; color: #3d4566; margin-top: -10px; margin-bottom: 10px; text-align: center;">
|
||||
添加模型
|
||||
</div>
|
||||
|
||||
<!-- 关闭按钮 -->
|
||||
|
||||
<button class="custom-close-btn" @click="handleClose">
|
||||
×
|
||||
</button>
|
||||
|
|
@ -61,23 +61,27 @@
|
|||
</el-form>
|
||||
|
||||
<div style="font-size: 20px; font-weight: bold; color: #3d4566; margin-bottom: 15px;">调用信息</div>
|
||||
<div style="height: 2px; background: #e9e9e9; margin-bottom: 15px;"></div>
|
||||
<div style="height: 2px; background: #e9e9e9; margin-bottom: 22px;"></div>
|
||||
|
||||
<el-form :model="formData" label-width="100px" label-position="left" class="custom-form">
|
||||
<div style="display: flex; gap: 10px; margin-bottom: 15px;">
|
||||
<el-form-item label="模型名称" prop="param1" style="flex: 0.5; margin-bottom: 0;">
|
||||
<el-input v-model="formData.configJson.param1" placeholder="请输入model_name"
|
||||
class="custom-input-bg"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="接口地址" prop="param2" style="flex: 1; margin-bottom: 0;">
|
||||
<el-input v-model="formData.configJson.param2" placeholder="请输入base_url" class="custom-input-bg"></el-input>
|
||||
</el-form-item>
|
||||
</div>
|
||||
|
||||
<el-form-item label="秘钥信息" prop="apiKey">
|
||||
<el-input v-model="formData.configJson.apiKey" placeholder="请输入api_key" show-password
|
||||
class="custom-input-bg"></el-input>
|
||||
</el-form-item>
|
||||
<el-form :model="formData.configJson" label-width="auto" label-position="left" class="custom-form">
|
||||
<template v-for="(row, rowIndex) in chunkedCallInfoFields">
|
||||
<div :key="rowIndex" style="display: flex; gap: 20px; margin-bottom: 0;">
|
||||
<el-form-item
|
||||
v-for="field in row"
|
||||
:key="field.prop"
|
||||
:label="field.label"
|
||||
:prop="field.prop"
|
||||
style="flex: 1;">
|
||||
<el-input
|
||||
v-model="formData.configJson[field.prop]"
|
||||
:placeholder="field.placeholder"
|
||||
:type="field.type || 'text'"
|
||||
class="custom-input-bg"
|
||||
:show-password="field.type === 'password'">
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</template>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
|
|
@ -100,7 +104,10 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
providers: [],
|
||||
dialogVisible: false,
|
||||
providersLoaded: false,
|
||||
providerFields: [],
|
||||
currentProvider: null,
|
||||
formData: {
|
||||
modelName: '',
|
||||
modelCode: '',
|
||||
|
|
@ -110,14 +117,38 @@ export default {
|
|||
remark: '',
|
||||
isEnabled: true,
|
||||
isDefault: true,
|
||||
configJson: {
|
||||
param1: '',
|
||||
param2: '',
|
||||
apiKey: ''
|
||||
}
|
||||
configJson: {}
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
visible(val) {
|
||||
this.dialogVisible = val;
|
||||
if(val) {
|
||||
this.initConfigJson();
|
||||
} else {
|
||||
this.resetForm();
|
||||
}
|
||||
},
|
||||
'formData.supplier'(newVal) {
|
||||
this.currentProvider = this.providers.find(p => p.value === newVal);
|
||||
this.providerFields = this.currentProvider?.fields || [];
|
||||
this.initDynamicConfig();
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
dynamicCallInfoFields() {
|
||||
return this.providerFields;
|
||||
},
|
||||
chunkedCallInfoFields() {
|
||||
const chunkSize = 2;
|
||||
const result = [];
|
||||
for (let i = 0; i < this.dynamicCallInfoFields.length; i += chunkSize) {
|
||||
result.push(this.dynamicCallInfoFields.slice(i, i + chunkSize));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
loadProviders() {
|
||||
if (this.providersLoaded)
|
||||
|
|
@ -126,23 +157,65 @@ export default {
|
|||
Api.model.getModelProviders(this.modelType, (data) => {
|
||||
this.providers = data.map(item => ({
|
||||
label: item.name,
|
||||
value: item.providerCode
|
||||
value: item.providerCode,
|
||||
fields: JSON.parse(item.fields || '[]').map(f => ({
|
||||
label: f.label,
|
||||
prop: f.key,
|
||||
type: f.type === 'password' ? 'password' : 'text',
|
||||
placeholder: `请输入${f.label}`
|
||||
}))
|
||||
}))
|
||||
this.providersLoaded = true
|
||||
})
|
||||
},
|
||||
initConfigJson() {
|
||||
const defaultConfig = {};
|
||||
this.providerFields.forEach(field => {
|
||||
defaultConfig[field.prop] = '';
|
||||
});
|
||||
this.formData.configJson = { ...defaultConfig };
|
||||
},
|
||||
handleVisibleChange(val) {
|
||||
this.dialogVisible = val;
|
||||
this.$emit('update:visible', val);
|
||||
if (!val) {
|
||||
this.resetForm();
|
||||
}
|
||||
},
|
||||
|
||||
handleClose() {
|
||||
this.$emit('update:visible', false);
|
||||
},
|
||||
initDynamicConfig() {
|
||||
const newConfig = {};
|
||||
this.providerFields.forEach(field => {
|
||||
newConfig[field.prop] = this.formData.configJson[field.prop] || '';
|
||||
});
|
||||
this.formData.configJson = newConfig;
|
||||
},
|
||||
confirm() {
|
||||
if (!this.formData.modelName || !this.formData.modelCode || !this.formData.supplier ||
|
||||
!this.formData.configJson.param1 || !this.formData.configJson.param2 || !this.formData.configJson.apiKey) {
|
||||
this.$message.error('请填写所有必填字段');
|
||||
if (!this.formData.supplier) {
|
||||
this.$message.error('请选择供应器');
|
||||
return;
|
||||
}
|
||||
|
||||
this.$emit('confirm', {
|
||||
...this.formData,
|
||||
const submitData = {
|
||||
modelName: this.formData.modelName || '',
|
||||
modelCode: this.formData.modelCode || '',
|
||||
supplier: this.formData.supplier,
|
||||
sort: this.formData.sort || 1,
|
||||
docLink: this.formData.docLink || '',
|
||||
remark: this.formData.remark || '',
|
||||
isEnabled: this.formData.isEnabled ? 1 : 0,
|
||||
isDefault: this.formData.isDefault ? 1 : 0,
|
||||
provideCode: this.formData.supplier,
|
||||
configJson: this.formData.configJson
|
||||
});
|
||||
configJson: {
|
||||
...this.formData.configJson,
|
||||
type: this.formData.supplier
|
||||
}
|
||||
};
|
||||
|
||||
this.$emit('confirm', submitData);
|
||||
this.$emit('update:visible', false);
|
||||
this.resetForm();
|
||||
},
|
||||
|
|
@ -156,20 +229,15 @@ export default {
|
|||
remark: '',
|
||||
isEnabled: true,
|
||||
isDefault: true,
|
||||
configJson: {
|
||||
param1: '',
|
||||
param2: '',
|
||||
apiKey: ''
|
||||
}
|
||||
configJson: {}
|
||||
};
|
||||
// 重置加载状态
|
||||
this.providers = [];
|
||||
this.providersLoaded = false;
|
||||
// 重置字段配置
|
||||
this.providerFields = [];
|
||||
this.currentProvider = null;
|
||||
},
|
||||
handleClose() {
|
||||
this.resetForm();
|
||||
this.$emit('update:visible', false);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
379
main/manager-web/src/components/AudioPlayer.vue
Normal file
379
main/manager-web/src/components/AudioPlayer.vue
Normal file
|
|
@ -0,0 +1,379 @@
|
|||
<template>
|
||||
<div class="audio-container">
|
||||
<audio
|
||||
ref="audioRef"
|
||||
:src="audioUrl"
|
||||
@timeupdate="updateProgress"
|
||||
@loadedmetadata="updateDuration"
|
||||
style="display: none"
|
||||
></audio>
|
||||
|
||||
<div class="custom-controls">
|
||||
<!-- 播放/暂停按钮 -->
|
||||
<button class="play-btn" @click="togglePlay">
|
||||
<svg width="20" height="20" viewBox="0 0 20 20">
|
||||
<path
|
||||
fill="#4362b3"
|
||||
:d="isPlaying
|
||||
? 'M6 3h3v14H6zm5 0h3v14h-3z'
|
||||
: 'M5 3l12 7-12 7z'"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
<!-- 时间显示 -->
|
||||
<span class="time-display">{{ formattedCurrentTime }}/{{ formattedDuration }}</span>
|
||||
|
||||
<!-- 进度条 -->
|
||||
<div class="progress-container">
|
||||
<div class="progress-bar" @click="handleProgressClick">
|
||||
<div
|
||||
class="progress-track"
|
||||
:style="{ width: progress + '%' }"
|
||||
></div>
|
||||
<div
|
||||
class="progress-thumb"
|
||||
:style="{ left: progress + '%' }"
|
||||
@mousedown="startDrag"
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 音量控制 -->
|
||||
<div class="volume-control" ref="volumeControl">
|
||||
<button
|
||||
@click="toggleMute"
|
||||
@mouseenter="handleVolumeMouseEnter"
|
||||
@mouseleave="startVolumeSliderHideTimer"
|
||||
ref="volumeButton"
|
||||
class="volume-button"
|
||||
>
|
||||
<svg width="20" height="20" viewBox="0 0 24 24">
|
||||
<path fill="currentColor" :d="volumeIconPath"/>
|
||||
</svg>
|
||||
</button>
|
||||
<div
|
||||
v-show="showVolumeSlider"
|
||||
class="volume-slider-container"
|
||||
@mouseenter="cancelVolumeSliderHideTimer"
|
||||
@mouseleave="startVolumeSliderHideTimer"
|
||||
ref="volumeSlider"
|
||||
>
|
||||
<div class="volume-slider-track">
|
||||
<input
|
||||
type="range"
|
||||
v-model="volume"
|
||||
min="0"
|
||||
max="1"
|
||||
step="0.1"
|
||||
class="volume-slider"
|
||||
@input="handleVolumeChange"
|
||||
orient="vertical"
|
||||
>
|
||||
<div class="volume-slider-thumb" :style="{ bottom: volume * 100 + '%' }"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted, onUnmounted, nextTick } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
audioUrl: String
|
||||
})
|
||||
|
||||
// 音频元素引用
|
||||
const audioRef = ref(null)
|
||||
const volumeButton = ref(null)
|
||||
const volumeSlider = ref(null)
|
||||
|
||||
// 播放状态
|
||||
const isPlaying = ref(false)
|
||||
const currentTime = ref(0)
|
||||
const duration = ref(0)
|
||||
const progress = ref(0)
|
||||
|
||||
// 音量状态
|
||||
const volume = ref(0.7)
|
||||
const isMuted = ref(false)
|
||||
const showVolumeSlider = ref(false)
|
||||
let volumeSliderHideTimer = null
|
||||
|
||||
// 格式化时间为 MM:SS
|
||||
const formatTime = (seconds) => {
|
||||
const sec = Math.floor(seconds || 0)
|
||||
return `${Math.floor(sec / 60)}:${(sec % 60).toString().padStart(2, '0')}`
|
||||
}
|
||||
|
||||
const formattedCurrentTime = computed(() => formatTime(currentTime.value))
|
||||
const formattedDuration = computed(() => formatTime(duration.value))
|
||||
|
||||
// 根据音量状态返回对应的图标路径
|
||||
const volumeIconPath = computed(() => {
|
||||
if (isMuted.value || volume.value === 0) {
|
||||
return 'M16.5 12c0-1.77-1.02-3.29-2.5-4.03v2.21l2.45 2.45c.03-.2.05-.41.05-.63zm2.5 0c0 .94-.2 1.82-.54 2.64l1.51 1.51C20.63 14.91 21 13.5 21 12c0-4.28-2.99-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71zM4.27 3L3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25c-.67.52-1.42.93-2.25 1.18v2.06c1.38-.31 2.63-.95 3.69-1.81L19.73 21 21 19.73l-9-9L4.27 3zM12 4L9.91 6.09 12 8.18V4z'
|
||||
}
|
||||
return 'M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z'
|
||||
})
|
||||
|
||||
// 播放控制
|
||||
const togglePlay = () => {
|
||||
if (isPlaying.value) {
|
||||
audioRef.value.pause()
|
||||
} else {
|
||||
audioRef.value.play()
|
||||
}
|
||||
isPlaying.value = !isPlaying.value
|
||||
}
|
||||
|
||||
const updateDuration = () => {
|
||||
if (audioRef.value) {
|
||||
duration.value = audioRef.value.duration
|
||||
}
|
||||
}
|
||||
|
||||
const updateProgress = () => {
|
||||
if (audioRef.value?.duration) {
|
||||
currentTime.value = audioRef.value.currentTime
|
||||
progress.value = (currentTime.value / duration.value) * 100
|
||||
}
|
||||
}
|
||||
|
||||
const handleProgressClick = (e) => {
|
||||
const rect = e.currentTarget.getBoundingClientRect()
|
||||
const percentage = ((e.clientX - rect.left) / rect.width) * 100
|
||||
seekToPercentage(percentage)
|
||||
}
|
||||
|
||||
// 音量控制
|
||||
const toggleMute = () => {
|
||||
isMuted.value = !isMuted.value
|
||||
audioRef.value.muted = isMuted.value
|
||||
|
||||
// 如果取消静音且音量为0,则恢复默认音量
|
||||
if (!isMuted.value && volume.value === 0) {
|
||||
volume.value = 0.5
|
||||
audioRef.value.volume = 0.5
|
||||
}
|
||||
}
|
||||
|
||||
const handleVolumeChange = (e) => {
|
||||
const newVolume = parseFloat(e.target.value)
|
||||
audioRef.value.volume = newVolume
|
||||
isMuted.value = newVolume === 0
|
||||
}
|
||||
|
||||
// 进度条拖拽功能
|
||||
let isDragging = false
|
||||
|
||||
const startDrag = (e) => {
|
||||
isDragging = true
|
||||
document.addEventListener('mousemove', handleDrag)
|
||||
document.addEventListener('mouseup', stopDrag)
|
||||
e.preventDefault()
|
||||
}
|
||||
|
||||
const handleDrag = (e) => {
|
||||
if (!isDragging) return
|
||||
|
||||
const rect = document.querySelector('.progress-bar').getBoundingClientRect()
|
||||
const percentage = ((e.clientX - rect.left) / rect.width) * 100
|
||||
seekToPercentage(percentage)
|
||||
}
|
||||
|
||||
const stopDrag = () => {
|
||||
isDragging = false
|
||||
document.removeEventListener('mousemove', handleDrag)
|
||||
document.removeEventListener('mouseup', stopDrag)
|
||||
}
|
||||
|
||||
const seekToPercentage = (percentage) => {
|
||||
const clampedPercentage = Math.min(Math.max(percentage, 0), 100)
|
||||
progress.value = clampedPercentage
|
||||
audioRef.value.currentTime = (clampedPercentage / 100) * duration.value
|
||||
}
|
||||
|
||||
// 音量滑块显示/隐藏控制
|
||||
const startVolumeSliderHideTimer = () => {
|
||||
volumeSliderHideTimer = setTimeout(() => {
|
||||
showVolumeSlider.value = false
|
||||
}, 300)
|
||||
}
|
||||
|
||||
const cancelVolumeSliderHideTimer = () => {
|
||||
clearTimeout(volumeSliderHideTimer)
|
||||
}
|
||||
|
||||
// 音量滑块定位
|
||||
const updateSliderPosition = () => {
|
||||
nextTick(() => {
|
||||
if (!volumeButton.value || !volumeSlider.value) return
|
||||
|
||||
const buttonRect = volumeButton.value.getBoundingClientRect()
|
||||
const slider = volumeSlider.value
|
||||
|
||||
// 计算相对于视口的位置
|
||||
const left = buttonRect.left + window.scrollX
|
||||
const top = buttonRect.top + window.scrollY
|
||||
|
||||
// 定位到按钮正中间,垂直居中
|
||||
slider.style.left = `${left + 5}px`
|
||||
slider.style.top = `${top - 85}px`
|
||||
})
|
||||
}
|
||||
|
||||
const handleVolumeMouseEnter = () => {
|
||||
showVolumeSlider.value = true
|
||||
updateSliderPosition()
|
||||
}
|
||||
|
||||
// 初始化
|
||||
onMounted(() => {
|
||||
if (audioRef.value) {
|
||||
audioRef.value.volume = volume.value
|
||||
}
|
||||
window.addEventListener('resize', updateSliderPosition)
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('resize', updateSliderPosition)
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.audio-container {
|
||||
background: #eef0fd;
|
||||
padding: 8px;
|
||||
height: 40px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.custom-controls {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.play-btn {
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 0;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.time-display {
|
||||
font-size: 12px;
|
||||
color: #5f7ba7;
|
||||
min-width: 40px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.progress-container {
|
||||
flex: 1;
|
||||
padding: 0 10px;
|
||||
opacity: 0.7;
|
||||
transition: opacity 0.3s ease;
|
||||
}
|
||||
|
||||
.progress-container:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.progress-bar {
|
||||
height: 2px;
|
||||
background: #bfcadb;
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.progress-track {
|
||||
position: absolute;
|
||||
height: 100%;
|
||||
background: #4167ed;
|
||||
}
|
||||
|
||||
.progress-thumb {
|
||||
position: absolute;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
background: #4167ed;
|
||||
border: 2px solid #d6dcfc;
|
||||
border-radius: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
cursor: pointer;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.volume-control {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.volume-button {
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 0;
|
||||
color: #8f95cd;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.volume-slider-container {
|
||||
position: fixed;
|
||||
padding: 10px 4px;
|
||||
background: #eef0fd;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||
z-index: 1000;
|
||||
height: 75px;
|
||||
}
|
||||
|
||||
.volume-slider-track {
|
||||
position: relative;
|
||||
height: 55px;
|
||||
width: 2px;
|
||||
background: #bfcadb;
|
||||
margin: 1px;
|
||||
}
|
||||
|
||||
.volume-slider-thumb {
|
||||
position: absolute;
|
||||
left: 1px;
|
||||
width: 9px;
|
||||
height: 9px;
|
||||
background: #4167ed;
|
||||
border: 2px solid #d6dcfc;
|
||||
border-radius: 50%;
|
||||
transform: translateX(-50%);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.volume-slider {
|
||||
position: absolute;
|
||||
left: -14px;
|
||||
width: 30px;
|
||||
height: 60px;
|
||||
writing-mode: vertical-lr;
|
||||
direction: rtl;
|
||||
opacity: 0;
|
||||
cursor: pointer;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.volume-slider-track::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
width: 2px;
|
||||
height: calc(100% * v-bind(volume));
|
||||
background: #4167ed;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -26,6 +26,12 @@
|
|||
:style="{ filter: $route.path === '/user-management' ? 'brightness(0) invert(1)' : 'None' }" />
|
||||
用户管理
|
||||
</div>
|
||||
<div v-if="isSuperAdmin" class="equipment-management"
|
||||
:class="{ 'active-tab': $route.path === '/params-management' }" @click="goParamManagement">
|
||||
<img loading="lazy" alt="" src="@/assets/header/param_management.png"
|
||||
:style="{ filter: $route.path === '/params-management' ? 'brightness(0) invert(1)' : 'None' }" />
|
||||
参数管理
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 右侧元素 -->
|
||||
|
|
@ -96,6 +102,9 @@ export default {
|
|||
goModelConfig() {
|
||||
this.$router.push('/model-config')
|
||||
},
|
||||
goParamManagement() {
|
||||
this.$router.push('/params-management')
|
||||
},
|
||||
// 获取用户信息
|
||||
fetchUserInfo() {
|
||||
userApi.getUserInfo(({ data }) => {
|
||||
|
|
|
|||
|
|
@ -15,11 +15,11 @@
|
|||
<div style="display: flex; align-items: center; gap: 20px;">
|
||||
<div style="display: flex; align-items: center;">
|
||||
<span style="margin-right: 8px;">是否启用</span>
|
||||
<el-switch v-model="form.isEnabled" :active-value="1" :inactive-value="0" class="custom-switch"></el-switch>
|
||||
<el-switch v-model="form.isEnabled" :active-value="1" :inactive-value="0" class="custom-switch"></el-switch>
|
||||
</div>
|
||||
<div style="display: flex; align-items: center;">
|
||||
<span style="margin-right: 8px;">设为默认</span>
|
||||
<el-switch v-model="form.isDefault" :active-value="1" :inactive-value="0" class="custom-switch"></el-switch>
|
||||
<el-switch v-model="form.isDefault" :active-value="1" :inactive-value="0" class="custom-switch"></el-switch>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -38,13 +38,13 @@
|
|||
|
||||
<div style="display: flex; gap: 20px; margin-bottom: 0;">
|
||||
<el-form-item label="供应器" prop="supplier" style="flex: 1;">
|
||||
<el-select v-model="form.modelType" placeholder="请选择" class="custom-select custom-input-bg"
|
||||
<el-select v-model="form.configJson.type" placeholder="请选择" class="custom-select custom-input-bg"
|
||||
style="width: 100%;" @focus="loadProviders" filterable>
|
||||
<el-option v-for="item in providers" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="排序号" prop="sort" style="flex: 1;">
|
||||
<el-input v-model="form.sort" placeholder="请输入排序号" class="custom-input-bg"></el-input>
|
||||
<el-input v-model.number="form.sort" type="number" placeholder="请输入排序号" class="custom-input-bg"></el-input>
|
||||
</el-form-item>
|
||||
</div>
|
||||
|
||||
|
|
@ -59,21 +59,27 @@
|
|||
</el-form>
|
||||
|
||||
<div style="font-size: 20px; font-weight: bold; color: #3d4566; margin-bottom: 15px;">调用信息</div>
|
||||
<div style="height: 2px; background: #e9e9e9; margin-bottom: 15px;"></div>
|
||||
<div style="height: 2px; background: #e9e9e9; margin-bottom: 22px;"></div>
|
||||
|
||||
<el-form :model="form" label-width="100px" label-position="left" class="custom-form">
|
||||
<div style="display: flex; gap: 10px; margin-bottom: 15px;">
|
||||
<el-form-item label="模型名称" prop="modelName" style="flex: 0.5; margin-bottom: 0;">
|
||||
<el-input v-model="form.name" placeholder="请输入model_name" class="custom-input-bg"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="接口地址" prop="apiUrl" style="flex: 1; margin-bottom: 0;">
|
||||
<el-input v-model="form.apiUrl" placeholder="请输入base_url" class="custom-input-bg"></el-input>
|
||||
</el-form-item>
|
||||
</div>
|
||||
|
||||
<el-form-item label="秘钥信息" prop="apiKey">
|
||||
<el-input v-model="form.apiKey" placeholder="请输入api_key" show-password class="custom-input-bg"></el-input>
|
||||
</el-form-item>
|
||||
<el-form :model="form.configJson" ref="callInfoForm" label-width="auto" class="custom-form">
|
||||
<template v-for="(row, rowIndex) in chunkedCallInfoFields">
|
||||
<div :key="rowIndex" style="display: flex; gap: 20px; margin-bottom: 0;">
|
||||
<el-form-item
|
||||
v-for="field in row"
|
||||
:key="field.prop"
|
||||
:label="field.label"
|
||||
:prop="field.prop"
|
||||
style="flex: 1;">
|
||||
<el-input
|
||||
v-model="form.configJson[field.prop]"
|
||||
:placeholder="field.placeholder"
|
||||
:type="field.type"
|
||||
class="custom-input-bg"
|
||||
:show-password="field.type === 'password'">
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</template>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
|
|
@ -89,7 +95,6 @@
|
|||
import Api from '@/apis/api';
|
||||
|
||||
const DEFAULT_CONFIG_JSON = {
|
||||
provider: "",
|
||||
type: "",
|
||||
base_url: "",
|
||||
model_name: "",
|
||||
|
|
@ -97,8 +102,8 @@ const DEFAULT_CONFIG_JSON = {
|
|||
raw: {},
|
||||
config: {
|
||||
keyComparator: {},
|
||||
ignoreError: 0,
|
||||
ignoreCase: 0,
|
||||
ignoreError: false,
|
||||
ignoreCase: false,
|
||||
dateFormat: "",
|
||||
ignoreNullValue: false,
|
||||
transientSupport: false,
|
||||
|
|
@ -111,7 +116,7 @@ const DEFAULT_CONFIG_JSON = {
|
|||
|
||||
export default {
|
||||
name: "ModelEditDialog",
|
||||
props: {
|
||||
props: {
|
||||
visible: { type: Boolean, default: false },
|
||||
modelData: {
|
||||
type: Object,
|
||||
|
|
@ -125,6 +130,10 @@ export default {
|
|||
dialogVisible: this.visible,
|
||||
providers: [],
|
||||
providersLoaded: false,
|
||||
allProvidersData: null,
|
||||
pendingProviderType: null,
|
||||
pendingModelData: null,
|
||||
dynamicCallInfoFields: [],
|
||||
form: {
|
||||
id: "",
|
||||
modelType: "",
|
||||
|
|
@ -135,15 +144,24 @@ export default {
|
|||
docLink: "",
|
||||
remark: "",
|
||||
sort: 0,
|
||||
apiKey: "",
|
||||
apiUrl: "",
|
||||
configJson: JSON.parse(JSON.stringify(DEFAULT_CONFIG_JSON))
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
chunkedCallInfoFields() {
|
||||
const chunkSize = 2;
|
||||
const result = [];
|
||||
for (let i = 0; i < this.dynamicCallInfoFields.length; i += chunkSize) {
|
||||
result.push(this.dynamicCallInfoFields.slice(i, i + chunkSize));
|
||||
}
|
||||
return result;
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
modelType() {
|
||||
this.resetProviders()
|
||||
this.resetProviders();
|
||||
this.loadProviders();
|
||||
},
|
||||
dialogVisible(val) {
|
||||
this.$emit('update:visible', val);
|
||||
|
|
@ -155,6 +173,14 @@ export default {
|
|||
},
|
||||
visible(val) {
|
||||
this.dialogVisible = val;
|
||||
if (val) {
|
||||
this.loadProviders();
|
||||
}
|
||||
},
|
||||
'form.configJson.type'(newVal) {
|
||||
if (newVal && this.providersLoaded) {
|
||||
this.loadProviderFields(newVal);
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
|
@ -168,9 +194,7 @@ export default {
|
|||
isEnabled: false,
|
||||
docLink: "",
|
||||
remark: "",
|
||||
sort: 0,
|
||||
apiKey: "",
|
||||
apiUrl: "",
|
||||
sort: "",
|
||||
configJson: JSON.parse(JSON.stringify(DEFAULT_CONFIG_JSON))
|
||||
};
|
||||
},
|
||||
|
|
@ -183,59 +207,40 @@ export default {
|
|||
Api.model.getModelConfig(this.modelData.id, ({ data }) => {
|
||||
if (data.code === 0 && data.data) {
|
||||
const model = data.data;
|
||||
this.pendingProviderType = model.configJson.type;
|
||||
this.pendingModelData = model;
|
||||
|
||||
this.loadProviders();
|
||||
|
||||
let configJson = model.configJson || {};
|
||||
if (typeof configJson !== 'object' || Array.isArray(configJson)) {
|
||||
console.warn('Invalid configJson format, using default');
|
||||
configJson = {};
|
||||
if (this.providersLoaded) {
|
||||
this.loadProviderFields(model.configJson.type);
|
||||
} else {
|
||||
this.loadProviders();
|
||||
}
|
||||
|
||||
this.form = {
|
||||
id: model.id || "",
|
||||
modelType: model.modelType || "",
|
||||
modelCode: model.modelCode || "",
|
||||
modelName: model.modelName || "",
|
||||
isDefault: model.isDefault || 0,
|
||||
isEnabled: model.isEnabled || 0,
|
||||
docLink: model.docLink || "",
|
||||
remark: model.remark || "",
|
||||
sort: model.sort || 0,
|
||||
apiKey: configJson.api_key || "",
|
||||
apiUrl: configJson.base_url || "",
|
||||
name:configJson.model_name,
|
||||
configJson: {
|
||||
...JSON.parse(JSON.stringify(DEFAULT_CONFIG_JSON)),
|
||||
...configJson,
|
||||
config: {
|
||||
...DEFAULT_CONFIG_JSON.config,
|
||||
...(configJson.config || {})
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
handleSave() {
|
||||
const provideCode = this.form.configJson.type;
|
||||
const { provider, ...restConfigJson } = this.form.configJson;
|
||||
const formData = {
|
||||
modelCode: this.form.code,
|
||||
modelName: this.form.name,
|
||||
supplier: this.form.supplier,
|
||||
id: this.form.id,
|
||||
modelCode: this.form.modelCode,
|
||||
modelName: this.form.modelName,
|
||||
isDefault: this.form.isDefault ? 1 : 0,
|
||||
isEnabled: this.form.isEnable ? 1 : 0,
|
||||
docLink: this.form.docUrl,
|
||||
sort: this.form.sort,
|
||||
isEnabled: this.form.isEnabled ? 1 : 0,
|
||||
docLink: this.form.docLink,
|
||||
remark: this.form.remark,
|
||||
sort: this.form.sort || 0,
|
||||
configJson: {
|
||||
provider: this.form.supplier,
|
||||
modelName: this.form.modelName,
|
||||
apiUrl: this.form.apiUrl,
|
||||
apiKey: this.form.apiKey
|
||||
...restConfigJson,
|
||||
config: {
|
||||
...restConfigJson.config,
|
||||
ignoreError: !!restConfigJson.config?.ignoreError,
|
||||
ignoreCase: !!restConfigJson.config?.ignoreCase,
|
||||
}
|
||||
}
|
||||
};
|
||||
this.$emit("save", formData);
|
||||
this.$emit("save", { provideCode, formData });
|
||||
this.dialogVisible = false;
|
||||
},
|
||||
loadProviders() {
|
||||
|
|
@ -247,8 +252,61 @@ export default {
|
|||
value: item.providerCode
|
||||
}));
|
||||
this.providersLoaded = true;
|
||||
|
||||
this.allProvidersData = data;
|
||||
|
||||
if (this.pendingProviderType) {
|
||||
this.loadProviderFields(this.pendingProviderType);
|
||||
}
|
||||
});
|
||||
},
|
||||
loadProviderFields(providerCode) {
|
||||
if (this.allProvidersData) {
|
||||
const provider = this.allProvidersData.find(p => p.providerCode === providerCode);
|
||||
if (provider) {
|
||||
this.dynamicCallInfoFields = JSON.parse(provider.fields || '[]').map(f => ({
|
||||
label: f.label,
|
||||
prop: f.key,
|
||||
type: f.type === 'password' ? 'password' : 'text',
|
||||
placeholder: `请输入${f.label}`
|
||||
}));
|
||||
|
||||
if (this.pendingModelData && this.pendingProviderType === providerCode) {
|
||||
this.processModelData(this.pendingModelData);
|
||||
this.pendingModelData = null;
|
||||
this.pendingProviderType = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
processModelData(model) {
|
||||
let configJson = model.configJson || {};
|
||||
this.dynamicCallInfoFields.forEach(field => {
|
||||
if (!configJson.hasOwnProperty(field.prop)) {
|
||||
configJson[field.prop] = '';
|
||||
}
|
||||
});
|
||||
|
||||
this.form = {
|
||||
id: model.id || "",
|
||||
modelType: model.modelType || "",
|
||||
modelCode: model.modelCode || "",
|
||||
modelName: model.modelName || "",
|
||||
isDefault: model.isDefault || 0,
|
||||
isEnabled: model.isEnabled || 0,
|
||||
docLink: model.docLink || "",
|
||||
remark: model.remark || "",
|
||||
sort: Number(model.sort) || 0,
|
||||
configJson: {
|
||||
...JSON.parse(JSON.stringify(DEFAULT_CONFIG_JSON)),
|
||||
...configJson,
|
||||
config: {
|
||||
...DEFAULT_CONFIG_JSON.config,
|
||||
...(configJson.config || {})
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
|
@ -414,4 +472,22 @@ export default {
|
|||
.custom-input-bg .el-input__inner {
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
|
||||
.custom-form .el-form-item {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
|
||||
.custom-input-bg .el-input__inner {
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
|
||||
.custom-form .el-form-item__label {
|
||||
color: #3d4566;
|
||||
font-weight: normal;
|
||||
text-align: right;
|
||||
padding-right: 20px;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -1,201 +1,693 @@
|
|||
<template>
|
||||
<el-dialog :visible.sync="localVisible" width="80%" @close="handleClose">
|
||||
<el-row class="main-container">
|
||||
<el-col :span="4">
|
||||
<el-menu class="model-menu" :default-active="activeModel" mode="vertical" @select="handleModelSelect">
|
||||
<el-menu-item index="EdgeTTS">EdgeTTS</el-menu-item>
|
||||
<el-menu-item index="DoubaoTTS">DoubaoTTS</el-menu-item>
|
||||
<el-menu-item index="TTS302AI">TTS302AI</el-menu-item>
|
||||
<el-menu-item index="CosyVoiceSiliconflow">CosyVoiceSiliconflow</el-menu-item>
|
||||
</el-menu>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="20">
|
||||
<div class="search-operate">
|
||||
<el-input placeholder="请输入音色名称查询" v-model="searchQuery" style="width: 300px; margin-right: 10px;"/>
|
||||
<el-button type="primary" @click="handleSearch">查询</el-button>
|
||||
<el-button type="primary" plain @click="handleAddVoice">添加音色</el-button>
|
||||
<el-button type="danger" plain @click="handleBatchDelete">批量删除</el-button>
|
||||
</div>
|
||||
|
||||
<el-table :data="filteredTtsModels" style="width: 100%" border stripe header-row-class-name="table-header">
|
||||
<el-table-column label="音色编码" prop="voiceCode" width="150" align="center"></el-table-column>
|
||||
<el-table-column label="音色名称" prop="voiceName" width="180" align="center"></el-table-column>
|
||||
<el-table-column label="语言类型" prop="languageType" width="120" align="center"></el-table-column>
|
||||
<el-table-column label="备注" prop="remark" align="center"></el-table-column>
|
||||
<el-table-column label="操作" width="200" align="center">
|
||||
<el-dialog
|
||||
:visible.sync="localVisible"
|
||||
width="75%"
|
||||
@close="handleClose"
|
||||
:show-close="false"
|
||||
:append-to-body="true"
|
||||
:close-on-click-modal="true">
|
||||
<button class="custom-close-btn" @click="handleClose">
|
||||
×
|
||||
</button>
|
||||
<div class="scroll-wrapper">
|
||||
<div
|
||||
class="table-container"
|
||||
ref="tableContainer"
|
||||
@scroll="handleScroll"
|
||||
>
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="filteredTtsModels"
|
||||
style="width: 100%;"
|
||||
class="data-table"
|
||||
header-row-class-name="table-header"
|
||||
:fit="true">
|
||||
<el-table-column label="选择" width="50" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" type="text" @click="editVoice(scope.row)" style="color: #409EFF; margin-right: 15px;">修改</el-button>
|
||||
<el-button size="mini" type="text" @click="deleteVoice(scope.row)" style="color: #F56C6C;">删除</el-button>
|
||||
<el-checkbox v-model="scope.row.selected"></el-checkbox>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="音色编码" align="center" min-width="50">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-if="scope.row.editing" v-model="scope.row.voiceCode"></el-input>
|
||||
<span v-else>{{ scope.row.voiceCode }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="音色名称" align="center" min-width="50">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-if="scope.row.editing" v-model="scope.row.voiceName"></el-input>
|
||||
<span v-else>{{ scope.row.voiceName }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="语言类型" align="center" min-width="50">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-if="scope.row.editing" v-model="scope.row.languageType"></el-input>
|
||||
<span v-else>{{ scope.row.languageType }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="试听" align="center" min-width="225" class-name="audio-column">
|
||||
<template slot-scope="scope">
|
||||
<div class="custom-audio-container">
|
||||
<el-input
|
||||
v-if="scope.row.editing"
|
||||
v-model="scope.row.voiceDemo"
|
||||
placeholder="请输入MP3地址"
|
||||
size="mini"
|
||||
class="audio-input"
|
||||
></el-input>
|
||||
<AudioPlayer v-else-if="isValidAudioUrl(scope.row.voiceDemo)" :audioUrl="scope.row.voiceDemo"/>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" align="center" min-width="120">
|
||||
<template slot-scope="scope">
|
||||
<el-input
|
||||
v-if="scope.row.editing"
|
||||
type="textarea"
|
||||
:rows="1"
|
||||
autosize
|
||||
v-model="scope.row.remark"
|
||||
placeholder="这里是备注"
|
||||
class="remark-input"></el-input>
|
||||
<span v-else>{{ scope.row.remark }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" width="150">
|
||||
<template slot-scope="scope">
|
||||
<template v-if="!scope.row.editing">
|
||||
<el-button type="primary" size="mini" @click="startEdit(scope.row)"
|
||||
style="background: #5cca8e;border:None">编辑
|
||||
</el-button>
|
||||
<el-button type="primary" size="mini" @click="deleteRow(scope.row)" style="background: red;border:None">
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
<el-button
|
||||
v-else
|
||||
type="success"
|
||||
size="mini"
|
||||
@click="saveEdit(scope.row)"
|
||||
class="save-Tts">保存
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<div class="pagination-container">
|
||||
<el-pagination :current-page="currentPage" :page-size="pageSize" :total="total" layout="prev, pager, next" prev-text="<" next-text=">"/>
|
||||
<!-- 自定义滚动条 -->
|
||||
<div class="custom-scrollbar" ref="scrollbar">
|
||||
<div class="custom-scrollbar-track" ref="scrollbarTrack" @click="handleTrackClick">
|
||||
<div class="custom-scrollbar-thumb" ref="scrollbarThumb" @mousedown="startDrag"></div>
|
||||
</div>
|
||||
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="handleClose" size="medium">关闭</el-button>
|
||||
<el-button type="primary" @click="handleImportExport" size="medium">导入导出配置</el-button>
|
||||
</div>
|
||||
<EditVoiceDialog :showDialog="editDialogVisible" :voiceData="editVoiceData" @update:showDialog="editDialogVisible = $event" @saveVoice="handleSaveEditedVoice"/>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</div>
|
||||
<div class="action-buttons">
|
||||
<el-button type="primary" size="mini" @click="toggleSelectAll" style="background: #606ff3;border: None">
|
||||
{{ selectAll ? '取消全选' : '全选' }}
|
||||
</el-button>
|
||||
<el-button type="primary" size="mini" @click="addNew" style="background: #f6cf79;border: None; color: #000012">
|
||||
新增
|
||||
</el-button>
|
||||
<el-button type="primary" size="mini" @click="batchDelete" style="background: red;border:None">删除</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import EditVoiceDialog from "@/components/EditVoiceDialog.vue";
|
||||
import AudioPlayer from './AudioPlayer.vue'
|
||||
import Api from "@/apis/api";
|
||||
|
||||
export default {
|
||||
components: { EditVoiceDialog },
|
||||
components: {AudioPlayer},
|
||||
props: {
|
||||
visible: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
ttsModelId: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
localVisible: this.visible,
|
||||
activeModel: 'EdgeTTS',
|
||||
searchQuery: '',
|
||||
editDialogVisible: false,
|
||||
editVoiceData: {},
|
||||
ttsModels: [
|
||||
{ voiceCode: 'wawaxiaohe', voiceName: '湾湾小何', languageType: '中文', remark: '' },
|
||||
{ voiceCode: 'wawaxiaohe', voiceName: '湾湾小何', languageType: '中文', remark: '' },
|
||||
{ voiceCode: 'wawaxiaohe', voiceName: '湾湾小何', languageType: '中文', remark: '' },
|
||||
{ voiceCode: 'wawaxiaohe', voiceName: '湾湾小何', languageType: '中文', remark: '' },
|
||||
],
|
||||
ttsModels: [],
|
||||
currentPage: 1,
|
||||
pageSize: 4,
|
||||
total: 20
|
||||
pageSize: 10000,
|
||||
total: 0,
|
||||
isDragging: false,
|
||||
startY: 0,
|
||||
scrollTop: 0,
|
||||
selectAll: false,
|
||||
selectedRows: [],
|
||||
loading: false,
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
visible(newVal) {
|
||||
this.localVisible = newVal;
|
||||
if (newVal) {
|
||||
this.currentPage = 1;
|
||||
this.loadData(); // 对话框显示时加载数据
|
||||
this.$nextTick(() => {
|
||||
this.updateScrollbar();
|
||||
});
|
||||
}
|
||||
},
|
||||
filteredTtsModels() {
|
||||
this.$nextTick(() => {
|
||||
this.updateScrollbar();
|
||||
});
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
filteredTtsModels() {
|
||||
return this.ttsModels.filter(model =>
|
||||
model.voiceName.toLowerCase().includes(this.searchQuery.toLowerCase())
|
||||
model.voiceName.toLowerCase().includes(this.searchQuery.toLowerCase())
|
||||
);
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.updateScrollbar();
|
||||
window.addEventListener('resize', this.updateScrollbar);
|
||||
window.addEventListener('mouseup', this.stopDrag);
|
||||
window.addEventListener('mousemove', this.handleDrag);
|
||||
},
|
||||
beforeDestroy() {
|
||||
window.removeEventListener('resize', this.updateScrollbar);
|
||||
window.removeEventListener('mouseup', this.stopDrag);
|
||||
window.removeEventListener('mousemove', this.handleDrag);
|
||||
},
|
||||
methods: {
|
||||
loadData() {
|
||||
const params = {
|
||||
ttsModelId: this.ttsModelId,
|
||||
page: this.currentPage,
|
||||
limit: this.pageSize,
|
||||
name: this.searchQuery
|
||||
};
|
||||
|
||||
Api.timbre.getVoiceList(params, (data) => {
|
||||
if (data.code === 0) {
|
||||
this.ttsModels = data.data.list
|
||||
.map(item => ({
|
||||
id: item.id || '',
|
||||
voiceCode: item.ttsVoice || '',
|
||||
voiceName: item.name || '未命名音色',
|
||||
languageType: item.languages || '',
|
||||
remark: item.remark || '',
|
||||
voiceDemo: item.voiceDemo || '',
|
||||
selected: false,
|
||||
editing: false,
|
||||
sort: Number(item.sort)
|
||||
}))
|
||||
.sort((a, b) => a.sort - b.sort);
|
||||
this.total = data.total;
|
||||
} else {
|
||||
this.$message.error({
|
||||
message: data.msg || '获取音色列表失败',
|
||||
showClose: true
|
||||
});
|
||||
}
|
||||
}, (err) => {
|
||||
console.error('加载失败:', err);
|
||||
this.$message.error({
|
||||
message: '加载音色数据失败',
|
||||
showClose: true
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
handleClose() {
|
||||
// 重置状态
|
||||
this.ttsModels = [];
|
||||
this.currentPage = 1;
|
||||
this.total = 0;
|
||||
this.selectAll = false;
|
||||
this.searchQuery = '';
|
||||
|
||||
this.localVisible = false;
|
||||
this.$emit('update:visible', false);
|
||||
},
|
||||
handleModelSelect(index) {
|
||||
this.activeModel = index;
|
||||
// 可根据选中模型加载对应数据
|
||||
|
||||
updateScrollbar() {
|
||||
const container = this.$refs.tableContainer;
|
||||
const scrollbarThumb = this.$refs.scrollbarThumb;
|
||||
const scrollbarTrack = this.$refs.scrollbarTrack;
|
||||
|
||||
if (!container || !scrollbarThumb || !scrollbarTrack) return;
|
||||
|
||||
const {scrollHeight, clientHeight} = container;
|
||||
const trackHeight = scrollbarTrack.clientHeight;
|
||||
const thumbHeight = Math.max((clientHeight / scrollHeight) * trackHeight, 20);
|
||||
|
||||
scrollbarThumb.style.height = `${thumbHeight}px`;
|
||||
this.updateThumbPosition();
|
||||
},
|
||||
handleSearch() {
|
||||
// 搜索
|
||||
|
||||
updateThumbPosition() {
|
||||
const container = this.$refs.tableContainer;
|
||||
const scrollbarThumb = this.$refs.scrollbarThumb;
|
||||
const scrollbarTrack = this.$refs.scrollbarTrack;
|
||||
|
||||
if (!container || !scrollbarThumb || !scrollbarTrack) return;
|
||||
|
||||
const {scrollHeight, clientHeight, scrollTop} = container;
|
||||
const trackHeight = scrollbarTrack.clientHeight;
|
||||
const thumbHeight = scrollbarThumb.clientHeight;
|
||||
const maxTop = trackHeight - thumbHeight;
|
||||
const thumbTop = (scrollTop / (scrollHeight - clientHeight)) * (trackHeight - thumbHeight);
|
||||
|
||||
scrollbarThumb.style.top = `${Math.min(thumbTop, maxTop)}px`;
|
||||
},
|
||||
handleAddVoice() {
|
||||
// 添加音色
|
||||
|
||||
handleScroll() {
|
||||
const container = this.$refs.tableContainer;
|
||||
if (container.scrollTop + container.clientHeight >= container.scrollHeight - 50) {
|
||||
if (this.currentPage * this.pageSize < this.total) {
|
||||
this.currentPage++;
|
||||
this.loadData();
|
||||
}
|
||||
}
|
||||
this.updateThumbPosition();
|
||||
},
|
||||
handleBatchDelete() {
|
||||
// 批量删除
|
||||
|
||||
startDrag(e) {
|
||||
this.isDragging = true;
|
||||
this.startY = e.clientY;
|
||||
this.scrollTop = this.$refs.tableContainer.scrollTop;
|
||||
e.preventDefault();
|
||||
},
|
||||
editVoice(voice) {
|
||||
this.editVoiceData = { ...voice };
|
||||
this.editDialogVisible = true;
|
||||
|
||||
stopDrag() {
|
||||
this.isDragging = false;
|
||||
},
|
||||
handleSaveEditedVoice(voiceForm) {
|
||||
const index = this.ttsModels.findIndex(item => item.voiceCode === voiceForm.voiceCode);
|
||||
if (index !== -1) {
|
||||
this.ttsModels.splice(index, 1, voiceForm);
|
||||
|
||||
handleDrag(e) {
|
||||
if (!this.isDragging) return;
|
||||
|
||||
const container = this.$refs.tableContainer;
|
||||
const scrollbarTrack = this.$refs.scrollbarTrack;
|
||||
const scrollbarThumb = this.$refs.scrollbarThumb;
|
||||
const deltaY = e.clientY - this.startY;
|
||||
const trackHeight = scrollbarTrack.clientHeight;
|
||||
const thumbHeight = scrollbarThumb.clientHeight;
|
||||
const maxScrollTop = container.scrollHeight - container.clientHeight;
|
||||
|
||||
const scrollRatio = (trackHeight - thumbHeight) / maxScrollTop;
|
||||
container.scrollTop = this.scrollTop + deltaY / scrollRatio;
|
||||
},
|
||||
|
||||
handleTrackClick(e) {
|
||||
const container = this.$refs.tableContainer;
|
||||
const scrollbarTrack = this.$refs.scrollbarTrack;
|
||||
const scrollbarThumb = this.$refs.scrollbarThumb;
|
||||
|
||||
if (!container || !scrollbarTrack || !scrollbarThumb) return;
|
||||
|
||||
const trackRect = scrollbarTrack.getBoundingClientRect();
|
||||
const thumbHeight = scrollbarThumb.clientHeight;
|
||||
const clickPosition = e.clientY - trackRect.top;
|
||||
const thumbCenter = clickPosition - thumbHeight / 2;
|
||||
|
||||
const trackHeight = scrollbarTrack.clientHeight;
|
||||
const maxTop = trackHeight - thumbHeight;
|
||||
const newTop = Math.max(0, Math.min(thumbCenter, maxTop));
|
||||
|
||||
scrollbarThumb.style.top = `${newTop}px`;
|
||||
container.scrollTop = (newTop / (trackHeight - thumbHeight)) * (container.scrollHeight - container.clientHeight);
|
||||
},
|
||||
|
||||
startEdit(row) {
|
||||
row.editing = true;
|
||||
this.$set(row, 'originalData', {...row});
|
||||
},
|
||||
|
||||
saveEdit(row) {
|
||||
try {
|
||||
const params = {
|
||||
id: row.id,
|
||||
voiceCode: row.voiceCode,
|
||||
voiceName: row.voiceName,
|
||||
languageType: row.languageType,
|
||||
remark: row.remark,
|
||||
ttsModelId: this.ttsModelId,
|
||||
voiceDemo: row.voiceDemo || '',
|
||||
sort: row.sort
|
||||
};
|
||||
|
||||
let res;
|
||||
if (row.id) {
|
||||
// 已有ID,执行更新操作
|
||||
Api.timbre.updateVoice(params, (response) => {
|
||||
res = response;
|
||||
this.handleResponse(res, row);
|
||||
});
|
||||
} else {
|
||||
// 没有ID,执行新增操作
|
||||
Api.timbre.saveVoice(params, (response) => {
|
||||
res = response;
|
||||
this.handleResponse(res, row);
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('操作失败:', error);
|
||||
// 异常情况下也恢复原始数据
|
||||
if (row.originalData) {
|
||||
Object.assign(row, row.originalData);
|
||||
row.editing = false;
|
||||
delete row.originalData;
|
||||
}
|
||||
this.$message.error({
|
||||
message: '操作失败,请重试',
|
||||
showClose: true
|
||||
});
|
||||
}
|
||||
},
|
||||
deleteVoice(voice) {
|
||||
// 删除
|
||||
|
||||
handleResponse(res, row) {
|
||||
if (res.code === 0) {
|
||||
this.$message.success({
|
||||
message: row.id ? '修改成功' : '保存成功',
|
||||
showClose: true
|
||||
});
|
||||
row.editing = false;
|
||||
delete row.originalData;
|
||||
this.loadData(); // 刷新数据
|
||||
} else {
|
||||
// 保存失败时恢复原始数据
|
||||
if (row.originalData) {
|
||||
Object.assign(row, row.originalData);
|
||||
row.editing = false;
|
||||
delete row.originalData;
|
||||
}
|
||||
this.$message.error({
|
||||
message: res.msg || (row.id ? '修改失败' : '保存失败'),
|
||||
showClose: true
|
||||
});
|
||||
}
|
||||
},
|
||||
handleImportExport() {
|
||||
// 导入导出
|
||||
|
||||
toggleSelectAll() {
|
||||
this.selectAll = !this.selectAll;
|
||||
this.filteredTtsModels.forEach(row => {
|
||||
row.selected = this.selectAll;
|
||||
});
|
||||
},
|
||||
|
||||
addNew() {
|
||||
const maxSort = this.ttsModels.length > 0
|
||||
? Math.max(...this.ttsModels.map(item => Number(item.sort) || 0))
|
||||
: 0;
|
||||
|
||||
const newRow = {
|
||||
voiceCode: '',
|
||||
voiceName: '',
|
||||
languageType: '中文',
|
||||
voiceDemo: '',
|
||||
remark: '',
|
||||
selected: false,
|
||||
editing: true,
|
||||
sort: maxSort + 1
|
||||
};
|
||||
|
||||
this.ttsModels.unshift(newRow);
|
||||
},
|
||||
|
||||
deleteRow(row) {
|
||||
this.$confirm("确定要删除该音色吗?", "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
})
|
||||
.then(() => {
|
||||
Api.timbre.deleteVoice(row.id, (response) => {
|
||||
if (response.code === 0) {
|
||||
this.$message.success({
|
||||
message: "删除成功",
|
||||
showClose: true
|
||||
});
|
||||
this.loadData(); // 刷新数据
|
||||
} else {
|
||||
this.$message.error({
|
||||
message: response.msg || "删除失败",
|
||||
showClose: true
|
||||
});
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
this.$message.info("已取消删除");
|
||||
});
|
||||
},
|
||||
|
||||
batchDelete() {
|
||||
const selectedRows = this.filteredTtsModels.filter(row => row.selected);
|
||||
if (selectedRows.length === 0) {
|
||||
this.$message.warning("请先选择需要删除的音色");
|
||||
return;
|
||||
}
|
||||
|
||||
this.$confirm(`确定要删除选中的${selectedRows.length}个音色吗?`, "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
})
|
||||
.then(async () => {
|
||||
const loading = this.$loading({
|
||||
lock: true,
|
||||
text: "正在删除中...",
|
||||
spinner: "el-icon-loading",
|
||||
background: "rgba(0, 0, 0, 0.7)",
|
||||
});
|
||||
|
||||
try {
|
||||
const results = await Promise.all(
|
||||
selectedRows.map((row) => {
|
||||
return new Promise((resolve) => {
|
||||
Api.timbre.deleteVoice(row.id, (response) => {
|
||||
if (response.code === 0) {
|
||||
resolve({ success: true, id: row.id });
|
||||
} else {
|
||||
resolve({
|
||||
success: false,
|
||||
id: row.id,
|
||||
msg: response.msg || '删除失败'
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
const successCount = results.filter(r => r.success).length;
|
||||
const failCount = results.length - successCount;
|
||||
|
||||
if (failCount === 0) {
|
||||
this.$message.success({
|
||||
message: `成功删除${successCount}个音色`,
|
||||
showClose: true
|
||||
});
|
||||
} else if (successCount === 0) {
|
||||
this.$message.error({
|
||||
message: '删除失败,请重试',
|
||||
showClose: true
|
||||
});
|
||||
} else {
|
||||
this.$message.warning({
|
||||
message: `成功删除${successCount}个音色,${failCount}个删除失败`,
|
||||
showClose: true
|
||||
});
|
||||
}
|
||||
|
||||
this.loadData(); // 刷新数据
|
||||
} catch (error) {
|
||||
console.error('批量删除出错:', error);
|
||||
this.$message.error({
|
||||
message: '删除过程中发生错误',
|
||||
showClose: true
|
||||
});
|
||||
} finally {
|
||||
loading.close();
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
this.$message.info("已取消删除");
|
||||
});
|
||||
},
|
||||
|
||||
isValidAudioUrl(url) {
|
||||
return url && (url.endsWith('.mp3') || url.endsWith('.ogg') || url.endsWith('.wav'));
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.main-container {
|
||||
padding: 20px;
|
||||
|
||||
::v-deep .el-dialog {
|
||||
border-radius: 8px !important;
|
||||
overflow: hidden;
|
||||
top: 8vh !important;
|
||||
}
|
||||
|
||||
.model-menu {
|
||||
border-right: 1px solid #ebeef5;
|
||||
height: calc(100vh - 300px);
|
||||
background-color: #fafafa;
|
||||
::v-deep .el-dialog__header {
|
||||
display: none !important;
|
||||
padding: 0 !important;
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
.search-operate {
|
||||
margin-bottom: 20px;
|
||||
/* 表格样式 */
|
||||
::v-deep .data-table .el-table__header th {
|
||||
color: black;
|
||||
padding: 6px 0 !important;
|
||||
}
|
||||
|
||||
::v-deep .data-table .el-table__row td {
|
||||
padding: 8px 0 12px !important;
|
||||
}
|
||||
|
||||
::v-deep .data-table {
|
||||
border: none !important;
|
||||
}
|
||||
|
||||
::v-deep .data-table.el-table::before {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
::v-deep .data-table .el-table__header-wrapper {
|
||||
border-bottom: 2px solid #f1f2fb !important;
|
||||
}
|
||||
|
||||
::v-deep .data-table .el-table__body-wrapper .el-table__body td {
|
||||
border: none !important;
|
||||
}
|
||||
|
||||
/* 关闭按钮 */
|
||||
.custom-close-btn {
|
||||
position: absolute;
|
||||
top: 15px;
|
||||
right: 15px;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
border-radius: 50%;
|
||||
border: 2px solid #cfcfcf;
|
||||
background: none;
|
||||
font-size: 30px;
|
||||
font-weight: lighter;
|
||||
color: #cfcfcf;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 1;
|
||||
padding: 0;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.pagination-container {
|
||||
margin: 20px 0;
|
||||
display: flex;
|
||||
justify-content: right;
|
||||
}
|
||||
|
||||
.dialog-footer {
|
||||
text-align: right;
|
||||
padding: 20px 20px 0;
|
||||
border-top: 1px solid #ebeef5;
|
||||
}
|
||||
|
||||
::v-deep .table-header th {
|
||||
background-color: #f5f7fa;
|
||||
color: #606266;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
::v-deep .el-table--striped .el-table__body tr.el-table__row--striped td {
|
||||
background-color: #fafafa;
|
||||
}
|
||||
|
||||
::v-deep .el-table--border td, ::v-deep .el-table--border th {
|
||||
border-right: 1px solid #ebeef5;
|
||||
}
|
||||
|
||||
::v-deep .el-pagination {
|
||||
padding: 10px;
|
||||
background-color: #f5f7fa;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
::v-deep .el-pagination .btn-prev, ::v-deep .el-pagination .btn-next {
|
||||
background-color: #fff;
|
||||
border: 1px solid #dcdfe6;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
::v-deep .el-pagination .btn-prev:hover, ::v-deep .el-pagination .btn-next:hover {
|
||||
background-color: #f5f7fa;
|
||||
}
|
||||
|
||||
::v-deep .el-pagination .el-pager li {
|
||||
background-color: #fff;
|
||||
border: 1px solid #dcdfe6;
|
||||
border-radius: 4px;
|
||||
margin: 0 2px;
|
||||
}
|
||||
|
||||
::v-deep .el-pagination .el-pager li:hover {
|
||||
background-color: #f5f7fa;
|
||||
}
|
||||
|
||||
::v-deep .el-pagination .el-pager li.active {
|
||||
background-color: #409EFF;
|
||||
color: #fff;
|
||||
.custom-close-btn:hover {
|
||||
color: #409EFF;
|
||||
border-color: #409EFF;
|
||||
}
|
||||
</style>
|
||||
|
||||
/* 备注文本 */
|
||||
::v-deep .remark-input .el-textarea__inner {
|
||||
background-color: #f5f5f5;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #e6e6e6;
|
||||
padding: 8px 12px;
|
||||
resize: none;
|
||||
max-height: 40px !important;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
::v-deep .remark-input .el-textarea__inner::placeholder {
|
||||
color: black !important;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
::v-deep .remark-input .el-textarea__inner {
|
||||
background-color: #f4f6fa;
|
||||
}
|
||||
|
||||
::v-deep .remark-input .el-textarea__inner:focus {
|
||||
background-color: #edeffb;
|
||||
}
|
||||
|
||||
/* 滚动容器 */
|
||||
.scroll-wrapper {
|
||||
display: flex;
|
||||
max-height: 55vh;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.table-container {
|
||||
flex: 1;
|
||||
overflow-y: scroll;
|
||||
scrollbar-width: none; /* Firefox */
|
||||
padding-right: 15px; /* 为滚动条留出空间 */
|
||||
width: calc(100% - 16px); /* 减去滚动条宽度 */
|
||||
}
|
||||
|
||||
.table-container::-webkit-scrollbar {
|
||||
display: none; /* Chrome/Safari */
|
||||
}
|
||||
|
||||
/* 自定义滚动条 */
|
||||
.custom-scrollbar {
|
||||
width: 8px;
|
||||
background: #f1f1f1;
|
||||
border-radius: 4px;
|
||||
position: relative;
|
||||
margin-left: 8px;
|
||||
height: 100%;
|
||||
top: 55px;
|
||||
}
|
||||
|
||||
.custom-scrollbar-track {
|
||||
position: relative;
|
||||
height: 380px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.custom-scrollbar-thumb {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
background: #9dade7;
|
||||
border-radius: 4px;
|
||||
cursor: grab;
|
||||
transition: background 0.2s;
|
||||
}
|
||||
|
||||
.custom-scrollbar-thumb:hover {
|
||||
background: #6b84d9;
|
||||
}
|
||||
|
||||
.custom-scrollbar-thumb:active {
|
||||
cursor: grabbing;
|
||||
}
|
||||
|
||||
.save-Tts {
|
||||
background: #796dea;
|
||||
border: None;
|
||||
}
|
||||
|
||||
.save-Tts:hover {
|
||||
background: #8b80f0;
|
||||
}
|
||||
|
||||
.custom-audio-container audio {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* 新增按钮组样式 */
|
||||
.action-buttons {
|
||||
bottom: 20px;
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
|
@ -69,7 +69,17 @@ const routes = [
|
|||
return import('../views/test.vue')
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
path: '/params-management',
|
||||
name: 'ParamsManagement',
|
||||
component: function () {
|
||||
return import('../views/ParamsManagement.vue')
|
||||
},
|
||||
meta: {
|
||||
requiresAuth: true,
|
||||
title: '参数管理'
|
||||
}
|
||||
},
|
||||
]
|
||||
|
||||
const router = new VueRouter({
|
||||
|
|
|
|||
|
|
@ -4,16 +4,16 @@
|
|||
|
||||
<div class="operation-bar">
|
||||
<h2 class="page-title">模型配置</h2>
|
||||
<div class="right-operations">
|
||||
<el-button plain size="small" @click="handleImport" style="background: #7b9de5; color: white;">
|
||||
<img loading="lazy" alt="" src="@/assets/model/inner_conf.png">
|
||||
导入配置
|
||||
</el-button>
|
||||
<el-button plain size="small" @click="handleExport" style="background: #71c9d1; color: white;">
|
||||
<img loading="lazy" alt="" src="@/assets/model/output_conf.png">
|
||||
导出配置
|
||||
</el-button>
|
||||
</div>
|
||||
<!-- <div class="right-operations">-->
|
||||
<!-- <el-button plain size="small" @click="handleImport" style="background: #7b9de5; color: white;">-->
|
||||
<!-- <img loading="lazy" alt="" src="@/assets/model/inner_conf.png">-->
|
||||
<!-- 导入配置-->
|
||||
<!-- </el-button>-->
|
||||
<!-- <el-button plain size="small" @click="handleExport" style="background: #71c9d1; color: white;">-->
|
||||
<!-- <img loading="lazy" alt="" src="@/assets/model/output_conf.png">-->
|
||||
<!-- 导出配置-->
|
||||
<!-- </el-button>-->
|
||||
<!-- </div>-->
|
||||
</div>
|
||||
|
||||
<!-- 主体内容 -->
|
||||
|
|
@ -53,7 +53,7 @@
|
|||
</div>
|
||||
<div class="action-group">
|
||||
<div class="search-group">
|
||||
<el-input placeholder="请输入模型名称查询" v-model="search" size="small" class="search-input" clearable />
|
||||
<el-input placeholder="请输入模型名称查询" v-model="search" size="small" class="search-input" clearable @keyup.enter.native="handleSearch" />
|
||||
<el-button type="primary" size="small" class="search-btn" @click="handleSearch">
|
||||
查询
|
||||
</el-button>
|
||||
|
|
@ -69,7 +69,7 @@
|
|||
<el-table-column label="模型编码" prop="modelCode" align="center"></el-table-column>
|
||||
<el-table-column label="提供商" align="center">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.configJson?.provider || '未知' }}
|
||||
{{ scope.row.configJson.type || '未知' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="是否启用" align="center">
|
||||
|
|
@ -80,7 +80,11 @@
|
|||
</el-table-column>
|
||||
<el-table-column v-if="activeTab === 'tts'" label="音色管理" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" size="mini" @click="ttsDialogVisible = true" class="voice-management-btn">
|
||||
<el-button
|
||||
type="text"
|
||||
size="mini"
|
||||
@click="openTtsDialog(scope.row)"
|
||||
class="voice-management-btn">
|
||||
音色管理
|
||||
</el-button>
|
||||
</template>
|
||||
|
|
@ -124,7 +128,7 @@
|
|||
|
||||
<ModelEditDialog :modelType="activeTab" :visible.sync="editDialogVisible" :modelData="editModelData"
|
||||
@save="handleModelSave" />
|
||||
<TtsModel :visible.sync="ttsDialogVisible" />
|
||||
<TtsModel :visible.sync="ttsDialogVisible" :ttsModelId="selectedTtsModelId"/>
|
||||
<AddModelDialog :modelType="activeTab" :visible.sync="addDialogVisible" @confirm="handleAddConfirm" />
|
||||
</div>
|
||||
|
||||
|
|
@ -151,6 +155,7 @@ export default {
|
|||
editDialogVisible: false,
|
||||
editModelData: {},
|
||||
ttsDialogVisible: false,
|
||||
selectedTtsModelId: '',
|
||||
modelList: [],
|
||||
currentPage: 1,
|
||||
pageSize: 5,
|
||||
|
|
@ -200,6 +205,10 @@ export default {
|
|||
},
|
||||
|
||||
methods: {
|
||||
openTtsDialog(row) {
|
||||
this.selectedTtsModelId = row.id;
|
||||
this.ttsDialogVisible = true;
|
||||
},
|
||||
headerCellClassName({ column, columnIndex }) {
|
||||
if (columnIndex === 0) {
|
||||
return 'custom-selection-header';
|
||||
|
|
@ -212,8 +221,8 @@ export default {
|
|||
this.loadData();
|
||||
},
|
||||
handleSearch() {
|
||||
// TODO: 查询
|
||||
console.log('查询:', this.search);
|
||||
this.currentPage = 1;
|
||||
this.loadData();
|
||||
},
|
||||
// 批量删除
|
||||
batchDelete() {
|
||||
|
|
@ -301,9 +310,21 @@ export default {
|
|||
// TODO: 导出配置
|
||||
console.log('导出配置');
|
||||
},
|
||||
handleModelSave(formData) {
|
||||
// TODO: 保存模型数据
|
||||
console.log('保存的模型数据:', formData);
|
||||
handleModelSave({ provideCode, formData }) {
|
||||
const modelType = this.activeTab;
|
||||
const id = formData.id;
|
||||
Api.model.updateModel(
|
||||
{ modelType, provideCode, id, formData },
|
||||
({ data }) => {
|
||||
if (data.code === 0) {
|
||||
this.$message.success('保存成功');
|
||||
this.loadData();
|
||||
this.editDialogVisible = false;
|
||||
} else {
|
||||
this.$message.error(data.msg || '保存失败');
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
selectAll() {
|
||||
if (this.isAllSelected) {
|
||||
|
|
|
|||
536
main/manager-web/src/views/ParamsManagement.vue
Normal file
536
main/manager-web/src/views/ParamsManagement.vue
Normal file
|
|
@ -0,0 +1,536 @@
|
|||
<template>
|
||||
<div class="welcome">
|
||||
<HeaderBar />
|
||||
|
||||
<div class="operation-bar">
|
||||
<h2 class="page-title">参数管理</h2>
|
||||
<div class="right-operations">
|
||||
<el-input placeholder="请输入参数编码查询" v-model="searchCode" class="search-input"
|
||||
@keyup.enter.native="handleSearch" />
|
||||
<el-button class="btn-search" @click="handleSearch">搜索</el-button>
|
||||
<el-button type="primary" @click="showAddDialog">新增参数</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="main-wrapper">
|
||||
<div class="content-panel">
|
||||
<div class="content-area">
|
||||
<el-card class="params-card" shadow="never">
|
||||
<el-table ref="paramsTable" :data="paramsList" class="transparent-table"
|
||||
:header-cell-class-name="headerCellClassName">
|
||||
<el-table-column label="选择" type="selection" align="center" width="120"></el-table-column>
|
||||
<el-table-column label="参数编码" prop="paramCode" align="center"></el-table-column>
|
||||
<el-table-column label="参数值" prop="paramValue" align="center"></el-table-column>
|
||||
<el-table-column label="备注" prop="remark" align="center"></el-table-column>
|
||||
<el-table-column label="操作" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" type="text" @click="editParam(scope.row)">编辑</el-button>
|
||||
<el-button size="mini" type="text" @click="deleteParam(scope.row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<div class="table_bottom">
|
||||
<div class="ctrl_btn">
|
||||
<el-button size="mini" type="primary" class="select-all-btn"
|
||||
@click="handleSelectAll">全选</el-button>
|
||||
<el-button size="mini" type="danger" icon="el-icon-delete"
|
||||
@click="batchDelete">删除</el-button>
|
||||
</div>
|
||||
<div class="custom-pagination">
|
||||
<button class="pagination-btn" :disabled="currentPage === 1" @click="goFirst">
|
||||
首页
|
||||
</button>
|
||||
<button class="pagination-btn" :disabled="currentPage === 1" @click="goPrev">
|
||||
上一页
|
||||
</button>
|
||||
<button v-for="page in visiblePages" :key="page" class="pagination-btn"
|
||||
:class="{ active: page === currentPage }" @click="goToPage(page)">
|
||||
{{ page }}
|
||||
</button>
|
||||
<button class="pagination-btn" :disabled="currentPage === pageCount" @click="goNext">
|
||||
下一页
|
||||
</button>
|
||||
<span class="total-text">共{{ total }}条记录</span>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 新增/编辑参数对话框 -->
|
||||
<el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="500px">
|
||||
<el-form :model="paramForm" :rules="rules" ref="paramForm" label-width="100px">
|
||||
<el-form-item label="参数编码" prop="paramCode">
|
||||
<el-input v-model="paramForm.paramCode" placeholder="请输入参数编码"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="参数值" prop="paramValue">
|
||||
<el-input v-model="paramForm.paramValue" placeholder="请输入参数值"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input type="textarea" v-model="paramForm.remark" placeholder="请输入备注"></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<div class="copyright">©2025 xiaozhi-esp32-server</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Api from "@/apis/api";
|
||||
import HeaderBar from "@/components/HeaderBar.vue";
|
||||
|
||||
export default {
|
||||
components: { HeaderBar },
|
||||
data() {
|
||||
return {
|
||||
searchCode: "",
|
||||
paramsList: [],
|
||||
currentPage: 1,
|
||||
pageSize: 5,
|
||||
total: 0,
|
||||
dialogVisible: false,
|
||||
dialogTitle: "新增参数",
|
||||
paramForm: {
|
||||
id: null,
|
||||
paramCode: "",
|
||||
paramValue: "",
|
||||
remark: ""
|
||||
},
|
||||
rules: {
|
||||
paramCode: [
|
||||
{ required: true, message: "请输入参数编码", trigger: "blur" }
|
||||
],
|
||||
paramValue: [
|
||||
{ required: true, message: "请输入参数值", trigger: "blur" }
|
||||
]
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.fetchParams();
|
||||
},
|
||||
computed: {
|
||||
pageCount() {
|
||||
return Math.ceil(this.total / this.pageSize);
|
||||
},
|
||||
visiblePages() {
|
||||
const pages = [];
|
||||
const maxVisible = 3;
|
||||
let start = Math.max(1, this.currentPage - 1);
|
||||
let end = Math.min(this.pageCount, start + maxVisible - 1);
|
||||
|
||||
if (end - start + 1 < maxVisible) {
|
||||
start = Math.max(1, end - maxVisible + 1);
|
||||
}
|
||||
|
||||
for (let i = start; i <= end; i++) {
|
||||
pages.push(i);
|
||||
}
|
||||
return pages;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
fetchParams() {
|
||||
Api.admin.getParamsList(
|
||||
{
|
||||
page: this.currentPage,
|
||||
limit: this.pageSize,
|
||||
paramCode: this.searchCode,
|
||||
},
|
||||
({ data }) => {
|
||||
if (data.code === 0) {
|
||||
this.paramsList = data.data.list;
|
||||
this.total = data.data.total;
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
handleSearch() {
|
||||
this.currentPage = 1;
|
||||
this.fetchParams();
|
||||
},
|
||||
handleSelectAll() {
|
||||
this.$refs.paramsTable.toggleAllSelection();
|
||||
},
|
||||
showAddDialog() {
|
||||
this.dialogTitle = "新增参数";
|
||||
this.paramForm = {
|
||||
id: null,
|
||||
paramCode: "",
|
||||
paramValue: "",
|
||||
remark: ""
|
||||
};
|
||||
this.dialogVisible = true;
|
||||
},
|
||||
editParam(row) {
|
||||
this.dialogTitle = "编辑参数";
|
||||
this.paramForm = { ...row };
|
||||
this.dialogVisible = true;
|
||||
},
|
||||
submitForm() {
|
||||
this.$refs.paramForm.validate((valid) => {
|
||||
if (valid) {
|
||||
if (this.paramForm.id) {
|
||||
// 编辑
|
||||
Api.admin.updateParam(this.paramForm, ({ data }) => {
|
||||
if (data.code === 0) {
|
||||
this.$message.success("修改成功");
|
||||
this.dialogVisible = false;
|
||||
this.fetchParams();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 新增
|
||||
Api.admin.addParam(this.paramForm, ({ data }) => {
|
||||
if (data.code === 0) {
|
||||
this.$message.success("新增成功");
|
||||
this.dialogVisible = false;
|
||||
this.fetchParams();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
deleteParam(row) {
|
||||
this.$confirm("确定要删除该参数吗?", "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
})
|
||||
.then(() => {
|
||||
Api.admin.deleteParam(row.id, ({ data }) => {
|
||||
if (data.code === 0) {
|
||||
this.$message.success("删除成功");
|
||||
this.fetchParams();
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch(() => { });
|
||||
},
|
||||
batchDelete() {
|
||||
const selectedParams = this.$refs.paramsTable.selection;
|
||||
if (selectedParams.length === 0) {
|
||||
this.$message.warning("请先选择需要删除的参数");
|
||||
return;
|
||||
}
|
||||
|
||||
this.$confirm(`确定要删除选中的${selectedParams.length}个参数吗?`, "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
})
|
||||
.then(() => {
|
||||
const ids = selectedParams.map(item => item.id);
|
||||
Api.admin.batchDeleteParams(ids, ({ data }) => {
|
||||
if (data.code === 0) {
|
||||
this.$message.success("删除成功");
|
||||
this.fetchParams();
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch(() => { });
|
||||
},
|
||||
headerCellClassName({ columnIndex }) {
|
||||
if (columnIndex === 0) {
|
||||
return "custom-selection-header";
|
||||
}
|
||||
return "";
|
||||
},
|
||||
goFirst() {
|
||||
this.currentPage = 1;
|
||||
this.fetchParams();
|
||||
},
|
||||
goPrev() {
|
||||
if (this.currentPage > 1) {
|
||||
this.currentPage--;
|
||||
this.fetchParams();
|
||||
}
|
||||
},
|
||||
goNext() {
|
||||
if (this.currentPage < this.pageCount) {
|
||||
this.currentPage++;
|
||||
this.fetchParams();
|
||||
}
|
||||
},
|
||||
goToPage(page) {
|
||||
this.currentPage = page;
|
||||
this.fetchParams();
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.welcome {
|
||||
min-width: 900px;
|
||||
min-height: 506px;
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
position: relative;
|
||||
flex-direction: column;
|
||||
background-size: cover;
|
||||
background: linear-gradient(to bottom right, #dce8ff, #e4eeff, #e6cbfd) center;
|
||||
-webkit-background-size: cover;
|
||||
-o-background-size: cover;
|
||||
}
|
||||
|
||||
.main-wrapper {
|
||||
margin: 5px 22px;
|
||||
border-radius: 15px;
|
||||
min-height: 600px;
|
||||
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
|
||||
position: relative;
|
||||
background: rgba(237, 242, 255, 0.5);
|
||||
}
|
||||
|
||||
.operation-bar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 16px 24px;
|
||||
}
|
||||
|
||||
.page-title {
|
||||
font-size: 24px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.right-operations {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
width: 240px;
|
||||
}
|
||||
|
||||
.btn-search {
|
||||
background: linear-gradient(135deg, #6b8cff, #a966ff);
|
||||
border: none;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.content-panel {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
overflow: hidden;
|
||||
height: 100%;
|
||||
border-radius: 15px;
|
||||
background: transparent;
|
||||
border: 1px solid #fff;
|
||||
}
|
||||
|
||||
.content-area {
|
||||
flex: 1;
|
||||
height: 100%;
|
||||
min-width: 600px;
|
||||
overflow-x: auto;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.params-card {
|
||||
background: white;
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.table_bottom {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.ctrl_btn {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
padding-left: 26px;
|
||||
|
||||
.el-button {
|
||||
min-width: 72px;
|
||||
height: 32px;
|
||||
padding: 7px 12px 7px 10px;
|
||||
font-size: 12px;
|
||||
border-radius: 4px;
|
||||
line-height: 1;
|
||||
font-weight: 500;
|
||||
border: none;
|
||||
transition: all 0.3s ease;
|
||||
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
|
||||
|
||||
&:hover {
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
}
|
||||
|
||||
.el-button--primary {
|
||||
background: #5f70f3;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.el-button--danger {
|
||||
background: #fd5b63;
|
||||
color: white;
|
||||
}
|
||||
}
|
||||
|
||||
.copyright {
|
||||
text-align: center;
|
||||
color: #979db1;
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
margin-top: auto;
|
||||
padding: 30px 0 20px;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.custom-pagination {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-top: 15px;
|
||||
|
||||
.pagination-btn:first-child,
|
||||
.pagination-btn:nth-child(2),
|
||||
.pagination-btn:nth-last-child(2) {
|
||||
min-width: 60px;
|
||||
height: 32px;
|
||||
padding: 0 12px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #e4e7ed;
|
||||
background: #dee7ff;
|
||||
color: #606266;
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
|
||||
&:hover {
|
||||
background: #d7dce6;
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.6;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
.pagination-btn:not(:first-child):not(:nth-child(2)):not(:nth-last-child(2)) {
|
||||
min-width: 28px;
|
||||
height: 32px;
|
||||
padding: 0;
|
||||
border-radius: 4px;
|
||||
border: 1px solid transparent;
|
||||
background: transparent;
|
||||
color: #606266;
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
|
||||
&:hover {
|
||||
background: rgba(245, 247, 250, 0.3);
|
||||
}
|
||||
}
|
||||
|
||||
.pagination-btn.active {
|
||||
background: #5f70f3 !important;
|
||||
color: #ffffff !important;
|
||||
border-color: #5f70f3 !important;
|
||||
|
||||
&:hover {
|
||||
background: #6d7cf5 !important;
|
||||
}
|
||||
}
|
||||
|
||||
.total-text {
|
||||
color: #909399;
|
||||
font-size: 14px;
|
||||
margin-left: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.transparent-table) {
|
||||
background: white;
|
||||
|
||||
.el-table__header th {
|
||||
background: white !important;
|
||||
color: black;
|
||||
}
|
||||
|
||||
&::before {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.el-table__body tr {
|
||||
background-color: white;
|
||||
|
||||
td {
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.04);
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.04);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.custom-selection-header) {
|
||||
.el-checkbox {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
&::after {
|
||||
content: "选择";
|
||||
display: inline-block;
|
||||
color: black;
|
||||
font-weight: bold;
|
||||
padding-bottom: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.el-checkbox__inner) {
|
||||
background-color: #eeeeee !important;
|
||||
border-color: #cccccc !important;
|
||||
}
|
||||
|
||||
:deep(.el-checkbox__inner:hover) {
|
||||
border-color: #cccccc !important;
|
||||
}
|
||||
|
||||
:deep(.el-checkbox__input.is-checked .el-checkbox__inner) {
|
||||
background-color: #5f70f3 !important;
|
||||
border-color: #5f70f3 !important;
|
||||
}
|
||||
|
||||
@media (min-width: 1144px) {
|
||||
.table_bottom {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-top: 40px;
|
||||
}
|
||||
|
||||
:deep(.transparent-table) {
|
||||
.el-table__body tr {
|
||||
td {
|
||||
padding-top: 16px;
|
||||
padding-bottom: 16px;
|
||||
}
|
||||
|
||||
&+tr {
|
||||
margin-top: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
<div class="operation-bar">
|
||||
<h2 class="page-title">用户管理</h2>
|
||||
<div class="right-operations">
|
||||
<el-input placeholder="请输入手机号码查询" v-model="searchPhone" class="search-input"
|
||||
<el-input placeholder="请输入手机号码查询" v-model="searchPhone" class="search-input" clearable
|
||||
@keyup.enter.native="handleSearch" />
|
||||
<el-button class="btn-search" @click="handleSearch">搜索</el-button>
|
||||
</div>
|
||||
|
|
@ -296,7 +296,7 @@ export default {
|
|||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
const userIds = users.map(user => Number(user.userid));
|
||||
const userIds = users.map(user => user.userid);
|
||||
if (userIds.some(id => isNaN(id))) {
|
||||
this.$message.error('存在无效的用户ID');
|
||||
return;
|
||||
|
|
@ -556,6 +556,13 @@ export default {
|
|||
}
|
||||
}
|
||||
}
|
||||
:deep(.el-table .el-button--text) {
|
||||
color: #7079aa !important;
|
||||
}
|
||||
|
||||
:deep(.el-table .el-button--text:hover) {
|
||||
color: #5a64b5 !important;
|
||||
}
|
||||
|
||||
:deep(.custom-selection-header) {
|
||||
.el-checkbox {
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@
|
|||
<div style="cursor: pointer;" @click="goToRegister">新用户注册</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="login-btn" @click="login">登陆</div>
|
||||
<div class="login-btn" @click="login">登录</div>
|
||||
<div style="font-size: 14px;color: #979db1;">
|
||||
登录即同意
|
||||
<div style="display: inline-block;color: #5778FF;cursor: pointer;">《用户协议》</div>
|
||||
|
|
|
|||
|
|
@ -86,6 +86,35 @@ wakeup_words:
|
|||
- "小滨小滨"
|
||||
- "小冰小冰"
|
||||
|
||||
# 插件的基础配置
|
||||
plugins:
|
||||
# 获取天气插件的配置,这里填写你的api_key
|
||||
# 这个密钥是项目共用的key,用多了可能会被限制
|
||||
# 想稳定一点就自行申请替换,每天有1000次免费调用
|
||||
# 申请地址:https://console.qweather.com/#/apps/create-key/over
|
||||
get_weather: { "api_key": "a861d0d5e7bf4ee1a83d9a9e4f96d4da", "default_location": "广州" }
|
||||
# 获取新闻插件的配置,这里根据需要的新闻类型传入对应的url链接,默认支持社会、科技、财经新闻
|
||||
# 更多类型的新闻列表查看 https://www.chinanews.com.cn/rss/
|
||||
get_news:
|
||||
default_rss_url: "https://www.chinanews.com.cn/rss/society.xml"
|
||||
category_urls:
|
||||
society: "https://www.chinanews.com.cn/rss/society.xml"
|
||||
world: "https://www.chinanews.com.cn/rss/world.xml"
|
||||
finance: "https://www.chinanews.com.cn/rss/finance.xml"
|
||||
home_assistant:
|
||||
devices:
|
||||
- 客厅,玩具灯,switch.cuco_cn_460494544_cp1_on_p_2_1
|
||||
- 卧室,台灯,switch.iot_cn_831898993_socn1_on_p_2_1
|
||||
base_url: http://homeassistant.local:8123
|
||||
api_key: 你的home assistant api访问令牌
|
||||
play_music:
|
||||
music_dir: "./music" # 音乐文件存放路径,将从该目录及子目录下搜索音乐文件
|
||||
music_ext: # 音乐文件类型,p3格式效率最高
|
||||
- ".mp3"
|
||||
- ".wav"
|
||||
- ".p3"
|
||||
refresh_time: 300 # 刷新音乐列表的时间间隔,单位为秒
|
||||
|
||||
# #####################################################################################
|
||||
# ################################以下是角色模型配置######################################
|
||||
|
||||
|
|
@ -153,36 +182,6 @@ Intent:
|
|||
#- hass_set_state
|
||||
#- hass_play_music
|
||||
|
||||
# 插件的基础配置
|
||||
plugins:
|
||||
# 获取天气插件的配置,这里填写你的api_key
|
||||
# 这个密钥是项目共用的key,用多了可能会被限制
|
||||
# 想稳定一点就自行申请替换,每天有1000次免费调用
|
||||
# 申请地址:https://console.qweather.com/#/apps/create-key/over
|
||||
get_weather: { "api_key": "a861d0d5e7bf4ee1a83d9a9e4f96d4da", "default_location": "广州" }
|
||||
# 获取新闻插件的配置,这里根据需要的新闻类型传入对应的url链接,默认支持社会、科技、财经新闻
|
||||
# 更多类型的新闻列表查看 https://www.chinanews.com.cn/rss/
|
||||
get_news:
|
||||
default_rss_url: "https://www.chinanews.com.cn/rss/society.xml"
|
||||
category_urls:
|
||||
society: "https://www.chinanews.com.cn/rss/society.xml"
|
||||
world: "https://www.chinanews.com.cn/rss/world.xml"
|
||||
finance: "https://www.chinanews.com.cn/rss/finance.xml"
|
||||
home_assistant:
|
||||
devices:
|
||||
- 客厅,玩具灯,switch.cuco_cn_460494544_cp1_on_p_2_1
|
||||
- 卧室,台灯,switch.iot_cn_831898993_socn1_on_p_2_1
|
||||
base_url: http://homeassistant.local:8123
|
||||
api_key: 你的home assistant api访问令牌
|
||||
play_music:
|
||||
music_dir: "./music" # 音乐文件存放路径,将从该目录及子目录下搜索音乐文件
|
||||
music_ext: # 音乐文件类型,p3格式效率最高
|
||||
- ".mp3"
|
||||
- ".wav"
|
||||
- ".p3"
|
||||
refresh_time: 300 # 刷新音乐列表的时间间隔,单位为秒
|
||||
|
||||
|
||||
Memory:
|
||||
mem0ai:
|
||||
type: mem0ai
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ hass_get_state_function_desc = {
|
|||
"type": "function",
|
||||
"function": {
|
||||
"name": "hass_get_state",
|
||||
"description": "获取homeassistant里设备的状态,包括灯光亮度,媒体播放器的音量,设备的暂停、继续操作",
|
||||
"description": "获取homeassistant里设备的状态,包括查询灯光亮度、颜色、色温,媒体播放器的音量,设备的暂停、继续操作",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
|
@ -35,7 +35,7 @@ def hass_get_state(conn, entity_id=''):
|
|||
conn.loop
|
||||
)
|
||||
ha_response = future.result()
|
||||
return ActionResponse(action=Action.REQLLM, result="执行成功", response=ha_response)
|
||||
return ActionResponse( Action.REQLLM, ha_response , None )
|
||||
except Exception as e:
|
||||
logger.bind(tag=TAG).error(f"处理设置属性意图错误: {e}")
|
||||
|
||||
|
|
@ -51,6 +51,23 @@ async def handle_hass_get_state(conn, entity_id):
|
|||
}
|
||||
response = requests.get(url, headers=headers)
|
||||
if response.status_code == 200:
|
||||
return response.json()['state']
|
||||
responsetext = '设备状态:' + response.json()['state'] + ' '
|
||||
logger.bind(tag=TAG).info(f"api返回内容: {response.json()}")
|
||||
|
||||
if 'media_title' in response.json()['attributes']:
|
||||
responsetext = responsetext+ '正在播放的是:'+str(response.json()['attributes']['media_title'])+' '
|
||||
if 'volume_level' in response.json()['attributes']:
|
||||
responsetext = responsetext+ '音量是:'+str(response.json()['attributes']['volume_level'])+' '
|
||||
if 'color_temp_kelvin' in response.json()['attributes']:
|
||||
responsetext = responsetext+ '色温是:'+str(response.json()['attributes']['color_temp_kelvin'])+' '
|
||||
if 'rgb_color' in response.json()['attributes']:
|
||||
responsetext = responsetext+ 'rgb颜色是:'+str(response.json()['attributes']['rgb_color'])+' '
|
||||
if 'brightness' in response.json()['attributes']:
|
||||
responsetext = responsetext+ '亮度是:'+str(response.json()['attributes']['brightness'])+' '
|
||||
logger.bind(tag=TAG).info(f"查询返回内容: {responsetext}")
|
||||
return responsetext
|
||||
#return response.json()['attributes']
|
||||
#response.attributes
|
||||
|
||||
else:
|
||||
return f"切换失败,错误码: {response.status_code}"
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ hass_set_state_function_desc = {
|
|||
"type": "function",
|
||||
"function": {
|
||||
"name": "hass_set_state",
|
||||
"description": "设置homeassistant里设备的状态,包括开、关,调整灯光亮度,调整播放器的音量,设备的暂停、继续、静音操作",
|
||||
"description": "设置homeassistant里设备的状态,包括开、关,调整灯光亮度、颜色、色温,调整播放器的音量,设备的暂停、继续、静音操作",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
|
@ -20,7 +20,7 @@ hass_set_state_function_desc = {
|
|||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"description": "需要操作的动作,打开设备:turn_on,关闭设备:turn_off,增加亮度:brightness_up,降低亮度:brightness_down,设置亮度:brightness_value,增加>音量:,volume_up降低音量:volume_down,设置音量:volume_set,设备暂停:pause,设备继续:continue,静音/取消静音:volume_mute"
|
||||
"description": "需要操作的动作,打开设备:turn_on,关闭设备:turn_off,增加亮度:brightness_up,降低亮度:brightness_down,设置亮度:brightness_value,增加音量:volume_up,降低音量:volume_down,设置音量:volume_set,设置色温:set_kelvin,设置颜色:set_color,设备暂停:pause,设备继续:continue,静音/取消静音:volume_mute"
|
||||
},
|
||||
"input": {
|
||||
"type": "integer",
|
||||
|
|
@ -29,6 +29,10 @@ hass_set_state_function_desc = {
|
|||
"is_muted": {
|
||||
"type": "string",
|
||||
"description": "只有在设置静音操作时才需要,设置静音的时候该值为true,取消静音时该值为false"
|
||||
},
|
||||
"rgb_color":{
|
||||
"type":"list",
|
||||
"description": "只有在设置颜色时需要,这里填目标颜色的rgb值"
|
||||
}
|
||||
},
|
||||
"required": ["type"]
|
||||
|
|
@ -52,7 +56,7 @@ def hass_set_state(conn, entity_id='', state={}):
|
|||
conn.loop
|
||||
)
|
||||
ha_response = future.result()
|
||||
return ActionResponse(action=Action.REQLLM, result="执行成功", response=ha_response)
|
||||
return ActionResponse(Action.REQLLM, ha_response, None)
|
||||
except Exception as e:
|
||||
logger.bind(tag=TAG).error(f"处理设置属性意图错误: {e}")
|
||||
|
||||
|
|
@ -103,6 +107,16 @@ async def handle_hass_set_state(conn, entity_id, state):
|
|||
action = 'turn_on'
|
||||
arg = 'brightness_pct'
|
||||
value = state['input']
|
||||
elif state['type'] == 'set_color':
|
||||
description = f"颜色已调整到{state['rgb_color']}"
|
||||
action = 'turn_on'
|
||||
arg = 'rgb_color'
|
||||
value = state['rgb_color']
|
||||
elif state['type'] == 'set_kelvin':
|
||||
description = f"色温已调整到{state['input']}K"
|
||||
action = 'turn_on'
|
||||
arg = 'kelvin'
|
||||
value = state['input']
|
||||
elif state['type'] == 'volume_up':
|
||||
description = "音量已调大"
|
||||
action = state['type']
|
||||
|
|
@ -114,6 +128,8 @@ async def handle_hass_set_state(conn, entity_id, state):
|
|||
action = state['type']
|
||||
arg = 'volume_level'
|
||||
value = state['input']
|
||||
if state['input'] >= 1:
|
||||
value = state['input']/100
|
||||
elif state['type'] == 'volume_mute':
|
||||
description = f"设备已静音"
|
||||
action = state['type']
|
||||
|
|
@ -152,7 +168,7 @@ async def handle_hass_set_state(conn, entity_id, state):
|
|||
"Content-Type": "application/json"
|
||||
}
|
||||
response = requests.post(url, headers=headers, json=data)
|
||||
logger.bind(tag=TAG).info(f"设置状态:url:{url},return_code:{response.status_code}")
|
||||
logger.bind(tag=TAG).info(f"设置状态:{description},url:{url},return_code:{response.status_code}")
|
||||
if response.status_code == 200:
|
||||
return description
|
||||
else:
|
||||
|
|
|
|||
Loading…
Reference in a new issue