redeem code function is ready

This commit is contained in:
RockYang
2024-08-09 18:19:51 +08:00
parent c77843424b
commit 67c7132e6b
18 changed files with 979 additions and 123 deletions

View File

@@ -1,8 +1,7 @@
<template>
<div>
<textarea v-model="value"/>
{{data}}
</div>
<svg ref="svgRef"/>
</template>
<script setup>
@@ -10,34 +9,16 @@ import {ref, onMounted, onUpdated} from 'vue';
import {Markmap} from 'markmap-view';
import {loadJS, loadCSS} from 'markmap-common';
import {Transformer} from 'markmap-lib';
import {httpPost} from "@/utils/http";
const transformer = new Transformer();
const {scripts, styles} = transformer.getAssets();
loadCSS(styles);
loadJS(scripts);
const initValue = `# markmap
- beautiful
- useful
- easy
- interactive
`;
const value = ref(initValue);
const svgRef = ref(null);
let mm;
const update = () => {
const {root} = transformer.transform(value.value);
mm.setData(root);
mm.fit();
};
onMounted(() => {
mm = Markmap.create(svgRef.value);
update();
});
onUpdated(update);
const data=ref("")
httpPost("/api/test/sse",{
"message":"你是什么模型",
"user_id":123
}).then(res=>{
// const source = new EventSource("http://localhost:5678/api/test/sse");
// source.onmessage = function(event) {
// console.log(event.data)
// };
})
</script>