From 621b71bb1cc0dc383db1e4b89c9413bb9925b231 Mon Sep 17 00:00:00 2001 From: litian <2804272236@qq.com> Date: 星期三, 20 十一月 2024 16:54:32 +0800 Subject: [PATCH] Merge branch 'master' of http://182.92.203.7:2001/r/TextbookReader --- src/views/components/formula.vue | 61 ++++++++++++++++++++++++++++++ 1 files changed, 61 insertions(+), 0 deletions(-) diff --git a/src/views/components/formula.vue b/src/views/components/formula.vue new file mode 100644 index 0000000..fabe76d --- /dev/null +++ b/src/views/components/formula.vue @@ -0,0 +1,61 @@ +<template> + <div> + <h2>鎵嬪啓璇嗗埆</h2> + <div class="box" style="width: 100%;height: 400px;"> + <graffiti :save="save" /> + </div> + <div> + <p>璇嗗埆缁撴灉锛�</p> + + <div id="showData"> + <vue-latex :expression="content" display-mode /> + </div> + </div> + <h2>鍏紡杈撳叆</h2> + <math-field class="mathField" @input="handleInput" :menuItems="[]">{{valueData}}</math-field> + </div> +</template> + +<script setup lang="ts"> + import { ref, nextTick, reactive, watch, onMounted, onBeforeMount, onBeforeUnmount, inject } from 'vue' + import { MathfieldElement } from "mathlive" + import graffiti from '@/components/graffiti/index.vue' + const commonsVariable: any = inject('commonsVariable') + const MG: any = inject('MG') + const valueData = ref("f(x) = \\frac{x}{2}") + const handleInput = (data) => { + console.log(data.target.value); + } + + + + const content = ref('') + const save = (data) => { + console.log(data.split(",")[1]); + MG.app + .getLatexFormulaFromImage({ + base64Jpg: data.split(",")[1] + }) + .then((res: any) => { + content.value = res; + nextTick(() => { + + }) + }) + } + +</script> + +<style lang="less"> + .mathField { + width: 500px; + margin-top: 10px; + } + + #showData { + border: 1px solid #ccc; + padding: 20px; + margin-top: 10px; + margin-bottom: 50px; + } +</style> \ No newline at end of file -- Gitblit v1.9.1