update:设置接口读取方式

This commit is contained in:
hrz
2025-04-05 20:16:02 +08:00
parent 52187daafa
commit d255edfd5f
8 changed files with 90 additions and 105 deletions
+49 -50
View File
@@ -1,55 +1,52 @@
<template>
<div class="welcome">
<!-- 公共头部 -->
<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;">
小智
<!-- 公共头部 -->
<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;">
美好的一天
</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 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: 20px;color: #fff;" />
</div>
<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;" />
</div>
</div>
</div>
<div class="device-list-container">
<DeviceItem v-for="(item,index) in devices" :key="index" :device="item"
@configure="goToRoleConfig"
@deviceManage="handleDeviceManage"
@delete="handleDeleteAgent"
/>
</div>
</div>
<div class="copyright">
©2025 xiaozhi-esp32-server
<div class="device-list-container">
<DeviceItem v-for="(item, index) in devices" :key="index" :device="item" @configure="goToRoleConfig"
@deviceManage="handleDeviceManage" @delete="handleDeleteAgent" />
</div>
<AddWisdomBodyDialog :visible.sync="addDeviceDialogVisible" @confirm="handleWisdomBodyAdded" />
</el-main>
</div>
<div class="copyright">
©2025 xiaozhi-esp32-server
</div>
<AddWisdomBodyDialog :visible.sync="addDeviceDialogVisible" @confirm="handleWisdomBodyAdded" />
</el-main>
</div>
</template>
<script>
import DeviceItem from '@/components/DeviceItem.vue'
import AddWisdomBodyDialog from '@/components/AddWisdomBodyDialog.vue'
import DeviceItem from '@/components/DeviceItem.vue'
import HeaderBar from '@/components/HeaderBar.vue'
export default {
@@ -112,7 +109,7 @@ export default {
// 获取智能体列表
fetchAgentList() {
import('@/apis/module/agent').then(({ default: userApi }) => {
userApi.getAgentList(({data}) => {
userApi.getAgentList(({ data }) => {
this.originalDevices = data.data.map(item => ({
...item,
agentId: item.id // 字段映射
@@ -132,19 +129,19 @@ export default {
userApi.deleteAgent(agentId, (res) => {
if (res.data.code === 0) {
this.$message.success({
message: '删除成功',
showClose: true
message: '删除成功',
showClose: true
});
this.fetchAgentList(); // 刷新列表
} else {
this.$message.error({
message: res.data.msg || '删除失败',
showClose: true
message: res.data.msg || '删除失败',
showClose: true
});
}
});
});
}).catch(() => {});
}).catch(() => { });
}
}
}
@@ -167,18 +164,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 +190,7 @@ export default {
/* 兼容老版本WebKit浏览器 */
-o-background-size: cover;
box-sizing: border-box;
/* 兼容老版本Opera浏览器 */
.hellow-text {
margin-left: 75px;
@@ -252,7 +250,8 @@ export default {
/* 在 DeviceItem.vue 的样式中 */
.device-item {
margin: 0 !important; /* 避免冲突 */
margin: 0 !important;
/* 避免冲突 */
width: auto !important;
}
@@ -262,7 +261,7 @@ export default {
margin-top: auto;
padding-top: 30px;
color: #979db1;
text-align: center; /* 居中显示 */
text-align: center;
/* 居中显示 */
}
</style>