Loading [MathJax]/jax/output/CommonHTML/config.js
部署DeepSeek模型,进群交流最in玩法!
立即加群
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >deepseek+vue3.5+arco+markdown网页版流式AI聊天问答

deepseek+vue3.5+arco+markdown网页版流式AI聊天问答

原创
作者头像
andy2018
发布于 2025-03-28 03:12:08
发布于 2025-03-28 03:12:08
1.1K7
举报
文章被收录于专栏:h5h5

半个月之前有发布一篇vite6+deepseek+vant4构建mobile版智能ai对话助手。

https://cloud.tencent.com/developer/article/2505293

这次带来实战原创新作Vue3.5+DeepSeek API+Arco搭建网页版AI流式聊天会话小助手。

deepseek-vue3-webai实现流式打字输出,支持亮色+暗黑模式、各种代码高亮等功能。

实现技术

  • 开发工具:Vscode
  • 前端框架:vite^6.2.0+vue^3.5.13+vue-router^4.5.0
  • 大模型框架:DeepSeek-R1 + OpenAI
  • 组件库:arco-design^2.57.0 (字节桌面端组件库)
  • 状态管理:pinia^3.0.1
  • 本地存储:pinia-plugin-persistedstate^4.2.0
  • 高亮插件:highlight.js^11.11.1
  • markdown解析:markdown-it

项目特征

  1. 流式响应,基于Vue3+DeepSeek实现逐行打字输出效果
  2. 采用Vite6构建,接入DeepSeek,性能更优,聊天丝滑流畅
  3. 支持各种代码高亮,利于展示和分享代码片段
  4. 使用arco-design组件库,风格统一,美观大气

项目结构目录

整个项目使用vite6搭建框架,整合deepseek api实现流式会话功能,采用vue3 setup语法开发。

.env配置文件

去deepseek官网申请apikey,替换掉VITE_DEEPSEEK_API_KEY即可快速体验ai功能。

代码语言:actionscript
AI代码解释
复制
# title
VITE_APP_TITLE = 'Vue3-Web-DeepSeek'

# port
VITE_PORT = 3001

# 运行时自动打开浏览器
VITE_OPEN = true

# 开启https
VITE_HTTPS = false

# 是否删除生产环境 console
VITE_DROP_CONSOLE = true

# DeepSeek API配置
# VITE_DEEPSEEK_API_KEY = 替换为你的 API Key
VITE_DEEPSEEK_BASE_URL = https://api.deepseek.com

项目布局模板

如下图:整个项目分为侧边栏+顶部导航条+会话区域

代码语言:actionscript
AI代码解释
复制
<script setup>
  import Sidebar from '@/layouts/components/sidebar/index.vue'
</script>

<template>
  <div class="vu__container">
    <div class="vu__layout flexbox flex-col">
      <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>
</template>

如上图:侧边栏会话列表支持超过高度滚动条显示。

代码语言:actionscript
AI代码解释
复制
<template>
  <div class="vu__sidebar" :class="{'collapsed': appstate.config.collapsed}">
    <a-button class="vu__sidebar-collapse" shape="circle" @click="handleCollapse"></a-button>
    <aside class="vu__sidebar-aside flex1 flexbox flex-col">
      <div class="vu__aside-head">
        <router-link to="/" class="logo"><i class="iconfont ai-deepseek"></i><span class="fs-14 ff-ab">Vue3-WebSeek</span></router-link>
        <div class="btn-create flex-c mt-15" @click="handleCreate"><i class="iconfont ai-newchat fs-20"></i>新建对话</div>
      </div>
      <div class="vu__aside-navlinks flexbox flex-col">
        <div class="section-navitem" @click="toLink('/aihub')">
          <span class="icon flex-c"><icon-compass size="18" /></span>
          <div class="title">AI 导航</div>
        </div>
        <a-dropdown trigger="hover" :show-arrow="false" position="rt" :popup-offset="15" :content-style="{'min-width': '150px'}">
          <div class="section-navitem">
            <span class="icon flex-c"><icon-command size="18" /></span>
            <div class="title">AI 技能</div>
            <i class="iconfont ai-arrR c-999 fs-12"></i>
          </div>
          <template #content>
            <a-doption><i class="iconfont ai-aisousou"></i> AI搜索</a-doption>
            <a-doption><i class="iconfont ai-fanyi"></i> 快速翻译</a-doption>
            <a-doption><i class="iconfont ai-xiezuo"></i> 帮我写作</a-doption>
            <a-doption><i class="iconfont ai-tuxiang"></i> 图像生成</a-doption>
            <a-doption><i class="iconfont ai-aicode"></i> AI编程</a-doption>
          </template>
        </a-dropdown>
      </div>
      <a-divider style="margin: 0;" />
      <div class="vu__aside-sessions flex1 flexbox flex-col">
        <div class="vu__aside-navlinks">
          <div class="section-navitem plain">
            <span class="icon flex-c"><icon-message size="18" /></span>
            <div class="title">最近对话</div>
            <i class="clean iconfont ai-qingli" @click="handleClean"></i>
          </div>
        </div>
        <a-scrollbar :outer-style="{'height': '100%'}">
          <template v-if="sessionstate.session.length">
            <SessionList />
          </template>
          <template v-else>
            <a-empty description="暂无对话" />
          </template>
        </a-scrollbar>
      </div>
      <div class="vu__aside-navlinks" @click="toLink('/setting')">
        ...
      </div>
    </aside>
  </div>
</template>

vue3+deepseek对话框

代码语言:actionscript
AI代码解释
复制
<template>
  <div class="v3ai__footbar flexbox flex-col">
    <!-- 技能栏 -->
    <div v-if="skillbar" class="v3ai__skills flexbox flex-alignc">
      ...
    </div>
    <!-- 编辑栏 -->
    <div class="v3ai__inputbox flexbox flex-col">
      <div class="v3ai__editor flexbox">
        ...
      </div>
      <!-- 操作栏 -->
      <div class="v3ai__tools flexbox flex-alignc">
        <div class="option flex1 flexbox">
          <div class="btn" :class="{'active': isDeep}" @click="isDeep =! isDeep"><i class="iconfont ai-deepthink"></i> 深度思考 (R1)</div>
          <div class="btn" :class="{'active': isNetwork}" @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>
            ...
          </template>
        </a-dropdown>
        <a-tooltip content="添加图片" position="top" mini>
          <a-button shape="circle"><icon-image size="18" /></a-button>
        </a-tooltip>
        <a-dropdown :show-arrow="false" position="top" :popup-translate="[-10, -5]">
          <a-button shape="circle" style="background: none;"><icon-plus size="18" /></a-button>
          <template #content>
            <a-doption value="pyq"><icon-apps /> 文件</a-doption>
            <a-doption value="qq"><icon-apps /> PDF文档分析</a-doption>
            <a-doption value="qq"><icon-apps /> Word文档分析</a-doption>
            <a-doption value="qq"><icon-apps /> 网页总结</a-doption>
          </template>
        </a-dropdown>
        <a-divider direction="vertical" style="margin: 0 8px 0 5px;" />
        <a-button type="primary" shape="circle" :disabled="!editorText?.trim() || sessionstate.loading" @click="handleSubmit">
          <icon-arrow-up v-if="!sessionstate.loading" size="20" />
          <icon-loading v-else size="18" />
        </a-button>
      </div>
    </div>
  </div>
</template>

vue3对接deepseek

代码语言:actionscript
AI代码解释
复制
const completion = await openai.chat.completions.create({
  messages: [
    {role: 'user', content: editorValue}
  ],
  model: 'deepseek-chat', // deepseek-chat对话模型 deepseek-reasoner推理模型
  stream: false, // 流式输出
  max_tokens: 8192, // 限制一次请求中模型生成 completion 的最大 token 数(默认使用 4096)
  temperature: 0.4, // 严谨采样 越低越严谨(默认1)
})
// 处理返回数据
console.log(completion.choices[0].message.content)

处理流式返回结果。

代码语言:actionscript
AI代码解释
复制
// 处理流式输出
let content = ''
for await (const chunk of completion) {
  content += chunk.choices[0].delta.content;
  chatState.updateSession(uniKey, content)
  if(chunk.choices[0].finish_reason == 'stop') {
    loading.value = false
  }
  if(props.reachBottom) {
    props.scrollBottom()
  }
}

flutter3.27+getx仿抖音app商城:https://cloud.tencent.com/developer/article/2493971 Electron32桌面端os系统:https://cloud.tencent.com/developer/article/2449406 electron31+vue3客户端聊天Exe实例:https://cloud.tencent.com/developer/article/2435159 tauri2.0+vue3客户端admin后台系统:https://cloud.tencent.com/developer/article/2458392 uniapp+vue3仿携程预订客房模板:https://cloud.tencent.com/developer/article/2474766

OK,以上就是vue3.5集成deepseek实战智能AI聊天会话的一些知识分享,希望对大家有所帮助!

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
7 条评论
热度
最新
基于uniapp+deepseek+vue3跨平台ai流式对话 https://cloud.tencent.com/developer/article/2518214
基于uniapp+deepseek+vue3跨平台ai流式对话 https://cloud.tencent.com/developer/article/2518214
回复回复1举报
vite6+deepseek-v3搭建一款网页版ai聊天助手。 https://cloud.tencent.com/developer/article/2505293
vite6+deepseek-v3搭建一款网页版ai聊天助手。 https://cloud.tencent.com/developer/article/2505293
回复回复1举报
请问这个有源码吗?开源不想借鉴一下
请问这个有源码吗?开源不想借鉴一下
回复回复点赞举报
你好请问你的api是怎么调用的,我这边报了个错,提示402 Insufficient Balance, 你付费了吗?
你好请问你的api是怎么调用的,我这边报了个错,提示402 Insufficient Balance, 你付费了吗?
11点赞举报
应该欠费了吧
应该欠费了吧
回复回复点赞举报
大佬,这套源码有没有权限配置?
大佬,这套源码有没有权限配置?
11点赞举报
没有。
没有。
回复回复点赞举报
推荐阅读
编辑精选文章
换一批
deepseek-electron基于Electron35+Vue3.5仿deepseek/豆包ai客户端助手
2025跨平台ai实战-Electron35+Vite6对接DeepSeek-V3聊天模型搭建客户端AI聊天助手。
andy2018
2025/04/19
1590
deepseek-electron基于Electron35+Vue3.5仿deepseek/豆包ai客户端助手
DeepSeek-Vue3基于vite6+vant4仿deepseek/Kimi流式AI聊天小助手
2025年智能AI实战-Vue3+DeepSeek API打造一款mobile版ai聊天界面小助手。
andy2018
2025/03/17
1.3K3
DeepSeek-Vue3基于vite6+vant4仿deepseek/Kimi流式AI聊天小助手
基于uniapp+deepseek+vue3跨平台ai流式对话
基于uniapp+vue3集成deepseek-v3实战跨端流式输出AI对话系统。支持暗黑+亮色模式、代码高亮、本地会话存储等功能。支持编译到小程序+h5+app端。
andy2018
2025/05/06
8430
基于uniapp+deepseek+vue3跨平台ai流式对话
tauri2.x-admin基于vue3+tauri2+pinia2客户端后台系统
最近比较热门的跨端框架当属于tauri2.0了。tauri v2有了很多新的功能升级,而且还支持创建android/ios应用。
andy2018
2024/10/15
4690
tauri2.x-admin基于vue3+tauri2+pinia2客户端后台系统
tauri2.0+rust+vue3电脑版Exe聊天软件
经过大半个月爆肝式开发,重磅自研新作tauri2.0+vite.js跨平台桌面端聊天程序,正式完结了。
andy2018
2024/09/29
3003
tauri2.0+rust+vue3电脑版Exe聊天软件
vite5.x+vue3 setup网页版pc聊天模板
随着vitejs构建工具快速迭代,越来越多的开发者参与到vue3项目开发中来。最近新开发了一款vue3+element-plus网页版聊天项目。
andy2018
2024/06/23
2670
vite5.x+vue3 setup网页版pc聊天模板
tauri聊天应用篇|vue3+tauri桌面聊天实例
前几天有分享一篇tauri整合vue3.js创建多窗口应用,tauri封装多开窗体。
andy2018
2022/10/29
4.6K1
electron31+vue3 setup桌面端Exe聊天系统
几周之前有开发一款vite5+vue3网页web版聊天项目ViteWchat。这次带来全新跨平台electron31.x+vue3+vite5+element-plus仿微信电脑端聊天程序。
andy2018
2024/07/09
2420
electron31+vue3 setup桌面端Exe聊天系统
tauri2.0-winos基于vite6+tauri2+vue3客户端os系统
经过半个月的高强度研发,原创自研Tauri2.0-Vue3-MacOS客户端OS桌面系统终于宣告完结。
andy2018
2024/12/23
3260
tauri2.0-winos基于vite6+tauri2+vue3客户端os系统
Svelte3-Webchat基于svelte.js网页版聊天实例
svelte-webchat一款基于svelte3.x+sveltekit+svelteLayer开发构建的仿微信PC版聊天实例。
andy2018
2022/05/17
3.5K1
electron25+vue3+pinia2跨端chatgpt聊天应用
最近一直学习electron25集成vite4.x技术开发跨端应用。就搭建了一个electron-chatgpt聊天EXE程序。
andy2018
2023/06/11
1.2K2
uniapp-vue3-wechat聊天实例|uni-app+pinia2仿微信app
Uniapp_Vue3_Chat基于uni-app+vue3+pinia2+uv-ui跨三端(h5+小程序+APP端)仿微信聊天。
andy2018
2024/04/29
7390
原创electron32+vue3+arco-design桌面端winOS系统Vue3ElectronOS
经过半个月高效输出,原创新作electron32.x+vite5仿ipad/wins桌面os管理系统项目完结了。
andy2018
2024/09/05
2560
原创electron32+vue3+arco-design桌面端winOS系统Vue3ElectronOS
Vue3.0+Vant3移动端短视频+聊天+直播实战
随着人们生活品质的提高,5G及手机硬件的快速发展,短视频/直播快速的成为了很多人的娱乐方式。
andy2018
2021/02/03
4.8K1
Vue3.0+Vant3移动端短视频+聊天+直播实战
vite5+vue3+arcoDesign网页版webOS系统Vue3MacOS
历经半个月潜心研发,我的又一款原创新作vue3+arco仿macOS桌面pc版os管理系统项目正式完结了。
andy2018
2024/07/26
4230
vite5+vue3+arcoDesign网页版webOS系统Vue3MacOS
Electron13+Vue3+ElementPlus模仿macOS桌面版后台系统框架
electron-vue3-macOS 一款整合vite2.x+electron13跨平台构建模仿mac桌面UI后台管理系统。
andy2018
2021/06/24
3.2K2
Electron13+Vue3+ElementPlus模仿macOS桌面版后台系统框架
mobilegpt-vue3 基于vite4+vant高仿ChatGPT实战
最近闲暇时间利用vite4搭建了一个vue3移动端仿chatgpt聊天模板vue3-mobilegpt。
andy2018
2023/05/23
1K0
整合vite2+electron12撸后台管理系统
前一段时间有给大家分享一个Electron+Vue3.x短视频,今天再分享最新开发的Electron桌面端后台系统。
andy2018
2021/05/18
2.1K0
整合vite2+electron12撸后台管理系统
Vue3.x+ElementPlus桌面版聊天实例
2021让vue3生态越来越好,让更多的开发者参与进来。继上次分享了一个vue3移动端聊天实例,这次再给大家分享一个最新开发的vue3.0+饿了么vue3组件库开发的桌面端实例项目。
andy2018
2021/01/25
5.1K0
Vue3.x+ElementPlus桌面版聊天实例
Vue3+Pinia2模拟Chatgpt聊天模板Vue3ChatGPT
这几天一直在了解ChatGPT,结合vite4.x构建了一个vue3版vue3-webgpt。
andy2018
2023/05/08
2.5K2
推荐阅读
相关推荐
deepseek-electron基于Electron35+Vue3.5仿deepseek/豆包ai客户端助手
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档