2026最新原创vue3.5+vite7+deepseek-chat网页pc版流式打字ai系统

举报
yxybox 发表于 2026/01/08 21:27:52 2026/01/08
【摘要】 基于vite7.x+vue3+arco+deepseek-v3.2搭建网页版ai流式聊天模板。

2026最新研发vite7.x+vue3+arco+markdown对接deepseek api从0-1纯手搓网页版ai对话系统。


未标题-ee.png

p4.gif


使用技术

  • 开发工具:Vscode
  • 前端框架:vite^7.2.4+vue^3.5.24+vue-router^4.6.4
  • 大模型框架:DeepSeek-R1 + OpenAI
  • 组件库:arco-design^2.57.0 (字节桌面端组件库)
  • 状态管理:pinia^3.0.4
  • 本地存储:pinia-plugin-persistedstate^4.7.1
  • 高亮插件:highlight.js^11.11.1
  • markdown插件:markdown-it
  • katex公式:@mdit/plugin-katex^0.24.1


p4-3.gif


项目结构框架

使用最新vite7.2创建项目模板,接入deepseek-v3.2大模型。


360截图20260104094519850.png


目前该项目已经正式发布到我的原创作品集,有需要的可以去下载使用。

https://b23.tv/1uQ7JBH


未标题-jj.png


项目运行配置

申请一个deepseek apikey,替换如下图.env文件里的key即可使用流式打字效果。

# 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
  • yarn install安装依赖
  • yarn dev运行项目


p4-4.gif

001360截图20260103080509704.png

002360截图20260103081002002.png

002360截图20260103084412883.png

002360截图20260103084825451.png

002360截图20260103085708292.png

004360截图20260103115744725.png

004360截图20260103120054549.png

005360截图20260103120319468.png


项目通用布局

项目布局如下图所示

<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>

vue3+deepseek实现深度思考

// 调用deepseek接口
const completion = await openai.chat.completions.create({
  // 单一会话
  /* messages: [
    {role: 'user', content: editorValue}
  ], */
  // 多轮会话
  messages: props.multiConversation ? historySession.value : [{role: 'user', content: editorValue}],
  // deepseek-chat对话模型 deepseek-reasoner推理模型
  model: sessionstate.thinkingEnabled ? 'deepseek-reasoner' : 'deepseek-chat',
  stream: true, // 流式输出
  max_tokens: 8192, // 一次请求中模型生成 completion 的最大 token 数(默认使用 4096)
  temperature: 0.4, // 严谨采样
})

005360截图20260103120220904.png

006360截图20260103120533404.png

007360截图20260103120754684.png

008360截图20260103125126598.png

009360截图20260103125438125.png

010360截图20260103125925726.png

012360截图20260103130203476.png

vue3+deepseek集成katex和mermaid功能

import { katex } from "@mdit/plugin-katex"; // 支持数学公式
import 'katex/dist/katex.min.css'
// 渲染mermaid图表
import { markdownItMermaidPlugin } from '@/components/markdown/plugins/mermaidPlugin'


005360截图20260103120319468.png

008360截图20260103125040635.png

<Markdown
  :source="item.content"
  :html="true"
  :linkify="true"
  :typographer="true"
  :plugins="[
    [katex, {delimiters: 'all'}],
    [markdownItMermaidPlugin, { ... }]
  ]"
  @copy="onCopy"
/>

未标题-jj.png

vue3+deepseek流式ai

// 调用deepseek接口
const completion = await openai.chat.completions.create({
  // 单一会话
  // messages: [{role: 'user', content: editorValue}],
  // 多轮会话
  messages: props.multiConversation ? historySession.value : [{role: 'user', content: editorValue}],
  // deepseek-chat对话模型 deepseek-reasoner推理模型
  model: sessionstate.thinkingEnabled ? 'deepseek-reasoner' : 'deepseek-chat',
  stream: true, // 流式输出
  max_tokens: 8192,
  temperature: 0.4
})

处理流式结果

for await (const chunk of completion) {
  // 检查是否已终止
  if(sessionstate.aborted) break

  const content = chunk.choices[0]?.delta?.content || ''
  // 获取推理内容
  const reasoningContent = chunk.choices[0]?.delta?.reasoning_content || ''
  
  if(content || reasoningContent) {
    answerText += content
    reasoningText += reasoningContent

    // 限制更新频率:每100ms最多更新一次
    const now = Date.now()
    if(now - lastUpdate > 100) {
      lastUpdate = now
      requestAnimationFrame(() => {
        // ...
      })
    }
  }
  if(chunk.choices[0]?.finish_reason === 'stop') {
    // ...
  }
}

未标题-aa.png

好了,以上就是vue3+deepseek搭建网页版ai对话的一些项目分享,希望能给大家带来一些些帮助!

往期热文

Vite7.2仿写DeepSeek流式AI会话

2025最新款Tauri2.9+Vite7+Vue3+ElementPlus电脑端后台管理系统Exe

最新版Vite7.1+Tauri2.8+Vue3电脑端仿QQ/微信聊天程序

Electron38.2实战客户端OS系统|vite7+vue3+electron仿mac/wins桌面

2025最新款Electron38+Vite7+Vue3+ElementPlus桌面客户端后台管理系统Exe

最新研发vite7.0+electron38客户端仿微信EXE聊天软件

原创uniapp+vite5+vue3+uv-ui跨三端短视频+直播+聊天app应用

uni-app+deepseek-v3跨三端ai流式输出对话模板

Flutter3.32实战桌面端OS系统|flutter3仿macOS桌面

flutter3.27跨平台仿微信客户端聊天Exe程序|朋友圈|短视频

flutter3+deepseek手机端ai流式输出聊天模板

实战跨平台Electron35+DeepSeek-V3搭建客户端AI模板

【声明】本内容来自华为云开发者社区博主,不代表华为云及华为云开发者社区的观点和立场。转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息,否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。