allow users to select a chatApp to chat in chat app list page

This commit is contained in:
RockYang 2024-04-22 11:18:55 +08:00
parent 087f5ab2d1
commit 6807f7e88a
4 changed files with 20 additions and 12 deletions

View File

@ -3,8 +3,11 @@
## v4.0.4 ## v4.0.4
* Bug修复修复统一千问第二句不回复的问题 * Bug修复修复统一千问第二句不回复的问题
* 功能优化MJ 和 SD 任务正在执行时不更新已完成任务列表 * 功能优化MJ 和 SD 任务正在执行时不更新已完成任务列表,加快页面渲染速度
* 功能新增Dalle AI 绘画功能实现 * 功能新增Dalle AI 绘画功能实现
* Bug修复修复思维导图格式乱码问题
* 功能新增:支持从应用列表直接和某个应用对话
* 功能优化优化算力日志的页面和首页的UI
## v4.0.3 ## v4.0.3

View File

@ -47,6 +47,7 @@
.opt { .opt {
position: relative; position: relative;
width 100%
top -5px top -5px
} }
} }

View File

@ -12,14 +12,10 @@
<div class="title"> <div class="title">
<span class="name">{{ scope.item.name }}</span> <span class="name">{{ scope.item.name }}</span>
<div class="opt"> <div class="opt">
<div v-if="hasRole(scope.item.key)">
<el-button v-if="hasRole(scope.item.key)" size="small" type="danger" <el-button size="small" type="success" @click="useRole(scope.item.id)">使用</el-button>
@click="updateRole(scope.item,'remove')"> <el-button size="small" type="danger" @click="updateRole(scope.item,'remove')">移除</el-button>
<el-icon> </div>
<Delete/>
</el-icon>
<span>移除应用</span>
</el-button>
<el-button v-else size="small" <el-button v-else size="small"
style="--el-color-primary:#009999" style="--el-color-primary:#009999"
@click="updateRole(scope.item, 'add')"> @click="updateRole(scope.item, 'add')">
@ -47,10 +43,11 @@ import {onMounted, ref} from "vue"
import {ElMessage} from "element-plus"; import {ElMessage} from "element-plus";
import {httpGet, httpPost} from "@/utils/http"; import {httpGet, httpPost} from "@/utils/http";
import ItemList from "@/components/ItemList.vue"; import ItemList from "@/components/ItemList.vue";
import {Delete, Plus} from "@element-plus/icons-vue"; import {Plus} from "@element-plus/icons-vue";
import LoginDialog from "@/components/LoginDialog.vue"; import LoginDialog from "@/components/LoginDialog.vue";
import {checkSession} from "@/action/session"; import {checkSession} from "@/action/session";
import {arrayContains, removeArrayItem, substr} from "@/utils/libs"; import {arrayContains, removeArrayItem, substr} from "@/utils/libs";
import {useRouter} from "vue-router";
const listBoxHeight = window.innerHeight - 97 const listBoxHeight = window.innerHeight - 97
const list = ref([]) const list = ref([])
@ -111,6 +108,11 @@ const updateRole = (row, opt) => {
const hasRole = (roleKey) => { const hasRole = (roleKey) => {
return arrayContains(roles.value, roleKey, (v1, v2) => v1 === v2) return arrayContains(roles.value, roleKey, (v1, v2) => v1 === v2)
} }
const router = useRouter()
const useRole = (roleId) => {
router.push({name: "chat", params: {role_id: roleId}})
}
</script> </script>
<style lang="stylus"> <style lang="stylus">

View File

@ -295,9 +295,9 @@ const leftBoxHeight = ref(0);
const loading = ref(true); const loading = ref(true);
const loginUser = ref(null); const loginUser = ref(null);
const roles = ref([]); const roles = ref([]);
const router = useRouter();
const roleId = ref(0) const roleId = ref(0)
const newChatItem = ref(null); const newChatItem = ref(null);
const router = useRouter();
const showConfigDialog = ref(false); const showConfigDialog = ref(false);
const showLoginDialog = ref(false) const showLoginDialog = ref(false)
const isLogin = ref(false) const isLogin = ref(false)
@ -328,6 +328,7 @@ httpGet("/api/config/get?key=notice").then(res => {
showNotice.value = true showNotice.value = true
} }
} catch (e) { } catch (e) {
console.warn(e)
} }
}).catch(e => { }).catch(e => {
@ -376,7 +377,8 @@ const initData = () => {
// //
httpGet(`/api/role/list`).then((res) => { httpGet(`/api/role/list`).then((res) => {
roles.value = res.data; roles.value = res.data;
roleId.value = roles.value[0]['id']; console.log()
roleId.value = parseInt(router.currentRoute.value.params["role_id"]) ?? roles.value[0]['id'];
newChat(); newChat();
}).catch((e) => { }).catch((e) => {
ElMessage.error('获取聊天角色失败: ' + e.messages) ElMessage.error('获取聊天角色失败: ' + e.messages)