2025-03-05 23:13:24 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class="welcome">
|
2025-04-05 20:16:02 +08:00
|
|
|
|
<!-- 公共头部 -->
|
|
|
|
|
|
<HeaderBar :devices="devices" @search="handleSearch" @search-reset="handleSearchReset" />
|
|
|
|
|
|
<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;">
|
|
|
|
|
|
美好的一天!
|
2025-03-14 23:48:59 +08:00
|
|
|
|
</div>
|
2025-04-05 20:16:02 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="hi-hint">
|
|
|
|
|
|
Hello, Let's have a wonderful day!
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="add-device-btn" @click="showAddDialog">
|
|
|
|
|
|
<div class="left-add">
|
|
|
|
|
|
添加智能体
|
2025-03-05 23:13:24 +08:00
|
|
|
|
</div>
|
2025-04-05 20:16:02 +08:00
|
|
|
|
<div style="width: 23px;height: 13px;background: #5778ff;margin-left: -10px;" />
|
|
|
|
|
|
<div class="right-add">
|
|
|
|
|
|
<i class="el-icon-right" style="font-size: 20px;color: #fff;" />
|
2025-03-05 23:13:24 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2025-04-05 20:16:02 +08:00
|
|
|
|
<div class="device-list-container">
|
|
|
|
|
|
<DeviceItem v-for="(item, index) in devices" :key="index" :device="item" @configure="goToRoleConfig"
|
|
|
|
|
|
@deviceManage="handleDeviceManage" @delete="handleDeleteAgent" />
|
2025-03-07 21:19:41 +08:00
|
|
|
|
</div>
|
2025-04-05 20:16:02 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="copyright">
|
|
|
|
|
|
©2025 xiaozhi-esp32-server
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<AddWisdomBodyDialog :visible.sync="addDeviceDialogVisible" @confirm="handleWisdomBodyAdded" />
|
|
|
|
|
|
</el-main>
|
2025-03-05 23:13:24 +08:00
|
|
|
|
</div>
|
2025-03-14 23:48:59 +08:00
|
|
|
|
|
2025-03-05 23:13:24 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2025-04-05 21:03:46 +08:00
|
|
|
|
import Api from '@/apis/api';
|
|
|
|
|
|
import AddWisdomBodyDialog from '@/components/AddWisdomBodyDialog.vue';
|
|
|
|
|
|
import DeviceItem from '@/components/DeviceItem.vue';
|
|
|
|
|
|
import HeaderBar from '@/components/HeaderBar.vue';
|
2025-03-19 18:13:03 +08:00
|
|
|
|
|
2025-03-05 23:13:24 +08:00
|
|
|
|
export default {
|
2025-03-14 23:48:59 +08:00
|
|
|
|
name: 'HomePage',
|
2025-03-18 21:49:57 +08:00
|
|
|
|
components: { DeviceItem, AddWisdomBodyDialog, HeaderBar },
|
2025-03-05 23:13:24 +08:00
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
|
|
|
|
|
addDeviceDialogVisible: false,
|
2025-03-19 18:13:03 +08:00
|
|
|
|
devices: [],
|
|
|
|
|
|
originalDevices: [],
|
2025-04-03 17:07:13 +08:00
|
|
|
|
isSearching: false,
|
|
|
|
|
|
searchRegex: null
|
2025-03-14 23:48:59 +08:00
|
|
|
|
}
|
2025-03-05 23:13:24 +08:00
|
|
|
|
},
|
2025-03-19 18:13:03 +08:00
|
|
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
|
|
this.fetchAgentList();
|
|
|
|
|
|
},
|
|
|
|
|
|
|
2025-03-05 23:13:24 +08:00
|
|
|
|
methods: {
|
|
|
|
|
|
showAddDialog() {
|
2025-03-14 23:48:59 +08:00
|
|
|
|
this.addDeviceDialogVisible = true
|
2025-03-05 23:13:24 +08:00
|
|
|
|
},
|
2025-03-14 23:48:59 +08:00
|
|
|
|
goToRoleConfig() {
|
|
|
|
|
|
// 点击配置角色后跳转到角色配置页
|
|
|
|
|
|
this.$router.push('/role-config')
|
2025-03-07 21:19:41 +08:00
|
|
|
|
},
|
2025-03-19 18:13:03 +08:00
|
|
|
|
handleWisdomBodyAdded(res) {
|
|
|
|
|
|
this.fetchAgentList();
|
|
|
|
|
|
this.addDeviceDialogVisible = false;
|
2025-03-18 21:49:57 +08:00
|
|
|
|
},
|
|
|
|
|
|
handleDeviceManage() {
|
|
|
|
|
|
this.$router.push('/device-management');
|
|
|
|
|
|
},
|
2025-04-03 17:07:13 +08:00
|
|
|
|
handleSearch(regex) {
|
|
|
|
|
|
this.isSearching = true;
|
|
|
|
|
|
this.searchRegex = regex;
|
|
|
|
|
|
this.applySearchFilter();
|
|
|
|
|
|
},
|
|
|
|
|
|
handleSearchReset() {
|
|
|
|
|
|
this.isSearching = false;
|
|
|
|
|
|
this.searchRegex = null;
|
|
|
|
|
|
this.devices = [...this.originalDevices];
|
|
|
|
|
|
},
|
|
|
|
|
|
applySearchFilter() {
|
|
|
|
|
|
if (!this.isSearching || !this.searchRegex) {
|
|
|
|
|
|
this.devices = [...this.originalDevices];
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.devices = this.originalDevices.filter(device => {
|
|
|
|
|
|
return this.searchRegex.test(device.agentName);
|
2025-03-19 18:13:03 +08:00
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
// 搜索更新智能体列表
|
|
|
|
|
|
handleSearchResult(filteredList) {
|
|
|
|
|
|
this.devices = filteredList; // 更新设备列表
|
2025-03-24 09:16:48 +08:00
|
|
|
|
},
|
2025-04-03 17:07:13 +08:00
|
|
|
|
// 获取智能体列表
|
|
|
|
|
|
fetchAgentList() {
|
2025-04-05 21:03:46 +08:00
|
|
|
|
Api.agent.getAgentList(({ data }) => {
|
|
|
|
|
|
this.originalDevices = data.data.map(item => ({
|
|
|
|
|
|
...item,
|
|
|
|
|
|
agentId: item.id // 字段映射
|
|
|
|
|
|
}));
|
|
|
|
|
|
this.handleSearchReset(); // 重置搜索状态
|
2025-04-03 17:07:13 +08:00
|
|
|
|
});
|
|
|
|
|
|
},
|
2025-03-24 09:16:48 +08:00
|
|
|
|
// 删除智能体
|
|
|
|
|
|
handleDeleteAgent(agentId) {
|
|
|
|
|
|
this.$confirm('确定要删除该智能体吗?', '提示', {
|
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
|
cancelButtonText: '取消',
|
|
|
|
|
|
type: 'warning'
|
|
|
|
|
|
}).then(() => {
|
2025-04-05 21:03:46 +08:00
|
|
|
|
Api.agent.deleteAgent(agentId, (res) => {
|
|
|
|
|
|
if (res.data.code === 0) {
|
|
|
|
|
|
this.$message.success({
|
|
|
|
|
|
message: '删除成功',
|
|
|
|
|
|
showClose: true
|
|
|
|
|
|
});
|
|
|
|
|
|
this.fetchAgentList(); // 刷新列表
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error({
|
|
|
|
|
|
message: res.data.msg || '删除失败',
|
|
|
|
|
|
showClose: true
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2025-03-24 09:16:48 +08:00
|
|
|
|
});
|
2025-04-05 20:16:02 +08:00
|
|
|
|
}).catch(() => { });
|
2025-03-19 18:13:03 +08:00
|
|
|
|
}
|
2025-03-05 23:13:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
2025-03-07 21:19:41 +08:00
|
|
|
|
|
2025-03-14 23:48:59 +08:00
|
|
|
|
<style scoped>
|
2025-03-05 23:13:24 +08:00
|
|
|
|
.welcome {
|
2025-03-18 21:49:57 +08:00
|
|
|
|
min-width: 900px;
|
|
|
|
|
|
min-height: 506px;
|
2025-03-05 23:13:24 +08:00
|
|
|
|
height: 100vh;
|
2025-03-18 21:49:57 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
2025-04-05 21:55:50 +08:00
|
|
|
|
background: linear-gradient(145deg, #e6eeff, #eff0ff);
|
2025-03-05 23:13:24 +08:00
|
|
|
|
background-size: cover;
|
|
|
|
|
|
/* 确保背景图像覆盖整个元素 */
|
|
|
|
|
|
background-position: center;
|
|
|
|
|
|
/* 从顶部中心对齐 */
|
|
|
|
|
|
-webkit-background-size: cover;
|
|
|
|
|
|
/* 兼容老版本WebKit浏览器 */
|
|
|
|
|
|
-o-background-size: cover;
|
|
|
|
|
|
/* 兼容老版本Opera浏览器 */
|
|
|
|
|
|
}
|
2025-04-05 20:16:02 +08:00
|
|
|
|
|
2025-03-05 23:13:24 +08:00
|
|
|
|
.add-device {
|
2025-03-18 21:49:57 +08:00
|
|
|
|
height: 195px;
|
|
|
|
|
|
border-radius: 15px;
|
2025-03-05 23:13:24 +08:00
|
|
|
|
position: relative;
|
|
|
|
|
|
overflow: hidden;
|
2025-04-05 20:16:02 +08:00
|
|
|
|
background: linear-gradient(269.62deg,
|
2025-03-14 23:48:59 +08:00
|
|
|
|
#e0e6fd 0%,
|
|
|
|
|
|
#cce7ff 49.69%,
|
2025-04-05 20:16:02 +08:00
|
|
|
|
#d3d3fe 100%);
|
2025-03-05 23:13:24 +08:00
|
|
|
|
}
|
2025-04-05 20:16:02 +08:00
|
|
|
|
|
2025-03-05 23:13:24 +08:00
|
|
|
|
.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;
|
2025-04-05 20:16:02 +08:00
|
|
|
|
|
2025-03-05 23:13:24 +08:00
|
|
|
|
/* 兼容老版本Opera浏览器 */
|
|
|
|
|
|
.hellow-text {
|
2025-03-18 21:49:57 +08:00
|
|
|
|
margin-left: 75px;
|
2025-03-05 23:13:24 +08:00
|
|
|
|
color: #3d4566;
|
2025-03-18 21:49:57 +08:00
|
|
|
|
font-size: 33px;
|
2025-03-05 23:13:24 +08:00
|
|
|
|
font-weight: 700;
|
|
|
|
|
|
letter-spacing: 0;
|
|
|
|
|
|
}
|
2025-03-14 23:48:59 +08:00
|
|
|
|
|
2025-03-05 23:13:24 +08:00
|
|
|
|
.hi-hint {
|
|
|
|
|
|
font-weight: 400;
|
2025-03-18 21:49:57 +08:00
|
|
|
|
font-size: 10px;
|
2025-03-05 23:13:24 +08:00
|
|
|
|
text-align: left;
|
|
|
|
|
|
color: #818cae;
|
2025-03-18 21:49:57 +08:00
|
|
|
|
margin-left: 75px;
|
|
|
|
|
|
margin-top: 5px;
|
2025-03-05 23:13:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-03-14 23:48:59 +08:00
|
|
|
|
|
2025-03-05 23:13:24 +08:00
|
|
|
|
.add-device-btn {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
2025-03-18 21:49:57 +08:00
|
|
|
|
margin-left: 75px;
|
|
|
|
|
|
margin-top: 15px;
|
2025-03-05 23:13:24 +08:00
|
|
|
|
cursor: pointer;
|
2025-03-14 23:48:59 +08:00
|
|
|
|
|
2025-03-05 23:13:24 +08:00
|
|
|
|
.left-add {
|
2025-03-18 21:49:57 +08:00
|
|
|
|
width: 105px;
|
|
|
|
|
|
height: 34px;
|
|
|
|
|
|
border-radius: 17px;
|
2025-03-05 23:13:24 +08:00
|
|
|
|
background: #5778ff;
|
|
|
|
|
|
color: #fff;
|
2025-03-18 21:49:57 +08:00
|
|
|
|
font-size: 10px;
|
2025-03-05 23:13:24 +08:00
|
|
|
|
font-weight: 500;
|
|
|
|
|
|
text-align: center;
|
2025-03-18 21:49:57 +08:00
|
|
|
|
line-height: 34px;
|
2025-03-05 23:13:24 +08:00
|
|
|
|
}
|
2025-03-14 23:48:59 +08:00
|
|
|
|
|
2025-03-05 23:13:24 +08:00
|
|
|
|
.right-add {
|
2025-03-18 21:49:57 +08:00
|
|
|
|
width: 34px;
|
|
|
|
|
|
height: 34px;
|
2025-03-05 23:13:24 +08:00
|
|
|
|
border-radius: 50%;
|
|
|
|
|
|
background: #5778ff;
|
2025-03-18 21:49:57 +08:00
|
|
|
|
margin-left: -6px;
|
2025-03-05 23:13:24 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-04-03 17:07:13 +08:00
|
|
|
|
|
|
|
|
|
|
.device-list-container {
|
|
|
|
|
|
display: grid;
|
|
|
|
|
|
grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
|
|
|
|
|
|
gap: 30px;
|
|
|
|
|
|
padding: 30px 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 在 DeviceItem.vue 的样式中 */
|
|
|
|
|
|
.device-item {
|
2025-04-05 20:16:02 +08:00
|
|
|
|
margin: 0 !important;
|
|
|
|
|
|
/* 避免冲突 */
|
2025-04-03 17:07:13 +08:00
|
|
|
|
width: auto !important;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.footer {
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
font-weight: 400;
|
|
|
|
|
|
margin-top: auto;
|
|
|
|
|
|
padding-top: 30px;
|
|
|
|
|
|
color: #979db1;
|
2025-04-05 20:16:02 +08:00
|
|
|
|
text-align: center;
|
|
|
|
|
|
/* 居中显示 */
|
2025-04-03 17:07:13 +08:00
|
|
|
|
}
|
2025-03-14 23:48:59 +08:00
|
|
|
|
</style>
|