mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-29 05:09:46 +01:00
重构manager-web中智能体及设备管理页面
1.将原设备管理页重构为智能体页 2.设备管理及智能体配置都作为智能体下级页面配置 3.实现中发现apifox部分接口存在设计缺陷,需要获取权限后调整
This commit is contained in:
parent
bd556c33a0
commit
2dff9b3c6e
13 changed files with 762 additions and 257 deletions
|
|
@ -1,4 +1,6 @@
|
|||
// 引入各个模块的请求
|
||||
import agent from './module/agent.js'
|
||||
import device from './module/device.js'
|
||||
import user from './module/user.js'
|
||||
|
||||
/**
|
||||
|
|
@ -7,7 +9,7 @@ import user from './module/user.js'
|
|||
* 如果你想调用8002端口,就用'/xiaozhi-esp32-api/api/v1',请与vue.config.js的devServer配置相结合,方便跨域请求
|
||||
*
|
||||
*/
|
||||
const DEV_API_SERVICE = 'https://apifoxmock.com/m1/5931378-5618560-default'
|
||||
const DEV_API_SERVICE = 'https://m1.apifoxmock.com/m1/5931378-5618560-default'
|
||||
// 8002开发完成完成后使用这个
|
||||
// const DEV_API_SERVICE = '/xiaozhi-esp32-api'
|
||||
|
||||
|
|
@ -24,4 +26,6 @@ export function getServiceUrl() {
|
|||
export default {
|
||||
getServiceUrl,
|
||||
user,
|
||||
agent,
|
||||
device
|
||||
}
|
||||
|
|
|
|||
84
main/manager-web/src/apis/module/agent.js
Executable file
84
main/manager-web/src/apis/module/agent.js
Executable file
|
|
@ -0,0 +1,84 @@
|
|||
import RequestService from '../httpRequest'
|
||||
import {getServiceUrl} from '../api'
|
||||
|
||||
|
||||
export default {
|
||||
//智能体列表
|
||||
getAgentList(callback) {
|
||||
RequestService.sendRequest().url(`${getServiceUrl()}/api/v1/user/agent`)
|
||||
.method('GET')
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime()
|
||||
callback(res)
|
||||
})
|
||||
.fail((err) => {
|
||||
console.error('获取智能体列表失败:', err);
|
||||
}).send()
|
||||
},
|
||||
//添加智能体
|
||||
addAgent(name, callback) {
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/api/v1/user/agent`)
|
||||
.method('POST')
|
||||
.data({name})
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime();
|
||||
callback(res);
|
||||
})
|
||||
.fail((err) => {
|
||||
console.error('添加智能体失败:', err);
|
||||
RequestService.reAjaxFun(() => {
|
||||
this.addAgent(name, callback);
|
||||
});
|
||||
}).send();
|
||||
},
|
||||
//获取智能体配置
|
||||
getAgentConfig(agent_id, callback) {
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/api/v1/user/agent/${agent_id}`)
|
||||
.method('GET')
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime();
|
||||
callback(res);
|
||||
})
|
||||
.fail((err) => {
|
||||
console.error('获取智能体配置失败:', err);
|
||||
RequestService.reAjaxFun(() => {
|
||||
this.getAgentConfig(agent_id, callback);
|
||||
});
|
||||
}).send();
|
||||
},
|
||||
//配置智能体
|
||||
saveAgentConfig(agent_id, configData, callback) {
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/api/v1/user/agent/${agent_id}`)
|
||||
.method('PUT')
|
||||
.data(configData)
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime();
|
||||
callback(res);
|
||||
})
|
||||
.fail((err) => {
|
||||
console.error('保存智能体配置失败:', err);
|
||||
RequestService.reAjaxFun(() => {
|
||||
this.saveAgentConfig(device_id, configData, callback);
|
||||
});
|
||||
}).send();
|
||||
},
|
||||
//删除智能体
|
||||
delAgent(agent_id, callback) {
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/api/v1/user/agent/${agent_id}`)
|
||||
.method('DELETE')
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime();
|
||||
callback(res);
|
||||
})
|
||||
.fail((err) => {
|
||||
console.error('删除智能体失败:', err);
|
||||
RequestService.reAjaxFun(() => {
|
||||
this.deleteAgent(agent_id, callback);
|
||||
});
|
||||
}).send();
|
||||
},
|
||||
}
|
||||
51
main/manager-web/src/apis/module/device.js
Executable file
51
main/manager-web/src/apis/module/device.js
Executable file
|
|
@ -0,0 +1,51 @@
|
|||
import RequestService from '../httpRequest'
|
||||
import {getServiceUrl} from '../api'
|
||||
|
||||
|
||||
export default {
|
||||
//设备列表
|
||||
getDeviceList(agent_id, callback) {
|
||||
RequestService.sendRequest().url(`${getServiceUrl()}/api/v1/user/agent/device/bind/${agent_id}`)
|
||||
.method('GET')
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime()
|
||||
callback(res)
|
||||
})
|
||||
.fail((err) => {
|
||||
console.error('获取设备列表失败:', err);
|
||||
}).send()
|
||||
},
|
||||
//绑定设备
|
||||
bindDevice(agent_id, code, callback) {
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/api/v1/user/agent/device/bind/${agent_id}`)
|
||||
.method('POST')
|
||||
.data({code})
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime();
|
||||
callback(res);
|
||||
})
|
||||
.fail((err) => {
|
||||
console.error('绑定设备失败:', err);
|
||||
RequestService.reAjaxFun(() => {
|
||||
this.addDevice(name, callback);
|
||||
});
|
||||
}).send();
|
||||
},
|
||||
// 解绑设备
|
||||
unbindDevice(device_id, callback) {
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/api/v1/user/device/unbind/${device_id}`)
|
||||
.method('PUT')
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime();
|
||||
callback(res);
|
||||
})
|
||||
.fail(() => {
|
||||
RequestService.reAjaxFun(() => {
|
||||
this.unbindDevice(device_id, callback);
|
||||
});
|
||||
}).send()
|
||||
},
|
||||
|
||||
}
|
||||
|
|
@ -61,22 +61,6 @@ export default {
|
|||
});
|
||||
}).send()
|
||||
},
|
||||
// 绑定设备
|
||||
bindDevice(deviceCode, callback) {
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/api/v1/user/device/bind/${deviceCode}`)
|
||||
.method('POST')
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime();
|
||||
callback(res);
|
||||
})
|
||||
.fail((err) => {
|
||||
console.error('绑定设备失败:', err);
|
||||
RequestService.reAjaxFun(() => {
|
||||
this.bindDevice(deviceCode, callback);
|
||||
});
|
||||
}).send();
|
||||
},
|
||||
// 获取验证码
|
||||
getCaptcha(uuid, callback) {
|
||||
|
||||
|
|
|
|||
75
main/manager-web/src/components/AddAgentDialog.vue
Normal file
75
main/manager-web/src/components/AddAgentDialog.vue
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
<template>
|
||||
<el-dialog :visible.sync="visible" width="480px" center>
|
||||
<div style="margin: 0 20px 20px;display: flex;align-items: center;gap: 10px;font-weight: 700;font-size: 20px;text-align: left;color: #3d4566;">
|
||||
<div style="width: 36px;height: 36px;border-radius: 50%;background: #5778ff;display: flex;align-items: center;justify-content: center;">
|
||||
<img src="@/assets/home/equipment.png" alt="" style="width: 16px;height: 14px;" />
|
||||
</div>
|
||||
添加智能体
|
||||
</div>
|
||||
<div style="height: 1px;background: #e8f0ff;" />
|
||||
<div style="margin: 30px 20px;">
|
||||
<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: 10px;">
|
||||
<el-input placeholder="请输入智能体名称.." v-model="agentName" />
|
||||
</div>
|
||||
</div>
|
||||
<div style="display: flex;margin: 0 20px;gap: 10px;">
|
||||
<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>
|
||||
export default {
|
||||
name: 'AddAgentDialog',
|
||||
props: {
|
||||
visible: { type: Boolean, required: true }
|
||||
},
|
||||
data() {
|
||||
return { agentName: "" }
|
||||
},
|
||||
methods: {
|
||||
confirm() {
|
||||
this.$emit('update:visible', false)
|
||||
this.$emit('added', this.agentName)
|
||||
this.agentName = ""
|
||||
},
|
||||
cancel() {
|
||||
this.$emit('update:visible', false)
|
||||
this.agentName = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
|
||||
.input-46 {
|
||||
border: 1px solid #e4e6ef;
|
||||
background: #f6f8fb;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.dialog-btn {
|
||||
cursor: pointer;
|
||||
flex: 1;
|
||||
border-radius: 23px;
|
||||
background: #5778ff;
|
||||
height: 46px;
|
||||
font-weight: 500;
|
||||
font-size: 14px;
|
||||
color: #fff;
|
||||
line-height: 46px;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
77
main/manager-web/src/components/AgentItem.vue
Normal file
77
main/manager-web/src/components/AgentItem.vue
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
<template>
|
||||
<div class="agent-item">
|
||||
<div style="display: flex;justify-content: space-between;">
|
||||
<div style="font-weight: 700;font-size: 24px;text-align: left;color: #3d4566;">
|
||||
{{ agent.agentName }}
|
||||
</div>
|
||||
<div>
|
||||
<img src="@/assets/home/delete.png" alt=""
|
||||
style="width: 24px;height: 24px;" @click="$emit('del', agent.id)" />
|
||||
<!-- <img src="@/assets/home/info.png" alt="" style="width: 24px;height: 24px;margin-left: 10px;" /> -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="agent-name">
|
||||
角色音色:{{ agent.ttsModelName }}
|
||||
</div>
|
||||
<div class="agent-name">
|
||||
语言模型:{{ agent.llmModelName }}
|
||||
</div>
|
||||
<div class="agent-name">
|
||||
最近对话:{{ agent.lastConnectedAt }}
|
||||
</div>
|
||||
<div style="display: flex;gap: 10px;align-items: center;">
|
||||
<div class="settings-btn" @click="$emit('configure', agent.id, agent.agentName)">
|
||||
配置角色
|
||||
</div>
|
||||
<div class="settings-btn" @click="$emit('asr', agent.id)">
|
||||
声纹识别
|
||||
</div>
|
||||
<div class="settings-btn" @click="$emit('chat', agent.id)">
|
||||
历史对话
|
||||
</div>
|
||||
<div class="settings-btn" @click="$emit('device', agent.id)">
|
||||
设备数量({{agent.deviceCount}})
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'AgentItem',
|
||||
props: {
|
||||
agent: { type: Object, required: true }
|
||||
},
|
||||
data() {
|
||||
return { }
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
.agent-item {
|
||||
width: 455px;
|
||||
border-radius: 20px;
|
||||
background: #fafcfe;
|
||||
padding: 30px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.agent-name {
|
||||
margin: 10px 0 14px;
|
||||
font-weight: 400;
|
||||
font-size: 14px;
|
||||
color: #3d4566;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.settings-btn {
|
||||
font-weight: 500;
|
||||
font-size: 14px;
|
||||
color: #5778ff;
|
||||
background: #e6ebff;
|
||||
line-height: 28px;
|
||||
padding: 0 14px;
|
||||
cursor: pointer;
|
||||
border-radius: 14px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
|
@ -1,83 +0,0 @@
|
|||
<template>
|
||||
<div class="device-item">
|
||||
<div style="display: flex;justify-content: space-between;">
|
||||
<div style="font-weight: 700;font-size: 24px;text-align: left;color: #3d4566;">
|
||||
{{ device.mac }}
|
||||
</div>
|
||||
<div>
|
||||
<img src="@/assets/home/delete.png" alt=""
|
||||
style="width: 24px;height: 24px;margin-right: 10px;" />
|
||||
<img src="@/assets/home/info.png" alt="" style="width: 24px;height: 24px;" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="device-name">
|
||||
设备型号:{{ device.model }}
|
||||
</div>
|
||||
<div style="display: flex;gap: 10px;align-items: center;">
|
||||
<div class="settings-btn" @click="$emit('configure')">
|
||||
配置角色
|
||||
</div>
|
||||
<div class="settings-btn">
|
||||
声纹识别
|
||||
</div>
|
||||
<div class="settings-btn">
|
||||
历史对话
|
||||
</div>
|
||||
<el-switch v-model="switchValue" inactive-text="OTA升级:" :width="42"
|
||||
style="margin-left: auto;" />
|
||||
</div>
|
||||
<div class="version-info">
|
||||
<div>最近对话:{{ device.lastConversation }}</div>
|
||||
<div>APP版本:{{ device.appVersion }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'DeviceItem',
|
||||
props: {
|
||||
device: { type: Object, required: true }
|
||||
},
|
||||
data() {
|
||||
return { switchValue: false }
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
.device-item {
|
||||
width: 455px;
|
||||
border-radius: 20px;
|
||||
background: #fafcfe;
|
||||
padding: 30px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.device-name {
|
||||
margin: 10px 0 14px;
|
||||
font-weight: 400;
|
||||
font-size: 14px;
|
||||
color: #3d4566;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.settings-btn {
|
||||
font-weight: 500;
|
||||
font-size: 14px;
|
||||
color: #5778ff;
|
||||
background: #e6ebff;
|
||||
width: 76px;
|
||||
height: 28px;
|
||||
line-height: 28px;
|
||||
cursor: pointer;
|
||||
border-radius: 14px;
|
||||
}
|
||||
|
||||
.version-info {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-top: 20px;
|
||||
font-size: 14px;
|
||||
color: #979db1;
|
||||
font-weight: 400;
|
||||
}
|
||||
</style>
|
||||
30
main/manager-web/src/components/Footer.vue
Normal file
30
main/manager-web/src/components/Footer.vue
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<template>
|
||||
<div v-if="visible" class="message">
|
||||
{{message}}
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'Footer',
|
||||
props: {
|
||||
visible: { type: Boolean, required: true },
|
||||
message: { type: String, required: false, default: '©2025 xiaozhi-esp32-server' }
|
||||
},
|
||||
data() {
|
||||
return { }
|
||||
},
|
||||
methods: {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.message {
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
margin-top: auto;
|
||||
padding-top: 30px;
|
||||
color: #979db1;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -4,29 +4,35 @@
|
|||
<div style="display: flex;align-items: center;gap: 10px;">
|
||||
<img src="@/assets/xiaozhi-logo.png" alt="" style="width: 56px;height: 56px;" />
|
||||
<img src="@/assets/xiaozhi-ai.png" alt="" style="width: 78px;height: 16px;" />
|
||||
<div class="equipment-management" @click="goHome">
|
||||
<img src="@/assets/home/equipment.png" alt="" style="width: 16px;height: 14px;" />
|
||||
设备管理
|
||||
<div class="ml-20 menu-btn active" @click="goHome">
|
||||
<!-- <img src="@/assets/home/equipment.png" alt="" style="width: 16px;height: 14px;" /> -->
|
||||
智能体
|
||||
</div>
|
||||
<div class="console">
|
||||
<div class="menu-btn">
|
||||
<i class="el-icon-s-grid" style="font-size: 14px;color: #979db1;" />
|
||||
控制台
|
||||
</div>
|
||||
<div class="equipment-management2">
|
||||
<!-- <div class="menu-btn">
|
||||
设备管理
|
||||
<img src="@/assets/home/close.png" alt="" style="width: 8px;height: 8px;" />
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
<div style="display: flex;align-items: center;gap: 10px;">
|
||||
<div class="serach-box">
|
||||
<el-input placeholder="输入名称搜索.." v-model="serach" />
|
||||
<img src="@/assets/home/search.png" alt=""
|
||||
style="width: 16px;height: 16px;margin-right: 15px;cursor: pointer;" />
|
||||
style="width: 16px;height: 16px;margin:0 15px 0 10px;cursor: pointer;" />
|
||||
</div>
|
||||
<img src="@/assets/home/avatar.png" alt="" style="width: 28px;height: 28px;" />
|
||||
<div class="user-info">
|
||||
<el-dropdown>
|
||||
<span class="el-dropdown-link user-info">
|
||||
158 3632 4642
|
||||
</div>
|
||||
</span>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item>账号设置</el-dropdown-item>
|
||||
<el-dropdown-item>退出</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
</div>
|
||||
</div>
|
||||
</el-header>
|
||||
|
|
@ -41,46 +47,33 @@ export default {
|
|||
methods: {
|
||||
goHome() {
|
||||
// 跳转到首页
|
||||
this.$router.push('/')
|
||||
this.$router.push('/home')
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.equipment-management,
|
||||
.equipment-management2 {
|
||||
cursor: pointer;
|
||||
.ml-20 {
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
.equipment-management {
|
||||
.menu-btn {
|
||||
width: 110px;
|
||||
height: 32px;
|
||||
border-radius: 16px;
|
||||
background: #5778ff;
|
||||
height: 40px;
|
||||
border-radius: 8px;
|
||||
background: #fff;
|
||||
color: #979db1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 10px;
|
||||
font-weight: 500;
|
||||
color: #fff;
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.equipment-management2 {
|
||||
width: 116px;
|
||||
height: 30px;
|
||||
border-radius: 15px;
|
||||
background: #fff;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
font-size: 12px;
|
||||
color: #979db1;
|
||||
font-weight: 400;
|
||||
gap: 10px;
|
||||
color: #3d4566;
|
||||
margin-left: 20px;
|
||||
align-items: center;
|
||||
.menu-btn.active {
|
||||
background: #5778ff;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.header {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,13 @@ const routes = [
|
|||
return import('../views/login.vue')
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/device',
|
||||
name: 'RoleConfig',
|
||||
component: function () {
|
||||
return import('../views/device.vue')
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/role-config',
|
||||
name: 'RoleConfig',
|
||||
|
|
|
|||
218
main/manager-web/src/views/device.vue
Normal file
218
main/manager-web/src/views/device.vue
Normal file
|
|
@ -0,0 +1,218 @@
|
|||
<template>
|
||||
<div class="welcome">
|
||||
<!-- 公共头部 -->
|
||||
<HeaderBar />
|
||||
<el-main style="padding: 20px;display: flex;flex-direction: column;">
|
||||
<div>
|
||||
<!-- 首页内容 -->
|
||||
<div class="add-device">
|
||||
<div class="add-device-bg">
|
||||
<div class="hellow-text" style="margin-top: 30px;">
|
||||
您好,小智
|
||||
</div>
|
||||
<div class="hellow-text">
|
||||
让我们度过
|
||||
<div style="display: inline-block;color: #5778FF;">
|
||||
美好的一天!
|
||||
</div>
|
||||
</div>
|
||||
<div class="hi-hint">
|
||||
Hello, Let's have a wonderful day!
|
||||
</div>
|
||||
<div class="add-device-btn" @click="showAddDialog">
|
||||
<div class="left-add">
|
||||
添加设备
|
||||
</div>
|
||||
<div style="width: 23px;height: 13px;background: #5778ff;margin-left: -10px;" />
|
||||
<div class="right-add">
|
||||
<i class="el-icon-right" style="font-size: 30px;color: #fff;" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 面包屑-->
|
||||
<div class="breadcrumbs">
|
||||
<el-breadcrumb separator="/">
|
||||
<el-breadcrumb-item>控制台</el-breadcrumb-item>
|
||||
<el-breadcrumb-item><router-link to="/home">智能体</router-link></el-breadcrumb-item>
|
||||
<el-breadcrumb-item>设备</el-breadcrumb-item>
|
||||
</el-breadcrumb>
|
||||
</div>
|
||||
<!-- 智能体列表-->
|
||||
<div style="display: flex;flex-wrap: wrap;margin-top: 20px;">
|
||||
<el-table :data="devices" style="width: 100%">
|
||||
<el-table-column prop="device_type" label="设备型号">
|
||||
</el-table-column>
|
||||
<el-table-column prop="app_version" label="固件版本" width="180">
|
||||
</el-table-column>
|
||||
<el-table-column prop="mac_address" label="MAC地址">
|
||||
</el-table-column>
|
||||
<el-table-column prop="bind_time" label="绑定时间">
|
||||
</el-table-column>
|
||||
<el-table-column prop="recent_chat_time" label="最近对话">
|
||||
</el-table-column>
|
||||
<el-table-column prop="desc" label="备注">
|
||||
</el-table-column>
|
||||
<el-table-column label="OTA升级" width="100" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-switch v-model="scope.row.ota_upgrade" :active-value="1" :inactive-value="0" active-color="#13ce66" inactive-color="#ff4949">
|
||||
</el-switch>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="80" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" type="danger">解绑</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 底部 -->
|
||||
<Footer :visible="true" />
|
||||
<!-- 添加设备对话框 -->
|
||||
<AddDeviceDialog :visible.sync="addDeviceDialogVisible" @added="handleDeviceAdded" />
|
||||
</el-main>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {getUUID, goToPage, showDanger, showSuccess} from '@/utils'
|
||||
import Api from '@/apis/api';
|
||||
import AddDeviceDialog from '@/components/AddDeviceDialog.vue'
|
||||
import HeaderBar from '@/components/HeaderBar.vue'
|
||||
import Footer from '@/components/Footer.vue'
|
||||
export default {
|
||||
name: 'DevicePage',
|
||||
components: { AddDeviceDialog, HeaderBar, Footer },
|
||||
data() {
|
||||
return {
|
||||
addDeviceDialogVisible: false,
|
||||
devices: [],
|
||||
agentId: this.$route.query.agentId
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.getDeviceList();
|
||||
},
|
||||
methods: {
|
||||
getDeviceList() {
|
||||
Api.device.getDeviceList(this.agentId, ({data}) => {
|
||||
if (data.code === 0) {
|
||||
this.devices = data.data[0].list
|
||||
} else {
|
||||
showDanger(data.msg)
|
||||
}
|
||||
})
|
||||
},
|
||||
showAddDialog() {
|
||||
this.addDeviceDialogVisible = true
|
||||
},
|
||||
goToRoleConfig() {
|
||||
// 点击配置角色后跳转到角色配置页
|
||||
this.$router.push('/role-config')
|
||||
},
|
||||
handleDeviceAdded(deviceCode) {
|
||||
// 根据需要处理添加设备后逻辑,比如刷新设备列表等
|
||||
console.log('设备验证码:', deviceCode)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.breadcrumbs{
|
||||
padding: 20px 0 0 5px;
|
||||
}
|
||||
|
||||
.welcome {
|
||||
min-width: 1200px;
|
||||
min-height: 675px;
|
||||
height: 100vh;
|
||||
background-image: url("@/assets/home/background.png");
|
||||
background-size: cover;
|
||||
/* 确保背景图像覆盖整个元素 */
|
||||
background-position: center;
|
||||
/* 从顶部中心对齐 */
|
||||
-webkit-background-size: cover;
|
||||
/* 兼容老版本WebKit浏览器 */
|
||||
-o-background-size: cover;
|
||||
/* 兼容老版本Opera浏览器 */
|
||||
}
|
||||
.add-device {
|
||||
height: 260px;
|
||||
border-radius: 20px;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
background: linear-gradient(
|
||||
269.62deg,
|
||||
#e0e6fd 0%,
|
||||
#cce7ff 49.69%,
|
||||
#d3d3fe 100%
|
||||
);
|
||||
}
|
||||
.add-device-bg {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
text-align: left;
|
||||
background-image: url("@/assets/home/main-top-bg.png");
|
||||
overflow: hidden;
|
||||
background-size: cover;
|
||||
/* 确保背景图像覆盖整个元素 */
|
||||
background-position: center;
|
||||
/* 从顶部中心对齐 */
|
||||
-webkit-background-size: cover;
|
||||
/* 兼容老版本WebKit浏览器 */
|
||||
-o-background-size: cover;
|
||||
box-sizing: border-box;
|
||||
/* 兼容老版本Opera浏览器 */
|
||||
.hellow-text {
|
||||
margin-left: 100px;
|
||||
color: #3d4566;
|
||||
font-size: 44px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0;
|
||||
}
|
||||
|
||||
.hi-hint {
|
||||
font-weight: 400;
|
||||
font-size: 12px;
|
||||
text-align: left;
|
||||
color: #818cae;
|
||||
margin-left: 100px;
|
||||
margin-top: 7px;
|
||||
}
|
||||
}
|
||||
|
||||
.add-device-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-left: 100px;
|
||||
margin-top: 20px;
|
||||
cursor: pointer;
|
||||
width: 200px;
|
||||
|
||||
.left-add {
|
||||
width: 140px;
|
||||
height: 46px;
|
||||
border-radius: 23px;
|
||||
background: #5778ff;
|
||||
color: #fff;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
text-align: center;
|
||||
line-height: 46px;
|
||||
}
|
||||
|
||||
.right-add {
|
||||
width: 46px;
|
||||
height: 46px;
|
||||
border-radius: 50%;
|
||||
background: #5778ff;
|
||||
margin-left: -8px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
@ -5,8 +5,8 @@
|
|||
<el-main style="padding: 20px;display: flex;flex-direction: column;">
|
||||
<div>
|
||||
<!-- 首页内容 -->
|
||||
<div class="add-device">
|
||||
<div class="add-device-bg">
|
||||
<div class="add-agent">
|
||||
<div class="add-agent-bg">
|
||||
<div class="hellow-text" style="margin-top: 30px;">
|
||||
您好,小智
|
||||
</div>
|
||||
|
|
@ -19,9 +19,9 @@
|
|||
<div class="hi-hint">
|
||||
Hello, Let's have a wonderful day!
|
||||
</div>
|
||||
<div class="add-device-btn" @click="showAddDialog">
|
||||
<div class="add-agent-btn" @click="showAddDialog">
|
||||
<div class="left-add">
|
||||
添加设备
|
||||
添加智能体
|
||||
</div>
|
||||
<div style="width: 23px;height: 13px;background: #5778ff;margin-left: -10px;" />
|
||||
<div class="right-add">
|
||||
|
|
@ -30,56 +30,101 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="display: flex;flex-wrap: wrap;margin-top: 20px;gap: 20px;justify-content: space-between;box-sizing: border-box;">
|
||||
<DeviceItem v-for="(item,index) in devices" :key="index" :device="item" @configure="goToRoleConfig" />
|
||||
<!-- 面包屑-->
|
||||
<div class="breadcrumbs">
|
||||
<el-breadcrumb separator="/">
|
||||
<el-breadcrumb-item>控制台</el-breadcrumb-item>
|
||||
<el-breadcrumb-item>智能体</el-breadcrumb-item>
|
||||
</el-breadcrumb>
|
||||
</div>
|
||||
<!-- 智能体列表-->
|
||||
<div style="display: flex;flex-wrap: wrap;margin-top: 20px;gap: 20px; max-height: 800px; overflow-y: auto;">
|
||||
<AgentItem v-for="(item,index) in agents" :key="index" :agent="item" @configure="goToRoleConfig" @device="goToDevice" @del="handleAgentDel" />
|
||||
</div>
|
||||
</div>
|
||||
<div style="font-size: 12px;font-weight: 400;margin-top: auto;padding-top: 30px;color: #979db1;">
|
||||
©2025 xiaozhi-esp32-server
|
||||
</div>
|
||||
<AddDeviceDialog :visible.sync="addDeviceDialogVisible" @added="handleDeviceAdded" />
|
||||
<!-- 底部 -->
|
||||
<Footer :visible="true" />
|
||||
<!-- 添加设备对话框 -->
|
||||
<AddAgentDialog :visible.sync="addAgentDialogVisible" @added="handleAgentAdded" />
|
||||
</el-main>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import DeviceItem from '@/components/DeviceItem.vue'
|
||||
import AddDeviceDialog from '@/components/AddDeviceDialog.vue'
|
||||
import {getUUID, goToPage, showDanger, showSuccess} from '@/utils'
|
||||
import Api from '@/apis/api';
|
||||
import AgentItem from '@/components/AgentItem.vue'
|
||||
import AddAgentDialog from '@/components/AddAgentDialog.vue'
|
||||
import HeaderBar from '@/components/HeaderBar.vue'
|
||||
import Footer from '@/components/Footer.vue'
|
||||
export default {
|
||||
name: 'HomePage',
|
||||
components: { DeviceItem, AddDeviceDialog, HeaderBar },
|
||||
components: { AgentItem, AddAgentDialog, HeaderBar, Footer },
|
||||
data() {
|
||||
return {
|
||||
addDeviceDialogVisible: false,
|
||||
// 此处模拟设备列表(10条数据)
|
||||
devices: Array.from({ length: 10 }, (_, i) => ({
|
||||
id: i,
|
||||
mac: 'CC:ba:97:11:a6:ac',
|
||||
model: 'esp32-s3-touch-amoled-1.8',
|
||||
lastConversation: '6天前',
|
||||
appVersion: '1.1.0'
|
||||
}))
|
||||
addAgentDialogVisible: false,
|
||||
agents: [],
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
// 获取智能体列表
|
||||
this.getAgentList();
|
||||
},
|
||||
methods: {
|
||||
getAgentList() {
|
||||
// 获取智能体列表
|
||||
Api.agent.getAgentList(({data}) => {
|
||||
if (data.code === 0) {
|
||||
this.agents = data.data
|
||||
} else {
|
||||
showDanger(data.msg)
|
||||
}
|
||||
})
|
||||
},
|
||||
showAddDialog() {
|
||||
this.addDeviceDialogVisible = true
|
||||
this.addAgentDialogVisible = true
|
||||
},
|
||||
goToRoleConfig() {
|
||||
goToRoleConfig(agentId, agentName) {
|
||||
// 点击配置角色后跳转到角色配置页
|
||||
this.$router.push('/role-config')
|
||||
this.$router.push({path:'/role-config', query: {agentId: agentId, agentName: agentName}})
|
||||
},
|
||||
handleDeviceAdded(deviceCode) {
|
||||
// 根据需要处理添加设备后逻辑,比如刷新设备列表等
|
||||
console.log('设备验证码:', deviceCode)
|
||||
|
||||
goToDevice(agentId) {
|
||||
// 点击设备后跳转到设备页
|
||||
this.$router.push({path:'/device', query: {agentId: agentId}})
|
||||
},
|
||||
handleAgentAdded(agentName) {
|
||||
// 添加智能体
|
||||
Api.agent.addAgent(agentName, ({data}) => {
|
||||
if (data.status === 200) {
|
||||
showSuccess('添加成功')
|
||||
this.getAgentList()
|
||||
} else {
|
||||
showDanger(data.msg)
|
||||
}
|
||||
})
|
||||
},
|
||||
handleAgentDel(agetnId){
|
||||
// 删除智能体
|
||||
Api.agent.delAgent(agetnId, (data) => {
|
||||
if (data.status === 200) {
|
||||
showSuccess('删除成功')
|
||||
this.getAgentList()
|
||||
} else {
|
||||
showDanger(data.msg)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.breadcrumbs{
|
||||
padding: 20px 0 0 5px;
|
||||
}
|
||||
|
||||
.welcome {
|
||||
min-width: 1200px;
|
||||
min-height: 675px;
|
||||
|
|
@ -94,7 +139,7 @@ export default {
|
|||
-o-background-size: cover;
|
||||
/* 兼容老版本Opera浏览器 */
|
||||
}
|
||||
.add-device {
|
||||
.add-agent {
|
||||
height: 260px;
|
||||
border-radius: 20px;
|
||||
position: relative;
|
||||
|
|
@ -106,7 +151,7 @@ export default {
|
|||
#d3d3fe 100%
|
||||
);
|
||||
}
|
||||
.add-device-bg {
|
||||
.add-agent-bg {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
text-align: left;
|
||||
|
|
@ -139,12 +184,13 @@ export default {
|
|||
}
|
||||
}
|
||||
|
||||
.add-device-btn {
|
||||
.add-agent-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-left: 100px;
|
||||
margin-top: 20px;
|
||||
cursor: pointer;
|
||||
width: 200px;
|
||||
|
||||
.left-add {
|
||||
width: 140px;
|
||||
|
|
|
|||
|
|
@ -2,24 +2,28 @@
|
|||
<div class="welcome">
|
||||
<!-- 公共头部 -->
|
||||
<HeaderBar/>
|
||||
<el-main style="padding: 20px;display: flex;flex-direction: column;">
|
||||
<div style="border-radius: 20px;background: #fafcfe;">
|
||||
<!-- 面包屑-->
|
||||
<div class="breadcrumbs" style="padding: 20px;">
|
||||
<el-breadcrumb separator="/">
|
||||
<el-breadcrumb-item>控制台</el-breadcrumb-item>
|
||||
<el-breadcrumb-item><router-link to="/home">智能体</router-link></el-breadcrumb-item>
|
||||
<el-breadcrumb-item>配置智能体</el-breadcrumb-item>
|
||||
</el-breadcrumb>
|
||||
</div>
|
||||
<el-main style="padding: 20px;display: flex;justify-content: center;">
|
||||
<div style="border-radius: 20px;background: #fafcfe; max-width: 1200px;">
|
||||
<div
|
||||
style="padding: 19px 30px;font-weight: 700;font-size: 24px;text-align: left;color: #3d4566;display: flex;gap: 16px;align-items: center;">
|
||||
<div
|
||||
style="width: 46px;height: 46px;background: #5778ff;border-radius: 50%;display: flex;align-items: center;justify-content: center;">
|
||||
<img src="@/assets/home/setting-user.png" alt="" style="width: 24px;height: 24px;"/>
|
||||
</div>
|
||||
{{ deviceMac }}
|
||||
{{ agentName }} ({{ agentId }})
|
||||
</div>
|
||||
<div style="height: 1px;background: #e8f0ff;"/>
|
||||
<el-form ref="form" :model="form" label-width="90px">
|
||||
<div style="padding: 20px 30px;max-width: 990px;">
|
||||
<el-form-item label="助手昵称:">
|
||||
<div class="input-46">
|
||||
<el-input v-model="form.name"/>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<div style="max-height: 800px;overflow-y: auto;">
|
||||
<el-form ref="form" :model="form" label-width="120px">
|
||||
<div style="padding: 20px 30px;">
|
||||
<el-form-item label="角色模版:">
|
||||
<div style="display: flex;gap: 10px;">
|
||||
<div class="template-item">
|
||||
|
|
@ -39,6 +43,11 @@
|
|||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="助手昵称:">
|
||||
<div class="input-46">
|
||||
<el-input v-model="form.nickName"/>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="角色音色:">
|
||||
<div style="display: flex;gap: 10px;align-items: center;">
|
||||
<div class="input-46" style="flex:1.4;">
|
||||
|
|
@ -76,7 +85,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="语言模型(内测):" class="lh-form-item">
|
||||
<el-form-item label="语言模型(内测):" class="lh-form-item">
|
||||
<div style="display: flex;gap: 10px;">
|
||||
<div class="input-46" style="width: 100%;">
|
||||
<el-select v-model="form.model" placeholder="请选择" style="width: 100%;">
|
||||
|
|
@ -94,7 +103,8 @@
|
|||
</el-form-item>
|
||||
</div>
|
||||
</el-form>
|
||||
<div style="display: flex;padding: 20px;gap: 10px;align-items: center;">
|
||||
</div>
|
||||
<div style="display: flex;padding: 20px;gap: 10px;align-items: center;justify-content: center;">
|
||||
<div class="save-btn" @click="saveConfig">
|
||||
保存配置
|
||||
</div>
|
||||
|
|
@ -107,22 +117,22 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="font-size: 12px;font-weight: 400;margin-top: auto;padding-top: 30px;color: #979db1;">
|
||||
©2025 xiaozhi-esp32-server
|
||||
</div>
|
||||
</el-main>
|
||||
<Footer :visible="true" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import HeaderBar from "@/components/HeaderBar.vue";
|
||||
import Footer from "@/components/Footer.vue";
|
||||
|
||||
export default {
|
||||
name: 'RoleConfigPage',
|
||||
components: {HeaderBar},
|
||||
components: {HeaderBar,Footer},
|
||||
data() {
|
||||
return {
|
||||
deviceMac: 'CC:ba:97:11:a6:ac',
|
||||
agentId: this.$route.query.agentId,
|
||||
agentName: this.$route.query.agentName,
|
||||
form: {
|
||||
name: "",
|
||||
timbre: "",
|
||||
|
|
@ -140,6 +150,11 @@ export default {
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
handleGetConfig(){
|
||||
api.agent.getAgentConfig(this.agentId, ({data}) => {
|
||||
this.form = data
|
||||
})
|
||||
},
|
||||
saveConfig() {
|
||||
// 此处写保存配置逻辑
|
||||
this.$message.success('配置已保存')
|
||||
|
|
@ -167,6 +182,10 @@ export default {
|
|||
</script>
|
||||
|
||||
<style scoped>
|
||||
.breadcrumbs{
|
||||
padding: 20px 0 0 5px;
|
||||
}
|
||||
|
||||
.welcome {
|
||||
min-width: 1200px;
|
||||
min-height: 675px;
|
||||
|
|
@ -185,7 +204,7 @@ export default {
|
|||
flex: 1;
|
||||
height: 46px;
|
||||
border-radius: 10px;
|
||||
border: 1px solid #e4e6ef;
|
||||
/* border: 1px solid #e4e6ef; */
|
||||
}
|
||||
|
||||
.clear-btn {
|
||||
|
|
@ -209,15 +228,15 @@ export default {
|
|||
}
|
||||
|
||||
.template-item {
|
||||
height: 46px;
|
||||
width: 100px;
|
||||
padding: 0 20px;
|
||||
border-radius: 10px;
|
||||
background: #e6ebff;
|
||||
line-height: 46px;
|
||||
line-height: 42px;
|
||||
font-weight: 400;
|
||||
font-size: 14px;
|
||||
text-align: center;
|
||||
color: #5778ff;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.prompt-bottom {
|
||||
|
|
|
|||
Loading…
Reference in a new issue