Merge pull request #672 from xinnan-tech/hot-fix

合并多个提交
This commit is contained in:
欣南科技
2025-04-05 22:14:30 +08:00
committed by GitHub
52 changed files with 1208 additions and 1107 deletions
@@ -25,7 +25,8 @@ public interface AgentService extends BaseService<AgentEntity> {
/**
* 删除这个用户的所有
*
* @param userId
*/
void deleteAgentByUserId(String userId);
void deleteAgentByUserId(Long userId);
}
@@ -65,7 +65,7 @@ public class AgentServiceImpl extends BaseServiceImpl<AgentDao, AgentEntity> imp
}
@Override
public void deleteAgentByUserId(String userId) {
public void deleteAgentByUserId(Long userId) {
UpdateWrapper<AgentEntity> wrapper = new UpdateWrapper<>();
wrapper.eq("user_id", userId);
baseDao.delete(wrapper);
@@ -17,11 +17,12 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import xiaozhi.common.page.PageData;
import xiaozhi.common.utils.ConvertUtils;
import xiaozhi.common.utils.Result;
import xiaozhi.modules.model.dto.ModelConfigBodyDTO;
import xiaozhi.modules.model.dto.ModelConfigDTO;
import xiaozhi.modules.model.dto.ModelProviderDTO;
import xiaozhi.modules.model.dto.ModelProviderFieldDTO;
import xiaozhi.modules.model.entity.ModelConfigEntity;
import xiaozhi.modules.model.service.ModelConfigService;
import xiaozhi.modules.model.service.ModelProviderService;
@@ -52,15 +53,6 @@ public class ModelController {
return new Result<List<ModelProviderDTO>>().ok(modelProviderDTOS);
}
@GetMapping("/{modelType}/{provideCode}/fields")
@Operation(summary = "获取模型供应器字段")
@RequiresPermissions("sys:role:superAdmin")
public Result<List<ModelProviderFieldDTO>> getModelProviderFields(@PathVariable String modelType,
@PathVariable String provideCode) {
List<ModelProviderFieldDTO> fieldList = modelProviderService.getFieldList(modelType, provideCode);
return new Result<List<ModelProviderFieldDTO>>().ok(fieldList);
}
@GetMapping("/models/list")
@Operation(summary = "获取模型配置列表")
@RequiresPermissions("sys:role:superAdmin")
@@ -94,15 +86,23 @@ public class ModelController {
return new Result<ModelConfigDTO>().ok(modelConfigDTO);
}
@DeleteMapping("/models/{modelType}/{provideCode}/{id}")
@DeleteMapping("/models/{id}")
@Operation(summary = "删除模型配置")
@RequiresPermissions("sys:role:superAdmin")
public Result<Void> deleteModelConfig(@PathVariable String modelType, @PathVariable String provideCode,
@PathVariable String id) {
modelConfigService.delete(modelType, provideCode, id);
public Result<Void> deleteModelConfig(@PathVariable String id) {
modelConfigService.delete(id);
return new Result<>();
}
@GetMapping("/models/{id}")
@Operation(summary = "获取模型配置")
@RequiresPermissions("sys:role:superAdmin")
public Result<ModelConfigDTO> getModelConfig(@PathVariable String id) {
ModelConfigEntity item = modelConfigService.selectById(id);
ModelConfigDTO modelConfigDTO = ConvertUtils.sourceToTarget(item, ModelConfigDTO.class);
return new Result<ModelConfigDTO>().ok(modelConfigDTO);
}
@GetMapping("/models/{modelId}/voices")
@Operation(summary = "获取模型音色")
@RequiresPermissions("sys:role:normal")
@@ -2,6 +2,7 @@ package xiaozhi.modules.model.dto;
import java.io.Serial;
import cn.hutool.json.JSONObject;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@@ -28,7 +29,7 @@ public class ModelConfigBodyDTO {
private Integer isEnabled;
@Schema(description = "模型配置(JSON格式)")
private String configJson;
private JSONObject configJson;
@Schema(description = "官方文档链接")
private String docLink;
@@ -3,6 +3,7 @@ package xiaozhi.modules.model.dto;
import java.io.Serial;
import java.io.Serializable;
import cn.hutool.json.JSONObject;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@@ -32,7 +33,7 @@ public class ModelConfigDTO implements Serializable {
private Integer isEnabled;
@Schema(description = "模型配置(JSON格式)")
private String configJson;
private JSONObject configJson;
@Schema(description = "官方文档链接")
private String docLink;
@@ -1,19 +0,0 @@
package xiaozhi.modules.model.dto;
import java.io.Serializable;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@Schema(description = "模型供应器字段")
public class ModelProviderFieldDTO implements Serializable {
@Schema(description = "字段名")
private String key;
@Schema(description = "字段标签")
private String label;
@Schema(description = "字段类型")
private String type;
}
@@ -9,11 +9,12 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import cn.hutool.json.JSONObject;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
@TableName("ai_model_config")
@TableName(value = "ai_model_config", autoResultMap = true)
@Schema(description = "模型配置表")
public class ModelConfigEntity {
@@ -38,7 +39,7 @@ public class ModelConfigEntity {
@TableField(typeHandler = JacksonTypeHandler.class)
@Schema(description = "模型配置(JSON格式)")
private String configJson;
private JSONObject configJson;
@Schema(description = "官方文档链接")
private String docLink;
@@ -3,10 +3,12 @@ package xiaozhi.modules.model.service;
import java.util.List;
import xiaozhi.common.page.PageData;
import xiaozhi.common.service.BaseService;
import xiaozhi.modules.model.dto.ModelConfigBodyDTO;
import xiaozhi.modules.model.dto.ModelConfigDTO;
import xiaozhi.modules.model.entity.ModelConfigEntity;
public interface ModelConfigService {
public interface ModelConfigService extends BaseService<ModelConfigEntity> {
List<String> getModelCodeList(String modelType, String modelName);
@@ -16,7 +18,7 @@ public interface ModelConfigService {
ModelConfigDTO edit(String modelType, String provideCode, String id, ModelConfigBodyDTO modelConfigBodyDTO);
void delete(String modelType, String provideCode, String id);
void delete(String id);
List<String> getVoiceList(String modelName, String voiceName);
}
@@ -3,7 +3,6 @@ package xiaozhi.modules.model.service;
import java.util.List;
import xiaozhi.modules.model.dto.ModelProviderDTO;
import xiaozhi.modules.model.dto.ModelProviderFieldDTO;
import xiaozhi.modules.model.entity.ModelProviderEntity;
public interface ModelProviderService {
@@ -19,6 +18,4 @@ public interface ModelProviderService {
void delete();
List<ModelProviderDTO> getList(String modelType, String provideCode);
List<ModelProviderFieldDTO> getFieldList(String modelType, String provideCode);
}
@@ -91,16 +91,7 @@ public class ModelConfigServiceImpl extends BaseServiceImpl<ModelConfigDao, Mode
}
@Override
public void delete(String modelType, String provideCode, String id) {
// 先验证有没有供应器
if (StringUtils.isBlank(modelType) || StringUtils.isBlank(provideCode)) {
throw new RenException("modelType和provideCode不能为空");
}
List<ModelProviderDTO> providerList = modelProviderService.getList(modelType, provideCode);
if (CollectionUtil.isEmpty(providerList)) {
throw new RenException("供应器不存在");
}
public void delete(String id) {
modelConfigDao.deleteById(id);
}
@@ -10,10 +10,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.AllArgsConstructor;
import xiaozhi.common.service.impl.BaseServiceImpl;
import xiaozhi.common.utils.ConvertUtils;
import xiaozhi.common.utils.JsonUtils;
import xiaozhi.modules.model.dao.ModelProviderDao;
import xiaozhi.modules.model.dto.ModelProviderDTO;
import xiaozhi.modules.model.dto.ModelProviderFieldDTO;
import xiaozhi.modules.model.entity.ModelProviderEntity;
import xiaozhi.modules.model.service.ModelProviderService;
@@ -56,15 +54,4 @@ public class ModelProviderServiceImpl extends BaseServiceImpl<ModelProviderDao,
List<ModelProviderEntity> providerEntities = modelProviderDao.selectList(queryWrapper);
return ConvertUtils.sourceToTarget(providerEntities, ModelProviderDTO.class);
}
@Override
public List<ModelProviderFieldDTO> getFieldList(String modelType, String providerCode) {
List<String> modelProviderEntities = modelProviderDao.getFieldList(modelType, providerCode);
if (modelProviderEntities == null || modelProviderEntities.isEmpty()) {
return null;
}
String fields = modelProviderEntities.getFirst();
List<ModelProviderFieldDTO> fieldList = JsonUtils.parseArray(fields, ModelProviderFieldDTO.class);
return fieldList;
}
}
@@ -7,6 +7,7 @@ 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.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;
@@ -79,6 +80,15 @@ public class AdminController {
return new Result<>();
}
@PutMapping("/users/changeStatus/{status}")
@Operation(summary = "批量修改用户状态")
@RequiresPermissions("sys:role:superAdmin")
@Parameter(name = "status", description = "用户状态", required = true)
public Result<Void> changeStatus(@PathVariable Integer status, @RequestBody Long[] userIds) {
sysUserService.changeStatus(status, userIds);
return new Result<Void>();
}
@GetMapping("/device/all")
@Operation(summary = "分页查找设备")
@RequiresPermissions("sys:role:superAdmin")
@@ -57,4 +57,12 @@ public interface SysUserService extends BaseService<SysUserEntity> {
* @return 用户列表分页数据
*/
PageData<AdminPageUserVO> page(AdminPageUserDTO dto);
/**
* 批量修改用户状态
*
* @param status 用户状态
* @param userIds 用户ID数组
*/
void changeStatus(Integer status, Long[] userIds);
}
@@ -98,7 +98,7 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
// 删除设备
deviceService.deleteByUserId(id);
// 删除智能体
agentService.deleteById(id);
agentService.deleteAgentByUserId(id);
}
@Override
@@ -189,10 +189,20 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
*/
private String generatePassword() {
StringBuilder password = new StringBuilder();
for (int i = 0; i < 10; i++) {
int randomIndex = random.nextInt(CHARACTERS.length());
password.append(CHARACTERS.charAt(randomIndex));
for (int i = 0; i < 12; i++) {
password.append(CHARACTERS.charAt(random.nextInt(CHARACTERS.length())));
}
return password.toString();
}
@Override
@Transactional(rollbackFor = Exception.class)
public void changeStatus(Integer status, Long[] userIds) {
for (Long userId : userIds) {
SysUserEntity entity = new SysUserEntity();
entity.setId(userId);
entity.setStatus(status);
updateById(entity);
}
}
}
@@ -2,6 +2,22 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="xiaozhi.modules.model.dao.ModelConfigDao">
<resultMap id="ModelConfigResultMap" type="xiaozhi.modules.model.entity.ModelConfigEntity">
<id column="id" property="id"/>
<result column="model_type" property="modelType"/>
<result column="model_code" property="modelCode"/>
<result column="model_name" property="modelName"/>
<result column="is_default" property="isDefault"/>
<result column="is_enabled" property="isEnabled"/>
<result column="config_json" property="configJson" typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/>
<result column="doc_link" property="docLink"/>
<result column="remark" property="remark"/>
<result column="sort" property="sort"/>
<result column="updater" property="updater"/>
<result column="update_date" property="updateDate"/>
<result column="creator" property="creator"/>
<result column="create_date" property="createDate"/>
</resultMap>
<!-- 获取模型供应器字段 -->
<select id="getModelCodeList" resultType="String">
select model_name from ai_model_config where model_type = #{modelType}
+4 -1
View File
@@ -1 +1,4 @@
VUE_APP_API_BASE_URL=https://2662r3426b.vicp.fun
# 暂时使用群主的接口
VUE_APP_API_BASE_URL=https://2662r3426b.vicp.fun/xiaozhi-esp32-api
# 如果本地开发,请使用以下接口
# VUE_APP_API_BASE_URL=http://localhost:8002/xiaozhi-esp32-api
+1 -1
View File
@@ -1 +1 @@
VUE_APP_API_BASE_URL=https://2662r3426b.vicp.fun
VUE_APP_API_BASE_URL=/xiaozhi-esp32-api
-1
View File
@@ -10,4 +10,3 @@ module.exports = {
'@babel/plugin-transform-runtime'
]
}
+1 -2
View File
@@ -5,7 +5,6 @@
</template>
<style lang="scss">
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
@@ -40,10 +39,10 @@ nav {
transform: translateX(-50%);
width: 100%;
}
.el-message {
top: 45px !important;
}
</style>
<script>
</script>
+12 -8
View File
@@ -1,22 +1,22 @@
// 引入各个模块的请求
import user from './module/user.js'
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 user from './module/user.js'
/**
* 接口地址
* 当前8002端口接口还没开发完成,暂时用 apifoxmock 接口代替
* 如果你想调用8002端口,就用'/xiaozhi-esp32-api/api/v1',请与vue.config.js的devServer配置相结合,方便跨域请求
*
* 开发时自动读取使用.env.development文件
* 编译时自动读取使用.env.production文件
*/
const DEV_API_SERVICE = 'https://2662r3426b.vicp.fun/xiaozhi-esp32-api'
// 8002开发完成完成后使用这个
// const DEV_API_SERVICE = '/xiaozhi-esp32-api'
const DEV_API_SERVICE = process.env.VUE_APP_API_BASE_URL
/**
* 根据开发环境返回接口url
* @returns {string}
*/
export function getServiceUrl() {
// return '/xiaozhi-esp32-api'
return DEV_API_SERVICE
}
@@ -25,4 +25,8 @@ export function getServiceUrl() {
export default {
getServiceUrl,
user,
admin,
agent,
device,
model,
}
+3 -5
View File
@@ -1,7 +1,7 @@
import {goToPage, showDanger, showWarning, isNotNull} from '../utils/index'
import Constant from '../utils/constant'
import Fly from 'flyio/dist/npm/fly';
import store from '../store/index'
import store from '../store/index';
import Constant from '../utils/constant';
import { goToPage, isNotNull, showDanger, showWarning } from '../utils/index';
const fly = new Fly()
// 设置超时
@@ -100,7 +100,6 @@ function sendRequest() {
*/
// 在错误处理函数中添加日志
function httpHandlerError(info, callBack) {
console.log('httpHandlerError', info)
/** 请求成功,退出该函数 可以根据项目需求来判断是否请求成功。这里判断的是status为200的时候是成功 */
let networkError = false
@@ -108,7 +107,6 @@ function httpHandlerError(info, callBack) {
if (info.data.code === 'success' || info.data.code === 0 || info.data.code === undefined) {
return networkError
} else if (info.data.code === 401) {
console.log('触发 401,清除 Token 并跳转登录页');
store.commit('clearAuth');
goToPage(Constant.PAGE.LOGIN, true);
return true
+2 -2
View File
@@ -1,5 +1,5 @@
import RequestService from '../httpRequest'
import {getServiceUrl} from '../api'
import { getServiceUrl } from '../api';
import RequestService from '../httpRequest';
export default {
+2 -2
View File
@@ -1,5 +1,5 @@
import RequestService from '../httpRequest'
import {getServiceUrl} from '../api'
import { getServiceUrl } from '../api';
import RequestService from '../httpRequest';
export default {
+2 -2
View File
@@ -1,5 +1,5 @@
import RequestService from '../httpRequest'
import {getServiceUrl} from '../api'
import { getServiceUrl } from '../api';
import RequestService from '../httpRequest';
export default {
// 已绑设备
+68 -2
View File
@@ -1,5 +1,5 @@
import RequestService from '../httpRequest'
import {getServiceUrl} from '../api'
import { getServiceUrl } from '../api';
import RequestService from '../httpRequest';
export default {
@@ -26,5 +26,71 @@ export default {
})
}).send()
},
// 获取模型供应器列表
getModelProviders(modelType, callback) {
RequestService.sendRequest()
.url(`${getServiceUrl()}/api/v1/models/${modelType}/provideTypes`)
.method('GET')
.success((res) => {
RequestService.clearRequestTime()
callback(res.data?.data || [])
})
.fail((err) => {
console.error('获取供应器列表失败:', err)
this.$message.error('获取供应器列表失败')
RequestService.reAjaxFun(() => {
this.getModelProviders(modelType, callback)
})
}).send()
},
// 新增模型配置
addModel(params, callback) {
const { modelType, provideCode, formData } = params;
const postData = {
modelCode: formData.modelCode,
modelName: formData.modelName,
isDefault: formData.isDefault ? 1 : 0,
isEnabled: formData.isEnabled ? 1 : 0,
configJson: JSON.stringify(formData.configJson),
docLink: formData.docLink,
remark: formData.remark,
sort: formData.sort || 0
};
RequestService.sendRequest()
.url(`${getServiceUrl()}/api/v1/models/models/${modelType}/${provideCode}`)
.method('POST')
.data(postData)
.success((res) => {
RequestService.clearRequestTime()
callback(res)
})
.fail((err) => {
console.error('新增模型失败:', err)
this.$message.error(err.msg || '新增模型失败')
RequestService.reAjaxFun(() => {
this.addModel(params, callback)
})
}).send()
},
// 删除模型配置
deleteModel(id, callback) {
RequestService.sendRequest()
.url(`${getServiceUrl()}/api/v1/models/models/${id}`)
.method('DELETE')
.success((res) => {
RequestService.clearRequestTime()
callback(res)
})
.fail((err) => {
console.error('删除模型失败:', err)
this.$message.error(err.msg || '删除模型失败')
RequestService.reAjaxFun(() => {
this.deleteModel(id, callback)
})
}).send()
},
}
-54
View File
@@ -1,54 +0,0 @@
import RequestService from '../httpRequest'
import {getServiceUrl} from '../api'
export default {
/**
* 设备激活接口
* @param {string} code 激活码
* @param {function} callback 回调函数
*/
activateDevice(code, callback) {
RequestService.sendRequest()
.url(`${getServiceUrl()}/api/v1/ota/activation`)
.method('GET')
.query({code})
.success((res) => {
RequestService.clearRequestTime()
callback(res)
})
.fail((err) => {
console.error('设备激活失败:', err)
RequestService.reAjaxFun(() => {
this.activateDevice(code, callback)
})
}).send()
},
/**
* 检查OTA版本和设备激活状态
* @param {object} deviceInfo 设备信息对象
* @param {string} deviceId 设备唯一标识
* @param {string} clientId 客户端标识
* @param {function} callback 回调函数
*/
checkOtaVersion(deviceInfo, deviceId, clientId, callback) {
RequestService.sendRequest()
.url(`${getServiceUrl()}/api/v1/ota`)
.method('POST')
.header({
'Device-Id': deviceId,
'Client-Id': clientId
})
.data(deviceInfo)
.success((res) => {
RequestService.clearRequestTime()
callback(res)
})
.fail((err) => {
console.error('检查OTA版本失败:', err)
RequestService.reAjaxFun(() => {
this.checkOtaVersion(deviceInfo, deviceId, clientId, callback)
})
}).send()
}
}
+1 -1
View File
@@ -1,5 +1,5 @@
import RequestService from '../httpRequest'
import { getServiceUrl } from '../api'
import RequestService from '../httpRequest'
export default {
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

@@ -1,98 +0,0 @@
<template>
<el-dialog :visible.sync="visible" width="400px" center>
<div style="margin: 0 10px 10px;display: flex;align-items: center;gap: 10px;font-weight: 700;font-size: 20px;text-align: left;color: #3d4566;">
<div style="width: 40px;height: 40px;border-radius: 50%;background: #5778ff;display: flex;align-items: center;justify-content: center;">
<img src="@/assets/home/equipment.png" alt="" style="width: 18px;height: 15px;" />
</div>
激活设备
</div>
<div style="height: 1px;background: #e8f0ff;" />
<div style="margin: 22px 15px;">
<div style="font-weight: 400;font-size: 14px;text-align: left;color: #3d4566;">
<div style="color: red;display: inline-block;">*</div> 设备激活码
</div>
<div class="input-46" style="margin-top: 12px;">
<el-input placeholder="请输入设备播报的激活码.." v-model="activateCode" />
</div>
</div>
<div style="display: flex;margin: 15px 15px;gap: 7px;">
<div class="dialog-btn" @click="confirm">
确定
</div>
<div class="dialog-btn"
style="background: #e6ebff;border: 1px solid #adbdff;color: #5778ff;"
@click="cancel">
取消
</div>
</div>
</el-dialog>
</template>
<script>
import userApi from '@/apis/module/user';
export default {
name: 'ActivateDeviceDialog',
props: {
visible: { type: Boolean, required: true }
},
data() {
return { activateCode: "" }
},
methods: {
confirm() {
if (!this.activateCode.trim()) {
this.$message.error('请输入激活码');
return;
}
userApi.activateDevice(this.activateCode, (res) => {
this.$message.success('激活成功,请重新唤醒设备即可完成激活!');
this.$emit('confirm', res);
this.$emit('update:visible', false);
console.log("res: ", res)
this.activateCode = "";
});
},
cancel() {
this.$emit('update:visible', false)
this.activateCode = ""
}
}
}
</script>
<style scoped>
.input-46 {
border: 1px solid #e4e6ef;
background: #f6f8fb;
border-radius: 15px;
}
.dialog-btn {
cursor: pointer;
flex: 1;
border-radius: 23px;
background: #5778ff;
height: 40px;
font-weight: 500;
font-size: 12px;
color: #fff;
line-height: 40px;
text-align: center;
}
::v-deep .el-dialog {
border-radius: 15px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
::v-deep .el-dialog__headerbtn {
display: none;
}
::v-deep .el-dialog__body {
padding: 4px 6px;
}
::v-deep .el-dialog__header{
padding: 10px;
}
</style>
@@ -1,7 +1,9 @@
<template>
<el-dialog :visible.sync="visible" width="400px" center>
<div style="margin: 0 10px 10px;display: flex;align-items: center;gap: 10px;font-weight: 700;font-size: 20px;text-align: left;color: #3d4566;">
<div style="width: 40px;height: 40px;border-radius: 50%;background: #5778ff;display: flex;align-items: center;justify-content: center;">
<div
style="margin: 0 10px 10px;display: flex;align-items: center;gap: 10px;font-weight: 700;font-size: 20px;text-align: left;color: #3d4566;">
<div
style="width: 40px;height: 40px;border-radius: 50%;background: #5778ff;display: flex;align-items: center;justify-content: center;">
<img src="@/assets/home/equipment.png" alt="" style="width: 18px;height: 15px;" />
</div>
添加设备
@@ -20,9 +22,7 @@
<div class="dialog-btn" @click="confirm">
确定
</div>
<div class="dialog-btn"
style="background: #e6ebff;border: 1px solid #adbdff;color: #5778ff;"
@click="cancel">
<div class="dialog-btn" style="background: #e6ebff;border: 1px solid #adbdff;color: #5778ff;" @click="cancel">
取消
</div>
</div>
@@ -30,6 +30,8 @@
</template>
<script>
import Api from '@/apis/api';
export default {
name: 'AddDeviceDialog',
props: {
@@ -49,8 +51,7 @@ export default {
return;
}
this.loading = true;
import('@/apis/module/device').then(({ default: deviceApi }) => {
deviceApi.bindDevice(
Api.device.bindDevice(
this.agentId,
this.deviceCode, ({ data }) => {
this.loading = false;
@@ -69,11 +70,6 @@ export default {
}
}
);
}).catch((err) => {
this.loading = false;
console.error('API模块加载失败:', err);
this.$message.error('绑定服务不可用');
});
},
closeDialog() {
this.$emit('update:visible', false);
@@ -89,7 +85,6 @@ export default {
</script>
<style scoped>
.input-46 {
border: 1px solid #e4e6ef;
background: #f6f8fb;
@@ -113,14 +108,16 @@ export default {
border-radius: 15px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
::v-deep .el-dialog__headerbtn {
display: none;
}
::v-deep .el-dialog__body {
padding: 4px 6px;
}
::v-deep .el-dialog__header {
padding: 10px;
}
</style>
@@ -1,13 +1,6 @@
<template>
<el-dialog
:visible.sync="visible"
width="975px"
center
custom-class="custom-dialog"
:show-close="false"
class="center-dialog"
>
<el-dialog :visible.sync="visible" 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;">
添加模型
@@ -34,113 +27,62 @@
</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: 20px; margin-bottom: 0;">
<el-form-item label="模型名称" prop="modelName" style="flex: 1;">
<el-input
v-model="formData.modelName"
placeholder="请输入模型名称"
class="custom-input-bg"
></el-input>
<el-input v-model="formData.modelName" placeholder="请输入模型名称" class="custom-input-bg"></el-input>
</el-form-item>
<el-form-item label="模型编码" prop="modelCode" style="flex: 1;">
<el-input
v-model="formData.modelCode"
placeholder="请输入模型编码"
class="custom-input-bg"
></el-input>
<el-input v-model="formData.modelCode" placeholder="请输入模型编码" class="custom-input-bg"></el-input>
</el-form-item>
</div>
<!-- 第二行供应器和排序号 -->
<div style="display: flex; gap: 20px; margin-bottom: 0;">
<el-form-item label="供应器" prop="supplier" style="flex: 1;">
<el-select
v-model="formData.supplier"
placeholder="请选择"
class="custom-select custom-input-bg"
style="width: 100%;"
>
<el-option label="硅基流动" value="硅基流动"></el-option>
<el-option label="智脑科技" value="智脑科技"></el-option>
<el-option label="云智科技" value="云智科技"></el-option>
<el-option label="其他" value="其他"></el-option>
<el-select v-model="formData.supplier" 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="sortOrder" style="flex: 1;">
<el-input
v-model="formData.sort"
placeholder="请输入排序号"
class="custom-input-bg"
></el-input>
<el-input v-model="formData.sort" placeholder="请输入排序号" class="custom-input-bg"></el-input>
</el-form-item>
</div>
<!-- 文档地址 -->
<el-form-item label="文档地址" prop="docLink" style="margin-bottom: 27px;">
<el-input
v-model="formData.docLink"
placeholder="请输入文档地址"
class="custom-input-bg"
></el-input>
<el-input v-model="formData.docLink" placeholder="请输入文档地址" class="custom-input-bg"></el-input>
</el-form-item>
<!-- 备注 -->
<el-form-item label="备注" prop="remark" class="prop-remark">
<el-input
v-model="formData.remark"
type="textarea"
:rows="3"
placeholder="请输入模型备注"
class="custom-input-bg"
></el-input>
<el-input v-model="formData.remark" type="textarea" :rows="3" placeholder="请输入模型备注"
class="custom-input-bg"></el-input>
</el-form-item>
</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>
<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-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-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-input v-model="formData.configJson.apiKey" placeholder="请输入api_key" show-password
class="custom-input-bg"></el-input>
</el-form-item>
</el-form>
</div>
<!-- 保存按钮 -->
<div style="display: flex;justify-content: center;">
<el-button
type="primary"
@click="confirm"
class="save-btn"
>
<el-button type="primary" @click="confirm" class="save-btn">
保存
</el-button>
</div>
@@ -148,6 +90,7 @@
</template>
<script>
import Api from '@/apis/api';
export default {
name: 'AddModelDialog',
props: {
@@ -156,6 +99,8 @@ export default {
},
data() {
return {
providers: [],
providersLoaded: false,
formData: {
modelName: '',
modelCode: '',
@@ -174,6 +119,18 @@ export default {
}
},
methods: {
loadProviders() {
if (this.providersLoaded)
return
Api.model.getModelProviders(this.modelType, (data) => {
this.providers = data.map(item => ({
label: item.name,
value: item.providerCode
}))
this.providersLoaded = true
})
},
confirm() {
if (!this.formData.modelName || !this.formData.modelCode || !this.formData.supplier ||
!this.formData.configJson.param1 || !this.formData.configJson.param2 || !this.formData.configJson.apiKey) {
@@ -183,7 +140,8 @@ export default {
this.$emit('confirm', {
...this.formData,
provideType: this.formData.supplier
provideType: this.formData.supplier,
configJson: this.formData.configJson
});
this.$emit('update:visible', false);
this.resetForm();
@@ -204,6 +162,9 @@ export default {
apiKey: ''
}
};
// 重置加载状态
this.providers = [];
this.providersLoaded = false;
},
handleClose() {
this.resetForm();
@@ -297,7 +258,7 @@ export default {
}
.custom-form .el-form-item {
margin-bottom: 20px; /* 统一设置所有表单项的间距 */
margin-bottom: 20px;
}
.custom-form .el-form-item__label {
@@ -312,13 +273,12 @@ export default {
margin-top: -4px;
}
/* 修改placeholder颜色 */
.custom-input-bg .el-input__inner::-webkit-input-placeholder,
.custom-input-bg .el-textarea__inner::-webkit-input-placeholder {
color: #9c9f9e;
}
/* 输入框背景色 */
.custom-input-bg .el-input__inner,
.custom-input-bg .el-textarea__inner {
background-color: #f6f8fc;
@@ -342,13 +302,12 @@ export default {
}
/* 修改开关样式 */
.custom-switch .el-switch__core {
border-radius: 20px;
height: 23px;
background-color: #c0ccda;
width: 35px;
padding: 0 20px; /* 调整左右内边距 */
padding: 0 20px;
}
.custom-switch .el-switch__core:after {
@@ -363,7 +322,7 @@ export default {
.custom-switch.is-checked .el-switch__core {
border-color: #b5bcf0;
background-color: #cfd7fa;
padding: 0 20px; /* 确保启用状态也有相同的间隔 */
padding: 0 20px;
}
.custom-switch.is-checked .el-switch__core:after {
@@ -373,15 +332,11 @@ export default {
}
/* 调整flex布局的gap */
[style*="display: flex"] {
gap: 20px; /* 扩大flex项间距 */
gap: 20px;
}
/* 调整输入框高度 */
.custom-input-bg .el-input__inner {
height: 32px; /* 固定输入框高度 */
height: 32px;
}
</style>
@@ -1,7 +1,9 @@
<template>
<el-dialog :visible.sync="visible" width="400px" center @open="handleOpen">
<div style="margin: 0 10px 10px;display: flex;align-items: center;gap: 10px;font-weight: 700;font-size: 20px;text-align: left;color: #3d4566;">
<div style="width: 40px;height: 40px;border-radius: 50%;background: #5778ff;display: flex;align-items: center;justify-content: center;">
<div
style="margin: 0 10px 10px;display: flex;align-items: center;gap: 10px;font-weight: 700;font-size: 20px;text-align: left;color: #3d4566;">
<div
style="width: 40px;height: 40px;border-radius: 50%;background: #5778ff;display: flex;align-items: center;justify-content: center;">
<img loading="lazy" src="@/assets/home/equipment.png" alt="" style="width: 18px;height: 15px;" />
</div>
添加智能体
@@ -12,20 +14,14 @@
<div style="color: red;display: inline-block;">*</div> 智慧体名称
</div>
<div class="input-46" style="margin-top: 12px;">
<el-input
ref="inputRef"
placeholder="请输入智能体名称.."
v-model="wisdomBodyName"
@keyup.enter.native="confirm" />
<el-input ref="inputRef" placeholder="请输入智能体名称.." v-model="wisdomBodyName" @keyup.enter.native="confirm" />
</div>
</div>
<div style="display: flex;margin: 15px 15px;gap: 7px;">
<div class="dialog-btn" @click="confirm">
确定
</div>
<div class="dialog-btn"
style="background: #e6ebff;border: 1px solid #adbdff;color: #5778ff;"
@click="cancel">
<div class="dialog-btn" style="background: #e6ebff;border: 1px solid #adbdff;color: #5778ff;" @click="cancel">
取消
</div>
</div>
@@ -33,7 +29,7 @@
</template>
<script>
import userApi from '@/apis/module/agent';
import Api from '@/apis/api';
export default {
name: 'AddWisdomBodyDialog',
@@ -57,7 +53,7 @@ export default {
this.$message.error('请输入智能体名称');
return;
}
userApi.addAgent(this.wisdomBodyName, (res) => {
Api.agent.addAgent(this.wisdomBodyName, (res) => {
this.$message.success({
message: '添加成功',
showClose: true
@@ -94,16 +90,20 @@ export default {
line-height: 40px;
text-align: center;
}
::v-deep .el-dialog {
border-radius: 15px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
::v-deep .el-dialog__headerbtn {
display: none;
}
::v-deep .el-dialog__body {
padding: 4px 6px;
}
::v-deep .el-dialog__header {
padding: 10px;
}
+23 -22
View File
@@ -10,28 +10,29 @@
<!-- 中间导航菜单 -->
<div class="header-center">
<div class="equipment-management" :class="{ 'active-tab': $route.path === '/home' }" @click="goHome">
<img loading="lazy" alt="" src="@/assets/header/robot.png" :style="{ filter: $route.path === '/home' ? 'brightness(0) invert(1)' : 'None' }"/>
<img loading="lazy" alt="" src="@/assets/header/robot.png"
:style="{ filter: $route.path === '/home' ? 'brightness(0) invert(1)' : 'None' }" />
智能体管理
</div>
<div v-if="isSuperAdmin" class="equipment-management" :class="{ 'active-tab': $route.path === '/user-management' }" @click="goUserManagement">
<img loading="lazy" alt="" src="@/assets/header/user_management.png" :style="{ filter: $route.path === '/user-management' ? 'brightness(0) invert(1)' : 'None' }"/>
用户管理
</div>
<div v-if="isSuperAdmin" class="equipment-management" :class="{ 'active-tab': $route.path === '/model-config' }" @click="goModelConfig">
<img loading="lazy" alt="" src="@/assets/header/model_config.png" :style="{ filter: $route.path === '/model-config' ? 'brightness(0) invert(1)' : 'None' }"/>
<div v-if="isSuperAdmin" class="equipment-management" :class="{ 'active-tab': $route.path === '/model-config' }"
@click="goModelConfig">
<img loading="lazy" alt="" src="@/assets/header/model_config.png"
:style="{ filter: $route.path === '/model-config' ? 'brightness(0) invert(1)' : 'None' }" />
模型配置
</div>
<div v-if="isSuperAdmin" class="equipment-management"
:class="{ 'active-tab': $route.path === '/user-management' }" @click="goUserManagement">
<img loading="lazy" alt="" src="@/assets/header/user_management.png"
:style="{ filter: $route.path === '/user-management' ? 'brightness(0) invert(1)' : 'None' }" />
用户管理
</div>
</div>
<!-- 右侧元素 -->
<div class="header-right">
<div class="search-container">
<el-input
v-model="search"
placeholder="输入名称搜索.."
class="custom-search-input"
@keyup.enter.native="handleSearch"
>
<el-input v-model="search" placeholder="输入名称搜索.." class="custom-search-input"
@keyup.enter.native="handleSearch">
<i slot="suffix" class="el-icon-search search-icon" @click="handleSearch"></i>
</el-input>
</div>
@@ -41,9 +42,8 @@
{{ userInfo.username || '加载中...' }}<i class="el-icon-arrow-down el-icon--right"></i>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item icon="el-icon-plus" @click.native="">个人中心</el-dropdown-item>
<el-dropdown-item icon="el-icon-circle-plus" @click.native="showChangePasswordDialog">修改密码</el-dropdown-item>
<el-dropdown-item icon="el-icon-circle-plus-outline" @click.native="handleLogout">退出登录</el-dropdown-item>
<el-dropdown-item @click.native="showChangePasswordDialog">修改密码</el-dropdown-item>
<el-dropdown-item @click.native="handleLogout">退出登录</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
@@ -56,8 +56,8 @@
<script>
import userApi from '@/apis/module/user';
import ChangePasswordDialog from './ChangePasswordDialog.vue'; // 引入修改密码弹窗组件
import { mapActions, mapGetters } from 'vuex';
import ChangePasswordDialog from './ChangePasswordDialog.vue'; // 引入修改密码弹窗组件
export default {
@@ -162,7 +162,8 @@ export default {
background: #f6fcfe66;
border: 1px solid #fff;
height: 53px !important;
min-width: 900px; /* 设置最小宽度防止过度压缩 */
min-width: 900px;
/* 设置最小宽度防止过度压缩 */
overflow: hidden;
}
@@ -187,8 +188,7 @@ export default {
}
.brand-img {
width: 58px;
height: 12px;
height: 18px;
}
.header-center {
@@ -224,7 +224,8 @@ export default {
align-items: center;
transition: all 0.3s ease;
cursor: pointer;
flex-shrink: 0; /* 防止导航按钮被压缩 */
flex-shrink: 0;
/* 防止导航按钮被压缩 */
}
.equipment-management.active-tab {
@@ -247,7 +248,7 @@ export default {
.custom-search-input>>>.el-input__inner {
height: 30px;
border-radius: 15px;
background-color: #e2e5f8;
background-color: #fff;
border: 1px solid #e4e6ef;
padding-left: 15px;
font-size: 12px;
@@ -1,92 +1,104 @@
<template>
<el-dialog :visible.sync="dialogVisible" width="800px" center>
<el-form :model="form" ref="form" label-width="70px">
<el-row :gutter="20" class="form-row">
<el-col :span="12">
<el-form-item label="模型编码">
<el-input v-model="form.code" placeholder="请输入内容" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="模型名称">
<el-input v-model="form.name" placeholder="请输入内容" />
</el-form-item>
</el-col>
</el-row>
<el-dialog :visible.sync="dialogVisible" 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>
<!-- 供应商 -->
<el-row :gutter="20" class="form-row">
<el-col :span="12">
<el-form-item label="供应器">
<el-select v-model="form.supplier" placeholder="请选择">
<el-option label="openai" value="openai" />
<el-option label="dify" value="dify" />
<button class="custom-close-btn" @click="dialogVisible = false">
×
</button>
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px;">
<div style="font-size: 20px; font-weight: bold; color: #3d4566;">模型信息</div>
<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.isEnable" 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" class="custom-switch"></el-switch>
</div>
</div>
</div>
<div style="height: 2px; background: #e9e9e9; margin-bottom: 22px;"></div>
<el-form :model="form" ref="form" label-width="100px" label-position="left" class="custom-form">
<div style="display: flex; gap: 20px; margin-bottom: 0;">
<el-form-item label="模型名称" prop="name" style="flex: 1;">
<el-input v-model="form.name" placeholder="请输入模型名称" class="custom-input-bg"></el-input>
</el-form-item>
<el-form-item label="模型编码" prop="code" style="flex: 1;">
<el-input v-model="form.code" placeholder="请输入模型编码" class="custom-input-bg"></el-input>
</el-form-item>
</div>
<div style="display: flex; gap: 20px; margin-bottom: 0;">
<el-form-item label="供应器" prop="supplier" style="flex: 1;">
<el-select v-model="form.supplier" 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-col>
<el-col :span="12">
<el-form-item>
<div style="display: flex; align-items: center;">
<span class="el-form-item__label" style="width: 70px;">设成默认</span>
<el-switch v-model="form.isDefault" style="margin-right: 20px;" />
<span class="el-form-item__label" style="width: 70px;">是否启用</span>
<el-switch v-model="form.isEnable" />
</div>
</el-form-item>
</el-col>
</el-row>
<!-- 文档 -->
<el-row :gutter="20" class="form-row">
<el-col :span="12">
<el-form-item label="文档地址">
<el-input v-model="form.docUrl" placeholder="请输入内容" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="排序号">
<el-input-number v-model="form.sort" :min="1" :max="999" controls-position="right" placeholder="123"
/>
</el-form-item>
</el-col>
</el-row>
<!-- 备注 -->
<el-form-item label="备注" class="form-row">
<el-input type="textarea" v-model="form.remark" :rows="2" placeholder="请输入"
/>
</el-form-item>
<div class="vertical-fields">
<el-form-item label="接口地址">
<el-input v-model="form.apiUrl" placeholder="请输入base_url" />
</el-form-item>
<el-form-item label="模型名称">
<el-input v-model="form.modelName" placeholder="请输入model_name" />
</el-form-item>
<el-form-item label="密钥信息">
<el-input v-model="form.apiKey" placeholder="请输入api_key" show-password/>
<el-form-item label="排序号" prop="sort" style="flex: 1;">
<el-input v-model="form.sort" placeholder="请输入排序号" class="custom-input-bg"></el-input>
</el-form-item>
</div>
<el-form-item label="文档地址" prop="docUrl" style="margin-bottom: 27px;">
<el-input v-model="form.docUrl" placeholder="请输入文档地址" class="custom-input-bg"></el-input>
</el-form-item>
<el-form-item label="备注" prop="remark" class="prop-remark">
<el-input v-model="form.remark" type="textarea" :rows="3" placeholder="请输入模型备注"
class="custom-input-bg"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="handleSave">保存</el-button>
<el-button @click="dialogVisible = false">关闭</el-button>
<div style="font-size: 20px; font-weight: bold; color: #3d4566; margin-bottom: 15px;">调用信息</div>
<div style="height: 2px; background: #e9e9e9; margin-bottom: 15px;"></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.modelName" 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>
</div>
<div style="display: flex;justify-content: center;">
<el-button type="primary" @click="handleSave" class="save-btn">
保存
</el-button>
</div>
</el-dialog>
</template>
<script>
import Api from '@/apis/api';
export default {
name: "ModelConfigDialog",
props: {
visible: { type: Boolean, default: false },
configData: { type: Object, default: () => ({}) }
configData: { type: Object, default: () => ({}) },
modelType: { type: String, required: true }
},
data() {
return {
dialogVisible: this.visible,
providers: [],
providersLoaded: false,
form: {
code: "",
name: "",
@@ -103,57 +115,213 @@ export default {
};
},
watch: {
modelType() {
this.resetProviders()
},
dialogVisible(val) {
this.$emit('update:visible', val);
if (!val) {
this.form = {
code: "",
name: "",
supplier: "",
};
}
},
visible(val) {
this.dialogVisible = val;
if (val) this.form = { ...this.form, ...this.configData };
if (val) {
this.form = JSON.parse(JSON.stringify({
...this.form,
...this.configData
}));
this.resetProviders();
}
},
},
methods: {
resetProviders() {
this.providers = []
this.providersLoaded = false
},
handleSave() {
this.$emit("submit", this.form);
this.dialogVisible = false;
}
},
loadProviders() {
if (this.providersLoaded) return
Api.model.getModelProviders(this.modelType, (data) => {
this.providers = data.map(item => ({
label: item.name,
value: item.providerCode
}))
this.providersLoaded = true
})
},
}
};
</script>
<style scoped>
.dialog-footer {
margin-top: -30px;
text-align: center;
}
.el-form-item {
margin-bottom: 18px;
}
.el-input-number {
width: 100%;
}
.form-row {
margin-bottom: 12px;
.custom-dialog {
position: relative;
border-radius: 20px;
overflow: hidden;
background: white;
padding-bottom: 17px;
}
.vertical-fields {
margin-top: 8px;
.custom-dialog .el-dialog__header {
padding: 0;
border-bottom: none;
}
.dialog-footer {
margin-top: -10px;
text-align: center;
.center-dialog {
display: flex;
align-items: center;
justify-content: center;
}
.el-input-number {
.center-dialog .el-dialog {
margin: 4% 0 auto !important;
display: flex;
flex-direction: column;
}
.custom-close-btn {
position: absolute;
top: 20px;
right: 20px;
width: 35px;
height: 35px;
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;
}
.custom-close-btn:hover {
color: #409EFF;
border-color: #409EFF;
}
.custom-select .el-input__suffix {
background: #e6e8ea;
right: 6px;
width: 20px;
height: 20px;
display: flex;
justify-content: center;
align-items: center;
top: 9px;
}
.custom-select .el-input__suffix-inner {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
}
.el-input__inner {
height: 36px;
line-height: 36px;
.custom-select .el-icon-arrow-up:before {
content: "";
display: inline-block;
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-top: 7px solid #c0c4cc;
position: relative;
top: -2px;
transform: rotate(180deg);
}
.el-form-item__label {
text-align: left;
padding-right: 10px;
.custom-form .el-form-item {
margin-bottom: 20px;
}
.custom-form .el-form-item__label {
color: #3d4566;
font-weight: normal;
text-align: right;
padding-right: 20px;
}
.custom-form .el-form-item.prop-remark .el-form-item__label {
margin-top: -4px;
}
.custom-input-bg .el-input__inner::-webkit-input-placeholder,
.custom-input-bg .el-textarea__inner::-webkit-input-placeholder {
color: #9c9f9e;
}
.custom-input-bg .el-input__inner,
.custom-input-bg .el-textarea__inner {
background-color: #f6f8fc;
}
.save-btn {
background: #e6f0fd;
color: #237ff4;
border: 1px solid #b3d1ff;
width: 150px;
height: 40px;
font-size: 16px;
transition: all 0.3s ease;
}
.save-btn:hover {
background: linear-gradient(to right, #237ff4, #9c40d5);
color: white;
border: none;
}
.custom-switch .el-switch__core {
border-radius: 20px;
height: 23px;
background-color: #c0ccda;
width: 35px;
padding: 0 20px;
}
.custom-switch .el-switch__core:after {
width: 15px;
height: 15px;
background-color: white;
top: 3px;
left: 4px;
transition: all .3s;
}
.custom-switch.is-checked .el-switch__core {
border-color: #b5bcf0;
background-color: #cfd7fa;
padding: 0 20px;
}
.custom-switch.is-checked .el-switch__core:after {
left: 100%;
margin-left: -18px;
background-color: #1b47ee;
}
[style*="display: flex"] {
gap: 20px;
}
.custom-input-bg .el-input__inner {
height: 32px;
}
</style>
+6 -6
View File
@@ -1,11 +1,11 @@
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import 'normalize.css/normalize.css' // A modern alternative to CSS resets
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import './styles/global.scss'
import 'normalize.css/normalize.css'; // A modern alternative to CSS resets
import Vue from 'vue';
import App from './App.vue';
import router from './router';
import store from './store';
import './styles/global.scss';
Vue.use(ElementUI);
+3 -3
View File
@@ -1,7 +1,7 @@
import Vue from 'vue'
import Vuex from 'vuex'
import Constant from '../utils/constant'
import { goToPage } from "@/utils";
import Vue from 'vue';
import Vuex from 'vuex';
import Constant from '../utils/constant';
Vue.use(Vuex)
+1 -1
View File
@@ -1,6 +1,6 @@
import { Message } from 'element-ui'
import router from '../router'
import Constant from '../utils/constant'
import { Message } from 'element-ui'
/**
* 判断用户是否登录
+15 -29
View File
@@ -15,7 +15,8 @@
<el-table-column label="最近对话" prop="lastConversation" width="140"></el-table-column>
<el-table-column label="备注" width="180">
<template slot-scope="scope">
<el-input v-if="scope.row.isEdit" v-model="scope.row.remark" size="mini" @blur="stopEditRemark(scope.$index)"></el-input>
<el-input v-if="scope.row.isEdit" v-model="scope.row.remark" size="mini"
@blur="stopEditRemark(scope.$index)"></el-input>
<span v-else>
<i v-if="!scope.row.remark" class="el-icon-edit" @click="startEditRemark(scope.$index, scope.row)"></i>
<span v-else @click="startEditRemark(scope.$index, scope.row)">
@@ -26,7 +27,8 @@
</el-table-column>
<el-table-column label="OTA升级" width="120">
<template slot-scope="scope">
<el-switch v-model="scope.row.otaSwitch" size="mini" active-color="#13ce66" inactive-color="#ff4949"></el-switch>
<el-switch v-model="scope.row.otaSwitch" size="mini" active-color="#13ce66"
inactive-color="#ff4949"></el-switch>
</template>
</el-table-column>
<el-table-column label="操作" width="80">
@@ -37,28 +39,23 @@
</template>
</el-table-column>
</el-table>
<el-pagination
class="pagination"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="currentPage"
:page-sizes="[5, 10, 20, 50]"
:page-size="pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="deviceList.length"
></el-pagination>
<el-pagination class="pagination" @size-change="handleSizeChange" @current-change="handleCurrentChange"
:current-page="currentPage" :page-sizes="[5, 10, 20, 50]" :page-size="pageSize"
layout="total, sizes, prev, pager, next, jumper" :total="deviceList.length"></el-pagination>
</div>
<div class="copyright">
©2025 xiaozhi-esp32-server
</div>
<AddDeviceDialog :visible.sync="addDeviceDialogVisible" :agent-id="currentAgentId" @refresh="fetchBindDevices(currentAgentId)" />
<AddDeviceDialog :visible.sync="addDeviceDialogVisible" :agent-id="currentAgentId"
@refresh="fetchBindDevices(currentAgentId)" />
</el-main>
</div>
</template>
<script>
import HeaderBar from "@/components/HeaderBar.vue";
import Api from '@/apis/api';
import AddDeviceDialog from "@/components/AddDeviceDialog.vue";
import HeaderBar from "@/components/HeaderBar.vue";
export default {
components: { HeaderBar, AddDeviceDialog },
@@ -82,12 +79,9 @@ export default {
},
mounted() {
const agentId = this.$route.query.agentId;
import('@/apis/module/device').then(({ default: deviceApi }) => {
this.deviceApi = deviceApi;
if (agentId) {
this.fetchBindDevices(agentId);
}
});
},
methods: {
handleAddDevice() {
@@ -100,16 +94,12 @@ export default {
this.deviceList[index].isEdit = false;
},
handleUnbind(device_id) {
if (!this.deviceApi) {
this.$message.error('功能模块加载失败');
return;
}
this.$confirm('确认要解绑该设备吗?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.deviceApi.unbindDevice(device_id, ({ data }) => {
Api.device.unbindDevice(device_id, ({ data }) => {
if (data.code === 0) {
this.$message.success({
message: '设备解绑成功',
@@ -133,8 +123,7 @@ export default {
},
fetchBindDevices(agentId) {
this.loading = true;
import('@/apis/module/device').then(({ default: deviceApi }) => {
deviceApi.getAgentBindDevices(agentId, ({ data }) => {
Api.device.getAgentBindDevices(agentId, ({ data }) => {
this.loading = false;
if (data.code === 0) {
// 格式化日期并按照绑定时间降序排列
@@ -162,10 +151,6 @@ export default {
this.$message.error(data.msg || '获取设备列表失败');
}
});
}).catch(error => {
console.error('模块加载失败:', error);
this.$message.error('功能模块加载失败');
});
},
}
};
@@ -179,7 +164,7 @@ export default {
height: 100vh;
display: flex;
flex-direction: column;
background-image: url("@/assets/home/background.png");
background: linear-gradient(145deg, #e6eeff, #eff0ff);
background-size: cover;
background-position: center;
-webkit-background-size: cover;
@@ -207,6 +192,7 @@ export default {
font-size: 14px;
gap: 8px;
margin-bottom: 15px;
&:hover {
background: #3a8ee6;
}
+139 -52
View File
@@ -46,7 +46,7 @@
<div class="content-area">
<div class="title-bar">
<div class="title-wrapper">
<h2 class="model-title">大语言模型LLM</h2>
<h2 class="model-title">{{ modelTypeText }}</h2>
<el-button type="primary" size="small" @click="addModel" class="add-btn">
添加
</el-button>
@@ -61,14 +61,21 @@
</div>
</div>
<el-table ref="modelTable" style="width: 100%" :header-cell-style="{background: 'transparent'}" :data="modelList" class="data-table" header-row-class-name="table-header" :header-cell-class-name="headerCellClassName" @selection-change="handleSelectionChange">
<el-table ref="modelTable" style="width: 100%" :header-cell-style="{ background: 'transparent' }"
:data="modelList" class="data-table" header-row-class-name="table-header"
:header-cell-class-name="headerCellClassName" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center"></el-table-column>
<el-table-column label="模型名称" prop="candidateName" align="center"></el-table-column>
<el-table-column label="模型编码" prop="code" align="center"></el-table-column>
<el-table-column label="提供商" prop="supplier" align="center"></el-table-column>
<el-table-column label="模型名称" prop="modelName" align="center"></el-table-column>
<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 || '未知' }}
</template>
</el-table-column>
<el-table-column label="是否启用" align="center">
<template slot-scope="scope">
<el-switch v-model="scope.row.isApplied" class="custom-switch" :active-color="null" :inactive-color="null"/>
<el-switch v-model="scope.row.isEnabled" class="custom-switch" :active-value="1" :inactive-value="0"
:active-color="null" :inactive-color="null" />
</template>
</el-table-column>
<el-table-column v-if="activeTab === 'tts'" label="音色管理" align="center">
@@ -92,7 +99,9 @@
<div class="table-footer">
<div class="batch-actions">
<el-button size="mini" @click="selectAll" style="width: 75px; background: #606ff3">{{ isAllSelected ? '取消全选' : '全选' }}</el-button>
<el-button size="mini" @click="selectAll" style="width: 75px; background: #606ff3">{{ isAllSelected ?
'取消全选' : '全选'
}}</el-button>
<el-button size="mini" type="danger" icon="el-icon-delete" @click="batchDelete">
删除
</el-button>
@@ -101,7 +110,8 @@
<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)">
<button v-for="page in visiblePages" :key="page" class="pagination-btn"
:class="{ active: page === currentPage }" @click="goToPage(page)">
{{ page }}
</button>
@@ -112,7 +122,8 @@
</div>
</div>
<ModelEditDialog :visible.sync="editDialogVisible" :modelData="editModelData" @save="handleModelSave"/>
<ModelEditDialog :modelType="activeTab" :visible.sync="editDialogVisible" :modelData="editModelData"
@save="handleModelSave" />
<TtsModel :visible.sync="ttsDialogVisible" />
<AddModelDialog :modelType="activeTab" :visible.sync="addDialogVisible" @confirm="handleAddConfirm" />
</div>
@@ -124,10 +135,11 @@
</template>
<script>
import Api from "@/apis/api";
import AddModelDialog from "@/components/AddModelDialog.vue";
import HeaderBar from "@/components/HeaderBar.vue";
import ModelEditDialog from "@/components/ModelEditDialog.vue";
import TtsModel from "@/components/TtsModel.vue";
import AddModelDialog from "@/components/AddModelDialog.vue";
export default {
components: { HeaderBar, ModelEditDialog, TtsModel, AddModelDialog },
@@ -139,20 +151,34 @@ export default {
editDialogVisible: false,
editModelData: {},
ttsDialogVisible: false,
modelList: [
{ code: 'DeepSeek', candidateName: '深度求索', isApplied: true, supplier: '硅基流动' },
{ code: 'SmartAssist', candidateName: '智能助手', isApplied: false, supplier: '智脑科技' },
{ code: 'CogEngine', candidateName: '认知引擎', isApplied: true, supplier: '云智科技' },
],
modelList: [],
currentPage: 1,
pageSize: 4,
total: 20,
pageSize: 5,
total: 0,
selectedModels: [],
isAllSelected: false
};
},
created() {
this.loadData();
},
computed: {
modelTypeText() {
const map = {
vad: '语言活动检测模型(VAD)',
asr: '语音识别模型(ASR)',
llm: '大语言模型(LLM',
intent: '意图识别模型(Intent)',
tts: '语音合成模型(TTS)',
memory: '记忆模型(Memory)'
}
return map[this.activeTab] || '模型配置'
},
pageCount() {
return Math.ceil(this.total / this.pageSize);
},
@@ -182,64 +208,92 @@ export default {
},
handleMenuSelect(index) {
this.activeTab = index;
this.currentPage = 1;
this.loadData();
},
handleSearch() {
// TODO: 查询
console.log('查询:', this.search);
},
// 批量删除
batchDelete() {
if (this.selectedModels.length === 0) {
this.$message.warning('请先选择要删除的模型');
return;
this.$message.warning('请先选择要删除的模型')
return
}
this.$confirm('确定要删除选中的模型吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
const selectedIds = this.selectedModels.map(model => model.code);
this.modelList = this.modelList.filter(model => !selectedIds.includes(model.code));
this.$message.success('删除成功');
this.selectedModels = [];
this.isAllSelected = false;
const deletePromises = this.selectedModels.map(model =>
new Promise(resolve => {
// TODO: 删除获取model.id
Api.model.deleteModel(
model.id,
({ data }) => resolve(data.code === 0)
)
})
)
Promise.all(deletePromises).then(results => {
if (results.every(Boolean)) {
this.$message.success('批量删除成功')
this.loadData()
} else {
this.$message.error('部分删除失败')
}
})
}).catch(() => {
this.$message.info('已取消删除');
});
this.$message.info('已取消删除')
})
},
addModel() {
this.addDialogVisible = true;
},
editModel(model) {
this.editModelData = {
code: model.code,
name: model.candidateName,
supplier: model.supplier,
};
this.editModelData = JSON.parse(JSON.stringify(model));
this.editDialogVisible = true;
},
// 删除单个模型
deleteModel(model) {
this.$confirm(`确定要删除模型 ${model.candidateName} 吗?`, '提示', {
this.$confirm('确定要删除模型吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.modelList = this.modelList.filter(item => item.code !== model.code);
this.$message.success('删除成功');
Api.model.deleteModel(
this.activeTab,
model.configJson?.provider || '', // 从configJson获取provider
model.id,
({ data }) => {
if (data.code === 0) {
this.$message.success('删除成功')
this.loadData()
} else {
this.$message.error(data.msg || '删除失败')
}
}
)
}).catch(() => {
this.$message.info('已取消删除');
});
this.$message.info('已取消删除')
})
},
handleCurrentChange(page) {
this.currentPage = page;
this.$refs.modelTable.clearSelection();
console.log('当前页码:', page);
},
handleImport() {
// TODO: 导入配置
console.log('导入配置');
},
handleExport() {
// TODO: 导出配置
console.log('导出配置');
},
handleModelSave(formData) {
// TODO: 保存模型数据
console.log('保存的模型数据:', formData);
},
selectAll() {
@@ -256,8 +310,27 @@ export default {
this.isAllSelected = false;
}
},
// 新增模型配置
handleAddConfirm(newModel) {
console.log('新增模型数据:', newModel);
const params = {
modelType: this.activeTab,
provideCode: newModel.supplier,
formData: {
...newModel,
isDefault: newModel.isDefault ? 1 : 0,
isEnabled: newModel.isEnabled ? 1 : 0
}
};
Api.model.addModel(params, ({ data }) => {
if (data.code === 0) {
this.$message.success('新增成功');
this.loadData();
} else {
this.$message.error(data.msg || '新增失败');
}
});
},
// 分页器
@@ -281,8 +354,24 @@ export default {
this.currentPage = page;
this.loadData();
},
// 获取模型配置列表
loadData() {
console.log('加载数据,当前页:', this.currentPage);
const params = {
modelType: this.activeTab,
modelName: this.search,
page: this.currentPage,
limit: this.pageSize
};
Api.model.getModelList(params, ({ data }) => {
if (data.code === 0) {
this.modelList = data.data.list;
this.total = data.data.total;
} else {
this.$message.error(data.msg || '获取模型列表失败');
}
});
}
},
};
@@ -307,7 +396,7 @@ export default {
}
.main-wrapper {
margin: 5px 60px;
margin: 5px 20px;
border-radius: 15px;
min-height: 600px;
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
@@ -320,7 +409,6 @@ export default {
justify-content: space-between;
align-items: center;
padding: 16px 24px;
border-bottom: 1px solid #ebeef5;
}
.page-title {
@@ -341,6 +429,7 @@ export default {
height: 100%;
border-radius: 15px;
background: transparent;
border: 1px solid #fff;
}
.nav-panel {
@@ -348,12 +437,10 @@ export default {
height: 100%;
border-right: 1px solid #ebeef5;
background:
linear-gradient(
120deg,
linear-gradient(120deg,
rgba(107, 140, 255, 0.3) 0%,
rgba(169, 102, 255, 0.3) 25%,
transparent 60%
),
transparent 60%),
url("../assets/model/model.png") no-repeat center / cover;
padding: 16px 0;
flex-shrink: 0;
@@ -538,7 +625,8 @@ export default {
}
::v-deep .el-table .custom-selection-header .cell .el-checkbox__inner {
display: none !important; /* 使表头复选框不可见 */
display: none !important;
/* 使表头复选框不可见 */
}
::v-deep .el-table .custom-selection-header .cell::before {
@@ -564,6 +652,7 @@ export default {
}
::v-deep .data-table {
&.el-table::before,
&.el-table::after,
&.el-table__inner-wrapper::before {
@@ -607,7 +696,8 @@ export default {
}
.voice-management-btn:hover {
background: #8aa2e0; /* 悬停时颜色加深 */
background: #8aa2e0;
/* 悬停时颜色加深 */
transform: scale(1.05);
}
@@ -619,7 +709,8 @@ export default {
padding-right: 15px !important;
}
.edit-btn, .delete-btn {
.edit-btn,
.delete-btn {
margin: 0 8px;
color: #7079aa !important;
}
@@ -637,7 +728,6 @@ export default {
margin-top: 15px;
/* 导航按钮样式 (首页、上一页、下一页) */
.pagination-btn:first-child,
.pagination-btn:nth-child(2),
.pagination-btn:nth-last-child(2) {
@@ -663,7 +753,6 @@ export default {
}
/* 数字按钮样式 */
.pagination-btn:not(:first-child):not(:nth-child(2)):not(:nth-last-child(2)) {
min-width: 28px;
height: 32px;
@@ -697,6 +786,4 @@ export default {
margin-left: 10px;
}
}
</style>
+102 -87
View File
@@ -5,7 +5,8 @@
<div class="operation-bar">
<h2 class="page-title">用户管理</h2>
<div class="right-operations">
<el-input placeholder="请输入手机号码查询" v-model="searchPhone" class="search-input" @keyup.enter.native="handleSearch"/>
<el-input placeholder="请输入手机号码查询" v-model="searchPhone" class="search-input"
@keyup.enter.native="handleSearch" />
<el-button class="btn-search" @click="handleSearch">搜索</el-button>
</div>
</div>
@@ -14,7 +15,8 @@
<div class="content-panel">
<div class="content-area">
<el-card class="user-card" shadow="never">
<el-table ref="userTable" :data="userList" class="transparent-table" :header-cell-class-name="headerCellClassName">
<el-table ref="userTable" :data="userList" 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="用户Id" prop="userid" align="center"></el-table-column>
<el-table-column label="手机号码" prop="mobile" align="center"></el-table-column>
@@ -22,14 +24,12 @@
<el-table-column label="状态" prop="status" align="center"></el-table-column>
<el-table-column label="操作" align="center">
<template slot-scope="scope">
<el-button size="mini" type="text" @click="resetPassword(scope.row)" style="color: #989fdd">重置密码</el-button>
<el-button size="mini" type="text"
v-if="scope.row.status === '正常'"
<el-button size="mini" type="text" @click="resetPassword(scope.row)">重置密码</el-button>
<el-button size="mini" type="text" v-if="scope.row.status === '正常'"
@click="disableUser(scope.row)">禁用账户</el-button>
<el-button size="mini" type="text"
v-if="scope.row.status === '禁用'"
<el-button size="mini" type="text" v-if="scope.row.status === '禁用'"
@click="restoreUser(scope.row)">恢复账号</el-button>
<el-button size="mini" type="text" @click="deleteUser(scope.row)" style="color: #989fdd">删除用户</el-button>
<el-button size="mini" type="text" @click="deleteUser(scope.row)">删除用户</el-button>
</template>
</el-table-column>
</el-table>
@@ -38,18 +38,24 @@
<div class="ctrl_btn">
<el-button size="mini" type="primary" class="select-all-btn" @click="handleSelectAll">全选</el-button>
<el-button size="mini" type="success" icon="el-icon-circle-check" @click="batchEnable">启用</el-button>
<el-button size="mini" type="warning" @click="batchDisable"><i class="el-icon-remove-outline rotated-icon"></i>禁用</el-button>
<el-button size="mini" type="warning" @click="batchDisable"><i
class="el-icon-remove-outline rotated-icon"></i>禁用</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 class="pagination-btn" :disabled="currentPage === 1" @click="goFirst">
首页
</button>
<button class="pagination-btn" :disabled="currentPage === 1" @click="goPrev">
上一页
</button>
<button class="pagination-btn" :disabled="currentPage === pageCount" @click="goNext">下一页</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>
@@ -58,29 +64,27 @@
</div>
</div>
<div class="copyright">
©2025 xiaozhi-esp32-server
</div>
<div class="copyright">©2025 xiaozhi-esp32-server</div>
<view-password-dialog :visible.sync="showViewPassword" :password="currentPassword" />
</div>
</template>
<script>
import Api from "@/apis/api";
import HeaderBar from "@/components/HeaderBar.vue";
import adminApi from '@/apis/module/admin';
import ViewPasswordDialog from '@/components/ViewPasswordDialog.vue'
import ViewPasswordDialog from "@/components/ViewPasswordDialog.vue";
export default {
components: { HeaderBar, ViewPasswordDialog },
data() {
return {
showViewPassword: false,
currentPassword: '',
searchPhone: '',
currentPassword: "",
searchPhone: "",
userList: [],
currentPage: 1,
pageSize: 5,
total: 0
total: 0,
};
},
created() {
@@ -104,23 +108,26 @@ export default {
pages.push(i);
}
return pages;
}
},
},
methods: {
fetchUsers() {
adminApi.getUserList({
Api.admin.getUserList(
{
page: this.currentPage,
limit: this.pageSize,
mobile: this.searchPhone
}, ({ data }) => {
mobile: this.searchPhone,
},
({ data }) => {
if (data.code === 0) {
this.userList = data.data.list.map(user => ({
this.userList = data.data.list.map((user) => ({
...user,
status: user.status === '1' ? '正常' : '禁用'
status: user.status === "1" ? "正常" : "禁用",
}));
this.total = data.data.total;
}
});
}
);
},
handleSearch() {
this.currentPage = 1;
@@ -132,27 +139,28 @@ export default {
batchDelete() {
const selectedUsers = this.$refs.userTable.selection;
if (selectedUsers.length === 0) {
this.$message.warning('请先选择需要删除的用户');
this.$message.warning("请先选择需要删除的用户");
return;
}
this.$confirm(`确定要删除选中的${selectedUsers.length}个用户吗?`, '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(async () => {
this.$confirm(`确定要删除选中的${selectedUsers.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)'
text: "正在删除中...",
spinner: "el-icon-loading",
background: "rgba(0, 0, 0, 0.7)",
});
try {
const results = await Promise.all(
selectedUsers.map(user => {
selectedUsers.map((user) => {
return new Promise((resolve) => {
adminApi.deleteUser(user.userid, ({data}) => {
Api.admin.deleteUser(user.userid, ({ data }) => {
if (data.code === 0) {
resolve({ success: true, userid: user.userid });
} else {
@@ -163,7 +171,7 @@ export default {
})
);
const successCount = results.filter(r => r.success).length;
const successCount = results.filter((r) => r.success).length;
const failCount = results.length - successCount;
if (failCount === 0) {
@@ -171,79 +179,82 @@ export default {
} else if (successCount === 0) {
this.$message.error(`删除失败,请重试`);
} else {
this.$message.warning(`成功删除${successCount}个用户,${failCount}个删除失败`);
this.$message.warning(
`成功删除${successCount}个用户,${failCount}个删除失败`
);
}
this.fetchUsers();
} catch (error) {
this.$message.error('删除过程中发生错误');
this.$message.error("删除过程中发生错误");
} finally {
loading.close();
}
}).catch(() => {
this.$message.info('已取消删除');
})
.catch(() => {
this.$message.info("已取消删除");
});
},
batchEnable() {
const selectedUsers = this.$refs.userTable.selection;
if (selectedUsers.length === 0) {
this.$message.warning('请先选择需要启用的用户');
this.$message.warning("请先选择需要启用的用户");
return;
}
selectedUsers.forEach(user => {
user.status = '正常';
selectedUsers.forEach((user) => {
user.status = "正常";
});
this.$message.success('启用操作成功');
this.$message.success("启用操作成功");
},
batchDisable() {
this.userList.forEach(user => {
user.status = '禁用';
this.userList.forEach((user) => {
user.status = "禁用";
});
this.$message.success('状态已更新为禁用');
this.$message.success("状态已更新为禁用");
},
resetPassword(row) {
this.$confirm('重置后将会生成新密码,是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消'
this.$confirm("重置后将会生成新密码,是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
}).then(() => {
adminApi.resetUserPassword(row.userid, ({ data }) => {
Api.admin.resetUserPassword(row.userid, ({ data }) => {
if (data.code === 0) {
this.currentPassword = data.data
this.showViewPassword = true
this.$message.success('密码已重置,请通知用户使用新密码登录')
this.currentPassword = data.data;
this.showViewPassword = true;
this.$message.success("密码已重置,请通知用户使用新密码登录");
}
})
})
});
});
},
disableUser(row) {
row.status = '禁用';
console.log('禁用用户:', row);
row.status = "禁用";
},
restoreUser(row) {
row.status = '正常';
console.log('恢复用户:', row);
row.status = "正常";
},
deleteUser(row) {
this.$confirm('确定要删除该用户吗?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
adminApi.deleteUser(row.userid, ({data}) => {
if (data.code === 0) {
this.$message.success('删除成功')
this.fetchUsers()
} else {
this.$message.error(data.msg || '删除失败')
}
this.$confirm("确定要删除该用户吗?", "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
}).catch(() => {})
.then(() => {
Api.admin.deleteUser(row.userid, ({ data }) => {
if (data.code === 0) {
this.$message.success("删除成功");
this.fetchUsers();
} else {
this.$message.error(data.msg || "删除失败");
}
});
})
.catch(() => { });
},
headerCellClassName({ columnIndex }) {
if (columnIndex === 0) {
return 'custom-selection-header'
return "custom-selection-header";
}
return ''
return "";
},
goFirst() {
this.currentPage = 1;
@@ -265,7 +276,7 @@ export default {
this.currentPage = page;
this.fetchUsers();
},
}
},
};
</script>
@@ -297,7 +308,6 @@ export default {
justify-content: space-between;
align-items: center;
padding: 16px 24px;
border-bottom: 1px solid #ebeef5;
}
.page-title {
@@ -316,7 +326,7 @@ export default {
}
.btn-search {
background: linear-gradient(135deg, #6B8CFF, #A966FF);
background: linear-gradient(135deg, #6b8cff, #a966ff);
border: none;
color: white;
}
@@ -328,6 +338,7 @@ export default {
height: 100%;
border-radius: 15px;
background: transparent;
border: 1px solid #fff;
}
.content-area {
@@ -355,6 +366,7 @@ export default {
display: flex;
gap: 8px;
padding-left: 26px;
.el-button {
min-width: 72px;
height: 32px;
@@ -429,7 +441,7 @@ export default {
padding: 0 12px;
border-radius: 4px;
border: 1px solid #e4e7ed;
background: #DEE7FF;
background: #dee7ff;
color: #606266;
font-size: 14px;
cursor: pointer;
@@ -481,6 +493,7 @@ export default {
:deep(.transparent-table) {
background: white;
.el-table__header th {
background: white !important;
color: black;
@@ -492,6 +505,7 @@ export default {
.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);
@@ -505,7 +519,7 @@ export default {
}
&::after {
content: '选择';
content: "选择";
display: inline-block;
color: black;
font-weight: bold;
@@ -534,17 +548,18 @@ export default {
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>
+19 -24
View File
@@ -8,7 +8,7 @@
<div class="add-device">
<div class="add-device-bg">
<div class="hellow-text" style="margin-top: 30px;">
小智
小智
</div>
<div class="hellow-text">
让我们度过
@@ -31,11 +31,8 @@
</div>
</div>
<div class="device-list-container">
<DeviceItem v-for="(item,index) in devices" :key="index" :device="item"
@configure="goToRoleConfig"
@deviceManage="handleDeviceManage"
@delete="handleDeleteAgent"
/>
<DeviceItem v-for="(item, index) in devices" :key="index" :device="item" @configure="goToRoleConfig"
@deviceManage="handleDeviceManage" @delete="handleDeleteAgent" />
</div>
</div>
<div class="copyright">
@@ -48,9 +45,10 @@
</template>
<script>
import DeviceItem from '@/components/DeviceItem.vue'
import AddWisdomBodyDialog from '@/components/AddWisdomBodyDialog.vue'
import HeaderBar from '@/components/HeaderBar.vue'
import Api from '@/apis/api';
import AddWisdomBodyDialog from '@/components/AddWisdomBodyDialog.vue';
import DeviceItem from '@/components/DeviceItem.vue';
import HeaderBar from '@/components/HeaderBar.vue';
export default {
name: 'HomePage',
@@ -78,7 +76,6 @@ export default {
this.$router.push('/role-config')
},
handleWisdomBodyAdded(res) {
console.log('新增智能体响应', res);
this.fetchAgentList();
this.addDeviceDialogVisible = false;
},
@@ -111,15 +108,13 @@ export default {
},
// 获取智能体列表
fetchAgentList() {
import('@/apis/module/agent').then(({ default: userApi }) => {
userApi.getAgentList(({data}) => {
Api.agent.getAgentList(({ data }) => {
this.originalDevices = data.data.map(item => ({
...item,
agentId: item.id // 字段映射
}));
this.handleSearchReset(); // 重置搜索状态
});
});
},
// 删除智能体
handleDeleteAgent(agentId) {
@@ -128,8 +123,7 @@ export default {
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
import('@/apis/module/agent').then(({ default: userApi }) => {
userApi.deleteAgent(agentId, (res) => {
Api.agent.deleteAgent(agentId, (res) => {
if (res.data.code === 0) {
this.$message.success({
message: '删除成功',
@@ -143,7 +137,6 @@ export default {
});
}
});
});
}).catch(() => { });
}
}
@@ -157,7 +150,7 @@ export default {
height: 100vh;
display: flex;
flex-direction: column;
background-image: url("@/assets/home/background.png");
background: linear-gradient(145deg, #e6eeff, #eff0ff);
background-size: cover;
/* 确保背景图像覆盖整个元素 */
background-position: center;
@@ -167,18 +160,18 @@ export default {
-o-background-size: cover;
/* 兼容老版本Opera浏览器 */
}
.add-device {
height: 195px;
border-radius: 15px;
position: relative;
overflow: hidden;
background: linear-gradient(
269.62deg,
background: linear-gradient(269.62deg,
#e0e6fd 0%,
#cce7ff 49.69%,
#d3d3fe 100%
);
#d3d3fe 100%);
}
.add-device-bg {
width: 100%;
height: 100%;
@@ -193,6 +186,7 @@ export default {
/* 兼容老版本WebKit浏览器 */
-o-background-size: cover;
box-sizing: border-box;
/* 兼容老版本Opera浏览器 */
.hellow-text {
margin-left: 75px;
@@ -252,7 +246,8 @@ export default {
/* 在 DeviceItem.vue 的样式中 */
.device-item {
margin: 0 !important; /* 避免冲突 */
margin: 0 !important;
/* 避免冲突 */
width: auto !important;
}
@@ -262,7 +257,7 @@ export default {
margin-top: auto;
padding-top: 30px;
color: #979db1;
text-align: center; /* 居中显示 */
text-align: center;
/* 居中显示 */
}
</style>
+7 -15
View File
@@ -2,10 +2,9 @@
<div class="welcome">
<el-container style="height: 100%;">
<el-header>
<div
style="display: flex;align-items: center;margin-top: 15px;margin-left: 10px;gap: 10px;">
<div style="display: flex;align-items: center;margin-top: 15px;margin-left: 10px;gap: 10px;">
<img loading="lazy" alt="" src="@/assets/xiaozhi-logo.png" style="width: 45px;height: 45px;" />
<img loading="lazy" alt="" src="@/assets/xiaozhi-ai.png" style="width: 70px;height: 13px;"/>
<img loading="lazy" alt="" src="@/assets/xiaozhi-ai.png" style="height: 18px;" />
</div>
</el-header>
<div class="login-person">
@@ -13,8 +12,7 @@
</div>
<el-main style="position: relative;">
<div class="login-box" @keyup.enter="login">
<div
style="display: flex;align-items: center;gap: 20px;margin-bottom: 39px;padding: 0 30px;">
<div style="display: flex;align-items: center;gap: 20px;margin-bottom: 39px;padding: 0 30px;">
<img loading="lazy" alt="" src="@/assets/login/hi.png" style="width: 34px;height: 34px;" />
<div class="login-text">登录</div>
<div class="login-welcome">
@@ -35,12 +33,8 @@
<img loading="lazy" alt="" class="input-icon" src="@/assets/login/shield.png" />
<el-input v-model="form.captcha" placeholder="请输入验证码" style="flex: 1;" />
</div>
<img loading="lazy" v-if="captchaUrl"
:src="captchaUrl"
alt="验证码"
style="width: 150px; height: 40px; cursor: pointer;"
@click="fetchCaptcha"
/>
<img loading="lazy" v-if="captchaUrl" :src="captchaUrl" alt="验证码"
style="width: 150px; height: 40px; cursor: pointer;" @click="fetchCaptcha" />
</div>
<div
style="font-weight: 400;font-size: 14px;text-align: left;color: #5778ff;display: flex;justify-content: space-between;margin-top: 20px;">
@@ -66,8 +60,8 @@
</template>
<script>
import {getUUID, goToPage, showDanger, showSuccess} from '@/utils'
import Api from '@/apis/api';
import { getUUID, goToPage, showDanger, showSuccess } from '@/utils';
export default {
@@ -90,7 +84,6 @@ export default {
},
methods: {
fetchCaptcha() {
console.log(this.$store.getters.getToken)
if (this.$store.getters.getToken) {
if (this.$route.path !== '/home') {
this.$router.push('/home')
@@ -156,5 +149,4 @@ export default {
}
</script>
<style lang="scss" scoped>
@import './auth.scss'; // 添加这行引用
</style>
@import './auth.scss'; // 添加这行引用</style>
+8 -12
View File
@@ -5,10 +5,12 @@
<el-header>
<div style="display: flex;align-items: center;margin-top: 15px;margin-left: 10px;gap: 10px;">
<img loading="lazy" alt="" src="@/assets/xiaozhi-logo.png" style="width: 45px;height: 45px;" />
<img loading="lazy" alt="" src="@/assets/xiaozhi-ai.png" style="width: 70px;height: 13px;"/>
<img loading="lazy" alt="" src="@/assets/xiaozhi-ai.png" style="height: 18px;" />
</div>
</el-header>
<div class="login-person">
<img loading="lazy" alt="" src="@/assets/login/login-person.png" style="width: 100%;" />
</div>
<el-main style="position: relative;">
<div class="login-box">
<!-- 修改标题部分 -->
@@ -45,12 +47,8 @@
<img loading="lazy" alt="" class="input-icon" src="@/assets/login/shield.png" />
<el-input v-model="form.captcha" placeholder="请输入验证码" style="flex: 1;" />
</div>
<img loading="lazy" v-if="captchaUrl"
:src="captchaUrl"
alt="验证码"
style="width: 150px; height: 40px; cursor: pointer;"
@click="fetchCaptcha"
/>
<img loading="lazy" v-if="captchaUrl" :src="captchaUrl" alt="验证码"
style="width: 150px; height: 40px; cursor: pointer;" @click="fetchCaptcha" />
</div>
<!-- 修改底部链接 -->
@@ -83,8 +81,8 @@
</template>
<script>
import {getUUID, goToPage, showDanger, showSuccess} from '@/utils'
import Api from '@/apis/api';
import { getUUID, goToPage, showDanger, showSuccess } from '@/utils';
export default {
name: 'register',
@@ -147,7 +145,6 @@ export default {
}
Api.user.register(this.form, ({ data }) => {
console.log(data)
if (data.code === 0) {
showSuccess('注册成功!')
goToPage('/login')
@@ -169,5 +166,4 @@ export default {
</script>
<style lang="scss" scoped>
@import './auth.scss'; // 修改为导入新建的SCSS文件
</style>
@import './auth.scss'; // 修改为导入新建的SCSS文件</style>
+17 -23
View File
@@ -21,7 +21,8 @@
</el-form-item>
<el-form-item label="角色模版:">
<div style="display: flex;gap: 8px;">
<div v-for="template in templates" :key="template" class="template-item" :class="{ 'template-loading': loadingTemplate }" @click="selectTemplate(template)">
<div v-for="template in templates" :key="template" class="template-item"
:class="{ 'template-loading': loadingTemplate }" @click="selectTemplate(template)">
{{ template }}
</div>
</div>
@@ -30,8 +31,7 @@
<div style="display: flex;gap: 8px;align-items: center;">
<div class="input-46" style="flex:1.4;">
<el-select v-model="form.ttsVoiceId" placeholder="请选择" style="width: 100%;">
<el-option v-for="item in options" :key="item.value" :label="item.label"
:value="item.value">
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
</el-option>
</el-select>
</div>
@@ -43,14 +43,14 @@
</el-form-item>
<el-form-item label="角色介绍:">
<div class="textarea-box">
<el-input type="textarea" rows="5" resize="none" placeholder="请输入内容"
v-model="form.systemPrompt" maxlength="2000" show-word-limit/>
<el-input type="textarea" rows="5" resize="none" placeholder="请输入内容" v-model="form.systemPrompt"
maxlength="2000" show-word-limit />
</div>
</el-form-item>
<el-form-item label="记忆体:">
<div class="textarea-box">
<el-input type="textarea" rows="5" resize="none" placeholder="请输入内容"
v-model="form.langCode" maxlength="1000"/>
<el-input type="textarea" rows="5" resize="none" placeholder="请输入内容" v-model="form.langCode"
maxlength="1000" />
<div class="prompt-bottom" @click="clearMemory">
<div style="display: flex;gap: 8px;align-items: center;">
<div style="color: #979db1;font-size: 11px;">当前记忆每次对话后重新生成</div>
@@ -96,8 +96,10 @@
</template>
<script>
import Api from '@/apis/api';
import HeaderBar from "@/components/HeaderBar.vue";
export default {
name: 'RoleConfigPage',
components: { HeaderBar },
@@ -127,10 +129,10 @@ export default {
models: [
{ label: '大语言模型(LLM)', key: 'llmModelId' },
{ label: '语音识别(ASR)', key: 'asrModelId' },
{label: '语音活动检测模型(VAD)', key: 'vadModelId'},
{label: '语音合成模型(TTS)', key: 'ttsModelId'},
{label: '意图识别模型(Intent)', key: 'intentModelId'},
{label: '记忆模型(Memory)', key: 'memModelId'}
{ label: '语音活动检测(VAD)', key: 'vadModelId' },
{ label: '语音合成(TTS)', key: 'ttsModelId' },
{ label: '意图识别(Intent)', key: 'intentModelId' },
{ label: '记忆(Memory)', key: 'memModelId' }
],
templates: ['湾湾小何', '星际游子', '英语老师', '好奇男孩', '汪汪队长'],
loadingTemplate: false
@@ -153,15 +155,13 @@ export default {
language: this.form.language,
sort: this.form.sort
};
import('@/apis/module/agent').then(({default: agentApi}) => {
agentApi.updateAgentConfig(this.$route.query.agentId, configData, ({data}) => {
Api.agent.updateAgentConfig(this.$route.query.agentId, configData, ({ data }) => {
if (data.code === 0) {
this.$message.success('配置保存成功');
} else {
this.$message.error(data.msg || '配置保存失败');
}
});
});
},
resetConfig() {
this.$confirm('确定要重置配置吗?', '提示', {
@@ -194,8 +194,7 @@ export default {
selectTemplate(templateName) {
if (this.loadingTemplate) return;
this.loadingTemplate = true;
import('@/apis/module/agent').then(({default: agentApi}) => {
agentApi.getAgentTemplate((response) => { // 移除参数传递
Api.agent.getAgentTemplate((response) => { // 移除参数传递
this.loadingTemplate = false;
if (response.data.code === 0) {
// 在客户端过滤匹配的模板
@@ -211,7 +210,6 @@ export default {
} else {
this.$message.error(response.data.msg || '获取模板失败');
}
});
}).catch((error) => {
this.loadingTemplate = false;
this.$message.error('模板加载失败');
@@ -236,8 +234,7 @@ export default {
};
},
fetchAgentConfig(agentId) {
import('@/apis/module/agent').then(({default: agentApi}) => {
agentApi.getDeviceConfig(agentId, ({data}) => {
Api.agent.getDeviceConfig(agentId, ({ data }) => {
if (data.code === 0) {
this.form = {
...this.form,
@@ -255,7 +252,6 @@ export default {
this.$message.error(data.msg || '获取配置失败');
}
});
});
},
// 清空记忆体内容
clearMemory() {
@@ -265,7 +261,6 @@ export default {
},
mounted() {
const agentId = this.$route.query.agentId;
console.log('agentId2222',agentId);
if (agentId) {
this.fetchAgentConfig(agentId);
}
@@ -280,7 +275,7 @@ export default {
height: 100vh;
display: flex;
flex-direction: column;
background-image: url("@/assets/home/background.png");
background: linear-gradient(145deg, #e6eeff, #eff0ff);
background-size: cover;
/* 确保背景图像覆盖整个元素 */
background-position: center;
@@ -397,4 +392,3 @@ export default {
background: #f6f8fb;
}
</style>
+2 -3
View File
@@ -8,8 +8,7 @@
</div>
</div>
<div class="controls">
<button @click="toggleRecording" :disabled="wsStatus !== 'connected'"
:class="{ recording: isRecording }">
<button @click="toggleRecording" :disabled="wsStatus !== 'connected'" :class="{ recording: isRecording }">
{{ isRecording ? '停止录音' : '开始录音' }}
</button>
<p>WebSocket: {{ wsStatus }}</p>
@@ -18,8 +17,8 @@
</template>
<script>
import Recorder from 'opus-recorder';
import { OpusDecoder } from 'opus-decoder';
import Recorder from 'opus-recorder';
export default {
name: 'TestPage',
-7
View File
@@ -15,13 +15,6 @@ module.exports = defineConfig({
devServer: {
port: 8001, // 指定端口为 8001
proxy: {
'/xiaozhi-esp32-api': {
target: process.env.VUE_APP_API_BASE_URL, // 后端 API 的基础 URL
changeOrigin: true, // 允许跨域
pathRewrite: {
'^/xiaozhi-esp32-api': '/xiaozhi-esp32-api',
},
},
},
client: {
overlay: false, // 不显示 webpack 错误覆盖层