mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-28 10:03:54 +08:00
update:智控台可设置允许用户自由注册 (#809)
* update:修复默认模型没有修改到模版配置的bug * update:智控台可设置允许用户自由注册
This commit is contained in:
@@ -84,6 +84,16 @@ public interface Constant {
|
|||||||
*/
|
*/
|
||||||
String SERVER_SECRET = "server.secret";
|
String SERVER_SECRET = "server.secret";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否允许用户注册
|
||||||
|
*/
|
||||||
|
String SERVER_ALLOW_USER_REGISTER = "server.allow_user_register";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下发六位验证码时显示的控制面板地址
|
||||||
|
*/
|
||||||
|
String SERVER_FRONTED_URL = "server.fronted_url";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 路径分割符
|
* 路径分割符
|
||||||
*/
|
*/
|
||||||
|
|||||||
+25
-23
@@ -3,6 +3,7 @@ package xiaozhi.modules.agent.service.impl;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
|
||||||
import xiaozhi.modules.agent.dao.AgentTemplateDao;
|
import xiaozhi.modules.agent.dao.AgentTemplateDao;
|
||||||
@@ -39,29 +40,30 @@ public class AgentTemplateServiceImpl extends ServiceImpl<AgentTemplateDao, Agen
|
|||||||
@Override
|
@Override
|
||||||
public void updateDefaultTemplateModelId(String modelType, String modelId) {
|
public void updateDefaultTemplateModelId(String modelType, String modelId) {
|
||||||
modelType = modelType.toUpperCase();
|
modelType = modelType.toUpperCase();
|
||||||
AgentTemplateEntity defaultTemplate = getDefaultTemplate();
|
|
||||||
if (defaultTemplate != null) {
|
UpdateWrapper<AgentTemplateEntity> wrapper = new UpdateWrapper<>();
|
||||||
switch (modelType) {
|
switch (modelType) {
|
||||||
case "ASR":
|
case "ASR":
|
||||||
defaultTemplate.setAsrModelId(modelId);
|
wrapper.set("asr_model_id", modelId);
|
||||||
break;
|
break;
|
||||||
case "VAD":
|
case "VAD":
|
||||||
defaultTemplate.setVadModelId(modelId);
|
wrapper.set("vad_model_id", modelId);
|
||||||
break;
|
break;
|
||||||
case "LLM":
|
case "LLM":
|
||||||
defaultTemplate.setLlmModelId(modelId);
|
wrapper.set("llm_model_id", modelId);
|
||||||
break;
|
break;
|
||||||
case "TTS":
|
case "TTS":
|
||||||
defaultTemplate.setTtsModelId(modelId);
|
wrapper.set("tts_model_id", modelId);
|
||||||
break;
|
wrapper.set("tts_voice_id", null);
|
||||||
case "Memory":
|
break;
|
||||||
defaultTemplate.setMemModelId(modelId);
|
case "MEMORY":
|
||||||
break;
|
wrapper.set("mem_model_id", modelId);
|
||||||
case "Intent":
|
break;
|
||||||
defaultTemplate.setIntentModelId(modelId);
|
case "INTENT":
|
||||||
break;
|
wrapper.set("intent_model_id", modelId);
|
||||||
}
|
break;
|
||||||
this.updateById(defaultTemplate);
|
|
||||||
}
|
}
|
||||||
|
wrapper.ge("sort", 0);
|
||||||
|
update(wrapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -9,7 +9,6 @@ import java.util.TimeZone;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -34,6 +33,7 @@ import xiaozhi.modules.device.entity.DeviceEntity;
|
|||||||
import xiaozhi.modules.device.service.DeviceService;
|
import xiaozhi.modules.device.service.DeviceService;
|
||||||
import xiaozhi.modules.device.vo.UserShowDeviceListVO;
|
import xiaozhi.modules.device.vo.UserShowDeviceListVO;
|
||||||
import xiaozhi.modules.security.user.SecurityUser;
|
import xiaozhi.modules.security.user.SecurityUser;
|
||||||
|
import xiaozhi.modules.sys.service.SysParamsService;
|
||||||
import xiaozhi.modules.sys.service.SysUserUtilService;
|
import xiaozhi.modules.sys.service.SysUserUtilService;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@@ -49,11 +49,11 @@ public class DeviceServiceImpl extends BaseServiceImpl<DeviceDao, DeviceEntity>
|
|||||||
|
|
||||||
// 添加构造函数来初始化 deviceMapper
|
// 添加构造函数来初始化 deviceMapper
|
||||||
public DeviceServiceImpl(DeviceDao deviceDao, SysUserUtilService sysUserUtilService,
|
public DeviceServiceImpl(DeviceDao deviceDao, SysUserUtilService sysUserUtilService,
|
||||||
@Value("${app.fronted-url:http://localhost:8001}") String frontedUrl,
|
SysParamsService sysParamsService,
|
||||||
RedisTemplate<String, Object> redisTemplate) {
|
RedisTemplate<String, Object> redisTemplate) {
|
||||||
this.deviceDao = deviceDao;
|
this.deviceDao = deviceDao;
|
||||||
this.sysUserUtilService = sysUserUtilService;
|
this.sysUserUtilService = sysUserUtilService;
|
||||||
this.frontedUrl = frontedUrl;
|
this.frontedUrl = sysParamsService.getValue(Constant.SERVER_FRONTED_URL, true);
|
||||||
this.redisTemplate = redisTemplate;
|
this.redisTemplate = redisTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -135,6 +135,7 @@ public class ModelController {
|
|||||||
}
|
}
|
||||||
// 将其他模型设置为非默认
|
// 将其他模型设置为非默认
|
||||||
modelConfigService.setDefaultModel(entity.getModelType(), 0);
|
modelConfigService.setDefaultModel(entity.getModelType(), 0);
|
||||||
|
entity.setIsEnabled(1);
|
||||||
entity.setIsDefault(1);
|
entity.setIsDefault(1);
|
||||||
modelConfigService.updateById(entity);
|
modelConfigService.updateById(entity);
|
||||||
|
|
||||||
|
|||||||
+1
@@ -42,6 +42,7 @@ public class ModelConfigServiceImpl extends BaseServiceImpl<ModelConfigDao, Mode
|
|||||||
List<ModelConfigEntity> entities = modelConfigDao.selectList(
|
List<ModelConfigEntity> entities = modelConfigDao.selectList(
|
||||||
new QueryWrapper<ModelConfigEntity>()
|
new QueryWrapper<ModelConfigEntity>()
|
||||||
.eq("model_type", modelType)
|
.eq("model_type", modelType)
|
||||||
|
.eq("is_enabled", 1)
|
||||||
.like(StringUtils.isNotBlank(modelName), "model_name", "%" + modelName + "%")
|
.like(StringUtils.isNotBlank(modelName), "model_name", "%" + modelName + "%")
|
||||||
.select("id", "model_name"));
|
.select("id", "model_name"));
|
||||||
return ConvertUtils.sourceToTarget(entities, ModelBasicInfoDTO.class);
|
return ConvertUtils.sourceToTarget(entities, ModelBasicInfoDTO.class);
|
||||||
|
|||||||
+4
@@ -77,6 +77,9 @@ public class LoginController {
|
|||||||
@PostMapping("/register")
|
@PostMapping("/register")
|
||||||
@Operation(summary = "注册")
|
@Operation(summary = "注册")
|
||||||
public Result<Void> register(@RequestBody LoginDTO login) {
|
public Result<Void> register(@RequestBody LoginDTO login) {
|
||||||
|
if (!sysUserService.getAllowUserRegister()) {
|
||||||
|
throw new RenException("当前不允许普通用户注册");
|
||||||
|
}
|
||||||
// 验证是否正确输入验证码
|
// 验证是否正确输入验证码
|
||||||
boolean validate = captchaService.validate(login.getCaptchaId(), login.getCaptcha());
|
boolean validate = captchaService.validate(login.getCaptchaId(), login.getCaptcha());
|
||||||
if (!validate) {
|
if (!validate) {
|
||||||
@@ -119,6 +122,7 @@ public class LoginController {
|
|||||||
public Result<Map<String, Object>> pubConfig() {
|
public Result<Map<String, Object>> pubConfig() {
|
||||||
Map<String, Object> config = new HashMap<>();
|
Map<String, Object> config = new HashMap<>();
|
||||||
config.put("version", "0.3.3");
|
config.put("version", "0.3.3");
|
||||||
|
config.put("allowUserRegister", sysUserService.getAllowUserRegister());
|
||||||
return new Result<Map<String, Object>>().ok(config);
|
return new Result<Map<String, Object>>().ok(config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+5
-3
@@ -27,6 +27,7 @@ import xiaozhi.common.validator.ValidatorUtils;
|
|||||||
import xiaozhi.common.validator.group.AddGroup;
|
import xiaozhi.common.validator.group.AddGroup;
|
||||||
import xiaozhi.common.validator.group.DefaultGroup;
|
import xiaozhi.common.validator.group.DefaultGroup;
|
||||||
import xiaozhi.common.validator.group.UpdateGroup;
|
import xiaozhi.common.validator.group.UpdateGroup;
|
||||||
|
import xiaozhi.modules.config.service.ConfigService;
|
||||||
import xiaozhi.modules.sys.dto.SysParamsDTO;
|
import xiaozhi.modules.sys.dto.SysParamsDTO;
|
||||||
import xiaozhi.modules.sys.service.SysParamsService;
|
import xiaozhi.modules.sys.service.SysParamsService;
|
||||||
|
|
||||||
@@ -42,6 +43,7 @@ import xiaozhi.modules.sys.service.SysParamsService;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class SysParamsController {
|
public class SysParamsController {
|
||||||
private final SysParamsService sysParamsService;
|
private final SysParamsService sysParamsService;
|
||||||
|
private final ConfigService configService;
|
||||||
|
|
||||||
@GetMapping("page")
|
@GetMapping("page")
|
||||||
@Operation(summary = "分页")
|
@Operation(summary = "分页")
|
||||||
@@ -77,7 +79,7 @@ public class SysParamsController {
|
|||||||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
|
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
|
||||||
|
|
||||||
sysParamsService.save(dto);
|
sysParamsService.save(dto);
|
||||||
|
configService.getConfig(false);
|
||||||
return new Result<Void>();
|
return new Result<Void>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +92,7 @@ public class SysParamsController {
|
|||||||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
|
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
|
||||||
|
|
||||||
sysParamsService.update(dto);
|
sysParamsService.update(dto);
|
||||||
|
configService.getConfig(false);
|
||||||
return new Result<Void>();
|
return new Result<Void>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,7 +105,7 @@ public class SysParamsController {
|
|||||||
AssertUtils.isArrayEmpty(ids, "id");
|
AssertUtils.isArrayEmpty(ids, "id");
|
||||||
|
|
||||||
sysParamsService.delete(ids);
|
sysParamsService.delete(ids);
|
||||||
|
configService.getConfig(false);
|
||||||
return new Result<Void>();
|
return new Result<Void>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,4 +65,11 @@ public interface SysUserService extends BaseService<SysUserEntity> {
|
|||||||
* @param userIds 用户ID数组
|
* @param userIds 用户ID数组
|
||||||
*/
|
*/
|
||||||
void changeStatus(Integer status, String[] userIds);
|
void changeStatus(Integer status, String[] userIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取是否允许用户注册
|
||||||
|
*
|
||||||
|
* @return 是否允许用户注册
|
||||||
|
*/
|
||||||
|
boolean getAllowUserRegister();
|
||||||
}
|
}
|
||||||
|
|||||||
+16
@@ -30,6 +30,7 @@ import xiaozhi.modules.sys.dto.PasswordDTO;
|
|||||||
import xiaozhi.modules.sys.dto.SysUserDTO;
|
import xiaozhi.modules.sys.dto.SysUserDTO;
|
||||||
import xiaozhi.modules.sys.entity.SysUserEntity;
|
import xiaozhi.modules.sys.entity.SysUserEntity;
|
||||||
import xiaozhi.modules.sys.enums.SuperAdminEnum;
|
import xiaozhi.modules.sys.enums.SuperAdminEnum;
|
||||||
|
import xiaozhi.modules.sys.service.SysParamsService;
|
||||||
import xiaozhi.modules.sys.service.SysUserService;
|
import xiaozhi.modules.sys.service.SysUserService;
|
||||||
import xiaozhi.modules.sys.vo.AdminPageUserVO;
|
import xiaozhi.modules.sys.vo.AdminPageUserVO;
|
||||||
|
|
||||||
@@ -45,6 +46,8 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
|
|||||||
|
|
||||||
private final AgentService agentService;
|
private final AgentService agentService;
|
||||||
|
|
||||||
|
private final SysParamsService sysParamsService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SysUserDTO getByUsername(String username) {
|
public SysUserDTO getByUsername(String username) {
|
||||||
QueryWrapper<SysUserEntity> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<SysUserEntity> queryWrapper = new QueryWrapper<>();
|
||||||
@@ -205,4 +208,17 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
|
|||||||
updateById(entity);
|
updateById(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getAllowUserRegister() {
|
||||||
|
String allowUserRegister = sysParamsService.getValue(Constant.SERVER_ALLOW_USER_REGISTER, true);
|
||||||
|
if (allowUserRegister.equals("true")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Long userCount = baseDao.selectCount(new QueryWrapper<SysUserEntity>());
|
||||||
|
if (userCount == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,3 @@ mybatis-plus:
|
|||||||
prefix:
|
prefix:
|
||||||
blobType: BLOB
|
blobType: BLOB
|
||||||
boolValue: TRUE
|
boolValue: TRUE
|
||||||
|
|
||||||
app:
|
|
||||||
fronted-url: http://localhost:8001
|
|
||||||
+5
@@ -16,3 +16,8 @@ INSERT INTO `ai_tts_voice` VALUES
|
|||||||
('TTS_EdgeTTS0009', 'TTS_EdgeTTS', 'EdgeTTS女声-香港海佳', 'zh-HK-HiuGaaiNeural', '粤语', 'General', 'Friendly, Positive', 1, NULL, NULL, NULL, NULL),
|
('TTS_EdgeTTS0009', 'TTS_EdgeTTS', 'EdgeTTS女声-香港海佳', 'zh-HK-HiuGaaiNeural', '粤语', 'General', 'Friendly, Positive', 1, NULL, NULL, NULL, NULL),
|
||||||
('TTS_EdgeTTS0010', 'TTS_EdgeTTS', 'EdgeTTS女声-香港海曼', 'zh-HK-HiuMaanNeural', '粤语', 'General', 'Friendly, Positive', 1, NULL, NULL, NULL, NULL),
|
('TTS_EdgeTTS0010', 'TTS_EdgeTTS', 'EdgeTTS女声-香港海曼', 'zh-HK-HiuMaanNeural', '粤语', 'General', 'Friendly, Positive', 1, NULL, NULL, NULL, NULL),
|
||||||
('TTS_EdgeTTS0011', 'TTS_EdgeTTS', 'EdgeTTS男声-香港万龙', 'zh-HK-WanLungNeural', '粤语', 'General', 'Friendly, Positive', 1, NULL, NULL, NULL, NULL);
|
('TTS_EdgeTTS0011', 'TTS_EdgeTTS', 'EdgeTTS男声-香港万龙', 'zh-HK-WanLungNeural', '粤语', 'General', 'Friendly, Positive', 1, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
-- 增加是否允许用户注册参数
|
||||||
|
delete from `sys_params` where id in (103,104);
|
||||||
|
INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (103, 'server.allow_user_register', 'false', 'boolean', 1, '是否运行管理员以外的人注册');
|
||||||
|
INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES (104, 'server.fronted_url', 'http://xiaozhi.server.com', 'string', 1, '下发六位验证码时显示的控制面板地址');
|
||||||
@@ -52,9 +52,9 @@ databaseChangeLog:
|
|||||||
encoding: utf8
|
encoding: utf8
|
||||||
path: classpath:db/changelog/202504112058.sql
|
path: classpath:db/changelog/202504112058.sql
|
||||||
- changeSet:
|
- changeSet:
|
||||||
id: 202504131543
|
id: 202504151205
|
||||||
author: John
|
author: John
|
||||||
changes:
|
changes:
|
||||||
- sqlFile:
|
- sqlFile:
|
||||||
encoding: utf8
|
encoding: utf8
|
||||||
path: classpath:db/changelog/202504131543.sql
|
path: classpath:db/changelog/202504151205.sql
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-dialog :visible="dialogVisible" @update:visible="handleVisibleChange" width="975px" center custom-class="custom-dialog" :show-close="false"
|
<el-dialog :visible="dialogVisible" @update:visible="handleVisibleChange" width="975px" center
|
||||||
class="center-dialog">
|
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="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 style="font-size: 30px; color: #3d4566; margin-top: -10px; margin-bottom: 10px; text-align: center;">
|
||||||
添加模型
|
添加模型
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
<span style="margin-right: 8px;">是否启用</span>
|
<span style="margin-right: 8px;">是否启用</span>
|
||||||
<el-switch v-model="formData.isEnabled" class="custom-switch"></el-switch>
|
<el-switch v-model="formData.isEnabled" class="custom-switch"></el-switch>
|
||||||
</div>
|
</div>
|
||||||
<div style="display: flex; align-items: center;">
|
<div style="display: none; align-items: center;">
|
||||||
<span style="margin-right: 8px;">设为默认</span>
|
<span style="margin-right: 8px;">设为默认</span>
|
||||||
<el-switch v-model="formData.isDefault" class="custom-switch"></el-switch>
|
<el-switch v-model="formData.isDefault" class="custom-switch"></el-switch>
|
||||||
</div>
|
</div>
|
||||||
@@ -65,18 +65,10 @@
|
|||||||
<el-form :model="formData.configJson" label-width="auto" label-position="left" class="custom-form">
|
<el-form :model="formData.configJson" label-width="auto" label-position="left" class="custom-form">
|
||||||
<template v-for="(row, rowIndex) in chunkedCallInfoFields">
|
<template v-for="(row, rowIndex) in chunkedCallInfoFields">
|
||||||
<div :key="rowIndex" style="display: flex; gap: 20px; margin-bottom: 0;">
|
<div :key="rowIndex" style="display: flex; gap: 20px; margin-bottom: 0;">
|
||||||
<el-form-item
|
<el-form-item v-for="field in row" :key="field.prop" :label="field.label" :prop="field.prop"
|
||||||
v-for="field in row"
|
|
||||||
:key="field.prop"
|
|
||||||
:label="field.label"
|
|
||||||
:prop="field.prop"
|
|
||||||
style="flex: 1;">
|
style="flex: 1;">
|
||||||
<el-input
|
<el-input v-model="formData.configJson[field.prop]" :placeholder="field.placeholder"
|
||||||
v-model="formData.configJson[field.prop]"
|
:type="field.type || 'text'" class="custom-input-bg" :show-password="field.type === 'password'">
|
||||||
:placeholder="field.placeholder"
|
|
||||||
:type="field.type || 'text'"
|
|
||||||
class="custom-input-bg"
|
|
||||||
:show-password="field.type === 'password'">
|
|
||||||
</el-input>
|
</el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</div>
|
</div>
|
||||||
@@ -123,7 +115,7 @@ export default {
|
|||||||
watch: {
|
watch: {
|
||||||
visible(val) {
|
visible(val) {
|
||||||
this.dialogVisible = val;
|
this.dialogVisible = val;
|
||||||
if(val) {
|
if (val) {
|
||||||
this.initConfigJson();
|
this.initConfigJson();
|
||||||
} else {
|
} else {
|
||||||
this.resetForm();
|
this.resetForm();
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
<span style="margin-right: 8px;">是否启用</span>
|
<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>
|
||||||
<div style="display: flex; align-items: center;">
|
<div style="display: none; align-items: center;">
|
||||||
<span style="margin-right: 8px;">设为默认</span>
|
<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>
|
||||||
@@ -64,18 +64,10 @@
|
|||||||
<el-form :model="form.configJson" ref="callInfoForm" label-width="auto" class="custom-form">
|
<el-form :model="form.configJson" ref="callInfoForm" label-width="auto" class="custom-form">
|
||||||
<template v-for="(row, rowIndex) in chunkedCallInfoFields">
|
<template v-for="(row, rowIndex) in chunkedCallInfoFields">
|
||||||
<div :key="rowIndex" style="display: flex; gap: 20px; margin-bottom: 0;">
|
<div :key="rowIndex" style="display: flex; gap: 20px; margin-bottom: 0;">
|
||||||
<el-form-item
|
<el-form-item v-for="field in row" :key="field.prop" :label="field.label" :prop="field.prop"
|
||||||
v-for="field in row"
|
|
||||||
:key="field.prop"
|
|
||||||
:label="field.label"
|
|
||||||
:prop="field.prop"
|
|
||||||
style="flex: 1;">
|
style="flex: 1;">
|
||||||
<el-input
|
<el-input v-model="form.configJson[field.prop]" :placeholder="field.placeholder" :type="field.type"
|
||||||
v-model="form.configJson[field.prop]"
|
class="custom-input-bg" :show-password="field.type === 'password'">
|
||||||
:placeholder="field.placeholder"
|
|
||||||
:type="field.type"
|
|
||||||
class="custom-input-bg"
|
|
||||||
:show-password="field.type === 'password'">
|
|
||||||
</el-input>
|
</el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</div>
|
</div>
|
||||||
@@ -165,57 +157,57 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
resetForm() {
|
resetForm() {
|
||||||
this.form = {
|
this.form = {
|
||||||
id: "",
|
id: "",
|
||||||
modelType: "",
|
modelType: "",
|
||||||
modelCode: "",
|
modelCode: "",
|
||||||
modelName: "",
|
modelName: "",
|
||||||
isDefault: false,
|
isDefault: false,
|
||||||
isEnabled: false,
|
isEnabled: false,
|
||||||
docLink: "",
|
docLink: "",
|
||||||
remark: "",
|
remark: "",
|
||||||
sort: 0,
|
sort: 0,
|
||||||
configJson: {}
|
configJson: {}
|
||||||
};
|
};
|
||||||
this.dynamicCallInfoFields.forEach(field => {
|
this.dynamicCallInfoFields.forEach(field => {
|
||||||
this.$set(this.form.configJson, field.prop, '');
|
this.$set(this.form.configJson, field.prop, '');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
resetProviders() {
|
resetProviders() {
|
||||||
this.providers = [];
|
this.providers = [];
|
||||||
this.providersLoaded = false;
|
this.providersLoaded = false;
|
||||||
},
|
},
|
||||||
loadModelData() {
|
loadModelData() {
|
||||||
if (this.modelData.id) {
|
if (this.modelData.id) {
|
||||||
Api.model.getModelConfig(this.modelData.id, ({ data }) => {
|
Api.model.getModelConfig(this.modelData.id, ({ data }) => {
|
||||||
if (data.code === 0 && data.data) {
|
if (data.code === 0 && data.data) {
|
||||||
const model = data.data;
|
const model = data.data;
|
||||||
this.pendingProviderType = model.configJson.type;
|
this.pendingProviderType = model.configJson.type;
|
||||||
this.pendingModelData = model;
|
this.pendingModelData = model;
|
||||||
|
|
||||||
if (this.providersLoaded) {
|
if (this.providersLoaded) {
|
||||||
this.loadProviderFields(model.configJson.type);
|
this.loadProviderFields(model.configJson.type);
|
||||||
} else {
|
} else {
|
||||||
this.loadProviders();
|
this.loadProviders();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleSave() {
|
handleSave() {
|
||||||
const provideCode = this.form.configJson.type;
|
const provideCode = this.form.configJson.type;
|
||||||
const formData = {
|
const formData = {
|
||||||
id: this.modelData.id,
|
id: this.modelData.id,
|
||||||
modelCode: this.form.modelCode,
|
modelCode: this.form.modelCode,
|
||||||
modelName: this.form.modelName,
|
modelName: this.form.modelName,
|
||||||
isDefault: this.form.isDefault ? 1 : 0,
|
isDefault: this.form.isDefault ? 1 : 0,
|
||||||
isEnabled: this.form.isEnabled ? 1 : 0,
|
isEnabled: this.form.isEnabled ? 1 : 0,
|
||||||
docLink: this.form.docLink,
|
docLink: this.form.docLink,
|
||||||
remark: this.form.remark,
|
remark: this.form.remark,
|
||||||
sort: this.form.sort || 0,
|
sort: this.form.sort || 0,
|
||||||
configJson: {
|
configJson: {
|
||||||
...this.form.configJson,
|
...this.form.configJson,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.$emit("save", { provideCode, formData });
|
this.$emit("save", { provideCode, formData });
|
||||||
this.dialogVisible = false;
|
this.dialogVisible = false;
|
||||||
|
|||||||
@@ -5,33 +5,17 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Api from '@/apis/api';
|
import { mapState } from 'vuex';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'VersionFooter',
|
name: 'VersionFooter',
|
||||||
data() {
|
computed: {
|
||||||
return {
|
...mapState({
|
||||||
version: ''
|
version: state => state.pubConfig.version
|
||||||
}
|
})
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.getSystemVersion();
|
this.$store.dispatch('fetchPubConfig');
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
getSystemVersion() {
|
|
||||||
const storedVersion = sessionStorage.getItem('systemVersion');
|
|
||||||
if (storedVersion) {
|
|
||||||
this.version = storedVersion;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Api.user.getPubConfig(({ data }) => {
|
|
||||||
if (data.code === 0 && data.data.version) {
|
|
||||||
this.version = data.data.version;
|
|
||||||
sessionStorage.setItem('systemVersion', data.data.version);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { goToPage } from "@/utils";
|
import { goToPage } from "@/utils";
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import Vuex from 'vuex';
|
import Vuex from 'vuex';
|
||||||
|
import Api from '../apis/api';
|
||||||
import Constant from '../utils/constant';
|
import Constant from '../utils/constant';
|
||||||
|
|
||||||
Vue.use(Vuex)
|
Vue.use(Vuex)
|
||||||
@@ -9,7 +10,11 @@ export default new Vuex.Store({
|
|||||||
state: {
|
state: {
|
||||||
token: '',
|
token: '',
|
||||||
userInfo: {}, // 添加用户信息存储
|
userInfo: {}, // 添加用户信息存储
|
||||||
isSuperAdmin: false // 添加superAdmin状态
|
isSuperAdmin: false, // 添加superAdmin状态
|
||||||
|
pubConfig: { // 添加公共配置存储
|
||||||
|
version: '',
|
||||||
|
allowUserRegister: false
|
||||||
|
}
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
getToken(state) {
|
getToken(state) {
|
||||||
@@ -26,6 +31,9 @@ export default new Vuex.Store({
|
|||||||
return state.isSuperAdmin
|
return state.isSuperAdmin
|
||||||
}
|
}
|
||||||
return localStorage.getItem('isSuperAdmin') === 'true'
|
return localStorage.getItem('isSuperAdmin') === 'true'
|
||||||
|
},
|
||||||
|
getPubConfig(state) {
|
||||||
|
return state.pubConfig
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
@@ -39,6 +47,9 @@ export default new Vuex.Store({
|
|||||||
state.isSuperAdmin = isSuperAdmin
|
state.isSuperAdmin = isSuperAdmin
|
||||||
localStorage.setItem('isSuperAdmin', isSuperAdmin)
|
localStorage.setItem('isSuperAdmin', isSuperAdmin)
|
||||||
},
|
},
|
||||||
|
setPubConfig(state, config) {
|
||||||
|
state.pubConfig = config
|
||||||
|
},
|
||||||
clearAuth(state) {
|
clearAuth(state) {
|
||||||
state.token = ''
|
state.token = ''
|
||||||
state.userInfo = {}
|
state.userInfo = {}
|
||||||
@@ -55,6 +66,17 @@ export default new Vuex.Store({
|
|||||||
goToPage(Constant.PAGE.LOGIN, true);
|
goToPage(Constant.PAGE.LOGIN, true);
|
||||||
window.location.reload(); // 彻底重置状态
|
window.location.reload(); // 彻底重置状态
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
// 添加获取公共配置的 action
|
||||||
|
fetchPubConfig({ commit }) {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
Api.user.getPubConfig(({ data }) => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
commit('setPubConfig', data.data);
|
||||||
|
}
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
modules: {
|
modules: {
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
style="font-weight: 400;font-size: 14px;text-align: left;color: #5778ff;display: flex;justify-content: space-between;margin-top: 20px;">
|
style="font-weight: 400;font-size: 14px;text-align: left;color: #5778ff;display: flex;justify-content: space-between;margin-top: 20px;">
|
||||||
<div style="cursor: pointer;" @click="goToRegister">新用户注册</div>
|
<div v-if="allowUserRegister" style="cursor: pointer;" @click="goToRegister">新用户注册</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="login-btn" @click="login">登录</div>
|
<div class="login-btn" @click="login">登录</div>
|
||||||
@@ -61,12 +61,18 @@
|
|||||||
import Api from '@/apis/api';
|
import Api from '@/apis/api';
|
||||||
import VersionFooter from '@/components/VersionFooter.vue';
|
import VersionFooter from '@/components/VersionFooter.vue';
|
||||||
import { getUUID, goToPage, showDanger, showSuccess } from '@/utils';
|
import { getUUID, goToPage, showDanger, showSuccess } from '@/utils';
|
||||||
|
import { mapState } from 'vuex';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'login',
|
name: 'login',
|
||||||
components: {
|
components: {
|
||||||
VersionFooter
|
VersionFooter
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
...mapState({
|
||||||
|
allowUserRegister: state => state.pubConfig.allowUserRegister
|
||||||
|
})
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
activeName: "username",
|
activeName: "username",
|
||||||
@@ -77,13 +83,12 @@ export default {
|
|||||||
captchaId: ''
|
captchaId: ''
|
||||||
},
|
},
|
||||||
captchaUuid: '',
|
captchaUuid: '',
|
||||||
captchaUrl: '',
|
captchaUrl: ''
|
||||||
version: ''
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.fetchCaptcha();
|
this.fetchCaptcha();
|
||||||
this.getSystemVersion();
|
this.$store.dispatch('fetchPubConfig');
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
fetchCaptcha() {
|
fetchCaptcha() {
|
||||||
@@ -148,21 +153,6 @@ export default {
|
|||||||
goToRegister() {
|
goToRegister() {
|
||||||
goToPage('/register')
|
goToPage('/register')
|
||||||
},
|
},
|
||||||
|
|
||||||
getSystemVersion() {
|
|
||||||
const storedVersion = sessionStorage.getItem('systemVersion');
|
|
||||||
if (storedVersion) {
|
|
||||||
this.version = storedVersion;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Api.user.getPubConfig(({ data }) => {
|
|
||||||
if (data.code === 0 && data.data.version) {
|
|
||||||
this.version = data.data.version;
|
|
||||||
sessionStorage.setItem('systemVersion', data.data.version);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -82,12 +82,18 @@
|
|||||||
import Api from '@/apis/api';
|
import Api from '@/apis/api';
|
||||||
import VersionFooter from '@/components/VersionFooter.vue';
|
import VersionFooter from '@/components/VersionFooter.vue';
|
||||||
import { getUUID, goToPage, showDanger, showSuccess } from '@/utils';
|
import { getUUID, goToPage, showDanger, showSuccess } from '@/utils';
|
||||||
|
import { mapState } from 'vuex';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'register',
|
name: 'register',
|
||||||
components: {
|
components: {
|
||||||
VersionFooter
|
VersionFooter
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
...mapState({
|
||||||
|
allowUserRegister: state => state.pubConfig.allowUserRegister
|
||||||
|
})
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
form: {
|
form: {
|
||||||
@@ -101,6 +107,14 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
this.$store.dispatch('fetchPubConfig').then(() => {
|
||||||
|
if (!this.allowUserRegister) {
|
||||||
|
showDanger('当前不允许普通用户注册');
|
||||||
|
setTimeout(() => {
|
||||||
|
goToPage('/login');
|
||||||
|
}, 1500);
|
||||||
|
}
|
||||||
|
});
|
||||||
this.fetchCaptcha();
|
this.fetchCaptcha();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|||||||
Reference in New Issue
Block a user