提交 62c6c38d 编写于 作者: R root

Auto Commit

上级 669eac6d
run = "npm i && npm run dev"
run = "npm i ; npm run dev"
language = "node"
[env]
......
// Define your API key and API URL
export const apiKey = 'sk-qiskuwktimcsjaphnxpazikbyjnkhxssxwmuqctqgvbfg';
export const apiUrl = 'https://models.csdn.net/v1/chat/completions';
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Chat GPT - InsCode.net</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="main.js"></script>
</body>
</html>
\ No newline at end of file
console.log("欢迎来到 InsCode");
\ No newline at end of file
logo.png

94.5 KB

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 261.76 226.69">
<path d="M161.096.001l-30.225 52.351L100.647.001H-.005l130.877 226.688L261.749.001z" fill="#41b883" />
<path d="M161.096.001l-30.225 52.351L100.647.001H52.346l78.526 136.01L209.398.001z" fill="#34495e" />
</svg>
\ No newline at end of file
/* color palette from <https://github.com/vuejs/theme> */
:root {
--vt-c-white: #ffffff;
--vt-c-white-soft: #f8f8f8;
--vt-c-white-mute: #f2f2f2;
--vt-c-black: #181818;
--vt-c-black-soft: #222222;
--vt-c-black-mute: #282828;
--vt-c-indigo: #2c3e50;
--vt-c-divider-light-1: rgba(60, 60, 60, 0.29);
--vt-c-divider-light-2: rgba(60, 60, 60, 0.12);
--vt-c-divider-dark-1: rgba(84, 84, 84, 0.65);
--vt-c-divider-dark-2: rgba(84, 84, 84, 0.48);
--vt-c-text-light-1: var(--vt-c-indigo);
--vt-c-text-light-2: rgba(60, 60, 60, 0.66);
--vt-c-text-dark-1: var(--vt-c-white);
--vt-c-text-dark-2: rgba(235, 235, 235, 0.64);
}
/* semantic color variables for this project */
:root {
--color-background: var(--vt-c-white);
--color-background-soft: var(--vt-c-white-soft);
--color-background-mute: var(--vt-c-white-mute);
--color-border: var(--vt-c-divider-light-2);
--color-border-hover: var(--vt-c-divider-light-1);
--color-heading: var(--vt-c-text-light-1);
--color-text: var(--vt-c-text-light-1);
--section-gap: 160px;
}
@media (prefers-color-scheme: dark) {
:root {
--color-background: var(--vt-c-black);
--color-background-soft: var(--vt-c-black-soft);
--color-background-mute: var(--vt-c-black-mute);
--color-border: var(--vt-c-divider-dark-2);
--color-border-hover: var(--vt-c-divider-dark-1);
--color-heading: var(--vt-c-text-dark-1);
--color-text: var(--vt-c-text-dark-2);
}
}
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
font-weight: normal;
}
body {
min-height: 100vh;
color: var(--color-text);
background: var(--color-background);
transition:
color 0.5s,
background-color 0.5s;
line-height: 1.6;
font-family:
Inter,
-apple-system,
BlinkMacSystemFont,
'Segoe UI',
Roboto,
Oxygen,
Ubuntu,
Cantarell,
'Fira Sans',
'Droid Sans',
'Helvetica Neue',
sans-serif;
font-size: 15px;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
\ No newline at end of file
import { createApp } from 'vue';
import ViewUIPlus from 'view-ui-plus';
import App from './src/App.vue';
import 'view-ui-plus/dist/styles/viewuiplus.css';
import './main.css';
const app = createApp(App);
app.use(ViewUIPlus)
.mount('#app');
{
"name": "nodejs",
"version": "1.0.0",
"name": "vuejs-with-vite",
"version": "0.0.1",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"dev": "node index.js",
"dev": "vite",
"build": "vite build",
"preview": "vite preview --port 4173",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@microsoft/fetch-event-source": "^2.0.1",
"axios": "^1.4.0",
"guess": "^1.0.2",
"view-ui-plus": "^1.3.12",
"vue": "^3.2.37",
"@types/node": "^18.0.6",
"node-fetch": "^3.2.6"
},
"devDependencies": {
"@vitejs/plugin-vue": "^6.0.0",
"vite": "^5.4.19",
"vite-plugin-vue-devtools": "^7.7.7"
}
}
\ No newline at end of file
}
\ No newline at end of file
<template>
<div class="container ivu-p">
<div class="dialog">
<!-- 将 v-for 直接应用到 div 上,而不是 template -->
<div v-for="(item, index) in dialogs" :key="index" class="dialog-item" :class="{
'dialog-item-me': item.role === 'me',
'dialog-item-ai': item.role === 'ai'
}">
<div class="dialog-item-main">{{ item.text }}</div>
</div>
</div>
<div class="question ivu-mt">
<Input
v-model="question"
type="textarea"
:autosize="{ minRows: 4, maxRows: 6 }"
placeholder="输入你的问题"
/>
<Row class="ivu-mt">
<Col>
<Button
type="primary"
size="large"
icon="md-send"
:loading="loading"
@click="handleSend"
>发送</Button>
</Col>
<Col>
<Button
size="large"
class="ivu-ml"
icon="md-add"
:disabled="loading"
@click="handleNewChat"
>新对话</Button>
</Col>
</Row>
<Typography class="ivu-text-center ivu-m">
Powered By <img src="./assets/logo.png" class="logo" />
<a href="https://inscode.net" target="_blank">InsCode.net</a>
</Typography>
</div>
</div>
</template>
<!-- 脚本和样式部分保持不变 -->
<script>
import { fetchEventSource } from "@microsoft/fetch-event-source";
import { apiKey, apiUrl } from "../api";
export default {
data() {
return {
question: "",
loading: false,
dialogs: [],
};
},
methods: {
handleSend() {
if (this.loading || this.question === "") return;
this.loading = true;
const question = this.question;
this.question = "";
this.dialogs.push({
id: this.dialogs.length + 1,
role: "me",
text: question,
});
const aiDialogID = this.dialogs.length + 1;
this.dialogs.push({
id: aiDialogID,
role: "ai",
text: "AI 思考中...",
});
const dialog = this.dialogs.find((item) => item.id === aiDialogID);
const body = {
model: "Deepseek-R1",
messages: [
{
role: "user",
content: question,
},
],
stream: false,
max_tokens: 512,
temperature: 0.7,
top_p: 0.7,
top_k: 50,
frequency_penalty: 0.5,
n: 1,
response_format: {
type: "text",
},
};
const options = {
method: "POST",
headers: {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/json",
},
body: JSON.stringify(body),
};
fetch(apiUrl, options)
.then((response) => response.json())
.then((response) => {
if (response.choices && response.choices.length > 0) {
dialog.text = response.choices[0].message.content;
}
this.loading = false;
})
.catch((err) => {
console.error(err);
dialog.text = "请求失败,请稍后重试";
this.loading = false;
});
},
handleNewChat() {
this.dialogs = [];
},
},
};
</script>
<style>
.container {
height: 100%;
display: flex;
flex-direction: column;
}
.dialog {
flex: 1;
overflow: auto;
}
.dialog-item {
display: flex;
}
.dialog-item-main {
max-width: 80%;
padding: 8px;
word-wrap: break-word;
margin-top: 16px;
border-radius: 4px;
}
.dialog-item-me {
justify-content: flex-end;
}
.dialog-item-me .dialog-item-main {
background-color: antiquewhite;
}
.dialog-item-ai .dialog-item-main {
background-color: #eee;
}
.logo {
width: 16px;
height: 16px;
vertical-align: middle;
position: relative;
top: -1px;
}
</style>
\ No newline at end of file
/* color palette from <https://github.com/vuejs/theme> */
:root {
--vt-c-white: #ffffff;
--vt-c-white-soft: #f8f8f8;
--vt-c-white-mute: #f2f2f2;
--vt-c-black: #181818;
--vt-c-black-soft: #222222;
--vt-c-black-mute: #282828;
--vt-c-indigo: #2c3e50;
--vt-c-divider-light-1: rgba(60, 60, 60, 0.29);
--vt-c-divider-light-2: rgba(60, 60, 60, 0.12);
--vt-c-divider-dark-1: rgba(84, 84, 84, 0.65);
--vt-c-divider-dark-2: rgba(84, 84, 84, 0.48);
--vt-c-text-light-1: var(--vt-c-indigo);
--vt-c-text-light-2: rgba(60, 60, 60, 0.66);
--vt-c-text-dark-1: var(--vt-c-white);
--vt-c-text-dark-2: rgba(235, 235, 235, 0.64);
}
/* semantic color variables for this project */
:root {
--color-background: var(--vt-c-white);
--color-background-soft: var(--vt-c-white-soft);
--color-background-mute: var(--vt-c-white-mute);
--color-border: var(--vt-c-divider-light-2);
--color-border-hover: var(--vt-c-divider-light-1);
--color-heading: var(--vt-c-text-light-1);
--color-text: var(--vt-c-text-light-1);
--section-gap: 160px;
}
@media (prefers-color-scheme: dark) {
:root {
--color-background: var(--vt-c-black);
--color-background-soft: var(--vt-c-black-soft);
--color-background-mute: var(--vt-c-black-mute);
--color-border: var(--vt-c-divider-dark-2);
--color-border-hover: var(--vt-c-divider-dark-1);
--color-heading: var(--vt-c-text-dark-1);
--color-text: var(--vt-c-text-dark-2);
}
}
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
font-weight: normal;
}
body {
min-height: 100vh;
color: var(--color-text);
background: var(--color-background);
transition:
color 0.5s,
background-color 0.5s;
line-height: 1.6;
font-family:
Inter,
-apple-system,
BlinkMacSystemFont,
'Segoe UI',
Roboto,
Oxygen,
Ubuntu,
Cantarell,
'Fira Sans',
'Droid Sans',
'Helvetica Neue',
sans-serif;
font-size: 15px;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
\ No newline at end of file
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
export default defineConfig({
plugins: [vue()],
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册