最新版实战vite7.1+vue3+element-plus仿微信web聊天模板
【摘要】 基于vite7.1+vue3.5+pinia3+element-plus从0-1仿微信网页版聊天系统模板。
2025最新研发vite7+vue3+element-plus纯手撸开发仿微信网页版聊天系统。实现了聊天、联系人、收藏、朋友圈、小视频、我的等模块。

使用技术
- 技术框架:vite7.1+vue3.5+vue-router4.5+pinia3
- 组件库:element-plus^2.11.1 (饿了么网页端vue3组件库)
- 状态管理:pinia^3.0.3
- 视频滑动:swiper^11.2.10
- 富文本编辑器:wangeditor^4.7.15
- 样式编译:sass^1.91.0
- 构建工具:vite^7.1.2



项目结构框架
使用最新vite7构建工具搭建项目。



项目入口配置
import { createApp } from 'vue'
import './style.scss'
import App from './App.vue'
// 引入组件库
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import VEPlus from 've-plus'
import 've-plus/dist/ve-plus.css'
// 引入路由/状态管理
import Router from './router'
import Pinia from './pinia'
const app = createApp(App)
app
.use(ElementPlus)
.use(VEPlus)
.use(Router)
.use(Pinia)
.mount('#app')






vue3-router路由管理
import { createRouter, createWebHashHistory } from 'vue-router'
import { authState } from '@/pinia/modules/auth'
import Layout from '@/layouts/index.vue'
// 批量导入路由
const modules = import.meta.glob('./modules/*.js', { eager: true })
console.log(modules)
const patchRouters = Object.keys(modules).map(key => modules[key].default).flat()
console.log(patchRouters)
/**
* meta配置
* @param meta.requireAuth 需登录验证页面
* @param meta.hideWinBar 隐藏右上角按钮组
* @param meta.hideMenuBar 隐藏菜单栏
* @param meta.showSideBar 显示侧边栏
* @param meta.canGoBack 是否可回退上一页
*/
const routes = [
...patchRouters,
// 错误模块
{
path: '/:pathMatch(.*)*',
redirect: '/404',
component: Layout,
meta: {
title: '404error',
hideMenuBar: true,
hideWinBar: true,
},
children: [
{
path: '404',
component: () => import('@/views/error/404.vue'),
}
]
},
]
const router = createRouter({
history: createWebHashHistory(),
routes,
})
// 全局路由钩子拦截
router.beforeEach((to, from) => {
const authstate = authState()
if(to?.meta?.requireAuth && !authstate.authorization) {
return {
path: '/login'
}
}
})
router.afterEach((to, from) => {
// 阻止浏览器回退
if(to?.meta?.canGoBack == false && from.path != null) {
history.pushState(history.state, '', document.URL)
}
})
router.onError(error => {
console.warn('[Router Error]', error)
})
export default router







项目布局模板

<script setup>
import { useRoute } from 'vue-router'
import { appState } from '@/pinia/modules/app'
import MenuBar from './components/menubar/index.vue'
import SideBar from './components/sidebar/index.vue'
import Winbtn from './components/winbtn.vue'
const route = useRoute()
const appstate = appState()
</script>
<template>
<div class="vu__container" :class="{'fullscreen': appstate.config.fullscreen}" :style="{'--themeSkin': appstate.config.skin}">
<div class="vu__layout flexbox flex-col">
<div class="vu__layout-body flex1 flexbox" @contextmenu.prevent>
<!-- 菜单栏 -->
<slot v-if="!route?.meta?.hideMenuBar" name="menubar">
<MenuBar />
</slot>
<!-- 侧边栏 -->
<div v-if="route?.meta?.showSideBar" class="vu__layout-sidebar flexbox" :class="{'hidden': appstate.config.collapsed}">
<aside class="vu__layout-sidebar__body flexbox flex-col">
<slot name="sidebar">
<SideBar />
</slot>
</aside>
</div>
<!-- 主内容区 -->
<div class="vu__layout-main flex1 flexbox flex-col">
<Winbtn v-if="!route?.meta?.hideWinBar" />
<router-view v-slot="{ Component, route }">
<keep-alive>
<component :is="Component" :key="route.path" />
</keep-alive>
</router-view>
</div>
</div>
</div>
</div>
</template>

感谢小伙伴的阅读与支持,后续还会继续分享更多优质项目。
最新版uni-app+vue3+uvui跨三端手机桌面OA管理系统
Flutter3.32实战桌面端OS系统|flutter3仿macOS桌面
flutter3.27跨平台仿微信客户端聊天Exe程序|朋友圈|短视频
原创uniapp+vite5+vue3+uv-ui跨三端短视频+直播+聊天app应用
uni-app+deepseek-v3跨三端ai流式输出对话模板
flutter3+deepseek手机端ai流式输出聊天模板
实战跨平台Electron35+DeepSeek-V3搭建客户端AI模板
deepseek-v3+vue3.5网页版webai流式对话模板
Flutter3.27跨平台仿抖音商城|flutter3.x实战短视频+直播+聊天程序
原创tauri2.0+vue3.5+element-plus桌面版后台管理系统
【声明】本内容来自华为云开发者社区博主,不代表华为云及华为云开发者社区的观点和立场。转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息,否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)