@shijiu/jsview-vue-samples 2.3.151-test.0 → 3.0.0
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/ABImageAlt/App.vue +114 -0
- package/ABImageAlt/Item.vue +133 -0
- package/{MetroWidgetDemos/SkeletonDiagram/assets/imageList.json → ABImageAlt/assets/imageList.js} +9 -1
- package/ABImageAlt/data.js +17 -0
- package/AI_Check_Rules.txt +5 -0
- package/AnimPicture/App.vue +20 -10
- package/ApicSwitch/App.vue +90 -0
- package/ApicSwitch/TabItem.vue +65 -0
- package/ApicSwitch/WebpShow.vue +24 -0
- package/ApicSwitch/data.js +50 -0
- package/Basic/AI_skills_update.md +1 -0
- package/Basic/components/div/ColorFormatTest.vue +93 -0
- package/Basic/components/div/DivRadius.vue +97 -15
- package/Basic/components/div/DivTag3Group.vue +30 -0
- package/Basic/components/img/ImageType.vue +65 -0
- package/Basic/components/panel/Panel2.vue +13 -1
- package/Basic/components/text/TextAlign.vue +7 -1
- package/BlobLoadTest/App.vue +201 -0
- package/BreakLinesApi/App.vue +82 -0
- package/CanvasDrawChart/App.vue +11 -0
- package/CanvasDrawChart/Graph1.vue +104 -0
- package/CanvasDrawChart/Graph2.vue +115 -0
- package/CssPreprocessor/Scss/PanelData.js +1 -1
- package/CssPreprocessor/Scss/components/scss-group4/ScssMaps.vue +4 -3
- package/CssPreprocessor/Scss/components/scss-group5/ScssImporting.vue +2 -2
- package/DemoForOperator/Bounce/FreeMoveBuilder.js +1 -1
- package/DemoForOperator/Firework1/App.vue +12 -1
- package/DemoForOperator/Firework1/Fireworks.vue +18 -0
- package/DemoForOperator/FlipPage/FlipPage/FlipPage.vue +1 -0
- package/DemoForOperator/Focus/Alpha/Item.vue +1 -0
- package/DemoForOperator/Focus/Light/Item.vue +1 -0
- package/DemoForOperator/Focus/Normal/Item.vue +1 -0
- package/DemoForOperator/FrameShadow/FrameShadow.vue +1 -1
- package/DemoForOperator/Genie/App.vue +20 -6
- package/DemoForOperator/Genie/App2.vue +61 -0
- package/DemoForOperator/Genie/geniePakcer/GenieImage.vue +298 -0
- package/DemoForOperator/Genie/geniePakcer/GenieSlot.vue +292 -0
- package/DemoForOperator/Genie/geniePakcer/GenieTools.ts +463 -0
- package/DemoForOperator/Jigsaw/JigsawFull.vue +12 -7
- package/DemoForOperator/Jigsaw/JigsawSingle.vue +13 -7
- package/DemoForOperator/LongChatBox/App.vue +13 -13
- package/DemoForOperator/LongChatBox/Bubble.vue +78 -66
- package/DemoForOperator/LongChatBox/LongChat.vue +68 -36
- package/DemoForOperator/LongChatBox/testData.js +7 -44
- package/DemoForOperator/Sound/Bounce/FreeMoveBuilder.js +1 -1
- package/DemoForOperator/routeList.js +8 -2
- package/DemoHomepage/App.vue +74 -1
- package/DemoHomepage/components/BodyFrame.vue +1 -0
- package/DemoHomepage/components/TabFrame.vue +1 -1
- package/DemoHomepage/router.js +723 -160
- package/DemoHomepage/views/Homepage.vue +60 -2
- package/DemoHomepage/watchTest.vue +50 -0
- package/FilterDemo/AnimatePic.vue +63 -17
- package/FilterDemo/App.vue +3 -3
- package/FlexCellDemo/AI_skills_update.md +4 -0
- package/FlexCellDemo/TestFrame1.vue +12 -2
- package/FlexCellDemo/TestFrame2.vue +10 -1
- package/FlexCellDemo/TestFrame3.vue +114 -59
- package/FpsLimit/App.vue +102 -0
- package/FreeMoveChildAttract/App.vue +18 -8
- package/FreeMoveLink/App.vue +49 -20
- package/Hover/App.vue +144 -0
- package/HttpRequestSSE/SSEReader.js +200 -0
- package/ImpactStop/App.vue +2 -2
- package/Input/FullKeyboard.vue +3 -3
- package/Input/InputPanel.vue +63 -3
- package/JsvLine/App.vue +53 -38
- package/LatexDemo/App.vue +3 -1
- package/LatexFormula/App.vue +196 -0
- package/LongImage/App.vue +1 -1
- package/LongImage/LongImageScroll.vue +100 -47
- package/LongImage/Scroll.vue +28 -9
- package/LongText/LongTextScroll.vue +1 -0
- package/Markdown/App.vue +36 -0
- package/Markdown/Bubble.vue +109 -0
- package/Markdown/LongChat.vue +206 -0
- package/Markdown/Markdown/Markdown.vue +156 -0
- package/Markdown/Markdown/index.ts +1 -0
- package/Markdown/Markdown/marked/LICENSE.md +45 -0
- package/Markdown/Markdown/marked/index.ts +2 -0
- package/Markdown/Markdown/marked/marked.d.ts +756 -0
- package/Markdown/Markdown/marked/marked.js +71 -0
- package/Markdown/Markdown/parser.ts +1365 -0
- package/Markdown/data.js +581 -0
- package/MetroWidgetDemos/AI_skills_update.md +2 -0
- package/MetroWidgetDemos/ListExpand/ChildItem.vue +130 -0
- package/MetroWidgetDemos/ListExpand/ExpandItem.vue +375 -0
- package/MetroWidgetDemos/ListExpand/ExpandItem1.vue +403 -0
- package/MetroWidgetDemos/ListExpand/assets/arrow-down.png +0 -0
- package/MetroWidgetDemos/ListExpand/assets/up-arrow.png +0 -0
- package/MetroWidgetDemos/ListExpand/components/WidgetListHandler.vue +150 -0
- package/MetroWidgetDemos/ListExpand/index.vue +88 -0
- package/MetroWidgetDemos/ListExpand/list.js +2421 -0
- package/MetroWidgetDemos/RefreshDemo/App.vue +14 -1
- package/MetroWidgetDemos/RenderAccelerate/App.vue +142 -0
- package/MetroWidgetDemos/RenderAccelerate/AppPage.vue +78 -0
- package/MetroWidgetDemos/RenderAccelerate/AppTab.vue +62 -0
- package/MetroWidgetDemos/RenderAccelerate/ContentItem.vue +409 -0
- package/MetroWidgetDemos/RenderAccelerate/Item.vue +67 -0
- package/MetroWidgetDemos/RenderAccelerate/TabItem.vue +100 -0
- package/MetroWidgetDemos/RenderAccelerate/ViewSwiper.vue +215 -0
- package/MetroWidgetDemos/RenderAccelerate/WidgetItem.vue +107 -0
- package/MetroWidgetDemos/SkeletonDiagram/App.vue +35 -8
- package/MetroWidgetDemos/SkeletonDiagram/Item.vue +11 -2
- package/MetroWidgetDemos/SkeletonDiagram/assets/imageList.js +245 -0
- package/MetroWidgetDemos/SkeletonDiagram/data.js +3 -3
- package/MetroWidgetDemos/SpatialNav/App.vue +177 -0
- package/MetroWidgetDemos/SpatialNav/Buttons.vue +83 -0
- package/MetroWidgetDemos/SpatialNav/CustomFocus.vue +57 -0
- package/MetroWidgetDemos/{TripleWidget → SpatialNav}/Item.vue +1 -8
- package/MetroWidgetDemos/{TripleWidget/WidgetItem.vue → SpatialNav/SimpleFloor.vue} +14 -45
- package/MetroWidgetDemos/SpatialNav/StepMw.vue +113 -0
- package/MetroWidgetDemos/SpatialNav/TabContent/TabContent.vue +185 -0
- package/MetroWidgetDemos/SpatialNav/TripleSection/TripleSection.vue +69 -0
- package/MetroWidgetDemos/SpatialNav/TripleSection/WidgetItem.vue +100 -0
- package/MetroWidgetDemos/SpatialNav/TvSection/List.vue +75 -0
- package/MetroWidgetDemos/SpatialNav/TvSection/TvSection.vue +91 -0
- package/MetroWidgetDemos/basic2/App.vue +407 -0
- package/MetroWidgetDemos/basic2/Item.vue +68 -0
- package/MetroWidgetDemos/direction/App.vue +22 -0
- package/MetroWidgetDemos/gazeFocusDiff/App.vue +126 -0
- package/MetroWidgetDemos/gazeFocusDiff/Item.vue +87 -0
- package/MetroWidgetDemos/minimalUsage/App.vue +66 -0
- package/MetroWidgetDemos/minimalUsage/Item.vue +54 -0
- package/MetroWidgetDemos/ninePatchFocusPage/App.vue +22 -7
- package/MetroWidgetDemos/ninePatchFocusPage/Item.vue +7 -5
- package/MetroWidgetDemos/ninePatchFocusPage/focusConstants.js +2 -0
- package/MetroWidgetDemos/routeList.js +203 -12
- package/MetroWidgetDemos/slideSetting/App.vue +288 -99
- package/MetroWidgetDemos/zIndex/App.vue +117 -0
- package/MetroWidgetDemos/zIndex/Item.vue +61 -0
- package/NinePatchTester/App.vue +24 -31
- package/PreDecode/App.vue +140 -0
- package/ReactiveTest/App.vue +115 -0
- package/ReactiveTest/Item.vue +92 -0
- package/ReactiveTest/assets/imageList.js +245 -0
- package/ReactiveTest/component/TestSmartDiv.vue +50 -0
- package/ReactiveTest/component/TestSmartDivSrcList.vue +74 -0
- package/ReactiveTest/component/TestSmartImage.vue +46 -0
- package/ReactiveTest/component/TestSmartImageSrcList.vue +90 -0
- package/ReactiveTest/component/TestSmartImageStyle.vue +41 -0
- package/ReactiveTest/data.js +49 -0
- package/ScreenToBlob/App.vue +250 -0
- package/SecTorTest/App.vue +9 -3
- package/SpringFestival/SpringFestivalScene/FreeMoveBuilder.js +3 -3
- package/SyncDecode/App.vue +137 -0
- package/TextSizeLimit/App.vue +211 -0
- package/TransitPage/App.vue +2 -0
- package/assets/logo.png +0 -0
- package/package.json +5 -5
- package/DemoForOperator/Genie/geniePakcer/Genie.vue +0 -741
- package/DemoForOperator/LongChatBox/TextManager.ts +0 -147
- package/DemoForOperator/LongChatBox/VirtualList.vue +0 -298
- package/DemoForOperator/LongChatBox/utile.js +0 -331
- package/DivMetroPerformance/App.vue +0 -157
- package/DivMetroPerformance/Item.vue +0 -58
- package/DivMetroPerformance/assets/bg.jpg +0 -0
- package/DivMetroPerformance/assets/coupon_content.png +0 -0
- package/DivMetroPerformance/assets/coupon_left.png +0 -0
- package/DivMetroPerformance/assets/coupon_mid.png +0 -0
- package/DivMetroPerformance/assets/coupon_right.png +0 -0
- package/DivMetroPerformance/assets/focus_border.png +0 -0
- package/DivMetroPerformance/assets/holder_logo.png +0 -0
- package/DivMetroPerformance/assets/jrbm.png +0 -0
- package/DivMetroPerformance/assets/line_left.png +0 -0
- package/DivMetroPerformance/assets/line_mid.png +0 -0
- package/DivMetroPerformance/assets/line_right.png +0 -0
- package/DivMetroPerformance/assets/loading.png +0 -0
- package/DivMetroPerformance/assets/logo.png +0 -0
- package/DivMetroPerformance/assets/mcjx.png +0 -0
- package/DivMetroPerformance/assets/tao.png +0 -0
- package/DivMetroPerformance/assets/tmall.png +0 -0
- package/DivMetroPerformance/border.png +0 -0
- package/DivMetroPerformance/components/ContentItem.vue +0 -384
- package/DivMetroPerformance/components/MyTab.vue +0 -129
- package/DivMetroPerformance/data.js +0 -124
- package/DivMetroPerformance/utils/GridItem.vue +0 -28
- package/DivMetroPerformance/utils/GridPlate.vue +0 -85
- package/MediaDemo/App.vue +0 -127
- package/MediaDemo/assets/audio-poster.png +0 -0
- package/MediaDemo/components/Button.vue +0 -69
- package/MediaDemo/components/Controllor.vue +0 -286
- package/MediaDemo/components/StatusBar.vue +0 -100
- package/MediaDemo/components/frames/AudioFrame.vue +0 -39
- package/MediaDemo/components/frames/AudioPoster.vue +0 -48
- package/MediaDemo/components/frames/MediaFrame.vue +0 -153
- package/MediaDemo/components/frames/VideoFrame.vue +0 -39
- package/MetroWidgetDemos/TripleWidget/App.vue +0 -87
- package/MetroWidgetDemos/TripleWidget/SWidgetItem.vue +0 -99
- package/Parkour/App.vue +0 -13
- package/Parkour/Common/Context.js +0 -21
- package/Parkour/Common/MatchmanInfo.js +0 -62
- package/Parkour/Common/Random.js +0 -61
- package/Parkour/Common/Sound.js +0 -50
- package/Parkour/appConfig/HOW_TO_CONFIG.md +0 -20
- package/Parkour/appConfig/app.config.mjs +0 -5
- package/Parkour/appConfig/app_sign_private_key_sample.crt +0 -28
- package/Parkour/appConfig/app_sign_public_key_sample.pem +0 -9
- package/Parkour/appConfig/jsview.config.mjs +0 -39
- package/Parkour/assets/Bgimages/bg1.png +0 -0
- package/Parkour/assets/Bgimages/bg2.png +0 -0
- package/Parkour/assets/Bgimages/bg3.png +0 -0
- package/Parkour/assets/Bgimages/bg4.png +0 -0
- package/Parkour/assets/Bgimages/bg5.png +0 -0
- package/Parkour/assets/audio/jump.mp3 +0 -0
- package/Parkour/assets/audio/lose.mp3 +0 -0
- package/Parkour/assets/role_skin1/fail.json +0 -44
- package/Parkour/assets/role_skin1/fail.png +0 -0
- package/Parkour/assets/role_skin1/jump_down.json +0 -20
- package/Parkour/assets/role_skin1/jump_down.png +0 -0
- package/Parkour/assets/role_skin1/jump_up.json +0 -44
- package/Parkour/assets/role_skin1/jump_up.png +0 -0
- package/Parkour/assets/role_skin1/roll.json +0 -44
- package/Parkour/assets/role_skin1/roll.png +0 -0
- package/Parkour/assets/role_skin1/run.json +0 -52
- package/Parkour/assets/role_skin1/run.png +0 -0
- package/Parkour/components/Backdrop.vue +0 -61
- package/Parkour/components/GameSence.vue +0 -602
- package/Parkour/components/Matchman.vue +0 -85
- package/ThrowMoveDemo/AccelerateDemo.vue +0 -85
- package/ThrowMoveDemo/App.vue +0 -104
- package/ThrowMoveDemo/LRParabolicDemo.vue +0 -101
- package/ThrowMoveDemo/TargetDemo.vue +0 -87
- package/ThrowMoveDemo/UDParabolicDemo.vue +0 -92
- /package/{AnimPicture/assets → assets}/animated_webp.webp +0 -0
- /package/{AnimPicture/assets → assets}/ball_3.webp +0 -0
- /package/{AnimPicture/assets → assets}/girl_run.gif +0 -0
- /package/{AnimPicture/assets → assets}/quan.webp +0 -0
package/Markdown/App.vue
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import LongChat from "./LongChat.vue";
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<template>
|
|
6
|
+
<div
|
|
7
|
+
:style="{
|
|
8
|
+
width: 1280,
|
|
9
|
+
height: 720,
|
|
10
|
+
backgroundColor: '#666',
|
|
11
|
+
}"
|
|
12
|
+
>
|
|
13
|
+
<div :style="{
|
|
14
|
+
width: 1280,
|
|
15
|
+
height: 30,
|
|
16
|
+
left: 50,
|
|
17
|
+
top: 10,
|
|
18
|
+
backgroundColor: '#666',
|
|
19
|
+
fontSize: 20,
|
|
20
|
+
color: '#fff',
|
|
21
|
+
}">
|
|
22
|
+
按ok键添加对话框,按上下键滚动
|
|
23
|
+
</div>
|
|
24
|
+
<div
|
|
25
|
+
:style="{
|
|
26
|
+
top: 70,
|
|
27
|
+
left: 50,
|
|
28
|
+
width: 1280,
|
|
29
|
+
height: 600,
|
|
30
|
+
overflow: 'hidden',
|
|
31
|
+
}"
|
|
32
|
+
>
|
|
33
|
+
<LongChat />
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
</template>
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:style="{
|
|
4
|
+
top: -markdownTop,
|
|
5
|
+
width: visibleRect.width,
|
|
6
|
+
height: markdownHeight,
|
|
7
|
+
backgroundColor: backgroundColor,
|
|
8
|
+
}"
|
|
9
|
+
></div>
|
|
10
|
+
<Markdown
|
|
11
|
+
ref="markdownRef"
|
|
12
|
+
:layout="{ width: visibleRect.width, height: visibleRect.height }"
|
|
13
|
+
:content="''"
|
|
14
|
+
@sizechange="onSizeChange"
|
|
15
|
+
/>
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<script setup>
|
|
19
|
+
import { ref, shallowRef, onBeforeUnmount, onMounted } from "vue";
|
|
20
|
+
import { Markdown } from "./Markdown";
|
|
21
|
+
|
|
22
|
+
const emit = defineEmits(["sizechange"]);
|
|
23
|
+
const props = defineProps({
|
|
24
|
+
messages: Array,
|
|
25
|
+
onDone: Function,
|
|
26
|
+
left: Number,
|
|
27
|
+
visibleRect: Object,
|
|
28
|
+
backgroundColor: String,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
//fake data generator
|
|
32
|
+
const generateList = props.messages;
|
|
33
|
+
|
|
34
|
+
function* testMessageGenerator() {
|
|
35
|
+
for (const chunk of generateList) {
|
|
36
|
+
yield chunk;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const messageGen = testMessageGenerator();
|
|
40
|
+
|
|
41
|
+
const addText = () => {
|
|
42
|
+
const result = messageGen.next();
|
|
43
|
+
if (result.done) {
|
|
44
|
+
console.log("所有文本已写入完成");
|
|
45
|
+
markdownRef.value.writeDone();
|
|
46
|
+
props.onDone?.();
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const chunk = typeof result.value === "string" ? result.value : String(result.value ?? "");
|
|
51
|
+
markdownRef.value.write(chunk);
|
|
52
|
+
return true;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
let timeoutHandle = -1;
|
|
56
|
+
const startTestMessage = () => {
|
|
57
|
+
const tick = () => {
|
|
58
|
+
if (!addText()) {
|
|
59
|
+
timeoutHandle = -1;
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
timeoutHandle = setTimeout(() => {
|
|
63
|
+
tick();
|
|
64
|
+
}, 80);
|
|
65
|
+
};
|
|
66
|
+
tick();
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const stopTestMessage = () => {
|
|
70
|
+
clearTimeout(timeoutHandle);
|
|
71
|
+
timeoutHandle = -1;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const markdownRef = shallowRef();
|
|
75
|
+
const markdownHeight = ref(0);
|
|
76
|
+
const markdownTop = ref(0);
|
|
77
|
+
let autoSlide = true;
|
|
78
|
+
const onSizeChange = (width, height) => {
|
|
79
|
+
emit("sizechange", height);
|
|
80
|
+
markdownHeight.value = height;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
onBeforeUnmount(() => {
|
|
84
|
+
stopTestMessage();
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
onMounted(() => {
|
|
88
|
+
startTestMessage();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
function show() {
|
|
92
|
+
markdownRef.value?.show();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function hide() {
|
|
96
|
+
markdownRef.value?.hide();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function setVisibleRectStart(distance) {
|
|
100
|
+
markdownRef.value?.setVisibleStart(distance);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
defineExpose({
|
|
104
|
+
show,
|
|
105
|
+
hide,
|
|
106
|
+
setVisibleRectStart,
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
</script>
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { ref, reactive } from "vue";
|
|
3
|
+
import {
|
|
4
|
+
testMessage2,
|
|
5
|
+
testMessage3,
|
|
6
|
+
latexMessage,
|
|
7
|
+
longLatexMessage,
|
|
8
|
+
testMessage6Stream,
|
|
9
|
+
} from "./data.js";
|
|
10
|
+
import Bubble from "./Bubble.vue";
|
|
11
|
+
|
|
12
|
+
//可视范围的位置
|
|
13
|
+
let visibleStart = ref(0);
|
|
14
|
+
|
|
15
|
+
//聊天泡泡的消息列表
|
|
16
|
+
let messageList = [];
|
|
17
|
+
let renderList = reactive([]);
|
|
18
|
+
let totalHeight = 0;
|
|
19
|
+
let generating = false;
|
|
20
|
+
|
|
21
|
+
function createMessageItem(
|
|
22
|
+
key,
|
|
23
|
+
data,
|
|
24
|
+
left,
|
|
25
|
+
top,
|
|
26
|
+
width,
|
|
27
|
+
height,
|
|
28
|
+
backgroundColor
|
|
29
|
+
) {
|
|
30
|
+
let item = {
|
|
31
|
+
key,
|
|
32
|
+
data,
|
|
33
|
+
left: ref(left),
|
|
34
|
+
top: ref(top),
|
|
35
|
+
width: ref(width ?? 0),
|
|
36
|
+
height: ref(height ?? 0),
|
|
37
|
+
ref: null,
|
|
38
|
+
backgroundColor: backgroundColor,
|
|
39
|
+
onDone() {
|
|
40
|
+
generating = false;
|
|
41
|
+
console.log("onDone");
|
|
42
|
+
},
|
|
43
|
+
onSizeChange(height) {
|
|
44
|
+
this.height.value = height;
|
|
45
|
+
arrangeLayout();
|
|
46
|
+
updateRenderList();
|
|
47
|
+
},
|
|
48
|
+
onRef(ref) {
|
|
49
|
+
this.ref = ref;
|
|
50
|
+
},
|
|
51
|
+
show() {
|
|
52
|
+
this.ref?.show();
|
|
53
|
+
},
|
|
54
|
+
hide() {
|
|
55
|
+
this.ref?.hide();
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
item.onDone = item.onDone.bind(item);
|
|
59
|
+
item.onSizeChange = item.onSizeChange.bind(item);
|
|
60
|
+
item.onRef = item.onRef.bind(item);
|
|
61
|
+
item.show = item.show.bind(item);
|
|
62
|
+
item.hide = item.hide.bind(item);
|
|
63
|
+
return item;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function arrangeLayout() {
|
|
67
|
+
//更新item的布局
|
|
68
|
+
totalHeight = 0;
|
|
69
|
+
for (let i = 0; i < messageList.length; i++) {
|
|
70
|
+
const item = messageList[i];
|
|
71
|
+
item.top.value = totalHeight;
|
|
72
|
+
totalHeight += item.height.value;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const viewWidth = 400;
|
|
76
|
+
const viewHeight = 600;
|
|
77
|
+
|
|
78
|
+
function updateRenderList() {
|
|
79
|
+
renderList.length = 0;
|
|
80
|
+
if (autoSlideMode) {
|
|
81
|
+
//自动保持一行模式, 根据总高度和可视范围的高度, 计算出可视范围的开始位置
|
|
82
|
+
visibleStart.value =
|
|
83
|
+
totalHeight > viewHeight ? totalHeight - viewHeight : 0;
|
|
84
|
+
}
|
|
85
|
+
for (let i = 0; i < messageList.length; i++) {
|
|
86
|
+
const item = messageList[i];
|
|
87
|
+
renderList.push(item);
|
|
88
|
+
if (
|
|
89
|
+
item.top.value + item.height.value >= visibleStart.value &&
|
|
90
|
+
item.top.value <= visibleStart.value + viewHeight
|
|
91
|
+
) {
|
|
92
|
+
//可见的泡泡, 显示
|
|
93
|
+
item.show();
|
|
94
|
+
//此处要设置虚拟列表的可视范围的开始位置, 注意是转化为相对这个item的偏移量
|
|
95
|
+
item.ref?.setVisibleRectStart(visibleStart.value - item.top.value);
|
|
96
|
+
} else {
|
|
97
|
+
//不可见的泡泡, 隐藏
|
|
98
|
+
item.hide();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const messages = [longLatexMessage, testMessage6Stream, testMessage2];
|
|
104
|
+
function addData(message) {
|
|
105
|
+
const lastItem = messageList[messageList.length - 1];
|
|
106
|
+
const item = createMessageItem(
|
|
107
|
+
messageList.length,
|
|
108
|
+
message,
|
|
109
|
+
messageList.length % 2 == 0 ? 0 : 400,
|
|
110
|
+
lastItem ? lastItem.top.value + lastItem.height.value : 0,
|
|
111
|
+
800,
|
|
112
|
+
100,
|
|
113
|
+
messageList.length % 2 ? "#339933" : "#993333"
|
|
114
|
+
);
|
|
115
|
+
messageList.push(item);
|
|
116
|
+
updateRenderList();
|
|
117
|
+
generating = true;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function normalizeSlidePos(pos) {
|
|
121
|
+
return Math.max(Math.min(pos, totalHeight - viewHeight), 0);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
let autoSlideMode = true;
|
|
125
|
+
const onKeyDown = (ev) => {
|
|
126
|
+
switch (ev.keyCode) {
|
|
127
|
+
case 38:
|
|
128
|
+
autoSlideMode = false;
|
|
129
|
+
visibleStart.value = normalizeSlidePos(visibleStart.value - 100);
|
|
130
|
+
updateRenderList();
|
|
131
|
+
return true;
|
|
132
|
+
case 40:
|
|
133
|
+
visibleStart.value = normalizeSlidePos(visibleStart.value + 100);
|
|
134
|
+
if (visibleStart.value != totalHeight - viewHeight) {
|
|
135
|
+
autoSlideMode = false;
|
|
136
|
+
} else {
|
|
137
|
+
autoSlideMode = true;
|
|
138
|
+
}
|
|
139
|
+
updateRenderList();
|
|
140
|
+
return true;
|
|
141
|
+
case 49:
|
|
142
|
+
if (!generating) {
|
|
143
|
+
addData(messages[0]);
|
|
144
|
+
}
|
|
145
|
+
return true;
|
|
146
|
+
case 50:
|
|
147
|
+
if (!generating) {
|
|
148
|
+
addData(messages[1]);
|
|
149
|
+
}
|
|
150
|
+
return true;
|
|
151
|
+
case 51:
|
|
152
|
+
if (!generating) {
|
|
153
|
+
addData(messages[2]);
|
|
154
|
+
}
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
return false;
|
|
158
|
+
};
|
|
159
|
+
</script>
|
|
160
|
+
|
|
161
|
+
<template>
|
|
162
|
+
<jsv-focus-block
|
|
163
|
+
autoFocus
|
|
164
|
+
:onAction="{
|
|
165
|
+
onKeyDown,
|
|
166
|
+
}"
|
|
167
|
+
></jsv-focus-block>
|
|
168
|
+
<div
|
|
169
|
+
:style="{
|
|
170
|
+
top: -visibleStart,
|
|
171
|
+
}"
|
|
172
|
+
>
|
|
173
|
+
<template v-for="item in renderList">
|
|
174
|
+
<div
|
|
175
|
+
:style="{
|
|
176
|
+
left: item.left,
|
|
177
|
+
top: item.top,
|
|
178
|
+
width: item.width,
|
|
179
|
+
height: item.height,
|
|
180
|
+
// backgroundColor: '#99999999',
|
|
181
|
+
}"
|
|
182
|
+
>
|
|
183
|
+
<bubble
|
|
184
|
+
:messages="item.data"
|
|
185
|
+
:onDone="item.onDone"
|
|
186
|
+
:left="0"
|
|
187
|
+
:backgroundColor="item.backgroundColor"
|
|
188
|
+
:visibleRect="{
|
|
189
|
+
width: viewWidth,
|
|
190
|
+
height: viewHeight,
|
|
191
|
+
}"
|
|
192
|
+
@sizechange="item.onSizeChange"
|
|
193
|
+
:ref="item.onRef"
|
|
194
|
+
></bubble>
|
|
195
|
+
</div>
|
|
196
|
+
</template>
|
|
197
|
+
</div>
|
|
198
|
+
<div :style="{
|
|
199
|
+
top: 10,
|
|
200
|
+
left: 900,
|
|
201
|
+
width: 250,
|
|
202
|
+
height: 300,
|
|
203
|
+
color: '#fff',
|
|
204
|
+
fontSize: 20,
|
|
205
|
+
}">{{ "1键: latex + markdown\n2键: $格式latex\n3键: markdown" }}</div>
|
|
206
|
+
</template>
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Markdown 渲染组件
|
|
3
|
+
|
|
4
|
+
使用方式:
|
|
5
|
+
<Markdown
|
|
6
|
+
:layout="{ left, top, width, height }"
|
|
7
|
+
:content="markdown 字符串"
|
|
8
|
+
:baseFontSize="16"
|
|
9
|
+
@sizechange="(width, height) => {}"
|
|
10
|
+
/>
|
|
11
|
+
|
|
12
|
+
Props:
|
|
13
|
+
- layout: { left?, top?, width, height } 必填,容器尺寸与位置
|
|
14
|
+
- content: string 可选,初始 Markdown 内容
|
|
15
|
+
- baseFontSize: number 默认 16,基础字号
|
|
16
|
+
- color: string 默认 #000000,文字颜色
|
|
17
|
+
|
|
18
|
+
Events:
|
|
19
|
+
- sizechange: (width, height) 内容尺寸变化时触发
|
|
20
|
+
|
|
21
|
+
Expose 方法(通过 ref 调用):
|
|
22
|
+
- write(chunk): 追加内容
|
|
23
|
+
- writeDone(): 标记写入完成
|
|
24
|
+
- setVisibleStart(start): 设置可见区域起始位置(用于虚拟滚动)
|
|
25
|
+
- show(): 显示
|
|
26
|
+
- hide(): 隐藏
|
|
27
|
+
-->
|
|
28
|
+
<template>
|
|
29
|
+
<div
|
|
30
|
+
:style="{
|
|
31
|
+
...rootLayout,
|
|
32
|
+
// overflow: 'hidden',
|
|
33
|
+
}"
|
|
34
|
+
>
|
|
35
|
+
<div
|
|
36
|
+
:style="{
|
|
37
|
+
top: slideTop,
|
|
38
|
+
}"
|
|
39
|
+
>
|
|
40
|
+
<NodeComponent />
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
</template>
|
|
44
|
+
|
|
45
|
+
<script>
|
|
46
|
+
import { globalLoadJsvLatexPlugin } from "jsview";
|
|
47
|
+
|
|
48
|
+
let pluginLoaded = false;
|
|
49
|
+
const loadPlugin = () => {
|
|
50
|
+
if (pluginLoaded) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
pluginLoaded = true;
|
|
54
|
+
globalLoadJsvLatexPlugin((status) => {
|
|
55
|
+
console.log("load JsvLatex plugin status", status);
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
</script>
|
|
59
|
+
<script setup>
|
|
60
|
+
import { getMarkdownWriter, normalizeLatexDelimiters } from "./parser";
|
|
61
|
+
import { ref, shallowRef, computed, onBeforeUnmount } from "vue";
|
|
62
|
+
|
|
63
|
+
const props = defineProps({
|
|
64
|
+
layout: {
|
|
65
|
+
type: Object,
|
|
66
|
+
required: true,
|
|
67
|
+
validator: (value) => {
|
|
68
|
+
return value && value.width > 0 && value.height > 0;
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
content: {
|
|
72
|
+
type: String,
|
|
73
|
+
},
|
|
74
|
+
baseFontSize: {
|
|
75
|
+
type: Number,
|
|
76
|
+
default: 16,
|
|
77
|
+
},
|
|
78
|
+
color: {
|
|
79
|
+
type: String,
|
|
80
|
+
default: "#000000"
|
|
81
|
+
},
|
|
82
|
+
enableLatex: {
|
|
83
|
+
type: Boolean,
|
|
84
|
+
default: true,
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
const emit = defineEmits(["sizechange"]);
|
|
88
|
+
if (props.enableLatex) {
|
|
89
|
+
loadPlugin();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const slideTop = ref(0);
|
|
93
|
+
|
|
94
|
+
const rootLayout = computed(() => {
|
|
95
|
+
return {
|
|
96
|
+
left: props.layout.left ?? 0,
|
|
97
|
+
top: props.layout.top ?? 0,
|
|
98
|
+
width: props.layout.width,
|
|
99
|
+
height: props.layout.height,
|
|
100
|
+
};
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const onSizeChange = (width, height) => {
|
|
104
|
+
emit("sizechange", width, height);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const sharedInfo = {
|
|
108
|
+
baseFontSize: props.baseFontSize,
|
|
109
|
+
totalWidth: props.layout.width,
|
|
110
|
+
// totalHeight: props.layout.height,
|
|
111
|
+
curDepth: 0,
|
|
112
|
+
tabWidth: props.baseFontSize * 2,
|
|
113
|
+
visibleStart: 0,
|
|
114
|
+
visibleRange: -1,
|
|
115
|
+
enableLatex: props.enableLatex,
|
|
116
|
+
textColor: props.color,
|
|
117
|
+
};
|
|
118
|
+
const renderTrigger = ref(0);
|
|
119
|
+
const writer = getMarkdownWriter();
|
|
120
|
+
const rootNode = writer(normalizeLatexDelimiters(props.content) ?? "");
|
|
121
|
+
rootNode.registerOnSizeChanged(onSizeChange);
|
|
122
|
+
window.rootNode = rootNode;
|
|
123
|
+
const vNode = computed(() => {
|
|
124
|
+
renderTrigger.value;
|
|
125
|
+
return rootNode.render(sharedInfo);
|
|
126
|
+
});
|
|
127
|
+
const NodeComponent = () => {
|
|
128
|
+
return vNode.value;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
defineExpose({
|
|
132
|
+
write: (chunk) => {
|
|
133
|
+
renderTrigger.value++;
|
|
134
|
+
writer(chunk);
|
|
135
|
+
},
|
|
136
|
+
setVisibleStart: (start) => {
|
|
137
|
+
// slideTop.value = -start;
|
|
138
|
+
sharedInfo.visibleStart = start;
|
|
139
|
+
sharedInfo.visibleRange = props.layout.height + 50;
|
|
140
|
+
rootNode.setVisibleRange(sharedInfo.visibleStart, sharedInfo.visibleRange);
|
|
141
|
+
},
|
|
142
|
+
show: () => {
|
|
143
|
+
rootNode.show();
|
|
144
|
+
},
|
|
145
|
+
hide: () => {
|
|
146
|
+
rootNode.hide();
|
|
147
|
+
},
|
|
148
|
+
writeDone: () => {
|
|
149
|
+
renderTrigger.value++;
|
|
150
|
+
if (typeof writer.flush === "function") {
|
|
151
|
+
writer.flush();
|
|
152
|
+
}
|
|
153
|
+
rootNode.done();
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
</script>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Markdown } from "./Markdown.vue"
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# License information
|
|
2
|
+
|
|
3
|
+
## Contribution License Agreement
|
|
4
|
+
|
|
5
|
+
If you contribute code to this project, you are implicitly allowing your code
|
|
6
|
+
to be distributed under the MIT license. You are also implicitly verifying that
|
|
7
|
+
all code is your original work. `</legalese>`
|
|
8
|
+
|
|
9
|
+
## Marked
|
|
10
|
+
|
|
11
|
+
Copyright (c) 2018+, MarkedJS (https://github.com/markedjs/)
|
|
12
|
+
Copyright (c) 2011-2018, Christopher Jeffrey (https://github.com/chjj/)
|
|
13
|
+
|
|
14
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
16
|
+
in the Software without restriction, including without limitation the rights
|
|
17
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
19
|
+
furnished to do so, subject to the following conditions:
|
|
20
|
+
|
|
21
|
+
The above copyright notice and this permission notice shall be included in
|
|
22
|
+
all copies or substantial portions of the Software.
|
|
23
|
+
|
|
24
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
30
|
+
THE SOFTWARE.
|
|
31
|
+
|
|
32
|
+
## Markdown
|
|
33
|
+
|
|
34
|
+
Copyright © 2004, John Gruber
|
|
35
|
+
http://daringfireball.net/
|
|
36
|
+
All rights reserved.
|
|
37
|
+
|
|
38
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
39
|
+
|
|
40
|
+
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
41
|
+
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
42
|
+
* Neither the name "Markdown" nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
43
|
+
|
|
44
|
+
This software is provided by the copyright holders and contributors "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the copyright owner or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.
|
|
45
|
+
|