|
|
|
@ -46,12 +46,13 @@
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
<script setup>
|
|
|
|
<script setup>
|
|
|
|
import { MdPreview, MdCatalog } from "md-editor-v3";
|
|
|
|
import { MdPreview, MdCatalog } from "md-editor-v3";
|
|
|
|
|
|
|
|
import { getToken,getUserInfo } from '@/utils/auth'
|
|
|
|
|
|
|
|
import useUserStore from "@/store/modules/user";
|
|
|
|
import "md-editor-v3/lib/preview.css";
|
|
|
|
import "md-editor-v3/lib/preview.css";
|
|
|
|
import * as AI from "@/api/AI.js";
|
|
|
|
import * as AI from "@/api/AI.js";
|
|
|
|
import { marked } from "marked";
|
|
|
|
|
|
|
|
import "highlight.js/lib/common";
|
|
|
|
|
|
|
|
import hljs from "highlight.js";
|
|
|
|
|
|
|
|
import { getAssetsFile } from "@/utils/index.js";
|
|
|
|
import { getAssetsFile } from "@/utils/index.js";
|
|
|
|
|
|
|
|
import { computed, onMounted } from "vue";
|
|
|
|
|
|
|
|
const userStore = useUserStore();
|
|
|
|
const input = ref("");
|
|
|
|
const input = ref("");
|
|
|
|
const butFlag = ref(false);
|
|
|
|
const butFlag = ref(false);
|
|
|
|
const messages = reactive([]);
|
|
|
|
const messages = reactive([]);
|
|
|
|
@ -98,6 +99,9 @@ const sendExample = (item) => {
|
|
|
|
input.value = item.text;
|
|
|
|
input.value = item.text;
|
|
|
|
sendText();
|
|
|
|
sendText();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const aiUserid=computed(()=>{
|
|
|
|
|
|
|
|
return getUserInfo() ? JSON.parse(getUserInfo()) : "";
|
|
|
|
|
|
|
|
})
|
|
|
|
const sendText = async () => {
|
|
|
|
const sendText = async () => {
|
|
|
|
if (input.value.trim() === "" || isRequestPending.value) return;
|
|
|
|
if (input.value.trim() === "" || isRequestPending.value) return;
|
|
|
|
if (input.value.trim() === "") return;
|
|
|
|
if (input.value.trim() === "") return;
|
|
|
|
@ -118,17 +122,17 @@ const sendText = async () => {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
name: "",
|
|
|
|
name: "",
|
|
|
|
role: "user",
|
|
|
|
role: "user",
|
|
|
|
userId: "512",
|
|
|
|
userId: aiUserid.value.userId,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
];
|
|
|
|
];
|
|
|
|
const messageId = Date.now();
|
|
|
|
const messageId = Date.now();
|
|
|
|
0;
|
|
|
|
|
|
|
|
const newMessage = reactive({ id: messageId, type: "ai-main", displayContent: "" });
|
|
|
|
const newMessage = reactive({ id: messageId, type: "ai-main", displayContent: "" });
|
|
|
|
messages.push(newMessage);
|
|
|
|
messages.push(newMessage);
|
|
|
|
const resp = await fetch("http://192.168.2.28:9868/api/bigModule/createArticleByAi", {
|
|
|
|
const resp = await fetch("http://118.31.7.2:9868/api/bigModule/createArticleByAi", {
|
|
|
|
method: "POST",
|
|
|
|
method: "POST",
|
|
|
|
headers: {
|
|
|
|
headers: {
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
|
|
|
Authorization: `Bearer ${getToken()}`,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
body: JSON.stringify(sendData),
|
|
|
|
body: JSON.stringify(sendData),
|
|
|
|
});
|
|
|
|
});
|
|
|
|
@ -174,7 +178,7 @@ const handleKeyDown = (event) => {
|
|
|
|
event.preventDefault();
|
|
|
|
event.preventDefault();
|
|
|
|
sendText();
|
|
|
|
sendText();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|