找回密码
 立即注册
首页 业界区 业界 Vite7网页版聊天|Vue3.5+Pinia3+ElementPlus仿微信网页 ...

Vite7网页版聊天|Vue3.5+Pinia3+ElementPlus仿微信网页端web聊天系统

腥狩频 昨天 06:40
最新研发vite7.1+vue3.5+element-plus仿微信网页版聊天vite7-webchat
vite-vue3-webchat基于Vite7+Vue3+Pinia3+elementPlus实战仿微信界面网页端聊天模板。实现了聊天、联系人、收藏、朋友圈、小视频、我的等模块。支持消息+emo混排、光标位置插入gif动图、图片/视频预览、红包等功能。
1.png

使用技术


  • 编辑器:Vscode
  • 技术框架:vite7.1+vue3.5+vue-router4.5+pinia3
  • UI组件库:element-plus^2.11.1 (饿了么网页端vue3组件库)
  • 状态管理:pinia^3.0.3
  • 地图插件:@amap/amap-jsapi-loader(高德地图组件)
  • 视频滑动:swiper^11.2.10
  • 富文本编辑器:wangeditor^4.7.15
  • 样式编译:sass^1.91.0
  • 构建工具:vite^7.1.2
2.png

3.gif

4.gif

项目框架结构

vite-vue3-wechat项目使用 vite7 搭建项目模板,采用 vue3 setup 语法糖编码。
5.png

vite7-webchat聊天项目已经更新到我的原创作品集,感谢支持!

vite7+vue3.5+pinia3+element-plus仿微信网页版聊天
6.gif

入口文件main.js
  1. import { createApp } from 'vue'
  2. import './style.scss'
  3. import App from './App.vue'
  4. // 引入组件库
  5. import ElementPlus from 'element-plus'
  6. import 'element-plus/dist/index.css'
  7. import VEPlus from 've-plus'
  8. import 've-plus/dist/ve-plus.css'
  9. // 引入路由/状态管理
  10. import Router from './router'
  11. import Pinia from './pinia'
  12. const app = createApp(App)
  13. app
  14. .use(ElementPlus)
  15. .use(VEPlus)
  16. .use(Router)
  17. .use(Pinia)
  18. .mount('#app')
复制代码
7.gif

8.png

9.png

10.png

11.png

12.png

13.png

14.png

15.png

16.png

17.png

18.png

19.png

20.png

21.png

22.png

23.png

24.png

25.png

26.png

27.png

28.png

29.png

通用布局模板

项目整体布局结构分为左侧菜单栏+侧边栏+右侧主内容区三部分。
30.png

31.png
  1. <template>
  2.   
  3.    
  4.       
  5.         
  6.         <slot v-if="!route?.meta?.hideMenuBar" name="menubar">
  7.           <MenuBar />
  8.         </slot>
  9.         
  10.         
  11.          
  12.             <slot name="sidebar">
  13.               <SideBar />
  14.             </slot>
  15.           </aside>
  16.         
  17.         
  18.         
  19.           <Winbtn v-if="!route?.meta?.hideWinBar" />
  20.           <router-view v-slot="{ Component, route }">
  21.             <keep-alive>
  22.               <component :is="Component" :key="route.path" />
  23.             </keep-alive>
  24.           </router-view>
  25.         
  26.       
  27.    
  28.   
  29. </template>
复制代码
vue-router@4路由管理

32.png
  1. import { createRouter, createWebHashHistory } from 'vue-router'
  2. import { authState } from '@/pinia/modules/auth'
  3. import Layout from '@/layouts/index.vue'
  4. // 批量导入路由
  5. const modules = import.meta.glob('./modules/*.js', { eager: true })
  6. console.log(modules)
  7. const patchRouters = Object.keys(modules).map(key => modules[key].default).flat()
  8. console.log(patchRouters)
  9. /**
  10. * meta配置
  11. * @param meta.requireAuth 需登录验证页面
  12. * @param meta.hideWinBar 隐藏右上角按钮组
  13. * @param meta.hideMenuBar 隐藏菜单栏
  14. * @param meta.showSideBar 显示侧边栏
  15. * @param meta.canGoBack 是否可回退上一页
  16. */
  17. const routes = [
  18.   ...patchRouters,
  19.   // 错误模块
  20.   {
  21.     path: '/:pathMatch(.*)*',
  22.     redirect: '/404',
  23.     component: Layout,
  24.     meta: {
  25.       title: '404error',
  26.       hideMenuBar: true,
  27.       hideWinBar: true,
  28.     },
  29.     children: [
  30.       {
  31.         path: '404',
  32.         component: () => import('@/views/error/404.vue'),
  33.       }
  34.     ]
  35.   },
  36. ]
  37. const router = createRouter({
  38.   history: createWebHashHistory(),
  39.   routes,
  40. })
  41. // 全局路由钩子拦截
  42. router.beforeEach((to, from) => {
  43.   const authstate = authState()
  44.   if(to?.meta?.requireAuth && !authstate.authorization) {
  45.     return {
  46.       path: '/login'
  47.     }
  48.   }
  49. })
  50. router.afterEach((to, from) => {
  51.   // 阻止浏览器回退
  52.   if(to?.meta?.canGoBack == false && from.path != null) {
  53.     history.pushState(history.state, '', document.URL)
  54.   }
  55. })
  56. router.onError(error => {
  57.   console.warn('[Router Error]', error)
  58. })
  59. export default router
复制代码
vue3+pinia3状态管理

使用最新Pinia3状态管理工具。
33.png
  1. /**
  2. * 状态管理Pinia
  3. * @author andy
  4. */
  5. import { createPinia } from 'pinia'
  6. // 引入pinia持久化存储
  7. import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
  8. const pinia = createPinia()
  9. pinia.use(piniaPluginPersistedstate)
  10. export default pinia
复制代码
vue3小视频模块

vite-webchat项目增加了短视频模块,支持上下滑动切换小视频。
34.png

底部mini播放进度条,采用Slider组件实现功能。支持实时显示当前播放进度、拖拽到指定位置
  1.    
  2.    
  3.         <el-tabs v-model="activeName" class="vu__video-tabs">
  4.             <el-tab-pane label="关注" name="attention" />
  5.             <el-tab-pane label="推荐" name="recommend" />
  6.         </el-tabs>
  7.    
  8.     <swiper-container
  9.         class="vu__swiper"
  10.         direction="vertical"
  11.         :speed="150"
  12.         :grabCursor="true"
  13.         :mousewheel="{invert: true}"
  14.         @swiperslidechange="onSlideChange"
  15.     >
  16.         <swiper-slide v-for="(item, index) in videoList" :key="index">
  17.             
  18.             <video
  19.                 class="vu__player"
  20.                 :id="'vuplayer-' + index"
  21.                 :src="item.src"
  22.                 :poster="item.poster"
  23.                 loop
  24.                 preload="auto"
  25.                 :autoplay="index == currentVideo"
  26.                 webkit-playsinline="true"
  27.                 x5-video-player-type="h5-page"
  28.                 x5-video-player-fullscreen="true"
  29.                 playsinline
  30.                 @click="handleVideoClicked"
  31.             >
  32.             </video>
  33.             
  34.             
  35.             
  36.                 ...
  37.             
  38.             
  39.             
  40.                 @{{item.author}}
  41.                 {{item.desc}}
  42.             
  43.         </swiper-slide>
  44.     </swiper-container>
  45.     <el-slider class="vu__video-progressbar" v-model="progressBar" @input="handleSlider" @change="handlePlay" />
  46.     {{videoTime}} / {{videoDuration}}
复制代码
vue3-webchat聊天模块

35.gif

聊天模块编辑器,支持多行文本输入、光标处插入gif图片、粘贴截图发送图片等功能。
36.png

37.png
  1. <template>
  2.   
  3.   ...
  4.   
  5.   
  6.     <Scrollbar ref="scrollRef" autohide gap="2">
  7.       
  8.       
  9.         ...
  10.       
  11.     </Scrollbar>
  12.   
  13.   
  14.   
  15.    
  16.       ...
  17.    
  18.    
  19.       <Editor ref="editorRef" v-model="editorValue" @paste="handleEditorPaste" />
  20.    
  21.    
  22.       <button @click="handleSubmit">发送(S)</button>
  23.    
  24.   
  25.   ...
  26. </template>
复制代码
综上就是vue3+pinia3仿微信web版聊天系统的一些分享,希望对大家有所帮助哈~
附上几个最新实战项目
uniapp-vue3-os手机oa系统|uni-app+vue3跨三端os后台管理模板
最新版uni-app+vue3+uv-ui跨三端仿微信app聊天应用【h5+小程序+app端】
Flutter3-MacOS桌面OS系统|flutter3.32+window_manager客户端OS模板
最新研发flutter3.27+bitsdojo_window+getx客户端仿微信聊天Exe应用
最新版uniapp+vue3+uv-ui跨三端短视频+直播+聊天【H5+小程序+App端】
Uniapp-DeepSeek跨三端AI助手|uniapp+vue3+deepseek-v3流式ai聊天模板
vue3-webseek网页版AI问答|Vite6+DeepSeek+Arco流式ai聊天打字效果
flutter3-deepseek流式AI模板|Flutter3.27+Dio+DeepSeeek聊天ai助手
flutter3-dymall仿抖音直播商城|Flutter3.27短视频+直播+聊天App实例
Tauri2.0+Vite5聊天室|vue3+tauri2+element-plus仿微信|tauri聊天应用
Electron32-ViteOS桌面版os系统|vue3+electron+arco客户端OS管理模板
Electron31-Vue3Admin管理系统|vite5+electron+pinia桌面端后台Exe
38.png

 

来源:程序园用户自行投稿发布,如果侵权,请联系站长删除
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!

相关推荐

您需要登录后才可以回帖 登录 | 立即注册