litian
2024-11-20 621b71bb1cc0dc383db1e4b89c9413bb9925b231
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<template>
    <div ref="ggbContainer" class="ggb-container"></div>
</template>
 
<script lang="ts">
import { defineComponent, onMounted, ref } from 'vue';
export default defineComponent({
    name: 'GeoGebraCalculator',
    setup() {
        const ggbContainer = ref<HTMLDivElement | null>(null);
 
        onMounted(() => {
            if (!window.GGBApplet) {
                const script = document.createElement('script');
                script.src = 'https://www.geogebra.org/apps/deployggb.js';
                script.onload = () => {
                    initGeoGebra();
                };
                document.body.appendChild(script);
            } else {
                initGeoGebra();
            }
 
            function initGeoGebra() {
                var params = {
                    "id": "ggbApplet",
                    "appName": "scientific",
                    "width": 800,
                    "height": 800,
                    "showToolBar": true,
                    "borderColor": null,
                    "showMenuBar": true,
                    "allowStyleBar": true,
                    "showAlgebraInput": true,
                    "enableLabelDrags": false,
                    "enableShiftDragZoom": true,
                    "capturingThreshold": null,
                    "showToolBarHelp": false,
                    "errorDialogsActive": true,
                    "showTutorialLink": true,
                    "showLogging": true,
                    "useBrowserForJS": false
                };
 
                if (ggbContainer.value) {
                    const applet = new GGBApplet(params, true);
                    applet.inject(ggbContainer.value);
                }
            }
        });
 
        return {
            ggbContainer,
        };
    },
});
</script>
 
<style scoped>
.ggb-container {
    width: 100%;
    height: 100%;
    /* 其他样式 */
}
</style>