vue模仿chatgpt官网聊天界面并免费调用chatgpt api实现ai智能问答效果代码
代码语言:html
所属分类:其他
代码描述:vue模仿chatgpt官网聊天界面并免费调用chatgpt api实现ai智能问答效果代码,使用markdown及highlight高亮显示代码,实现localstorage实现会话消息本地存储,支持多个聊天自定义。
代码标签: vue 模仿 chatgpt 官网 聊天 界面 免费 调用 api ai 智能 问答
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<html class="light" style="color-scheme: light;"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> <meta property="og:title" content="ChatGPT"> <meta property="og:image" content="https://chat.openai.com/images/chatgpt-share-og.png"> <meta property="og:description" content="A conversational AI system that listens, learns, and challenges"> <meta property="og:url" content="https://chat.openai.com"> <meta name="next-head-count" content="8"> <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"> <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"> <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/tailwind.3.2.4.js"></script> </head> <body class="antialiased"> <div id="app"> <div></div> <div class="overflow-hidden w-full h-full relative flex z-0"> <div class="absolute left-2 top-2 z-10 md:inline-block" data-projection-id="176" style="opacity: 0;" id="showsliderbtn"><span class="" data-state="closed"><button aria-label="Show sidebar" class="flex p-3 items-center gap-3 transition-colors duration-200 text-white cursor-pointer text-sm rounded-md border bg-white dark:bg-gray-800 border-black/10 dark:border-white/20 hover:bg-gray-50 dark:hover:bg-gray-700 h-11"><svg stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4 text-black dark:text-white" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><line x1="9" y1="3" x2="9" y2="21"></line></svg></button></span></div> <div class="dark flex-shrink-0 overflow-x-hidden bg-gray-900" data-projection-id="40" id="sidebar" style="width: 260px; visibility: visible;"> <div class="h-full w-[260px]"> <div class="flex h-full min-h-0 flex-col "> <div class="scrollbar-trigger relative h-full w-full flex-1 items-start border-white/20"> <h2 style="position: absolute; border: 0px; width: 1px; height: 1px; padding: 0px; margin: -1px; overflow: hidden; clip: rect(0px, 0px, 0px, 0px); white-space: nowrap; overflow-wrap: normal;">Chat history</h2> <nav class="flex h-full w-full flex-col p-2" aria-label="Chat history"> <div class="mb-1 flex flex-row gap-2"><a @click="newchat" class="flex p-3 items-center gap-3 transition-colors duration-200 text-white cursor-pointer text-sm rounded-md border border-white/20 hover:bg-gray-500/10 h-11 flex-shrink-0 flex-grow"><svg stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line></svg>New chat</a> <span class="" data-state="closed"><a class="flex p-3 gap-3 transition-colors duration-200 text-white cursor-pointer text-sm rounded-md border border-white/20 hover:bg-gray-500/10 h-11 w-11 flex-shrink-0 items-center justify-center" id="hidesidebar"><svg stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><line x1="9" y1="3" x2="9" y2="21"></line></svg><span style="position: absolute; border: 0px; width: 1px; height: 1px; padding: 0px; margin: -1px; overflow: hidden; clip: rect(0px, 0px, 0px, 0px); white-space: nowrap; overflow-wrap: normal;">Hide sidebar</span></a> </span> </div> <div class="absolute left-0 top-14 z-20 overflow-hidden transition-all duration-500 invisible max-h-0"> <div class="bg-gray-900 px-4 py-3"> <div class="p-1 text-sm text-gray-100">Chat History is off for this browser.</div> <div class="p-1 text-xs text-gray-500">When history is turned off, new chats on this browser won't appear in your history on any of your devices, be used to train our models, or stored for longer than 30 days. <strong>This setting does not sync across browsers or devices.</strong> <a href="" target="_blank" class="underline" rel="noreferrer">Learn more</a></div><button class="btn relative btn-primary mt-4 w-full"><div class="flex w-full gap-2 items-center justify-center"><svg stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M18.36 6.64a9 9 0 1 1-12.73 0"></path><line x1="12" y1="2" x2="12" y2="12"></line></svg>Enable chat history</div></button></div> <div class="h-24 bg-gradient-to-t from-gray-900/0 to-gray-900"></div> </div> <div class="flex-col flex-1 transition-opacity duration-500 overflow-y-auto -mr-2"> <div class="flex flex-col gap-2 pb-2 text-gray-100 text-sm"> <div><span><div class="relative" data-projection-id="41" style="height: auto; opacity: 1;"><ol></ol></div><div class="relative" data-projection-id="42" style="height: auto; opacity: 1;"><div class="sticky top-0 z-[16]" data-projection-id="43" style="opacity: 1;"><h3 class="h-9 pb-2 pt-3 px-3 text-xs text-gray-500 font-medium text-ellipsis overflow-hidden break-all bg-gray-900">Previous 7 Days</h3></div> <ol> <!-- <li @click="newchat">添加</li> <li :class="{ active: contact.id === currentContact.id }" @click="setCurrentContact(contact)"> {{ contact.name }} <button>Rename</button> <button>Delete</button> </li> --> <li v-for="contact in reversedContacts" @click="setCurrentContact(contact)" class="relative z-[15]" data-projection-id="44" style="opacity: 1; height: auto;"> <a :class="{ 'bg-gray-800': contact.id === currentContact.id }" class="flex py-3 px-3 items-center gap-3 relative rounded-md cursor-pointer break-all pr-[4.5rem] )} )} hover:bg-gray-800 group"><svg stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path></svg> .........完整代码请登录后点击上方下载按钮下载查看
网友评论0