Skip to content

Commit

Permalink
feat:优化代码
Browse files Browse the repository at this point in the history
  • Loading branch information
gzydong committed Sep 4, 2024
1 parent 065d99b commit 9052c7c
Show file tree
Hide file tree
Showing 10 changed files with 259 additions and 164 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"pinia-plugin-persistedstate": "^3.2.1",
"quill": "^2.0.2",
"quill-mention": "^6.0.1",
"vue": "^3.4.38",
"vue": "^3.5.1",
"vue-cropper": "^1.1.3",
"vue-router": "^4.4.3",
"vuedraggable": "^4.1.0",
Expand Down Expand Up @@ -96,4 +96,4 @@
"output": "dist_electron"
}
}
}
}
4 changes: 2 additions & 2 deletions src/components/quill-editor/editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const emit = defineEmits(['ready', 'change', 'blur', 'focus'])
const model = defineModel()
const props = defineProps({
const { options } = defineProps({
options: {
type: Object,
required: false,
Expand All @@ -41,7 +41,7 @@ function getQuill(): Quill | null {
const initialize = () => {
if (!editor.value) return
quill = new Quill(editor.value, mergeOptions(defaultOptions, props.options))
quill = new Quill(editor.value, mergeOptions(defaultOptions, options))
quill.on('selection-change', (range) => {
emit(!range ? 'blur' : 'focus', quill)
Expand Down
4 changes: 4 additions & 0 deletions src/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ class Connect {
this.onImContactApply()
this.onImGroupApply()
this.onEventError()

this.conn.on('webrtc_answer', () => {})
this.conn.on('webrtc_ice_candidate', () => {})
this.conn.on('webrtc_offer', () => {})
}

onPing() {
Expand Down
92 changes: 35 additions & 57 deletions src/layout/MainLayout.vue
Original file line number Diff line number Diff line change
@@ -1,83 +1,61 @@
<script lang="ts" setup>
import Menu from './component/Menu.vue'
import Sponsor from './component/Sponsor.vue'
import { useSettingsStore } from '@/store'
import { isElectronMode } from '@/utils/electron'
const settingsStore = useSettingsStore()
const isElectron = isElectronMode()
</script>

<template>
<section class="container flex-center">
<section
class="el-container im-container"
:class="{
'small-screen': !settingsStore.isFullScreen
}"
>
<aside
class="el-aside app-drag"
:class="{
'pd-t15': isElectronMode()
}"
>
<Menu />
</aside>
<main class="el-main">
<router-view />
</main>
</section>
<section class="el-container is-vertical im-container">
<header v-if="isElectron" class="el-header app-header flex-center app-drag">
LumenIM 在线聊天
</header>
<main class="el-main">
<section class="el-container">
<aside class="el-aside"><Menu></Menu></aside>
<main class="el-main"><router-view /></main>
</section>
</main>
</section>

<Sponsor />
</template>
<style lang="less" scoped>
.container {
.im-container {
height: 100vh;
width: 100vw;
background: url(@/assets/image/background.jpeg);
background-position: center center;
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
.im-container {
height: 100vh;
width: 100vw;
overflow: hidden;
background-color: #fff;
.el-aside {
width: 60px;
box-shadow: 2px 0 8px 0 rgba(29, 35, 41, 0.05);
}
overflow: hidden;
background-color: #ffffff;
.app-header {
height: 28px;
background-color: #1890ff;
color: #ffffff;
font-size: 13px;
cursor: pointer;
user-select: none;
}
&.small-screen {
position: fixed;
width: 1000px;
height: 650px;
border-radius: 10px;
transition: all 0.5s;
}
.el-aside {
width: 60px;
box-shadow: 2px 0 8px 0 rgba(29, 35, 41, 0.05);
}
}
html[theme-mode='dark'] {
.container {
background: unset;
.im-container {
background-color: unset;
.im-container {
background-color: unset;
.el-aside {
background-color: rgba(255, 255, 255, 0.05);
box-shadow: unset;
}
.app-header {
background-color: #383838;
color: #9d9696;
}
}
.small-screen {
border: 1px solid #494949;
.el-aside {
background-color: rgba(255, 255, 255, 0.05);
box-shadow: unset;
}
}
}
</style>
11 changes: 6 additions & 5 deletions src/views/message/panel/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useUserStore, useDialogueStore, useUploadsStore, useTalkStore } from '@
import PanelHeader from './Header.vue'
import PanelContent from './Content.vue'
import PanelFooter from './Footer.vue'
// import VoiceCall from './VoiceCall.vue'
import GroupPanel from '@/components/group/GroupPanel.vue'
import GroupLaunch from '@/components/group/GroupLaunch.vue'
import UploadsModal from '@/components/base/UploadsModal.vue'
Expand Down Expand Up @@ -76,7 +77,9 @@ useEventBus([
</script>

<template>
<section id="drawer-container" class="el-container is-vertical">
<!-- <VoiceCall /> -->

<section class="el-container is-vertical" id="drawer-container2" style="position: relative">
<!-- 头部区域 -->
<header class="el-header border-bottom">
<PanelHeader
Expand Down Expand Up @@ -130,7 +133,7 @@ useEventBus([
:trap-focus="false"
:block-scroll="false"
show-mask="transparent"
to="#drawer-container"
to="#drawer-container2"
>
<UploadsModal />
</n-drawer>
Expand All @@ -139,10 +142,8 @@ useEventBus([
v-model:show="isShowGroupAside"
:width="400"
placement="right"
:trap-focus="false"
:block-scroll="false"
show-mask="transparent"
to="#drawer-container"
to="#drawer-container2"
>
<GroupPanel :group-id="talkParams.toFromId" @close="isShowGroupAside = false" />
</n-drawer>
Expand Down
108 changes: 108 additions & 0 deletions src/views/message/panel/VoiceCall.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<script lang="ts" setup>
import { ref } from 'vue'
import { NModal } from 'naive-ui'
const emit = defineEmits([])
const show = ref(true)
const localStream = ref()
const remoteStream = ref()
const peerConnection = ref()
const remoteVideo = ref()
const localVideo = ref()
const startCall = async () => {
// 获取本地媒体流
const stream = await navigator.mediaDevices.getUserMedia({ audio: true, video: true })
localStream.value = stream
// 将本地视频流绑定到video元素
// @ts-ignore
localVideo.value.srcObject = localStream.value
// 初始化RTCPeerConnection
peerConnection.value = new RTCPeerConnection()
// 将本地媒体流添加到RTCPeerConnection
localStream.value
.getTracks()
.forEach((track) => peerConnection.value.addTrack(track, localStream.value))
// 监听来自远端的IceCandidate
peerConnection.value.onicecandidate = ({ candidate }) => {
if (candidate) {
// 发送candidate到远端
}
}
// 监听远端的media流
peerConnection.value.ontrack = ({ streams: [stream] }) => {
remoteStream.value = stream
// 将远端视频流绑定到video元素
remoteVideo.value.srcObject = remoteStream.value
}
// 创建offer
const offer = await peerConnection.value.createOffer()
await peerConnection.value.setLocalDescription(offer)
// // 发送offer到远端
// // 远端接收offer,创建answer,并返回给你
// const answer = /* 远端返回的answer */;
// // 设置远端的answer
// await peerConnection.value.setRemoteDescription(answer);
}
</script>

<template>
<n-modal
v-model:show="show"
preset="card"
title="语音通话"
class="modal-radius"
style="max-width: 350px; height: 550px"
:segmented="{
content: true,
footer: true
}"
:content-style="{
padding: 0
}"
>
<section class="el-container is-vertical launch-box">
<button @click="startCall">发起视频通话</button>
<button @click="startCall">挂断</button>

<!-- 本地视频 -->
<video autoplay ref="localVideo" id="localVideo" muted playsinline class="local"></video>
<!-- 远端视频 -->
<video autoplay ref="remoteVideo" id="remoteVideo" playsinline class="remote"></video>
</section>

<template #footer>
<div class="footer">
<div></div>

<div>
<n-button type="primary" text-color="#ffffff" class="mt-l15"> 确定 </n-button>
</div>
</div>
</template>
</n-modal>
</template>

<style lang="less" scoped>
.launch-box {
height: 410px;
width: 100%;
overflow: hidden;
}
.footer {
display: flex;
align-items: center;
justify-content: space-between;
}
</style>
11 changes: 7 additions & 4 deletions src/views/note/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,25 @@ import { useNoteStore } from '@/store'
const noteStore = useNoteStore()
const loadId = computed(() => noteStore.view.loadId)
const currentLoadId = computed(() => noteStore.view.loadId)
</script>

<template>
<section class="el-container height100">
<aside class="el-aside" style="width: 230px"><NoteMenu /></aside>
<aside class="el-aside" style="width: 230px">
<NoteMenu />
</aside>

<aside
class="el-aside"
style="width: 350px"
style="width: 280px"
v-dropsize="{ min: 200, max: 500, direction: 'right' }"
>
<NoteList />
</aside>

<main class="el-main">
<component :is="loadId > 0 ? NoteView : NoteEmpty" />
<component :is="currentLoadId > 0 ? NoteView : NoteEmpty" />
</main>
</section>
</template>
Expand Down
Loading

0 comments on commit 9052c7c

Please sign in to comment.