Tauri2.0-DeepSeek电脑端Ai对话|tauri2+vite6+deepseek流式ai聊天系统
重磅新作tauri2.0+vue3.5+deepseek+arco桌面客户端ai流式输出聊天对话系统。
tauri2-vue3-deepseek:桌面端ai聊天对话,基于Tauri2.x+Vite6集成接入DeepSeek-V3聊天对话系统,支持圆角阴影多窗口、流式输出打字效果、浅色+暗黑模式、代码高亮美化、会话本地存储等功能。
技术栈
- 编辑器:VScode
- 技术框架:vite^6.3.5+vue^3.5.15+vue-router^4.5.1
- Ai大模型框架:DeepSeek-V3-0324 + OpenAI
- 跨平台框架:tauri^2.5.0
- UI组件库:arco-design^2.57.0 (字节桌面端组件库)
- 状态管理:pinia^3.0.3
- 本地缓存:pinia-plugin-persistedstate^4.3.0
- 高亮插件:highlight.js^11.11.1
- markdown插件:markdown-it
项目特性
- 基于跨平台Tauri2.0搭建项目,接入DeepSeek-V3,体积小、性能优、效果丝滑
- 封装多窗口管理、支持暗黑+浅色主题模式、展开/收缩侧边栏
- 支持各种代码高亮效果、易于展示分享代码片段
- 支持上下文多轮对话、提示词生成图片及预览功能
- 支持在浏览器打开会话里面的链接
- 使用arco-design组件库,保证UI风格统一性
项目结构目录
使用 tauri2.0+vite6 搭建跨平台项目模板,接入 deepseek-v3 对话模型,采用vue3 setup语法糖开发编码。
目前Tauri2-Vue3-DeepSeek客户端Ai对话项目已经更新到我的原创作品集。
环境变量配置.env
# 项目名称 VITE_APPNAME = 'Tauri2-DeepSeek' # 运行端口 VITE_PORT = 1420 # DeepSeek API配置 VITE_DEEPSEEK_API_KEY = 替换为你的 API Key VITE_DEEPSEEK_BASE_URL = https://api.deepseek.com
入口配置文件main.js
/** * 渲染页面入口main.js * @author andy */ import { createApp } from "vue" import App from "./App.vue" import './style.scss' // 引入插件配置 import Plugins from './plugins' // 引入路由/状态管理 import Router from './router' import Pinia from './pinia' createApp(App) .use(Plugins) .use(Router) .use(Pinia) .mount("#app");
项目通用布局
项目整体分为自定义顶部导航栏+侧边栏+右侧对话区三个板块。
<script setup> import { appState } from '@/pinia/modules/app' import Titlebar from '@/layouts/components/titlebar/index.vue' import Sidebar from '@/layouts/components/sidebar/index.vue' const appstate = appState() </script> <template> <div class="vu__chatbot"> <div class="vu__container" :style="{'--themeSkin': appstate.config.skin}"> <div class="vu__layout flexbox flex-col"> <!-- 导航栏 --> <Titlebar /> <div class="vu__layout-body flex1 flexbox"> <!-- 侧边栏 --> <Sidebar /> <!-- 主面板 --> <div class="vu__layout-main flex1"> <router-view v-slot="{ Component, route }"> <keep-alive> <component :is="Component" :key="route.path" /> </keep-alive> </router-view> </div> </div> </div> </div> </div> </template>
Ai聊天编辑框
编辑框组件封装在components目录下。
<template> <div class="v3ai__footbar flexbox flex-col"> <!-- 技能栏 --> <div v-if="skillbar" class="v3ai__skills flexbox flex-alignc"> <div class="item" v-for="(item, index) in skills" :key="index" @click="handleSkill(item)"> <i class="iconfont" :class="item.icon"></i><span class="text">{{item.text}}</span> </div> </div> <!-- 编辑栏 --> <div class="v3ai__inputbox flexbox flex-col"> <div class="v3ai__editor flexbox"> <a-textarea v-model="editorText" :auto-size="autoSize" placeholder="想问点什么..." spellcheck="false" @input="handleInput" /> </div> <!-- 操作栏 --> <div class="v3ai__tools flexbox flex-alignc"> <div class="option flex1 flexbox"> <div class="btn" @click="isDeep =! isDeep"><i class="iconfont ai-deepthink"></i> 深度思考 <span class="fs-12">(R1)</span></div> <div class="btn" @click="isNetwork =! isNetwork"><i class="iconfont ai-network"></i> 联网</div> </div> <a-dropdown trigger="hover" :show-arrow="false" position="lb" :content-style="{'min-width': '250px'}"> <a-button shape="circle"><icon-attachment size="18" /></a-button> <template #content> <a-dgroup> <template #title><div style="margin-bottom: 5px;">从网盘添加</div></template> <a-doption value="wx"><icon-more /> 选择网盘文件</a-doption> </a-dgroup> <a-dgroup> <template #title><div style="margin-bottom: 5px;">从本地添加</div></template> <a-doption value="wx"><icon-apps /> 上传文件</a-doption> <a-dsubmenu trigger="hover" position="rb" :popup-translate="[8, 8]" value="option-1"> <template #default><icon-apps /> 上传代码</template> <template #content> <a-doption value="pyq"><icon-apps /> 代码文件</a-doption> <a-doption value="qq"><icon-apps /> 代码文件夹</a-doption> <a-doption value="qq"><icon-apps /> GitHub仓库</a-doption> </template> </a-dsubmenu> </a-dgroup> </template> </a-dropdown> <a-dropdown :show-arrow="false" position="top" :popup-translate="[-5, -5]" :content-style="{'min-width': '150px'}"> <a-button shape="circle"><icon-plus size="18" /></a-button> <template #content> <a-doption value="image"><icon-file-image /> 图片</a-doption> <a-doption value="file"><icon-file /> 本地文件</a-doption> <a-doption value="pdf"><icon-file-pdf /> PDF文档分析</a-doption> <a-doption value="page"><icon-cloud /> 网页总结</a-doption> </template> </a-dropdown> <a-divider direction="vertical" style="margin: 0 7px;" /> <a-button class="submit" type="primary" shape="circle" @click="handleSubmit"> <icon-send v-if="!sessionstate.loading" size="20" /> <icon-loading v-else size="18" /> </a-button> </div> </div> </div> </template>
tauri2+vue3接入deepseek流式输出
const completion = await openai.chat.completions.create({ // 单一会话 // messages: [ {role: 'user', content: editorValue} ], // 多轮会话 messages: props.multiConversation ? historySession.value : [{role: 'user', content: editorValue}], model: 'deepseek-chat', stream: true, // 流式输出 max_tokens: 8192, // 限制一次请求中模型生成 completion 的最大 token 数(默认使用 4096) temperature: 0.4, // 严谨采样 越低越严谨(默认1) })
通过for循环分片返回流式。
// 使用数组存储chunk内容,提高拼接效率 let chunks = [] let lastUpdate = 0 // 处理流式输出 for await (const chunk of completion) { const content = chunk.choices[0]?.delta?.content || '' if(content) { chunks.push(content) // 限制更新频率:每100ms最多更新一次 const now = Date.now() if (now - lastUpdate > 100) { sessionstate.updateSession(botKey, {content: chunks.join('')}) lastUpdate = now // 滚动最底部 if (sessionstate.reachBottom) { props.scrollBottom() } } } if(chunk.choices[0]?.finish_reason === 'stop') { sessionstate.loading = false // 确保最终内容完整更新 sessionstate.updateSession(botKey, {content: chunks.join(''), loading: false}) if (sessionstate.reachBottom) { props.scrollBottom() } } }
Ok,以上就是tauri2.0+vue3对接deepseek实战桌面端ai流式对话系统的一些分享,希望对大家有所帮助!
Uniapp-DeepSeek跨三端AI助手|uniapp+vue3+deepseek-v3流式ai聊天模板
vue3-webseek网页版AI问答|Vite6+DeepSeek+Arco流式ai聊天打字效果
flutter3-deepseek流式AI模板|Flutter3.27+Dio+DeepSeeek聊天ai助手
Vue3-DeepSeek-Chat流式AI对话|vite6+vant4+deepseek智能ai聊天助手
附上几个最新实战项目
Tauri2.0-Vue3OS桌面端os平台|tauri2+vite6+arco电脑版OS管理系统
Tauri2.0+Vite5聊天室|vue3+tauri2+element-plus仿微信|tauri聊天应用
Electron35-DeepSeek桌面端AI系统|vue3.5+electron+arco客户端ai模板
flutter3-dymall仿抖音直播商城|Flutter3.27短视频+直播+聊天App实例
Electron31-Vue3Admin管理系统|vite5+electron+pinia桌面端后台Exe
本文为博主原创文章,未经博主允许不得转载,欢迎大家一起交流 QQ(282310962) wx(xy190310)