修改:使用动态组件而非路由跳转
parent
8eb43bdd01
commit
93ba6c579a
|
@ -97,7 +97,7 @@ $prefix-cls: #{$namespace}--cropper-avatar;
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transition: opacity 0.4s;
|
transition: opacity 0.4s;
|
||||||
|
|
||||||
::v-deep(svg) {
|
:deep(svg) {
|
||||||
margin: auto;
|
margin: auto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ const querySearch = () => {
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
::v-deep .el-input__wrapper {
|
:deep(.el-input__wrapper) {
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,28 +1,28 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Dialog } from '@/components/Dialog'
|
import { Dialog } from '@/components/Dialog'
|
||||||
import { ref } from 'vue'
|
import { ref, defineAsyncComponent } from 'vue'
|
||||||
import IM from '@/views/im/index.vue'
|
|
||||||
import { useRouter } from 'vue-router' // 导入 useRouter 方法
|
|
||||||
|
|
||||||
defineOptions({ name: 'ImChat' })
|
// 异步加载可能的对话框内容组件
|
||||||
|
const IMComponent = defineAsyncComponent(() => import('@/views/im/index.vue'))
|
||||||
|
|
||||||
const dialogVisible = ref(false)
|
const dialogVisible = ref(false)
|
||||||
const router = useRouter() // 创建 router 实例
|
const currentComponent = ref(null)
|
||||||
|
|
||||||
// 添加点击事件处理函数
|
// 添加点击事件处理函数,显示对话框并加载 IM 组件
|
||||||
function handleClick() {
|
function openDialog() {
|
||||||
dialogVisible.value = !dialogVisible.value
|
dialogVisible.value = true
|
||||||
router.push('/im/conversation') // 设置路由为 /im/conversation
|
currentComponent.value = IMComponent // 加载 IM 组件
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="custom-hover" v-bind="$attrs">
|
<div class="custom-hover" v-bind="$attrs" @click="openDialog">
|
||||||
<ElBadge>
|
<ElBadge>
|
||||||
<Icon :size="18" class="cursor-pointer" icon="ep:chat-round" @click="handleClick" />
|
<Icon :size="18" class="cursor-pointer" icon="ep:chat-round" />
|
||||||
</ElBadge>
|
</ElBadge>
|
||||||
</div>
|
</div>
|
||||||
<Dialog v-model="dialogVisible" width="90%" top="10vh">
|
<Dialog v-model="dialogVisible" width="90%" top="10vh">
|
||||||
<IM />
|
<component :is="currentComponent" />
|
||||||
|
<!-- 使用动态组件 -->
|
||||||
</Dialog>
|
</Dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,28 +1,28 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
/* 搜索框组件 */
|
import { ref, defineAsyncComponent } from 'vue'
|
||||||
import { SearchInput } from '@/components/Im/SearchInput'
|
import { SearchInput } from '@/components/Im/SearchInput'
|
||||||
/* 欢迎页 */
|
|
||||||
import { Welcome } from '@/components/Im/Welcome'
|
|
||||||
import ConversationList from '../Conversation/components/ConversationList.vue'
|
import ConversationList from '../Conversation/components/ConversationList.vue'
|
||||||
import router from '@/router'
|
import { Welcome } from '@/components/Im/Welcome'
|
||||||
|
|
||||||
//路由跳转-系统通知
|
// 异步加载可能的对话框内容组件
|
||||||
|
const InformDetailsComponent = defineAsyncComponent(
|
||||||
|
() => import('@/views/im/InformDetails/index.vue')
|
||||||
|
)
|
||||||
|
const MessageComponent = defineAsyncComponent(() => import('@/views/im/Message/index.vue'))
|
||||||
|
|
||||||
|
const currentComponent = ref(Welcome) // 默认加载欢迎页组件
|
||||||
|
|
||||||
|
// 更改为使用动态组件切换而非路由跳转
|
||||||
const toInformDetails = () => {
|
const toInformDetails = () => {
|
||||||
router.push('/im/conversation/informDetails')
|
currentComponent.value = InformDetailsComponent // 加载系统通知组件
|
||||||
}
|
}
|
||||||
|
|
||||||
//路由跳转-对应好友会话
|
|
||||||
const toChatMessage = (id, chatType) => {
|
const toChatMessage = (id, chatType) => {
|
||||||
console.log('>>>>>>>id', id)
|
console.log('>>>>>>>id', id)
|
||||||
router.push({
|
currentComponent.value = MessageComponent // 加载消息组件
|
||||||
path: '/im/conversation/message',
|
|
||||||
query: {
|
|
||||||
id,
|
|
||||||
chatType
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<el-container style="height: 100%">
|
<el-container style="height: 100%">
|
||||||
<el-aside class="chat_conversation_box">
|
<el-aside class="chat_conversation_box">
|
||||||
|
@ -33,8 +33,7 @@ const toChatMessage = (id, chatType) => {
|
||||||
</div>
|
</div>
|
||||||
</el-aside>
|
</el-aside>
|
||||||
<el-main class="chat_conversation_main_box">
|
<el-main class="chat_conversation_main_box">
|
||||||
<router-view />
|
<component :is="currentComponent" />
|
||||||
<Welcome />
|
|
||||||
</el-main>
|
</el-main>
|
||||||
</el-container>
|
</el-container>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
/* loading svg大小调整 */
|
/* loading svg大小调整 */
|
||||||
::v-deep .circular {
|
:deep(.circular) {
|
||||||
margin-top: 8px;
|
margin-top: 8px;
|
||||||
width: 25px;
|
width: 25px;
|
||||||
height: 25px;
|
height: 25px;
|
||||||
|
|
|
@ -111,7 +111,7 @@
|
||||||
border-radius: 0 0 3px 0;
|
border-radius: 0 0 3px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
::v-deep .el-drawer {
|
:deep(.el-drawer) {
|
||||||
margin-top: 60px;
|
margin-top: 60px;
|
||||||
width: 150px;
|
width: 150px;
|
||||||
height: calc(100% - 60px);
|
height: calc(100% - 60px);
|
||||||
|
|
|
@ -250,36 +250,36 @@ watch(
|
||||||
}
|
}
|
||||||
|
|
||||||
.components {
|
.components {
|
||||||
::v-deep .edit_userinfo_diglog {
|
:deep(.edit_userinfo_diglog) {
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
::v-deep .setting_func_diglog > .el-dialog__body {
|
.setting_func_diglog :deep(.el-dialog__body) {
|
||||||
padding: 28px 24px 24px 24px;
|
padding: 28px 24px 24px 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
::v-deep .setting_func_diglog > .el-dialog__header {
|
.setting_func_diglog :deep(.el-dialog__header) {
|
||||||
background: #f2f2f2;
|
background: #f2f2f2;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
::v-deep .edit_userinfo_diglog > .el-dialog__header {
|
.edit_userinfo_diglog :deep(.el-dialog__header) {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin-right: 0;
|
margin-right: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
::v-deep .edit_userinfo_diglog > .el-dialog__body {
|
.edit_userinfo_diglog :deep(.el-dialog__body) {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
::v-deep .login_diglog > .el-dialog__header {
|
.login_diglog :deep(.el-dialog__header) {
|
||||||
background: #f2f2f2;
|
background: #f2f2f2;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
::v-deep .personal_setting_card > .el-dialog__header {
|
.personal_setting_card :deep(.el-dialog__header) {
|
||||||
background: #f2f2f2;
|
background: #f2f2f2;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,17 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { ref, defineAsyncComponent } from 'vue'
|
||||||
import NavBar from './NavBar/index.vue'
|
import NavBar from './NavBar/index.vue'
|
||||||
|
|
||||||
|
// 定义异步加载的组件
|
||||||
|
const ConversationComponent = defineAsyncComponent(
|
||||||
|
() => import('@/views/im/Conversation/index.vue')
|
||||||
|
)
|
||||||
|
|
||||||
|
const currentComponent = ref(ConversationComponent) // 默认加载对话组件
|
||||||
|
|
||||||
defineOptions({ name: 'IM' })
|
defineOptions({ name: 'IM' })
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<el-container class="chat_container">
|
<el-container class="chat_container">
|
||||||
|
@ -10,11 +19,12 @@ defineOptions({ name: 'IM' })
|
||||||
<NavBar />
|
<NavBar />
|
||||||
</el-aside>
|
</el-aside>
|
||||||
<el-main class="chat_main_box">
|
<el-main class="chat_main_box">
|
||||||
<router-view />
|
<component :is="currentComponent" />
|
||||||
</el-main>
|
</el-main>
|
||||||
</el-container>
|
</el-container>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.app-container {
|
.app-container {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
|
|
Loading…
Reference in New Issue