mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-22 23:23:55 +08:00
update:统一接口读取方式
This commit is contained in:
@@ -53,6 +53,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Api from '@/apis/api';
|
||||
import AddDeviceDialog from "@/components/AddDeviceDialog.vue";
|
||||
import HeaderBar from "@/components/HeaderBar.vue";
|
||||
|
||||
@@ -78,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);
|
||||
}
|
||||
});
|
||||
if (agentId) {
|
||||
this.fetchBindDevices(agentId);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleAddDevice() {
|
||||
@@ -105,7 +103,7 @@ export default {
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.deviceApi.unbindDevice(device_id, ({ data }) => {
|
||||
Api.device.unbindDevice(device_id, ({ data }) => {
|
||||
if (data.code === 0) {
|
||||
this.$message.success({
|
||||
message: '设备解绑成功',
|
||||
@@ -129,38 +127,33 @@ export default {
|
||||
},
|
||||
fetchBindDevices(agentId) {
|
||||
this.loading = true;
|
||||
import('@/apis/module/device').then(({ default: deviceApi }) => {
|
||||
deviceApi.getAgentBindDevices(agentId, ({ data }) => {
|
||||
this.loading = false;
|
||||
if (data.code === 0) {
|
||||
// 格式化日期并按照绑定时间降序排列
|
||||
this.deviceList = data.data.map(device => {
|
||||
// 格式化绑定时间
|
||||
const bindDate = new Date(device.createDate);
|
||||
const formattedBindTime = `${bindDate.getFullYear()}-${(bindDate.getMonth() + 1).toString().padStart(2, '0')}-${bindDate.getDate().toString().padStart(2, '0')} ${bindDate.getHours().toString().padStart(2, '0')}:${bindDate.getMinutes().toString().padStart(2, '0')}:${bindDate.getSeconds().toString().padStart(2, '0')}`;
|
||||
return {
|
||||
device_id: device.id,
|
||||
model: device.board,
|
||||
firmwareVersion: device.appVersion,
|
||||
macAddress: device.macAddress,
|
||||
bindTime: formattedBindTime, // 使用格式化后的时间
|
||||
lastConversation: device.lastConnectedAt,
|
||||
remark: device.alias,
|
||||
isEdit: false,
|
||||
otaSwitch: device.autoUpdate === 1,
|
||||
// 添加原始时间用于排序
|
||||
rawBindTime: new Date(device.createDate).getTime()
|
||||
};
|
||||
})
|
||||
// 按照绑定时间降序排序
|
||||
.sort((a, b) => a.rawBindTime - b.rawBindTime);
|
||||
} else {
|
||||
this.$message.error(data.msg || '获取设备列表失败');
|
||||
}
|
||||
});
|
||||
}).catch(error => {
|
||||
console.error('模块加载失败:', error);
|
||||
this.$message.error('功能模块加载失败');
|
||||
Api.device.getAgentBindDevices(agentId, ({ data }) => {
|
||||
this.loading = false;
|
||||
if (data.code === 0) {
|
||||
// 格式化日期并按照绑定时间降序排列
|
||||
this.deviceList = data.data.map(device => {
|
||||
// 格式化绑定时间
|
||||
const bindDate = new Date(device.createDate);
|
||||
const formattedBindTime = `${bindDate.getFullYear()}-${(bindDate.getMonth() + 1).toString().padStart(2, '0')}-${bindDate.getDate().toString().padStart(2, '0')} ${bindDate.getHours().toString().padStart(2, '0')}:${bindDate.getMinutes().toString().padStart(2, '0')}:${bindDate.getSeconds().toString().padStart(2, '0')}`;
|
||||
return {
|
||||
device_id: device.id,
|
||||
model: device.board,
|
||||
firmwareVersion: device.appVersion,
|
||||
macAddress: device.macAddress,
|
||||
bindTime: formattedBindTime, // 使用格式化后的时间
|
||||
lastConversation: device.lastConnectedAt,
|
||||
remark: device.alias,
|
||||
isEdit: false,
|
||||
otaSwitch: device.autoUpdate === 1,
|
||||
// 添加原始时间用于排序
|
||||
rawBindTime: new Date(device.createDate).getTime()
|
||||
};
|
||||
})
|
||||
// 按照绑定时间降序排序
|
||||
.sort((a, b) => a.rawBindTime - b.rawBindTime);
|
||||
} else {
|
||||
this.$message.error(data.msg || '获取设备列表失败');
|
||||
}
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@
|
||||
<div class="batch-actions">
|
||||
<el-button size="mini" @click="selectAll" style="width: 75px; background: #606ff3">{{ isAllSelected ?
|
||||
'取消全选' : '全选'
|
||||
}}</el-button>
|
||||
}}</el-button>
|
||||
<el-button size="mini" type="danger" icon="el-icon-delete" @click="batchDelete">
|
||||
删除
|
||||
</el-button>
|
||||
@@ -135,7 +135,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ModelApi from "@/apis/module/model";
|
||||
import Api from "@/apis/api";
|
||||
import AddModelDialog from "@/components/AddModelDialog.vue";
|
||||
import HeaderBar from "@/components/HeaderBar.vue";
|
||||
import ModelEditDialog from "@/components/ModelEditDialog.vue";
|
||||
@@ -212,6 +212,7 @@ export default {
|
||||
this.loadData();
|
||||
},
|
||||
handleSearch() {
|
||||
// TODO: 查询
|
||||
console.log('查询:', this.search);
|
||||
},
|
||||
// 批量删除
|
||||
@@ -228,7 +229,7 @@ export default {
|
||||
}).then(() => {
|
||||
const deletePromises = this.selectedModels.map(model =>
|
||||
new Promise(resolve => {
|
||||
ModelApi.deleteModel(
|
||||
Api.model.deleteModel(
|
||||
this.activeTab,
|
||||
model.configJson?.provider || '',
|
||||
model.id,
|
||||
@@ -263,7 +264,7 @@ export default {
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
ModelApi.deleteModel(
|
||||
Api.model.deleteModel(
|
||||
this.activeTab,
|
||||
model.configJson?.provider || '', // 从configJson获取provider
|
||||
model.id,
|
||||
@@ -283,15 +284,17 @@ export default {
|
||||
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() {
|
||||
@@ -321,7 +324,7 @@ export default {
|
||||
}
|
||||
};
|
||||
|
||||
ModelApi.addModel(params, ({ data }) => {
|
||||
Api.model.addModel(params, ({ data }) => {
|
||||
if (data.code === 0) {
|
||||
this.$message.success('新增成功');
|
||||
this.loadData();
|
||||
@@ -362,7 +365,7 @@ export default {
|
||||
limit: this.pageSize
|
||||
};
|
||||
|
||||
ModelApi.getModelList(params, ({ data }) => {
|
||||
Api.model.getModelList(params, ({ data }) => {
|
||||
if (data.code === 0) {
|
||||
this.modelList = data.data.list;
|
||||
this.total = data.data.total;
|
||||
|
||||
@@ -45,15 +45,20 @@
|
||||
<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 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>getUserList <button class="pagination-btn" :disabled="currentPage === pageCount"
|
||||
@click="goNext">
|
||||
下一页
|
||||
</button>
|
||||
|
||||
<button class="pagination-btn" :disabled="currentPage === pageCount" @click="goNext">下一页</button>
|
||||
<span class="total-text">共{{ total }}条记录</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -62,29 +67,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 adminApi from '@/apis/module/admin';
|
||||
import Api from "@/apis/api";
|
||||
import HeaderBar from "@/components/HeaderBar.vue";
|
||||
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() {
|
||||
@@ -108,23 +111,26 @@ export default {
|
||||
pages.push(i);
|
||||
}
|
||||
return pages;
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
fetchUsers() {
|
||||
adminApi.getUserList({
|
||||
page: this.currentPage,
|
||||
limit: this.pageSize,
|
||||
mobile: this.searchPhone
|
||||
}, ({ data }) => {
|
||||
if (data.code === 0) {
|
||||
this.userList = data.data.list.map(user => ({
|
||||
...user,
|
||||
status: user.status === '1' ? '正常' : '禁用'
|
||||
}));
|
||||
this.total = data.data.total;
|
||||
Api.admin.getUserList(
|
||||
{
|
||||
page: this.currentPage,
|
||||
limit: this.pageSize,
|
||||
mobile: this.searchPhone,
|
||||
},
|
||||
({ data }) => {
|
||||
if (data.code === 0) {
|
||||
this.userList = data.data.list.map((user) => ({
|
||||
...user,
|
||||
status: user.status === "1" ? "正常" : "禁用",
|
||||
}));
|
||||
this.total = data.data.total;
|
||||
}
|
||||
}
|
||||
});
|
||||
);
|
||||
},
|
||||
handleSearch() {
|
||||
this.currentPage = 1;
|
||||
@@ -136,118 +142,122 @@ 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 () => {
|
||||
const loading = this.$loading({
|
||||
lock: true,
|
||||
text: '正在删除中...',
|
||||
spinner: 'el-icon-loading',
|
||||
background: 'rgba(0, 0, 0, 0.7)'
|
||||
});
|
||||
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)",
|
||||
});
|
||||
|
||||
try {
|
||||
const results = await Promise.all(
|
||||
selectedUsers.map(user => {
|
||||
return new Promise((resolve) => {
|
||||
adminApi.deleteUser(user.userid, ({ data }) => {
|
||||
if (data.code === 0) {
|
||||
resolve({ success: true, userid: user.userid });
|
||||
} else {
|
||||
resolve({ success: false, userid: user.userid, msg: data.msg });
|
||||
}
|
||||
try {
|
||||
const results = await Promise.all(
|
||||
selectedUsers.map((user) => {
|
||||
return new Promise((resolve) => {
|
||||
Api.admin.deleteUser(user.userid, ({ data }) => {
|
||||
if (data.code === 0) {
|
||||
resolve({ success: true, userid: user.userid });
|
||||
} else {
|
||||
resolve({ success: false, userid: user.userid, msg: data.msg });
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
})
|
||||
);
|
||||
})
|
||||
);
|
||||
|
||||
const successCount = results.filter(r => r.success).length;
|
||||
const failCount = results.length - successCount;
|
||||
const successCount = results.filter((r) => r.success).length;
|
||||
const failCount = results.length - successCount;
|
||||
|
||||
if (failCount === 0) {
|
||||
this.$message.success(`成功删除${successCount}个用户`);
|
||||
} else if (successCount === 0) {
|
||||
this.$message.error(`删除失败,请重试`);
|
||||
} else {
|
||||
this.$message.warning(`成功删除${successCount}个用户,${failCount}个删除失败`);
|
||||
if (failCount === 0) {
|
||||
this.$message.success(`成功删除${successCount}个用户`);
|
||||
} else if (successCount === 0) {
|
||||
this.$message.error(`删除失败,请重试`);
|
||||
} else {
|
||||
this.$message.warning(
|
||||
`成功删除${successCount}个用户,${failCount}个删除失败`
|
||||
);
|
||||
}
|
||||
|
||||
this.fetchUsers();
|
||||
} catch (error) {
|
||||
this.$message.error("删除过程中发生错误");
|
||||
} finally {
|
||||
loading.close();
|
||||
}
|
||||
|
||||
this.fetchUsers();
|
||||
} catch (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",
|
||||
})
|
||||
.then(() => {
|
||||
Api.admin.deleteUser(row.userid, ({ data }) => {
|
||||
if (data.code === 0) {
|
||||
this.$message.success("删除成功");
|
||||
this.fetchUsers();
|
||||
} else {
|
||||
this.$message.error(data.msg || "删除失败");
|
||||
}
|
||||
});
|
||||
})
|
||||
}).catch(() => { })
|
||||
.catch(() => { });
|
||||
},
|
||||
headerCellClassName({ columnIndex }) {
|
||||
if (columnIndex === 0) {
|
||||
return 'custom-selection-header'
|
||||
return "custom-selection-header";
|
||||
}
|
||||
return ''
|
||||
return "";
|
||||
},
|
||||
goFirst() {
|
||||
this.currentPage = 1;
|
||||
@@ -269,7 +279,7 @@ export default {
|
||||
this.currentPage = page;
|
||||
this.fetchUsers();
|
||||
},
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -320,7 +330,7 @@ export default {
|
||||
}
|
||||
|
||||
.btn-search {
|
||||
background: linear-gradient(135deg, #6B8CFF, #A966FF);
|
||||
background: linear-gradient(135deg, #6b8cff, #a966ff);
|
||||
border: none;
|
||||
color: white;
|
||||
}
|
||||
@@ -434,7 +444,7 @@ export default {
|
||||
padding: 0 12px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #e4e7ed;
|
||||
background: #DEE7FF;
|
||||
background: #dee7ff;
|
||||
color: #606266;
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
@@ -512,7 +522,7 @@ export default {
|
||||
}
|
||||
|
||||
&::after {
|
||||
content: '选择';
|
||||
content: "选择";
|
||||
display: inline-block;
|
||||
color: black;
|
||||
font-weight: bold;
|
||||
@@ -555,4 +565,4 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -45,9 +45,10 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import AddWisdomBodyDialog from '@/components/AddWisdomBodyDialog.vue'
|
||||
import DeviceItem from '@/components/DeviceItem.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',
|
||||
@@ -75,7 +76,6 @@ export default {
|
||||
this.$router.push('/role-config')
|
||||
},
|
||||
handleWisdomBodyAdded(res) {
|
||||
console.log('新增智能体响应:', res);
|
||||
this.fetchAgentList();
|
||||
this.addDeviceDialogVisible = false;
|
||||
},
|
||||
@@ -108,14 +108,12 @@ export default {
|
||||
},
|
||||
// 获取智能体列表
|
||||
fetchAgentList() {
|
||||
import('@/apis/module/agent').then(({ default: userApi }) => {
|
||||
userApi.getAgentList(({ data }) => {
|
||||
this.originalDevices = data.data.map(item => ({
|
||||
...item,
|
||||
agentId: item.id // 字段映射
|
||||
}));
|
||||
this.handleSearchReset(); // 重置搜索状态
|
||||
});
|
||||
Api.agent.getAgentList(({ data }) => {
|
||||
this.originalDevices = data.data.map(item => ({
|
||||
...item,
|
||||
agentId: item.id // 字段映射
|
||||
}));
|
||||
this.handleSearchReset(); // 重置搜索状态
|
||||
});
|
||||
},
|
||||
// 删除智能体
|
||||
@@ -125,21 +123,19 @@ export default {
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
import('@/apis/module/agent').then(({ default: userApi }) => {
|
||||
userApi.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
|
||||
});
|
||||
}
|
||||
});
|
||||
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
|
||||
});
|
||||
}
|
||||
});
|
||||
}).catch(() => { });
|
||||
}
|
||||
|
||||
@@ -84,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')
|
||||
|
||||
@@ -143,7 +143,6 @@ export default {
|
||||
}
|
||||
|
||||
Api.user.register(this.form, ({ data }) => {
|
||||
console.log(data)
|
||||
if (data.code === 0) {
|
||||
showSuccess('注册成功!')
|
||||
goToPage('/login')
|
||||
|
||||
@@ -96,8 +96,10 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Api from '@/apis/api';
|
||||
import HeaderBar from "@/components/HeaderBar.vue";
|
||||
|
||||
|
||||
export default {
|
||||
name: 'RoleConfigPage',
|
||||
components: { HeaderBar },
|
||||
@@ -153,14 +155,12 @@ 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 }) => {
|
||||
if (data.code === 0) {
|
||||
this.$message.success('配置保存成功');
|
||||
} else {
|
||||
this.$message.error(data.msg || '配置保存失败');
|
||||
}
|
||||
});
|
||||
Api.agent.updateAgentConfig(this.$route.query.agentId, configData, ({ data }) => {
|
||||
if (data.code === 0) {
|
||||
this.$message.success('配置保存成功');
|
||||
} else {
|
||||
this.$message.error(data.msg || '配置保存失败');
|
||||
}
|
||||
});
|
||||
},
|
||||
resetConfig() {
|
||||
@@ -194,24 +194,22 @@ export default {
|
||||
selectTemplate(templateName) {
|
||||
if (this.loadingTemplate) return;
|
||||
this.loadingTemplate = true;
|
||||
import('@/apis/module/agent').then(({ default: agentApi }) => {
|
||||
agentApi.getAgentTemplate((response) => { // 移除参数传递
|
||||
this.loadingTemplate = false;
|
||||
if (response.data.code === 0) {
|
||||
// 在客户端过滤匹配的模板
|
||||
const matchedTemplate = response.data.data.find(
|
||||
t => t.agentName === templateName
|
||||
);
|
||||
if (matchedTemplate) {
|
||||
this.applyTemplateData(matchedTemplate);
|
||||
this.$message.success(`「${templateName}」模板已应用`);
|
||||
} else {
|
||||
this.$message.warning(`未找到「${templateName}」模板`);
|
||||
}
|
||||
Api.agent.getAgentTemplate((response) => { // 移除参数传递
|
||||
this.loadingTemplate = false;
|
||||
if (response.data.code === 0) {
|
||||
// 在客户端过滤匹配的模板
|
||||
const matchedTemplate = response.data.data.find(
|
||||
t => t.agentName === templateName
|
||||
);
|
||||
if (matchedTemplate) {
|
||||
this.applyTemplateData(matchedTemplate);
|
||||
this.$message.success(`「${templateName}」模板已应用`);
|
||||
} else {
|
||||
this.$message.error(response.data.msg || '获取模板失败');
|
||||
this.$message.warning(`未找到「${templateName}」模板`);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.$message.error(response.data.msg || '获取模板失败');
|
||||
}
|
||||
}).catch((error) => {
|
||||
this.loadingTemplate = false;
|
||||
this.$message.error('模板加载失败');
|
||||
@@ -236,25 +234,23 @@ export default {
|
||||
};
|
||||
},
|
||||
fetchAgentConfig(agentId) {
|
||||
import('@/apis/module/agent').then(({ default: agentApi }) => {
|
||||
agentApi.getDeviceConfig(agentId, ({ data }) => {
|
||||
if (data.code === 0) {
|
||||
this.form = {
|
||||
...this.form,
|
||||
...data.data,
|
||||
model: {
|
||||
ttsModelId: data.data.ttsModelId,
|
||||
vadModelId: data.data.vadModelId,
|
||||
asrModelId: data.data.asrModelId,
|
||||
llmModelId: data.data.llmModelId,
|
||||
memModelId: data.data.memModelId,
|
||||
intentModelId: data.data.intentModelId
|
||||
}
|
||||
};
|
||||
} else {
|
||||
this.$message.error(data.msg || '获取配置失败');
|
||||
}
|
||||
});
|
||||
Api.agent.getDeviceConfig(agentId, ({ data }) => {
|
||||
if (data.code === 0) {
|
||||
this.form = {
|
||||
...this.form,
|
||||
...data.data,
|
||||
model: {
|
||||
ttsModelId: data.data.ttsModelId,
|
||||
vadModelId: data.data.vadModelId,
|
||||
asrModelId: data.data.asrModelId,
|
||||
llmModelId: data.data.llmModelId,
|
||||
memModelId: data.data.memModelId,
|
||||
intentModelId: data.data.intentModelId
|
||||
}
|
||||
};
|
||||
} else {
|
||||
this.$message.error(data.msg || '获取配置失败');
|
||||
}
|
||||
});
|
||||
},
|
||||
// 清空记忆体内容
|
||||
@@ -265,7 +261,6 @@ export default {
|
||||
},
|
||||
mounted() {
|
||||
const agentId = this.$route.query.agentId;
|
||||
console.log('agentId2222', agentId);
|
||||
if (agentId) {
|
||||
this.fetchAgentConfig(agentId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user