mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-27 01:23:55 +08:00
增加“角色配置”页面返回按钮,智能体管理骨架屏加载显示
This commit is contained in:
@@ -31,8 +31,30 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="device-list-container">
|
<div class="device-list-container">
|
||||||
<DeviceItem v-for="(item, index) in devices" :key="index" :device="item" @configure="goToRoleConfig"
|
<template v-if="isLoading">
|
||||||
@deviceManage="handleDeviceManage" @delete="handleDeleteAgent" />
|
<div
|
||||||
|
v-for="i in skeletonCount"
|
||||||
|
:key="'skeleton-'+i"
|
||||||
|
class="skeleton-item"
|
||||||
|
>
|
||||||
|
<div class="skeleton-image"></div>
|
||||||
|
<div class="skeleton-content">
|
||||||
|
<div class="skeleton-line"></div>
|
||||||
|
<div class="skeleton-line-short"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template v-else>
|
||||||
|
<DeviceItem
|
||||||
|
v-for="(item, index) in devices"
|
||||||
|
:key="index"
|
||||||
|
:device="item"
|
||||||
|
@configure="goToRoleConfig"
|
||||||
|
@deviceManage="handleDeviceManage"
|
||||||
|
@delete="handleDeleteAgent"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<AddWisdomBodyDialog :visible.sync="addDeviceDialogVisible" @confirm="handleWisdomBodyAdded" />
|
<AddWisdomBodyDialog :visible.sync="addDeviceDialogVisible" @confirm="handleWisdomBodyAdded" />
|
||||||
@@ -60,7 +82,9 @@ export default {
|
|||||||
devices: [],
|
devices: [],
|
||||||
originalDevices: [],
|
originalDevices: [],
|
||||||
isSearching: false,
|
isSearching: false,
|
||||||
searchRegex: null
|
searchRegex: null,
|
||||||
|
isLoading: true,
|
||||||
|
skeletonCount: localStorage.getItem('skeletonCount') || 8,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -109,12 +133,26 @@ export default {
|
|||||||
},
|
},
|
||||||
// 获取智能体列表
|
// 获取智能体列表
|
||||||
fetchAgentList() {
|
fetchAgentList() {
|
||||||
|
this.isLoading = true;
|
||||||
Api.agent.getAgentList(({ data }) => {
|
Api.agent.getAgentList(({ data }) => {
|
||||||
this.originalDevices = data.data.map(item => ({
|
if (data?.data) {
|
||||||
...item,
|
this.originalDevices = data.data.map(item => ({
|
||||||
agentId: item.id // 字段映射
|
...item,
|
||||||
}));
|
agentId: item.id
|
||||||
this.handleSearchReset(); // 重置搜索状态
|
}));
|
||||||
|
|
||||||
|
// 动态设置骨架屏数量(可选)
|
||||||
|
this.skeletonCount = Math.min(
|
||||||
|
Math.max(this.originalDevices.length, 3), // 最少3个
|
||||||
|
10 // 最多10个
|
||||||
|
);
|
||||||
|
|
||||||
|
this.handleSearchReset();
|
||||||
|
}
|
||||||
|
this.isLoading = false;
|
||||||
|
}, (error) => {
|
||||||
|
console.error('Failed to fetch agent list:', error);
|
||||||
|
this.isLoading = false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 删除智能体
|
// 删除智能体
|
||||||
@@ -262,6 +300,66 @@ export default {
|
|||||||
/* 居中显示 */
|
/* 居中显示 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 骨架屏动画 */
|
||||||
|
@keyframes shimmer {
|
||||||
|
100% { transform: translateX(100%); }
|
||||||
|
}
|
||||||
|
|
||||||
|
.skeleton-item {
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 20px;
|
||||||
|
height: 120px;
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.skeleton-image {
|
||||||
|
width: 80px;
|
||||||
|
height: 80px;
|
||||||
|
background: #f0f2f5;
|
||||||
|
border-radius: 4px;
|
||||||
|
float: left;
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.skeleton-content {
|
||||||
|
margin-left: 100px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.skeleton-line {
|
||||||
|
height: 16px;
|
||||||
|
background: #f0f2f5;
|
||||||
|
border-radius: 4px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
width: 70%;
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.skeleton-line-short {
|
||||||
|
height: 12px;
|
||||||
|
background: #f0f2f5;
|
||||||
|
border-radius: 4px;
|
||||||
|
width: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.skeleton-item::after {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 50%;
|
||||||
|
height: 100%;
|
||||||
|
background: linear-gradient(
|
||||||
|
90deg,
|
||||||
|
rgba(255,255,255,0),
|
||||||
|
rgba(255,255,255,0.3),
|
||||||
|
rgba(255,255,255,0)
|
||||||
|
);
|
||||||
|
animation: shimmer 1.5s infinite;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
@@ -15,6 +15,9 @@
|
|||||||
<img loading="lazy" src="@/assets/home/setting-user.png" alt="">
|
<img loading="lazy" src="@/assets/home/setting-user.png" alt="">
|
||||||
</div>
|
</div>
|
||||||
<span class="header-title">{{ form.agentName }}</span>
|
<span class="header-title">{{ form.agentName }}</span>
|
||||||
|
<button class="custom-close-btn" @click="goToHome">
|
||||||
|
×
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="divider"></div>
|
<div class="divider"></div>
|
||||||
|
|
||||||
@@ -165,6 +168,9 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
goToHome() {
|
||||||
|
this.$router.push('/home');
|
||||||
|
},
|
||||||
saveConfig() {
|
saveConfig() {
|
||||||
const configData = {
|
const configData = {
|
||||||
agentCode: this.form.agentCode,
|
agentCode: this.form.agentCode,
|
||||||
@@ -423,6 +429,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.config-header {
|
.config-header {
|
||||||
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 13px;
|
gap: 13px;
|
||||||
@@ -560,8 +567,35 @@ export default {
|
|||||||
background: none;
|
background: none;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
bottom: -10px;
|
bottom: -10%;
|
||||||
right: 21px;
|
right: 3%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom-close-btn {
|
||||||
|
position: absolute;
|
||||||
|
top: 25%;
|
||||||
|
right: 0;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
Reference in New Issue
Block a user