修改了一些bug

This commit is contained in:
yuanteng 2025-04-02 23:43:41 +08:00
parent a966b53d28
commit 0766c051ed
4 changed files with 138 additions and 78 deletions

View File

@ -502,6 +502,16 @@ export const constantRoute = [
icon: 'Files', icon: 'Files',
hidden: false hidden: false
} }
},
{
path: '/ExpressManagement',
name: '偏远地区物流费用',
component: () => import("@/views/OtherManagement/ExpressManagement.vue"),
meta: {
title: '偏远地区物流费用',
icon: 'Money',
hidden: false
}
} }
] ]
}, },

View File

@ -20,9 +20,6 @@
<el-form-item label="课程简介" prop="intro"> <el-form-item label="课程简介" prop="intro">
<el-input v-model="form.intro" type="textarea" style="width: 250px;" /> <el-input v-model="form.intro" type="textarea" style="width: 250px;" />
</el-form-item> </el-form-item>
<el-form-item label="商品标签" prop="label">
<el-input v-model="form.label" type="textarea" placeholder="使用英文;分隔符分开" style="width: 250px;" />
</el-form-item>
<el-form-item label="课程详情"> <el-form-item label="课程详情">
<richTextUtil @richTextContent="getRichTextInfo"></richTextUtil> <richTextUtil @richTextContent="getRichTextInfo"></richTextUtil>
</el-form-item> </el-form-item>
@ -57,7 +54,6 @@ const form = ref({
name: '', name: '',
price: '', // price: '', //
intro: '',// intro: '',//
label: '',//
goodImg: '', //url goodImg: '', //url
richText: '', richText: '',
appointmentDateAddRequestList: [] // appointmentDateAddRequestList: [] //
@ -90,7 +86,6 @@ const onSubmit = async () => {
goodImg: form.value.goodImg, goodImg: form.value.goodImg,
intro: form.value.intro, intro: form.value.intro,
richText: form.value.richText, richText: form.value.richText,
label: form.value.label,
appointmentDateAddRequestList: toRaw(form.value.appointmentDateAddRequestList) appointmentDateAddRequestList: toRaw(form.value.appointmentDateAddRequestList)
}) })
console.log(res.data); console.log(res.data);

View File

@ -1,88 +1,143 @@
<template> <template>
<div style="display: flex"> <view class="container">
<el-input v-model="message[0].content" style="width: 240px" placeholder="Please input" /><el-button type="primary" @click="main()">启动</el-button> <!-- 聊天记录展示 -->
<div class="box1" v-html="markdown.render(reasoning_content)"></div> <scroll-view scroll-y class="chat-list" :style="{ height: chatHeight + 'px' }">
<div class="box" v-html="markdown.render(content)"></div> <view v-for="(msg, index) in messages" :key="index" class="message-item">
<view :class="msg.isUser ? 'message-user' : 'message-other'">
{{ msg.text }}
</view>
</view>
</scroll-view>
</div> <!-- 输入框和发送按钮 -->
<view class="input-area">
<input
v-model="newMessage"
class="input-box"
placeholder="请输入消息"
@confirm="sendMessage"
/>
<button class="send-btn" @click="sendMessage">发送</button>
</view>
</view>
</template> </template>
<script setup> <script>
import OpenAI from "openai"; import { ref, reactive, onMounted } from 'vue';
import {onMounted, ref} from "vue";
import MarkdownIt from "markdown-it";
import myAxios from "@/api/myAxios";
export default {
setup() {
//
const newMessage = ref(''); //
const messages = reactive([]); //
const chatHeight = ref(0); //
//
const content = ref('') onMounted(() => {
const reasoning_content = ref('') loadMessages();
const msg = ref('') setChatHeight();
const markdown = new MarkdownIt()
const productNum = ref('')
onMounted(()=>{
// console.log(123123)
// main()
getTotalProduct()
})
const message = ref([
{
role: "user",
content: ""
}
])
const getTotalProduct = async ()=> {
const res = await myAxios.get('/global/getAllGoods')
if(res.data.code === 1) {
// message.value[1].content = JSON.stringify(Object.entries(res.data.data))
}
console.log(JSON.stringify(Object.entries(res.data.data)));
// JSON.stringify(Object.fromEntries(map))
}
const openAI = new OpenAI({
baseURL: 'https://api.deepseek.com',
apiKey: 'sk-d9ab76d589d642f19198ed92acd182c5',
dangerouslyAllowBrowser: true
});
const main = async () => {
const completion = await openAI.chat.completions.create({
model:'deepseek-reasoner',
messages: message.value,
stream: true
}); });
for await ( const chunk of completion) { //
// console.log('chunk--->',chunk) const sendMessage = () => {
if(chunk.choices[0].delta.reasoning_content != null) { if (newMessage.value.trim() === '') return;
reasoning_content.value += chunk.choices[0].delta.reasoning_content
}
if(chunk.choices[0].delta.content != null) {
content.value += chunk.choices[0].delta.content
}
if(chunk.choices[0].finish_reason === 'stop') {
break;
}
}
// console.log(content)
}
//
messages.push({ text: newMessage.value, isUser: true });
saveMessages();
//
setTimeout(() => {
const response = '这是一条自动回复消息';
messages.push({ text: response, isUser: false });
saveMessages();
}, 1000);
//
newMessage.value = '';
};
//
const loadMessages = () => {
const savedMessages = uni.getStorageSync('chatMessages');
if (savedMessages) {
messages.push(...JSON.parse(savedMessages));
}
};
//
const saveMessages = () => {
uni.setStorageSync('chatMessages', JSON.stringify(messages));
};
//
const setChatHeight = () => {
const systemInfo = uni.getSystemInfoSync();
chatHeight.value = systemInfo.windowHeight - 150; //
};
return {
newMessage,
messages,
chatHeight,
sendMessage
};
}
};
</script> </script>
<style scoped> <style scoped>
.box1{ .container {
width: 500px; display: flex;
height: 100%; flex-direction: column;
border: 1px solid red; height: 100vh;
} }
.box {
width: 500px; .chat-list {
height: 100%; flex: 1;
border: 1px solid black; padding: 10px;
background-color: #f0f0f0;
}
.message-item {
margin-bottom: 10px;
}
.message-user {
background-color: #007aff;
color: white;
padding: 10px;
border-radius: 10px;
text-align: right;
}
.message-other {
background-color: #e5e5e5;
color: black;
padding: 10px;
border-radius: 10px;
}
.input-area {
display: flex;
padding: 10px;
background-color: #fff;
align-items: center;
}
.input-box {
flex: 1;
height: 40px;
padding: 0 10px;
border-radius: 20px;
border: 1px solid #ddd;
}
.send-btn {
background-color: #007aff;
color: white;
padding: 10px 20px;
border-radius: 20px;
margin-left: 10px;
} }
</style> </style>