From a4a0046f5cbd0b165f7597c2a0bcb6811681dc0c Mon Sep 17 00:00:00 2001 From: qx <1084500556@qq.com> Date: 星期四, 13 三月 2025 16:55:24 +0800 Subject: [PATCH] qx --- src/views/system/tijian/index.vue | 1 src/views/123+.vue | 73 ++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 0 deletions(-) diff --git a/src/views/123+.vue b/src/views/123+.vue new file mode 100644 index 0000000..864c6b3 --- /dev/null +++ b/src/views/123+.vue @@ -0,0 +1,73 @@ +<template> + <div> + <h2>DeepSeek 鑱婂ぉ</h2> + <textarea v-model="inputMessage" placeholder="璇疯緭鍏ユ秷鎭�"></textarea> + <button @click="sendMessage">鍙戦��</button> + <p>鍥炲: {{ reply }}</p> + <p v-if="error" style="color: red">{{ error }}</p> + </div> +</template> + +<script> +export default { + name: 'Chat', + data() { + return { + inputMessage: '', + reply: '', + error: '' + }; + }, + methods: { + async sendMessage() { + if (!this.inputMessage.trim()) { + this.error = '娑堟伅涓嶈兘涓虹┖'; + return; + } + this.error = ''; + this.reply = ''; + + try { + const response = await fetch('http://localhost:11434/api/chat', { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + model: 'ltkj-jy-ai', + messages: [ + { + role: 'system', + content: this.inputMessage + } + ], + stream: false + }) + }); + + if (!response.ok) { + throw new Error('缃戠粶鍝嶅簲閿欒'); + } + + const data = await response.json(); + // 浠庤繑鍥炴暟鎹腑鎻愬彇 message.content 浣滀负鍥炲 + this.reply = data.message?.content || '鏀跺埌鍥炲锛屼絾鏍煎紡鍙兘涓嶆纭�'; + } catch (err) { + this.error = '璇锋眰鍑洪敊: ' + err.message; + console.error('Fetch 閿欒:', err); + } + } + } +}; +</script> + +<style scoped> +textarea { + width: 300px; + height: 100px; + margin-bottom: 10px; +} +button { + padding: 5px 10px; +} +</style> \ No newline at end of file diff --git a/src/views/system/tijian/index.vue b/src/views/system/tijian/index.vue index ad39758..52c3914 100644 --- a/src/views/system/tijian/index.vue +++ b/src/views/system/tijian/index.vue @@ -3261,6 +3261,7 @@ discount: item.discount, parentProId: item.parentProId, cusIdCard: item.cusId, + yhj: item.nowPrice })); // 鍒涘缓鏂扮殑瀵硅薄锛屽寘鍚� discount 鍜� id gaibianzhekou(newArray).then((res) => { this.loadingSubmit = false; -- Gitblit v1.8.0