@shijiu/jsview-vue 2.1.25 → 2.1.200
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/utils/JsViewEngineWidget/JsvFocusBlock.vue +1 -1
- package/utils/JsViewEngineWidget/JsvFocusHub.ts +123 -0
- package/utils/JsViewEngineWidget/JsvFocusManager.js +4 -3
- package/utils/JsViewEngineWidget/MetroWidget/AnimationManager.ts +145 -51
- package/utils/JsViewEngineWidget/MetroWidget/ListWidget.vue +51 -64
- package/utils/JsViewEngineWidget/MetroWidget/MetroWidget.vue +62 -71
- package/utils/JsViewEngineWidget/MetroWidget/MetroWidgetSetup.js +308 -613
- package/utils/JsViewEngineWidget/TemplateParser/CommonMetroTemplate.ts +127 -247
- package/utils/JsViewEngineWidget/TemplateParser/ListMetroTemplate.ts +1 -0
- package/utils/JsViewEngineWidget/TemplateParser/MetroTemplate.ts +36 -2
- package/utils/JsViewEngineWidget/WidgetCommon.ts +25 -6
- package/utils/JsViewPlugin/JsvAudio/{JsvAudioBrowser.vue → BrowserAudio/BrowserAudio.vue} +1 -1
- package/utils/JsViewPlugin/JsvAudio/index.js +1 -1
- package/utils/JsViewPlugin/JsvLatex/BrowserDomBuilder.js +37 -0
- package/utils/JsViewPlugin/JsvLatex/Color.ts +43 -0
- package/utils/JsViewPlugin/JsvLatex/JsvLatex.vue +159 -0
- package/utils/JsViewPlugin/JsvLatex/JsvLatexBridgeProxy.js +16 -0
- package/utils/JsViewPlugin/JsvLatex/JsvLatexBrowser.vue +59 -0
- package/utils/JsViewPlugin/JsvLatex/PluginLoader.js +171 -0
- package/utils/JsViewPlugin/JsvLatex/index.js +28 -0
- package/utils/JsViewPlugin/JsvLatex/mathjax-tex-svg.txt +1 -0
- package/utils/JsViewPlugin/JsvLatex/version.js +24 -0
- package/utils/JsViewPlugin/JsvLatex/version.mjs +24 -0
- package/utils/JsViewPlugin/index.js +2 -1
- package/utils/JsViewVueTools/JsvDynamicCssStyle.js +2 -52
- package/utils/JsViewVueTools/JsvPerformance.ts +11 -0
- package/utils/JsViewVueTools/JsvPreDownloader.ts +55 -11
- package/utils/JsViewVueTools/JsvStyleSheetsDeclarer.js +40 -0
- package/utils/JsViewVueTools/JsvTextureStore/CanvasTexture/CanvasTexture.ts +143 -0
- package/utils/JsViewVueTools/JsvTextureStore/CanvasTexture/CommandList.ts +24 -0
- package/utils/JsViewVueTools/JsvTextureStore/CanvasTexture/Path.ts +198 -0
- package/utils/JsViewVueTools/JsvTextureStore/JsvTextureStore.ts +31 -0
- package/utils/JsViewVueTools/JsvTextureStore/Store.ts +32 -0
- package/utils/JsViewVueTools/JsvTextureStore/Texture.ts +38 -0
- package/utils/JsViewVueTools/index.js +3 -0
- package/utils/JsViewVueWidget/JsvEnableRenderBreak.vue +17 -0
- package/utils/JsViewVueWidget/JsvFreeMoveActor/ActionRefObject.ts +6 -0
- package/utils/JsViewVueWidget/JsvFreeMoveActor/ActorControl.ts +144 -0
- package/utils/JsViewVueWidget/JsvFreeMoveActor/ActorState.ts +6 -0
- package/utils/JsViewVueWidget/JsvFreeMoveActor/{CallbackManager.js → CallbackManager.ts} +19 -10
- package/utils/JsViewVueWidget/JsvFreeMoveActor/ForgeTypeDefine.ts +45 -0
- package/utils/JsViewVueWidget/JsvFreeMoveActor/FreeMoveActor.vue +1 -1
- package/utils/JsViewVueWidget/JsvFreeMoveActor/JsvEnvBlocker.vue +124 -0
- package/utils/JsViewVueWidget/JsvFreeMoveActor/KeepFlags.ts +6 -0
- package/utils/JsViewVueWidget/JsvFreeMoveActor/SetAction.ts +553 -0
- package/utils/JsViewVueWidget/JsvFreeMoveActor/SetCondition.ts +138 -0
- package/utils/JsViewVueWidget/JsvFreeMoveActor/SetState.ts +53 -0
- package/utils/JsViewVueWidget/JsvFreeMoveActor/index.js +11 -1
- package/utils/JsViewVueWidget/JsvHole.js +1 -1
- package/utils/JsViewVueWidget/JsvLine/JsvLine.vue +101 -0
- package/utils/JsViewVueWidget/JsvLine/LineManager.js +62 -0
- package/utils/JsViewVueWidget/JsvLine/index.js +3 -0
- package/utils/JsViewVueWidget/JsvMarquee.vue +316 -139
- package/utils/JsViewVueWidget/JsvMindMap/CommonType.ts +1 -0
- package/utils/JsViewVueWidget/JsvMindMap/Constant.ts +20 -0
- package/utils/JsViewVueWidget/JsvMindMap/DataTree.ts +394 -0
- package/utils/JsViewVueWidget/JsvMindMap/Geometry.ts +277 -0
- package/utils/JsViewVueWidget/JsvMindMap/JsvMindMap.vue +653 -0
- package/utils/JsViewVueWidget/JsvMindMap/index.js +1 -0
- package/utils/JsViewVueWidget/JsvMindMap/rtree.js +628 -0
- package/utils/JsViewVueWidget/JsvNinePatch.vue +2 -2
- package/utils/JsViewVueWidget/JsvPieChart.vue +124 -0
- package/utils/JsViewVueWidget/JsvPosterImage.vue +32 -9
- package/utils/JsViewVueWidget/JsvPreload/BrowserPreload.vue +135 -133
- package/utils/JsViewVueWidget/JsvPreload/JsvPreload.vue +273 -270
- package/utils/JsViewVueWidget/JsvSector.vue +107 -0
- package/utils/JsViewVueWidget/JsvTextBox.vue +14 -1
- package/utils/JsViewVueWidget/JsvTextureAnim/JsvTextureAnim.vue +28 -2
- package/utils/JsViewVueWidget/JsvVisibleSensor/JsvVisibleSensor.vue +122 -93
- package/utils/JsViewVueWidget/index.js +15 -7
- package/utils/JsViewVueWidget/JsvFreeMoveActor/ActorControl.js +0 -112
- package/utils/JsViewVueWidget/JsvFreeMoveActor/CommonTools.js +0 -18
- package/utils/JsViewVueWidget/JsvFreeMoveActor/SetAction.js +0 -216
- package/utils/JsViewVueWidget/JsvFreeMoveActor/SetCondition.js +0 -66
- package/utils/JsViewVueWidget/JsvFreeMoveActor/SetState.js +0 -38
- package/utils/JsViewVueWidget/JsvFreeMoveActor/TypeDefine.js +0 -12
- package/utils/JsViewVueWidget/JsvTouchContainer.vue +0 -183
- package/utils/JsViewVueWidget/JsvTransparentDiv.vue +0 -87
- /package/utils/{JsViewVueWidget → JsViewPlugin/JsvAudio/BrowserAudio}/JsvSystemAudio.vue +0 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export const getHtmlStr = (libPath, latexStr, fontSize, width, height, color) => {
|
|
2
|
+
return (
|
|
3
|
+
`<html>
|
|
4
|
+
<head>
|
|
5
|
+
<script type="text/javascript">
|
|
6
|
+
MathJax = {
|
|
7
|
+
tex: {
|
|
8
|
+
inlineMath: [['$', '$'], ['\\(', '\\)']]
|
|
9
|
+
},
|
|
10
|
+
svg: {
|
|
11
|
+
fontCache: 'global'
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
function bodyOnLoad() {
|
|
15
|
+
let divElement = document.createElement("div");
|
|
16
|
+
divElement.style.display = "inline-block";
|
|
17
|
+
divElement.style.fontSize = "${fontSize}px";
|
|
18
|
+
divElement.style.color = "${color}";
|
|
19
|
+
divElement.innerHTML = String.raw\`$$${latexStr}$$\`;
|
|
20
|
+
document.body.appendChild(divElement);
|
|
21
|
+
|
|
22
|
+
MathJax.typesetPromise().then(() => {
|
|
23
|
+
// modify the DOM here
|
|
24
|
+
let formulaMetrics = MathJax.getMetricsFor(divElement, true);
|
|
25
|
+
let scale = ${width} / divElement.clientWidth;
|
|
26
|
+
divElement.style.fontSize = Math.floor(scale * ${fontSize}) + "px";
|
|
27
|
+
MathJax.typeset();
|
|
28
|
+
}).catch((err) => console.error(err.message));
|
|
29
|
+
}
|
|
30
|
+
</script>
|
|
31
|
+
<script type="text/javascript" src="${libPath}"></script>
|
|
32
|
+
</head>
|
|
33
|
+
<body onload="bodyOnLoad()">
|
|
34
|
+
</body>
|
|
35
|
+
</html>`
|
|
36
|
+
)
|
|
37
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export const cssColor2Android = (cssColor: string): number => {
|
|
2
|
+
let validColor = false;
|
|
3
|
+
if (typeof cssColor == "string" && cssColor[0] == "#") {
|
|
4
|
+
const numberStr: string = cssColor.slice(1);
|
|
5
|
+
if (numberStr.length == 3) {
|
|
6
|
+
//rgb
|
|
7
|
+
try {
|
|
8
|
+
const colorNumber = parseInt(numberStr, 16);
|
|
9
|
+
validColor = true;
|
|
10
|
+
let red = ((colorNumber >> 8) & 0xF) * 17;
|
|
11
|
+
let green = ((colorNumber >> 4) & 0xF) * 17;
|
|
12
|
+
let blue = (colorNumber & 0xF) * 17;
|
|
13
|
+
return (0xff << 24) | (red << 16) | (green << 8) | blue;
|
|
14
|
+
} catch(e) {}
|
|
15
|
+
} else if (numberStr.length == 6) {
|
|
16
|
+
//rrggbb
|
|
17
|
+
try {
|
|
18
|
+
const colorNumber = parseInt(numberStr, 16);
|
|
19
|
+
validColor = true;
|
|
20
|
+
let red = (colorNumber >> 16) & 0xFF;
|
|
21
|
+
let green = (colorNumber >> 8) & 0xFF;
|
|
22
|
+
let blue = colorNumber & 0xFF;
|
|
23
|
+
return (0xff << 24) | (red << 16) | (green << 8) | blue;
|
|
24
|
+
} catch(e) {}
|
|
25
|
+
} else if (numberStr.length == 8) {
|
|
26
|
+
//rrggbbaa
|
|
27
|
+
try {
|
|
28
|
+
const colorNumber = parseInt(numberStr, 16);
|
|
29
|
+
validColor = true;
|
|
30
|
+
let red = (colorNumber >> 24) & 0xFF;
|
|
31
|
+
let green = (colorNumber >> 16) & 0xFF;
|
|
32
|
+
let blue = (colorNumber >> 8) & 0xFF;
|
|
33
|
+
let alpha = colorNumber & 0xFF;
|
|
34
|
+
// 将通道重新组合成ARGB颜色值
|
|
35
|
+
return (alpha << 24) | (red << 16) | (green << 8) | blue;
|
|
36
|
+
} catch (e) {}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (!validColor) {
|
|
40
|
+
console.error(new Error("invalid color " + cssColor));
|
|
41
|
+
}
|
|
42
|
+
return 0;
|
|
43
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Author: ChenChanghua
|
|
3
|
+
* @Date: 2023-11-15 16:08:58
|
|
4
|
+
* @Description: file content
|
|
5
|
+
-->
|
|
6
|
+
|
|
7
|
+
<!--
|
|
8
|
+
[界面概述]
|
|
9
|
+
思维导图控件
|
|
10
|
+
|
|
11
|
+
[控件介绍]
|
|
12
|
+
JsvLatex:
|
|
13
|
+
props:
|
|
14
|
+
latexStr: {string} latex公式
|
|
15
|
+
fontSize: {function} 字号
|
|
16
|
+
left: {number} left
|
|
17
|
+
top: {number} top
|
|
18
|
+
width: {number} width
|
|
19
|
+
height: {number} height
|
|
20
|
+
lineSpace: {number} 行距
|
|
21
|
+
color: {string} 文字颜色
|
|
22
|
+
-->
|
|
23
|
+
<script setup>
|
|
24
|
+
import { onBeforeUnmount, ref } from "vue";
|
|
25
|
+
import { Forge } from "@shijiu/jsview/dom/jsv-forge-define";
|
|
26
|
+
import ForgeHandles from "../../JsViewVueTools/ForgeHandles";
|
|
27
|
+
import JsvLatexBridgeProxy from "./JsvLatexBridgeProxy";
|
|
28
|
+
import { cssColor2Android } from "./Color";
|
|
29
|
+
import sPluginLoader from "./PluginLoader";
|
|
30
|
+
|
|
31
|
+
const props = defineProps({
|
|
32
|
+
latexStr: {
|
|
33
|
+
type: String,
|
|
34
|
+
required: true,
|
|
35
|
+
},
|
|
36
|
+
width: {
|
|
37
|
+
type: Number,
|
|
38
|
+
required: true,
|
|
39
|
+
},
|
|
40
|
+
height: {
|
|
41
|
+
type: Number,
|
|
42
|
+
default: 0,
|
|
43
|
+
},
|
|
44
|
+
fontSize: {
|
|
45
|
+
type: Number,
|
|
46
|
+
default: 25,
|
|
47
|
+
},
|
|
48
|
+
lineSpace: {
|
|
49
|
+
type: Number,
|
|
50
|
+
default: 10,
|
|
51
|
+
},
|
|
52
|
+
color: {
|
|
53
|
+
type: String,
|
|
54
|
+
default: "#FFFFFF",
|
|
55
|
+
},
|
|
56
|
+
left: {
|
|
57
|
+
type: Number,
|
|
58
|
+
default: 0,
|
|
59
|
+
},
|
|
60
|
+
top: {
|
|
61
|
+
type: Number,
|
|
62
|
+
default: 0,
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const show = ref(false);
|
|
67
|
+
let innerViewId = -1;
|
|
68
|
+
let clientWidth = props.width;
|
|
69
|
+
let clientHeight = props.height;
|
|
70
|
+
|
|
71
|
+
const getClientSize = () => {
|
|
72
|
+
return {
|
|
73
|
+
width: clientWidth,
|
|
74
|
+
height: clientHeight,
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
const showView = () => {
|
|
78
|
+
show.value = true;
|
|
79
|
+
/**
|
|
80
|
+
* setting格式
|
|
81
|
+
* {
|
|
82
|
+
* libRootPath: string,
|
|
83
|
+
* width: number,
|
|
84
|
+
* textSize: number,
|
|
85
|
+
* lineSpace: number,
|
|
86
|
+
* latexStr: string,
|
|
87
|
+
* color: string,
|
|
88
|
+
* colorSpace?: string,
|
|
89
|
+
* }
|
|
90
|
+
*/
|
|
91
|
+
const textureManager = ForgeHandles.TextureManager;
|
|
92
|
+
const pluginTexture = textureManager.GetPluginTexture(
|
|
93
|
+
"latexPlugin",
|
|
94
|
+
JSON.stringify({
|
|
95
|
+
libRootPath: JsvLatexBridgeProxy.GetLibPath(),
|
|
96
|
+
latexStr: props.latexStr,
|
|
97
|
+
width: props.width,
|
|
98
|
+
textSize: props.fontSize,
|
|
99
|
+
lineSpace: props.lineSpace,
|
|
100
|
+
color: cssColor2Android(props.color),
|
|
101
|
+
})
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
pluginTexture.RegisterLoadImageCallback(null, (data) => {
|
|
105
|
+
tryUpdateClientSize(data.width, data.height);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const tryUpdateClientSize = (textureW, textureH) => {
|
|
109
|
+
if (props.width != 0 && props.height == 0) {
|
|
110
|
+
clientHeight = Math.round(props.width * (textureH / textureW));
|
|
111
|
+
} else if (props.height != 0 && props.width == 0) {
|
|
112
|
+
clientWidth = Math.round(props.height * (textureW / textureH));
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
let layoutView = new Forge.LayoutView(
|
|
117
|
+
new Forge.TextureSetting(pluginTexture)
|
|
118
|
+
);
|
|
119
|
+
layoutView.EnableAutoSize();
|
|
120
|
+
innerViewId = Forge.sViewStore.add(new Forge.ViewInfo(layoutView));
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const loadInfo = sPluginLoader.getLoadInfo();
|
|
124
|
+
if (loadInfo.done) {
|
|
125
|
+
if (loadInfo.succeed) {
|
|
126
|
+
showView();
|
|
127
|
+
}
|
|
128
|
+
} else {
|
|
129
|
+
//注册回调
|
|
130
|
+
sPluginLoader.registerOnDoneListener((status) => {
|
|
131
|
+
if (status != null) {
|
|
132
|
+
showView();
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
onBeforeUnmount(() => {
|
|
137
|
+
if (innerViewId !== -1) {
|
|
138
|
+
Forge.sViewStore.remove(innerViewId);
|
|
139
|
+
innerViewId = -1;
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
defineExpose({
|
|
144
|
+
getClientSize,
|
|
145
|
+
});
|
|
146
|
+
</script>
|
|
147
|
+
|
|
148
|
+
<template>
|
|
149
|
+
<div
|
|
150
|
+
v-if="show"
|
|
151
|
+
:data-jsv-vw-innerview="innerViewId"
|
|
152
|
+
:style="{
|
|
153
|
+
left: left,
|
|
154
|
+
top: top,
|
|
155
|
+
width: width,
|
|
156
|
+
height: height,
|
|
157
|
+
}"
|
|
158
|
+
></div>
|
|
159
|
+
</template>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: ChenChanghua
|
|
3
|
+
* @Date: 2023-02-23 10:06:08
|
|
4
|
+
* @Description: file content
|
|
5
|
+
*/
|
|
6
|
+
export default class {
|
|
7
|
+
static GetLibPath() {
|
|
8
|
+
if (typeof window.jsvLatexBridge != "undefined"
|
|
9
|
+
&& typeof window.jsvLatexBridge.GetLibPath != "undefined") {
|
|
10
|
+
return window.jsvLatexBridge.GetLibPath();
|
|
11
|
+
} else {
|
|
12
|
+
console.error("widnow.jsvLatexBridge doesn't exist.")
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
// import "./mathjax-tex-svg.js";
|
|
3
|
+
import { Forge } from "@shijiu/jsview/dom/jsv-forge-define";
|
|
4
|
+
import { ref, onMounted } from "vue";
|
|
5
|
+
import { getHtmlStr } from "./BrowserDomBuilder.js";
|
|
6
|
+
import libPath from "./mathjax-tex-svg.txt";
|
|
7
|
+
|
|
8
|
+
const props = defineProps({
|
|
9
|
+
latexStr: {
|
|
10
|
+
type: String,
|
|
11
|
+
required: true,
|
|
12
|
+
},
|
|
13
|
+
width: {
|
|
14
|
+
type: Number,
|
|
15
|
+
required: true,
|
|
16
|
+
},
|
|
17
|
+
height: {
|
|
18
|
+
type: Number,
|
|
19
|
+
default: 0,
|
|
20
|
+
},
|
|
21
|
+
fontSize: {
|
|
22
|
+
type: Number,
|
|
23
|
+
default: 25,
|
|
24
|
+
},
|
|
25
|
+
lineSpace: {
|
|
26
|
+
type: Number,
|
|
27
|
+
default: 10,
|
|
28
|
+
},
|
|
29
|
+
color: {
|
|
30
|
+
type: String,
|
|
31
|
+
default: "#FFFFFF",
|
|
32
|
+
},
|
|
33
|
+
left: {
|
|
34
|
+
type: Number,
|
|
35
|
+
default: 0,
|
|
36
|
+
},
|
|
37
|
+
top: {
|
|
38
|
+
type: Number,
|
|
39
|
+
default: 0,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
let layoutView = new Forge.IFrameView();
|
|
44
|
+
|
|
45
|
+
layoutView.SetIframeSize(props.width, props.height);
|
|
46
|
+
layoutView.SetInnerHtml(getHtmlStr(libPath, props.latexStr, props.fontSize, props.width, props.height, props.color));
|
|
47
|
+
let innerViewId = Forge.sViewStore.add(new Forge.ViewInfo(layoutView));
|
|
48
|
+
</script>
|
|
49
|
+
<template>
|
|
50
|
+
<div
|
|
51
|
+
:data-jsv-vw-innerview="innerViewId"
|
|
52
|
+
:style="{
|
|
53
|
+
left: left,
|
|
54
|
+
top: top,
|
|
55
|
+
width: width,
|
|
56
|
+
height: height,
|
|
57
|
+
}"
|
|
58
|
+
></div>
|
|
59
|
+
</template>
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: ChenChanghua
|
|
3
|
+
* @Date: 2023-02-27 20:04:28
|
|
4
|
+
* @Description: file content
|
|
5
|
+
*/
|
|
6
|
+
import PluginInfo from './version';
|
|
7
|
+
import jsvLatexBridge from "./JsvLatexBridgeProxy"
|
|
8
|
+
|
|
9
|
+
class PluginLoader {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.onDoneListener = [];
|
|
12
|
+
this.pluginLoadListener = [];
|
|
13
|
+
this.pluginInfo = this.getPluginInfo();
|
|
14
|
+
this.loadDone = false;
|
|
15
|
+
this.loadSucceed = false;
|
|
16
|
+
/**
|
|
17
|
+
* 0:未加载;
|
|
18
|
+
* 1:开始加载;
|
|
19
|
+
* 2:加载旧插件;
|
|
20
|
+
* 3:加载新插件;
|
|
21
|
+
* 4:加载成功;
|
|
22
|
+
* 5:加载失败。
|
|
23
|
+
*/
|
|
24
|
+
this.status = 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
getPluginInfo() {
|
|
28
|
+
let info = PluginInfo;
|
|
29
|
+
/** 获取下载链接 */
|
|
30
|
+
if (typeof window.jJsvRuntimeBridge !== 'undefined' && window.jJsvRuntimeBridge && typeof window.jJsvRuntimeBridge.getPluginBaseUrl !== "undefined") {
|
|
31
|
+
let plugin_base_url = window.jJsvRuntimeBridge.getPluginBaseUrl();
|
|
32
|
+
if (plugin_base_url) {
|
|
33
|
+
info.downloadUrl = (plugin_base_url[plugin_base_url.length - 1] === "/" ? plugin_base_url : (plugin_base_url + "/")) + info.packageName + "/JsvLatex-" + info.versionCodeMax + ".dat?md5=" + info.md5;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return info;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
registerOnDoneListener(listener) {
|
|
40
|
+
if (listener) {
|
|
41
|
+
this.onDoneListener.push(listener);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
getLoadInfo() {
|
|
46
|
+
return {
|
|
47
|
+
done: this.loadDone,
|
|
48
|
+
succeed: this.loadSucceed,
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* listener回调处理中参数信息的说明:
|
|
54
|
+
* 插件加载状态回调。
|
|
55
|
+
* 回调函数的参数定义如下:
|
|
56
|
+
* 1:无法正常加载插件。
|
|
57
|
+
* 2:正在加载旧插件,此时插件加载过程很短,可以不用出现用户提示界面。
|
|
58
|
+
* 3:正在加载新插件,此时插件需要经历下载、解压等过程,用时较长,可以考虑给用户相关提示。
|
|
59
|
+
* 4:插件加载完成。
|
|
60
|
+
* 5:已加载不同版本的插件,此版本无法加载。
|
|
61
|
+
*
|
|
62
|
+
* 备注:不管插件加载处于什么状态,都可以正常使用播放器组件,播放器对象在插件未加载完成的情况下,会把相关状态保存,等完成加载后再自动下发。
|
|
63
|
+
*/
|
|
64
|
+
loadPlugin(listener) {
|
|
65
|
+
console.log("globalLoadJsvLatexPlugin");
|
|
66
|
+
let plugin_status = 0;
|
|
67
|
+
if (typeof window.jPluginManagerBridge === 'undefined' || !window.jPluginManagerBridge) {
|
|
68
|
+
plugin_status = 1;
|
|
69
|
+
} else if (this.status === 2) {
|
|
70
|
+
plugin_status = 2;
|
|
71
|
+
} else if (this.status === 3) {
|
|
72
|
+
plugin_status = 3;
|
|
73
|
+
} else if (this.status === 4) {
|
|
74
|
+
plugin_status = 4;
|
|
75
|
+
} else if (this.status === 5) {
|
|
76
|
+
plugin_status = 1;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (plugin_status !== 0) {
|
|
80
|
+
if (typeof listener !== "undefined" && listener) {
|
|
81
|
+
setTimeout(() => { listener(plugin_status) }, 0);
|
|
82
|
+
}
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (typeof listener !== "undefined" && listener) {
|
|
87
|
+
this.pluginLoadListener.push(listener);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (this.status > 0) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
this.status = 1;
|
|
94
|
+
|
|
95
|
+
window.jPluginManagerBridge.LoadPlugin(JSON.stringify(this.pluginInfo));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
onStatusChange(status) {
|
|
99
|
+
console.log("JsvLatexPluginStatus: " + status);
|
|
100
|
+
let ret = JSON.parse(status);
|
|
101
|
+
|
|
102
|
+
let plugin_status = 2;
|
|
103
|
+
if (ret && ret.first_load) {
|
|
104
|
+
this.status = 3;
|
|
105
|
+
plugin_status = 3;
|
|
106
|
+
} else {
|
|
107
|
+
this.status = 2;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
for (let i = 0; i < this.pluginLoadListener.length; i++) {
|
|
111
|
+
this.pluginLoadListener[i](plugin_status);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
onLoadDone(result) {
|
|
118
|
+
console.log("JsvLatexPluginLoadResult: " + result);
|
|
119
|
+
this.loadDone = true;
|
|
120
|
+
let ret_obj = JSON.parse(result)
|
|
121
|
+
let plugin_status = 1;
|
|
122
|
+
if (ret_obj && (ret_obj.status === 4 || ret_obj.status === 1)) {
|
|
123
|
+
this.status = 4;
|
|
124
|
+
plugin_status = 4;
|
|
125
|
+
} else if (ret_obj && ret_obj.status === -12) {
|
|
126
|
+
this.status = 5;
|
|
127
|
+
plugin_status = 5;
|
|
128
|
+
} else {
|
|
129
|
+
this.status = 5;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (this.status === 5) {
|
|
133
|
+
this.loadSucceed = false;
|
|
134
|
+
console.log("*************************JsvLatex plugin load failed, error code is " + ret_obj.status + "*************************");
|
|
135
|
+
} else {
|
|
136
|
+
this.loadSucceed = true;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
//往forge设置latex库的path
|
|
140
|
+
if (window.JsView) {
|
|
141
|
+
const libPath = jsvLatexBridge.GetLibPath();
|
|
142
|
+
console.log("JsvLatex libPath", libPath);
|
|
143
|
+
if (libPath) {
|
|
144
|
+
window.JsView.loadRenderPlugin?.(
|
|
145
|
+
"latexPlugin",
|
|
146
|
+
"com.qcode.latexlib.Main",
|
|
147
|
+
libPath,
|
|
148
|
+
);
|
|
149
|
+
} else {
|
|
150
|
+
console.error("JsvLatexPlugin error: get libPath failed.")
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
for (let i = 0; i < this.pluginLoadListener.length; i++) {
|
|
155
|
+
this.pluginLoadListener[i](plugin_status);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
for (let listener of this.onDoneListener) {
|
|
159
|
+
listener(plugin_status);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
registerGlobalListener() {
|
|
164
|
+
window.top.JsvLatexPluginStatus = this.onStatusChange.bind(this);
|
|
165
|
+
window.top.JsvLatexPluginLoadResult = this.onLoadDone.bind(this);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const sPluginLoader = new PluginLoader();
|
|
170
|
+
sPluginLoader.registerGlobalListener();
|
|
171
|
+
export default sPluginLoader;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: ChenChanghua
|
|
3
|
+
* @Date: 2023-02-28 10:18:42
|
|
4
|
+
* @Description: file content
|
|
5
|
+
*/
|
|
6
|
+
import sPluginLoader from "./PluginLoader.js";
|
|
7
|
+
import JsvLatex from "./JsvLatex.vue"
|
|
8
|
+
|
|
9
|
+
let globalLoadJsvLatexPlugin;
|
|
10
|
+
let _JsvLatex;
|
|
11
|
+
|
|
12
|
+
if (!window.JsView) {
|
|
13
|
+
const BrowserJsvLatex = await import("./JsvLatexBrowser.vue");
|
|
14
|
+
//browser
|
|
15
|
+
globalLoadJsvLatexPlugin = (listener) => {
|
|
16
|
+
setTimeout(listener, 0);
|
|
17
|
+
};
|
|
18
|
+
_JsvLatex = BrowserJsvLatex.default;
|
|
19
|
+
} else {
|
|
20
|
+
//jsview
|
|
21
|
+
globalLoadJsvLatexPlugin = sPluginLoader.loadPlugin.bind(sPluginLoader);
|
|
22
|
+
_JsvLatex = JsvLatex;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
_JsvLatex as JsvLatex,
|
|
27
|
+
globalLoadJsvLatexPlugin,
|
|
28
|
+
}
|