@shijiu/jsview-vue 0.0.1-beta.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/docs/IMPORT_CHANGE_LOG.txt +3 -0
- package/docs/git_commit.md +15 -0
- package/docs/test_version_up.txt +1 -0
- package/dom/bin/jsview-dom-1.0.313.tgz +0 -0
- package/dom/browser-root-style.css +21 -0
- package/dom/jsv-browser-debug-dom.js +8 -0
- package/dom/jsv-dom.js +6 -0
- package/dom/jsv-forge-define.js +6 -0
- package/dom/target_core_revision.js +14 -0
- package/load/header_script_loader.js +134 -0
- package/load/jsview-main.js +42 -0
- package/load/jsview.config.default.js +37 -0
- package/load/jsview.default.config.js +37 -0
- package/load/loader.js +172 -0
- package/load/loader_webkit.js +40 -0
- package/package.json +27 -0
- package/patch/node_modules/@babel/preset-env/lib/available-plugins.js +219 -0
- package/patch/node_modules/@vue/cli-plugin-typescript/index.js +100 -0
- package/patch/node_modules/@vue/cli-service/lib/commands/serve.js +395 -0
- package/patch/node_modules/@vue/cli-service/lib/config/app.js +272 -0
- package/patch/node_modules/@vue/cli-service/lib/config/assets.js +70 -0
- package/patch/node_modules/@vue/cli-service/lib/config/base.js +212 -0
- package/patch/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +2566 -0
- package/patch/node_modules/@vue/compiler-sfc/dist/jsview-css-to-js.js +274 -0
- package/patch/node_modules/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js +1596 -0
- package/patch/node_modules/postcss-js/objectifier.js +90 -0
- package/patch/node_modules/vue-loader/dist/resolveScript.js +70 -0
- package/patch/package-lock.json +30051 -0
- package/samples/AdvanceMetroWidget/App.vue +123 -0
- package/samples/AdvanceMetroWidget/Frame.vue +101 -0
- package/samples/AdvanceMetroWidget/Item.vue +58 -0
- package/samples/AdvanceMetroWidget/data.js +137 -0
- package/samples/AnimPicture/App.vue +224 -0
- package/samples/AnimPicture/assets/animated_webp.webp +0 -0
- package/samples/AnimPicture/assets/ball_3.webp +0 -0
- package/samples/AnimPicture/assets/girl_run.gif +0 -0
- package/samples/AnimPicture/assets/quan.webp +0 -0
- package/samples/Basic/App.vue +129 -0
- package/samples/Basic/assets/border.png +0 -0
- package/samples/Basic/assets/border2.png +0 -0
- package/samples/Basic/assets/icon.png +0 -0
- package/samples/Basic/assets/test.jpg +0 -0
- package/samples/Basic/components/ContentBlock.vue +36 -0
- package/samples/Basic/components/FontStyle.css +10 -0
- package/samples/Basic/components/TitleBar.vue +29 -0
- package/samples/Basic/components/anim/AnimGroup.vue +68 -0
- package/samples/Basic/components/anim/AnimKeyframeBasic.vue +102 -0
- package/samples/Basic/components/anim/AnimKeyframeComposite.vue +53 -0
- package/samples/Basic/components/anim/AnimTransition.vue +116 -0
- package/samples/Basic/components/div/DivBackground.vue +15 -0
- package/samples/Basic/components/div/DivClip.vue +81 -0
- package/samples/Basic/components/div/DivCssScoped.vue +27 -0
- package/samples/Basic/components/div/DivCssVar.vue +50 -0
- package/samples/Basic/components/div/DivGroup1.vue +33 -0
- package/samples/Basic/components/div/DivGroup2.vue +41 -0
- package/samples/Basic/components/div/DivLayout.vue +12 -0
- package/samples/Basic/components/div/DivRadius.vue +47 -0
- package/samples/Basic/components/text/TextAlign.vue +48 -0
- package/samples/Basic/components/text/TextFontStyle.vue +58 -0
- package/samples/Basic/components/text/TextGroup.vue +32 -0
- package/samples/Basic/components/text/TextOverflow.vue +78 -0
- package/samples/BasicFocusControl/App.vue +125 -0
- package/samples/BasicFocusControl/components/BaseBlock.vue +51 -0
- package/samples/BasicFocusControl/components/MainArea.vue +98 -0
- package/samples/BasicFocusControl/components/MainAreaLeftBlock.vue +21 -0
- package/samples/BasicFocusControl/components/MainAreaRightBlock.vue +30 -0
- package/samples/BasicFocusControl/components/SideBar.vue +73 -0
- package/samples/BasicFocusControl/components/SideBarBlock.vue +30 -0
- package/samples/ClassNameDemo/App.vue +119 -0
- package/samples/ClassNameDemo/assets/bg.jpg +0 -0
- package/samples/ClassNameDemo/assets/coupon_content.png +0 -0
- package/samples/ClassNameDemo/assets/coupon_left.png +0 -0
- package/samples/ClassNameDemo/assets/coupon_mid.png +0 -0
- package/samples/ClassNameDemo/assets/coupon_right.png +0 -0
- package/samples/ClassNameDemo/assets/focus_border.png +0 -0
- package/samples/ClassNameDemo/assets/holder_logo.png +0 -0
- package/samples/ClassNameDemo/assets/jrbm.png +0 -0
- package/samples/ClassNameDemo/assets/line_left.png +0 -0
- package/samples/ClassNameDemo/assets/line_mid.png +0 -0
- package/samples/ClassNameDemo/assets/line_right.png +0 -0
- package/samples/ClassNameDemo/assets/loading.png +0 -0
- package/samples/ClassNameDemo/assets/logo.png +0 -0
- package/samples/ClassNameDemo/assets/mcjx.png +0 -0
- package/samples/ClassNameDemo/assets/tao.png +0 -0
- package/samples/ClassNameDemo/assets/tmall.png +0 -0
- package/samples/ClassNameDemo/components/ContentItem.vue +253 -0
- package/samples/ClassNameDemo/components/LoadingView.vue +43 -0
- package/samples/ClassNameDemo/components/TitleView.vue +24 -0
- package/samples/ClassNameDemo/data.js +24 -0
- package/samples/ColorSpace/App.vue +135 -0
- package/samples/ColorSpace/bmpDemo.bmp +0 -0
- package/samples/ColorSpace/jpegDemo.jpeg +0 -0
- package/samples/ColorSpace/pngDemo.png +0 -0
- package/samples/ColorSpace/pngNoAlphaDemo.png +0 -0
- package/samples/DemoHomepage/App.vue +31 -0
- package/samples/DemoHomepage/components/BodyFrame.vue +82 -0
- package/samples/DemoHomepage/components/Dialog.vue +94 -0
- package/samples/DemoHomepage/components/Item.vue +77 -0
- package/samples/DemoHomepage/components/TabFrame.vue +86 -0
- package/samples/DemoHomepage/router.js +132 -0
- package/samples/DemoHomepage/views/Homepage.vue +186 -0
- package/samples/FlipCard/App.vue +80 -0
- package/samples/FlipCard/FlipCard.vue +124 -0
- package/samples/FlipCard/assets/blue_egg.png +0 -0
- package/samples/FlipCard/assets/red_egg.png +0 -0
- package/samples/FlipCard/data.js +13 -0
- package/samples/FlowMultiWidget/App.vue +91 -0
- package/samples/FlowMultiWidget/assets/nine_patch_focus.png +0 -0
- package/samples/FlowMultiWidget/components/Block.vue +107 -0
- package/samples/FlowMultiWidget/components/FlowPage.vue +60 -0
- package/samples/FlowMultiWidget/components/Item.vue +103 -0
- package/samples/FlowMultiWidget/components/MenuItem.vue +72 -0
- package/samples/FlowMultiWidget/components/MyMenu.vue +90 -0
- package/samples/FlowMultiWidget/data.js +446 -0
- package/samples/HashHistory/App.vue +124 -0
- package/samples/HashHistory/components/HorizontalButtonList.vue +114 -0
- package/samples/HashHistory/components/Item.vue +74 -0
- package/samples/HashHistory/router.js +30 -0
- package/samples/HashHistory/views/BasePage.vue +19 -0
- package/samples/HashHistory/views/MainPage.vue +68 -0
- package/samples/HashHistory/views/SubPage.vue +79 -0
- package/samples/HashHistory/views/SubPageFirst.vue +10 -0
- package/samples/HashHistory/views/SubPageSecond.vue +10 -0
- package/samples/LongImage/App.vue +96 -0
- package/samples/LongImage/Button.vue +153 -0
- package/samples/LongImage/LongImageScroll.vue +127 -0
- package/samples/LongImage/Scroll.vue +16 -0
- package/samples/LongImage/assets/1280x7200.jpg +0 -0
- package/samples/LongText/App.vue +111 -0
- package/samples/LongText/Button.vue +153 -0
- package/samples/LongText/LongTextScroll.vue +225 -0
- package/samples/LongText/Scroll.vue +16 -0
- package/samples/Preload/App.vue +146 -0
- package/samples/Preload/data.js +23 -0
- package/samples/Preload/images/awesomeface.png +0 -0
- package/samples/Preload/images/cat.jpg +0 -0
- package/samples/Preload/images/rank.png +0 -0
- package/samples/Preload/images/rank_focus.png +0 -0
- package/samples/Preload/images/rule.png +0 -0
- package/samples/Preload/images/rule_focus.png +0 -0
- package/samples/Preload/images/start.png +0 -0
- package/samples/Preload/images/start_focus.png +0 -0
- package/samples/Preload/preloadItem.vue +22 -0
- package/samples/QrcodeDemo/App.vue +73 -0
- package/samples/SimpleWidgetDemo/App.vue +204 -0
- package/samples/SimpleWidgetDemo/Item.vue +83 -0
- package/samples/SimpleWidgetDemo/assets/bg.jpg +0 -0
- package/samples/SimpleWidgetDemo/assets/coupon_content.png +0 -0
- package/samples/SimpleWidgetDemo/assets/coupon_left.png +0 -0
- package/samples/SimpleWidgetDemo/assets/coupon_mid.png +0 -0
- package/samples/SimpleWidgetDemo/assets/coupon_right.png +0 -0
- package/samples/SimpleWidgetDemo/assets/focus_border.png +0 -0
- package/samples/SimpleWidgetDemo/assets/holder_logo.png +0 -0
- package/samples/SimpleWidgetDemo/assets/jrbm.png +0 -0
- package/samples/SimpleWidgetDemo/assets/line_left.png +0 -0
- package/samples/SimpleWidgetDemo/assets/line_mid.png +0 -0
- package/samples/SimpleWidgetDemo/assets/line_right.png +0 -0
- package/samples/SimpleWidgetDemo/assets/loading.png +0 -0
- package/samples/SimpleWidgetDemo/assets/logo.png +0 -0
- package/samples/SimpleWidgetDemo/assets/mcjx.png +0 -0
- package/samples/SimpleWidgetDemo/assets/tao.png +0 -0
- package/samples/SimpleWidgetDemo/assets/tmall.png +0 -0
- package/samples/SimpleWidgetDemo/border.png +0 -0
- package/samples/SimpleWidgetDemo/components/ContentItem.vue +412 -0
- package/samples/SimpleWidgetDemo/components/MyTab.vue +117 -0
- package/samples/SimpleWidgetDemo/data.js +110 -0
- package/samples/SprayView/App.vue +270 -0
- package/samples/SprayView/assets/snow.png +0 -0
- package/samples/SpriteImage/App.vue +174 -0
- package/samples/SpriteImage/images/cat_run.png +0 -0
- package/samples/SpriteImage/images/egg_break.json +116 -0
- package/samples/SpriteImage/images/egg_break.png +0 -0
- package/samples/SpriteImage/images/sprite.png +0 -0
- package/samples/TextBox/App.vue +179 -0
- package/samples/TextBox/RenderCenter.vue +109 -0
- package/samples/TextBox/RenderLeft.vue +109 -0
- package/samples/TextBox/RenderOneLine.vue +120 -0
- package/samples/TextBox/RenderRight.vue +107 -0
- package/samples/TextShadowDemo/App.vue +98 -0
- package/samples/TextureSize/App.vue +142 -0
- package/samples/TextureSize/bmpDemo.bmp +0 -0
- package/samples/TextureSize/jpegDemo.jpeg +0 -0
- package/samples/TextureSize/jpgDemo.jpg +0 -0
- package/samples/TextureSize/pngDemo.png +0 -0
- package/samples/TextureSize/pngNoAlphaDemo.png +0 -0
- package/samples/ThrowMoveDemo/AccelerateDemo.vue +118 -0
- package/samples/ThrowMoveDemo/App.vue +114 -0
- package/samples/ThrowMoveDemo/LRParabolicDemo.vue +116 -0
- package/samples/ThrowMoveDemo/TargetDemo.vue +117 -0
- package/samples/ThrowMoveDemo/UDParabolicDemo.vue +122 -0
- package/samples/TransitPage/App.vue +41 -0
- package/samples/VideoDemo/App.vue +137 -0
- package/samples/VideoDemo/components/Button.vue +69 -0
- package/samples/VideoDemo/components/Controllor.vue +195 -0
- package/samples/VideoDemo/components/VideoFrame.vue +152 -0
- package/scripts/git-commit-empty.js +21 -0
- package/scripts/install-local-packages.js +121 -0
- package/scripts/make-js.sh +181 -0
- package/scripts/post-build.js +132 -0
- package/scripts/post-install.js +127 -0
- package/scripts/pre-pack.js +2 -0
- package/scripts/run-android.js +64 -0
- package/utils/JsViewEngineWidget/bin/shijiu-jsview-vue-widget-1.0.1.tgz +0 -0
- package/utils/JsViewEngineWidget/index.d.ts +32 -0
- package/utils/JsViewEngineWidget/index.js +6 -0
- package/utils/JsViewVueTools/DebugContentShellJBridge.js +16 -0
- package/utils/JsViewVueTools/DebugTool.js +21 -0
- package/utils/JsViewVueTools/DefaultKeyMap.js +12 -0
- package/utils/JsViewVueTools/JsvDynamicCssStyle.js +73 -0
- package/utils/JsViewVueTools/JsvDynamicKeyFrames.js +128 -0
- package/utils/JsViewVueTools/JsvHashHistory.js +112 -0
- package/utils/JsViewVueTools/JsvRuntimeBridge.js +417 -0
- package/utils/JsViewVueTools/JsvStyleClass.js +290 -0
- package/utils/JsViewVueWidget/BrowserDebugWidget/BrowserPreload.vue +80 -0
- package/utils/JsViewVueWidget/BrowserDebugWidget/BrowserQrcode.vue +148 -0
- package/utils/JsViewVueWidget/BrowserDebugWidget/BrowserSpray.vue +55 -0
- package/utils/JsViewVueWidget/BrowserDebugWidget/JsvApic/ApicDataBase.js +29 -0
- package/utils/JsViewVueWidget/BrowserDebugWidget/JsvApic/BrowserApic.vue +124 -0
- package/utils/JsViewVueWidget/BrowserDebugWidget/JsvApic/GifData.js +83 -0
- package/utils/JsViewVueWidget/BrowserDebugWidget/JsvApic/LoopToolBase.js +25 -0
- package/utils/JsViewVueWidget/BrowserDebugWidget/JsvApic/NormalLoopTool.js +61 -0
- package/utils/JsViewVueWidget/BrowserDebugWidget/JsvApic/PartLoopTool.js +119 -0
- package/utils/JsViewVueWidget/BrowserDebugWidget/JsvApic/Viewer.js +106 -0
- package/utils/JsViewVueWidget/BrowserDebugWidget/JsvApic/WebpData.js +141 -0
- package/utils/JsViewVueWidget/BrowserDebugWidget/WidgetLoader.js +20 -0
- package/utils/JsViewVueWidget/BrowserDebugWidget/WidgetWrapper.js +11 -0
- package/utils/JsViewVueWidget/JsvActorMove/ActorControlBase.js +204 -0
- package/utils/JsViewVueWidget/JsvActorMove/JsvActorMove.vue +64 -0
- package/utils/JsViewVueWidget/JsvActorMove/JsvActorMoveControl.js +427 -0
- package/utils/JsViewVueWidget/JsvActorMove/index.js +12 -0
- package/utils/JsViewVueWidget/JsvApic/JsvApic.vue +179 -0
- package/utils/JsViewVueWidget/JsvApic/index.js +17 -0
- package/utils/JsViewVueWidget/JsvMarquee.vue +197 -0
- package/utils/JsViewVueWidget/JsvNativeSharedDiv.vue +92 -0
- package/utils/JsViewVueWidget/JsvNinePatch.vue +76 -0
- package/utils/JsViewVueWidget/JsvPreload/JsvPreload.vue +351 -0
- package/utils/JsViewVueWidget/JsvPreload/index.js +21 -0
- package/utils/JsViewVueWidget/JsvQrcode/JsvQrcode.vue +140 -0
- package/utils/JsViewVueWidget/JsvQrcode/index.js +18 -0
- package/utils/JsViewVueWidget/JsvSpray/JsvSpray.vue +140 -0
- package/utils/JsViewVueWidget/JsvSpray/index.js +15 -0
- package/utils/JsViewVueWidget/JsvSpriteAnim/JsvSpriteAnim.vue +448 -0
- package/utils/JsViewVueWidget/JsvSpriteAnim/SpriteController.js +57 -0
- package/utils/JsViewVueWidget/JsvSpriteAnim/index.js +6 -0
- package/utils/JsViewVueWidget/JsvSwiper/Indicator.vue +35 -0
- package/utils/JsViewVueWidget/JsvSwiper/JsvSwiper.vue +495 -0
- package/utils/JsViewVueWidget/JsvSwiper/index.js +10 -0
- package/utils/JsViewVueWidget/JsvSwiper3D/Indicator.vue +35 -0
- package/utils/JsViewVueWidget/JsvSwiper3D/JsvSwiper.vue +404 -0
- package/utils/JsViewVueWidget/JsvSwiper3D/index.js +10 -0
- package/utils/JsViewVueWidget/JsvTextBox.vue +111 -0
- package/utils/JsViewVueWidget/JsvVideo.vue +36 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
export default {
|
|
3
|
+
props: {
|
|
4
|
+
preloadList: Array,
|
|
5
|
+
downloadList: Array,
|
|
6
|
+
onPreloadDone: Function, // 预加载完成回调
|
|
7
|
+
onDownloadDone: Function, // 预下载完成回调
|
|
8
|
+
},
|
|
9
|
+
data() {
|
|
10
|
+
return {
|
|
11
|
+
preloadStateList: null,
|
|
12
|
+
downloadStateList: null,
|
|
13
|
+
};
|
|
14
|
+
},
|
|
15
|
+
created() {
|
|
16
|
+
if (this.preloadList) {
|
|
17
|
+
this.getPreloadList();
|
|
18
|
+
}
|
|
19
|
+
if (this.downloadList) {
|
|
20
|
+
this.getDownloadList();
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
methods: {
|
|
24
|
+
getPreloadList() {
|
|
25
|
+
this.preloadStateList = new Array(this.preloadList.length).fill(false);
|
|
26
|
+
let preloadListData = this.preloadList;
|
|
27
|
+
for (let i = 0; i < preloadListData.length; i++) {
|
|
28
|
+
if (!preloadListData[i]) {
|
|
29
|
+
preloadListData.splice(i, 1);
|
|
30
|
+
this.preloadIsNullNum++;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
this._PreloadViewList = preloadListData.map((item, index) => {
|
|
34
|
+
if (!item || !item.url) {
|
|
35
|
+
this.preloadStateList[index] = true;
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
const image = new Image();
|
|
39
|
+
image.onload = () => {
|
|
40
|
+
if (this.onPreloadDone) {
|
|
41
|
+
this.onPreloadDone();
|
|
42
|
+
}
|
|
43
|
+
this.preloadStateList[index] = true;
|
|
44
|
+
};
|
|
45
|
+
image.src = item.url;
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
getDownloadList() {
|
|
49
|
+
this.downloadStateList = new Array(this.downloadList.length).fill(false);
|
|
50
|
+
let downloadListData = this.downloadList;
|
|
51
|
+
for (let i = 0; i < downloadListData.length; i++) {
|
|
52
|
+
if (!downloadListData[i].url) {
|
|
53
|
+
downloadListData.splice(i, 1);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
this._DownloadViewList = downloadListData.map((item, index) => {
|
|
57
|
+
if (!item.url) {
|
|
58
|
+
this.downloadStateList[index] = true;
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
const image = new Image();
|
|
62
|
+
image.onload = () => {
|
|
63
|
+
if (this.onDownloadDone) {
|
|
64
|
+
this.onDownloadDone();
|
|
65
|
+
}
|
|
66
|
+
this.downloadStateList[index] = true;
|
|
67
|
+
console.log(`pre download succeed ${item.url}`);
|
|
68
|
+
};
|
|
69
|
+
image.src = item.url;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
</script>
|
|
75
|
+
|
|
76
|
+
<template>
|
|
77
|
+
<!-- 保证该组件不描画任何东西,只是为了触发onload,让网页自行下载图片 -->
|
|
78
|
+
<div v-if="!preloadList"></div>
|
|
79
|
+
</template>
|
|
80
|
+
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import QRCodeImpl from "qr.js/lib/QRCode";
|
|
3
|
+
export default {
|
|
4
|
+
props: {
|
|
5
|
+
value: String,
|
|
6
|
+
size: Number,
|
|
7
|
+
fgColor: String,
|
|
8
|
+
bgColor: String,
|
|
9
|
+
level: String, // ,容错级别,分别是L(7%)、M(15%)、Q(25%)、H(30%),
|
|
10
|
+
imageSettings: Object
|
|
11
|
+
},
|
|
12
|
+
data() {
|
|
13
|
+
return {
|
|
14
|
+
imageStyle: null,
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
methods: {
|
|
18
|
+
convertStr(str) {
|
|
19
|
+
let out = "";
|
|
20
|
+
for (let i = 0; i < str.length; i++) {
|
|
21
|
+
let charcode = str.charCodeAt(i);
|
|
22
|
+
if (charcode < 0x0080) {
|
|
23
|
+
out += String.fromCharCode(charcode);
|
|
24
|
+
} else if (charcode < 0x0800) {
|
|
25
|
+
out += String.fromCharCode(0xc0 | (charcode >> 6));
|
|
26
|
+
out += String.fromCharCode(0x80 | (charcode & 0x3f));
|
|
27
|
+
} else if (charcode < 0xd800 || charcode >= 0xe000) {
|
|
28
|
+
out += String.fromCharCode(0xe0 | (charcode >> 12));
|
|
29
|
+
out += String.fromCharCode(0x80 | ((charcode >> 6) & 0x3f));
|
|
30
|
+
out += String.fromCharCode(0x80 | (charcode & 0x3f));
|
|
31
|
+
} else {
|
|
32
|
+
// This is a surrogate pair, so we'll reconsitute the pieces and work
|
|
33
|
+
// from that
|
|
34
|
+
i++;
|
|
35
|
+
charcode =
|
|
36
|
+
0x10000 + (((charcode & 0x3ff) << 10) | (str.charCodeAt(i) & 0x3ff));
|
|
37
|
+
out += String.fromCharCode(0xf0 | (charcode >> 18));
|
|
38
|
+
out += String.fromCharCode(0x80 | ((charcode >> 12) & 0x3f));
|
|
39
|
+
out += String.fromCharCode(0x80 | ((charcode >> 6) & 0x3f));
|
|
40
|
+
out += String.fromCharCode(0x80 | (charcode & 0x3f));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return out;
|
|
44
|
+
},
|
|
45
|
+
generatePath(modules, margin = 0) {
|
|
46
|
+
const ops = [];
|
|
47
|
+
modules.forEach((row, y) => {
|
|
48
|
+
let start = null;
|
|
49
|
+
row.forEach((cell, x) => {
|
|
50
|
+
if (!cell && start !== null) {
|
|
51
|
+
// M0 0h7v1H0z injects the space with the move and drops the comma,
|
|
52
|
+
// saving a char per operation
|
|
53
|
+
ops.push(
|
|
54
|
+
`M${start + margin} ${y + margin}h${x - start}v1H${start + margin}z`
|
|
55
|
+
);
|
|
56
|
+
start = null;
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// end of row, clean up or skip
|
|
61
|
+
if (x === row.length - 1) {
|
|
62
|
+
if (!cell) {
|
|
63
|
+
// We would have closed the op above already so this can only mean
|
|
64
|
+
// 2+ light modules in a row.
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (start === null) {
|
|
68
|
+
// Just a single dark module.
|
|
69
|
+
ops.push(`M${x + margin},${y + margin} h1v1H${x + margin}z`);
|
|
70
|
+
} else {
|
|
71
|
+
// Otherwise finish the current line.
|
|
72
|
+
ops.push(
|
|
73
|
+
`M${start + margin},${y + margin} h${x + 1 - start}v1H${
|
|
74
|
+
start + margin
|
|
75
|
+
}z`
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (cell && start === null) {
|
|
82
|
+
start = x;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
return ops.join("");
|
|
87
|
+
},
|
|
88
|
+
getImageSettings(props) {
|
|
89
|
+
// const { imageSettings, size } = props;
|
|
90
|
+
const imageSettings = props.imageSettings;
|
|
91
|
+
const size = props.size;
|
|
92
|
+
if (!imageSettings) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
const w = imageSettings.width;
|
|
96
|
+
const h = imageSettings.height;
|
|
97
|
+
const x = !imageSettings.x ? size / 2 - w / 2 : imageSettings.x;
|
|
98
|
+
const y = !imageSettings.y ? size / 2 - h / 2 : imageSettings.y;
|
|
99
|
+
|
|
100
|
+
return { x, y, h, w };
|
|
101
|
+
},
|
|
102
|
+
renderQrcode() {
|
|
103
|
+
// const { value, size, level, bgColor, fgColor, imageSettings,} = this.props;
|
|
104
|
+
const ErrorCorrectLevel = require("qr.js/lib/ErrorCorrectLevel");
|
|
105
|
+
const qrcode = new QRCodeImpl(-1, ErrorCorrectLevel[this.level]);
|
|
106
|
+
qrcode.addData(this.convertStr(this.value));
|
|
107
|
+
qrcode.make();
|
|
108
|
+
|
|
109
|
+
const cells = qrcode.modules;
|
|
110
|
+
if (cells === null) {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const margin = 2;
|
|
115
|
+
const numCells = cells.length + margin * 2;
|
|
116
|
+
const propsData = {value: this.value, size: this.size, level: this.level, bgColor: this.bgColor, fgColor: this.fgColor, imageSettings: this.imageSettings,}
|
|
117
|
+
const calculatedImageSettings = this.getImageSettings(propsData);
|
|
118
|
+
if (this.imageSettings) {
|
|
119
|
+
this.imageStyle = {
|
|
120
|
+
backgroundImage: `url(${this.imageSettings.src})`,
|
|
121
|
+
height: calculatedImageSettings.h,
|
|
122
|
+
width: calculatedImageSettings.w,
|
|
123
|
+
left: calculatedImageSettings.x + margin,
|
|
124
|
+
top: calculatedImageSettings.y + margin
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const fgPath = this.generatePath(cells, margin);
|
|
128
|
+
return {numCells, fgPath};
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
}
|
|
132
|
+
</script>
|
|
133
|
+
|
|
134
|
+
<template>
|
|
135
|
+
<div>
|
|
136
|
+
<jsvsvg
|
|
137
|
+
:type="'qrcode'"
|
|
138
|
+
:shapeRendering="'crispEdges'"
|
|
139
|
+
:height="size"
|
|
140
|
+
:width="size"
|
|
141
|
+
:viewBox="'0 0 ' + renderQrcode().numCells + ' ' + renderQrcode().numCells"
|
|
142
|
+
>
|
|
143
|
+
<jsvpath :fill="bgColor" :d="'M0,0 h' + renderQrcode().numCells + 'v' + renderQrcode().numCells + 'H0z'" />
|
|
144
|
+
<jsvpath :fill="fgColor" :d="renderQrcode().fgPath" />
|
|
145
|
+
</jsvsvg>
|
|
146
|
+
<div :style="imageStyle"></div>
|
|
147
|
+
</div>
|
|
148
|
+
</template>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Author: ChenChanghua
|
|
3
|
+
* @Date: 2021-10-13 11:02:42
|
|
4
|
+
* @LastEditors: ChenChanghua
|
|
5
|
+
* @LastEditTime: 2021-10-13 15:10:01
|
|
6
|
+
* @Description: file content
|
|
7
|
+
-->
|
|
8
|
+
<script>
|
|
9
|
+
import { Forge } from "../../../dom/jsv-forge-define";
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
props: {
|
|
13
|
+
pointRes: {
|
|
14
|
+
type: String,
|
|
15
|
+
required: true,
|
|
16
|
+
},
|
|
17
|
+
sprayStyle: {
|
|
18
|
+
type: Object,
|
|
19
|
+
required: true,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
data() {
|
|
23
|
+
return {
|
|
24
|
+
viewId: -1,
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
computed: {
|
|
28
|
+
viewWidth() {
|
|
29
|
+
return this.sprayStyle.deltaWidth === 0 ? 1 : this.sprayStyle.deltaWidth * 2;
|
|
30
|
+
},
|
|
31
|
+
viewHeight() {
|
|
32
|
+
return this.sprayStyle.deltaHeight === 0 ? 1 : this.sprayStyle.deltaHeight * 2;
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
mounted() {
|
|
36
|
+
const viewSize = {
|
|
37
|
+
width: this.viewWidth,
|
|
38
|
+
height: this.viewHeight,
|
|
39
|
+
};
|
|
40
|
+
this.viewId = Forge.sParticleManager.addParticle(
|
|
41
|
+
this.sprayStyle,
|
|
42
|
+
this.pointRes,
|
|
43
|
+
viewSize,
|
|
44
|
+
this.$refs.element
|
|
45
|
+
);
|
|
46
|
+
},
|
|
47
|
+
beforeUnmount() {
|
|
48
|
+
Forge.sParticleManager.recycleView(this.viewId);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<template>
|
|
54
|
+
<div ref="element" :style="{ width: viewWidth, height: viewHeight }" />
|
|
55
|
+
</template>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: ChenChanghua
|
|
3
|
+
* @Date: 2021-10-13 14:00:38
|
|
4
|
+
* @LastEditors: ChenChanghua
|
|
5
|
+
* @LastEditTime: 2021-10-13 14:11:14
|
|
6
|
+
* @Description: file content
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
class ApicDataBase {
|
|
10
|
+
constructor(arrayBuffer) {
|
|
11
|
+
this.LoopCount = 0;
|
|
12
|
+
this.FrameCount = 0;
|
|
13
|
+
this.Width = 0;
|
|
14
|
+
this.Height = 0;
|
|
15
|
+
this._Canvas = window.originDocument.createElement("canvas");
|
|
16
|
+
this._Context = this._Canvas.getContext("2d");
|
|
17
|
+
this._DecodedData = null;
|
|
18
|
+
this.decode(arrayBuffer);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
decode(arrayBuffer) {
|
|
22
|
+
console.log("decode need override ", arrayBuffer);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
toImage(frameIndex, canvas, canvasCtx) {
|
|
26
|
+
console.log("toImage need override ", frameIndex, canvas, canvasCtx);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export default ApicDataBase;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Author: ChenChanghua
|
|
3
|
+
* @Date: 2021-10-13 13:14:49
|
|
4
|
+
* @LastEditors: ChenChanghua
|
|
5
|
+
* @LastEditTime: 2021-10-13 17:13:24
|
|
6
|
+
* @Description: file content
|
|
7
|
+
-->
|
|
8
|
+
<script>
|
|
9
|
+
import Viewer from "./Viewer";
|
|
10
|
+
import WebpData from "./WebpData";
|
|
11
|
+
import GifData from "./GifData";
|
|
12
|
+
import { LoopType } from "./LoopToolBase";
|
|
13
|
+
|
|
14
|
+
const loadImage = (url) => {
|
|
15
|
+
return new Promise((resolve, reject) => {
|
|
16
|
+
let xhr = new XMLHttpRequest();
|
|
17
|
+
xhr.open("GET", url);
|
|
18
|
+
xhr.responseType = "arraybuffer";
|
|
19
|
+
xhr.onreadystatechange = () => {
|
|
20
|
+
if (xhr.readyState === 4 && xhr.status === 200) {
|
|
21
|
+
if (xhr.status == 200) {
|
|
22
|
+
let apic_data;
|
|
23
|
+
if (url.indexOf(".webp") > 0) {
|
|
24
|
+
apic_data = new WebpData(xhr.response);
|
|
25
|
+
resolve(apic_data);
|
|
26
|
+
} else if (url.indexOf(".gif") > 0) {
|
|
27
|
+
apic_data = new GifData(xhr.response);
|
|
28
|
+
resolve(apic_data);
|
|
29
|
+
} else {
|
|
30
|
+
reject("unsupport file " + url);
|
|
31
|
+
}
|
|
32
|
+
} else {
|
|
33
|
+
reject("get image data failed. " + url + " " + xhr.status);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
xhr.send();
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const getUrl = (base_url) => {
|
|
42
|
+
let url_trim = base_url.trim();
|
|
43
|
+
if (url_trim.indexOf("http") === 0) {
|
|
44
|
+
return url_trim;
|
|
45
|
+
} else if (url_trim.indexOf("url") === 0) {
|
|
46
|
+
let index_1 = url_trim.indexOf("(");
|
|
47
|
+
let index_2 = url_trim.indexOf(")");
|
|
48
|
+
return url_trim.substring(index_1 + 1, index_2);
|
|
49
|
+
} else {
|
|
50
|
+
return url_trim;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
let TOKEN = 0;
|
|
55
|
+
|
|
56
|
+
export default {
|
|
57
|
+
props: {
|
|
58
|
+
src: String,
|
|
59
|
+
style: Object,
|
|
60
|
+
autoPlay: {
|
|
61
|
+
type: Boolean,
|
|
62
|
+
default: true,
|
|
63
|
+
},
|
|
64
|
+
loopType: {
|
|
65
|
+
type: Number,
|
|
66
|
+
default: LoopType.LOOP_DEFAULT,
|
|
67
|
+
},
|
|
68
|
+
loopInfo: {
|
|
69
|
+
type: Array,
|
|
70
|
+
default: () => [[-1, -1, -1]],
|
|
71
|
+
},
|
|
72
|
+
onStart: Function,
|
|
73
|
+
onEnd: Function,
|
|
74
|
+
onLoad: Function,
|
|
75
|
+
},
|
|
76
|
+
setup() {
|
|
77
|
+
return {
|
|
78
|
+
viewId: -1,
|
|
79
|
+
viewer: null,
|
|
80
|
+
canvasId: "JsvApic" + TOKEN++,
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
methods: {
|
|
84
|
+
play() {
|
|
85
|
+
this.viewer?.play();
|
|
86
|
+
},
|
|
87
|
+
stop() {
|
|
88
|
+
this.viewer?.stop();
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
mounted() {
|
|
92
|
+
let canvas = window.originDocument.getElementById(this.canvasId);
|
|
93
|
+
if (canvas) {
|
|
94
|
+
loadImage(getUrl(this.src))
|
|
95
|
+
.then((data) => {
|
|
96
|
+
let listener = {
|
|
97
|
+
onstart: this.onStart,
|
|
98
|
+
onend: this.onEnd,
|
|
99
|
+
};
|
|
100
|
+
this.viewer = new Viewer(
|
|
101
|
+
data,
|
|
102
|
+
canvas,
|
|
103
|
+
listener,
|
|
104
|
+
this.autoPlay,
|
|
105
|
+
this.loopType,
|
|
106
|
+
this.loopInfo
|
|
107
|
+
);
|
|
108
|
+
if (this.onLoad) {
|
|
109
|
+
this.onLoad();
|
|
110
|
+
}
|
|
111
|
+
})
|
|
112
|
+
.catch((err) => console.error(err));
|
|
113
|
+
} else {
|
|
114
|
+
console.error("apic get canvas failed.");
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export { LoopType };
|
|
120
|
+
</script>
|
|
121
|
+
|
|
122
|
+
<template>
|
|
123
|
+
<jsvcanvas :id="canvasId" :style="style" />
|
|
124
|
+
</template>
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: ChenChanghua
|
|
3
|
+
* @Date: 2021-10-13 14:00:52
|
|
4
|
+
* @LastEditors: ChenChanghua
|
|
5
|
+
* @LastEditTime: 2021-10-13 14:10:42
|
|
6
|
+
* @Description: file content
|
|
7
|
+
*/
|
|
8
|
+
import ApicDataBase from "./ApicDataBase";
|
|
9
|
+
|
|
10
|
+
class GifData extends ApicDataBase {
|
|
11
|
+
decode(array_buffer) {
|
|
12
|
+
const gif = window.ApicTools.parseGIF(array_buffer);
|
|
13
|
+
this._DecodedData = window.ApicTools.decompressFrames(gif, true);
|
|
14
|
+
this.LoopCount = 0;
|
|
15
|
+
this.FrameCount = this._DecodedData.length;
|
|
16
|
+
this.Width = this._DecodedData[0].dims.width;
|
|
17
|
+
this.Height = this._DecodedData[0].dims.height;
|
|
18
|
+
|
|
19
|
+
// 打patch
|
|
20
|
+
for (let i = 0; i < this._DecodedData.length; i++) {
|
|
21
|
+
let frame = this._DecodedData[i];
|
|
22
|
+
if (
|
|
23
|
+
frame["dims"]["width"] !== this.Width ||
|
|
24
|
+
frame["dims"]["height"] !== this.Height
|
|
25
|
+
) {
|
|
26
|
+
// 打patch
|
|
27
|
+
let pre_frame_data = this._DecodedData[i - 1]["frameData"];
|
|
28
|
+
let left = frame["dims"]["left"];
|
|
29
|
+
let top = frame["dims"]["top"];
|
|
30
|
+
let width = frame["dims"]["width"];
|
|
31
|
+
let height = frame["dims"]["height"];
|
|
32
|
+
let patch_data = frame["patch"];
|
|
33
|
+
let image_data = new Uint8ClampedArray(this.Width * this.Height * 4);
|
|
34
|
+
for (let x = 0; x < this.Width; x++) {
|
|
35
|
+
for (let y = 0; y < this.Height; y++) {
|
|
36
|
+
let patch_x = x - left;
|
|
37
|
+
let patch_y = y - top;
|
|
38
|
+
let pixel_index = y * this.Width + x;
|
|
39
|
+
let patch_pixel_index = patch_y * width + patch_x;
|
|
40
|
+
if (
|
|
41
|
+
x >= left &&
|
|
42
|
+
x < left + width &&
|
|
43
|
+
y >= top &&
|
|
44
|
+
y < top + height &&
|
|
45
|
+
patch_data[patch_pixel_index * 4 + 3] > 0
|
|
46
|
+
) {
|
|
47
|
+
image_data[pixel_index * 4] = patch_data[patch_pixel_index * 4];
|
|
48
|
+
image_data[pixel_index * 4 + 1] =
|
|
49
|
+
patch_data[patch_pixel_index * 4 + 1];
|
|
50
|
+
image_data[pixel_index * 4 + 2] =
|
|
51
|
+
patch_data[patch_pixel_index * 4 + 2];
|
|
52
|
+
image_data[pixel_index * 4 + 3] =
|
|
53
|
+
patch_data[patch_pixel_index * 4 + 3];
|
|
54
|
+
} else {
|
|
55
|
+
image_data[pixel_index * 4] = pre_frame_data[pixel_index * 4];
|
|
56
|
+
image_data[pixel_index * 4 + 1] =
|
|
57
|
+
pre_frame_data[pixel_index * 4 + 1];
|
|
58
|
+
image_data[pixel_index * 4 + 2] =
|
|
59
|
+
pre_frame_data[pixel_index * 4 + 2];
|
|
60
|
+
image_data[pixel_index * 4 + 3] =
|
|
61
|
+
pre_frame_data[pixel_index * 4 + 3];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
frame["frameData"] = image_data;
|
|
66
|
+
} else {
|
|
67
|
+
frame["frameData"] = frame["patch"];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
toImage(frame_index, canvas, canvas_ctx) {
|
|
73
|
+
canvas.width = this.Width;
|
|
74
|
+
canvas.height = this.Height;
|
|
75
|
+
let frame = this._DecodedData[frame_index];
|
|
76
|
+
let image_data = canvas_ctx.createImageData(this.Width, this.Height);
|
|
77
|
+
image_data.data.set(frame["frameData"]);
|
|
78
|
+
canvas_ctx.putImageData(image_data, 0, 0);
|
|
79
|
+
return frame["delay"];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export default GifData;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: ChenChanghua
|
|
3
|
+
* @Date: 2021-10-13 14:01:14
|
|
4
|
+
* @LastEditors: ChenChanghua
|
|
5
|
+
* @LastEditTime: 2021-10-13 15:20:48
|
|
6
|
+
* @Description: file content
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
class LoopToolBase {
|
|
10
|
+
getNextIndex() {
|
|
11
|
+
return -1;
|
|
12
|
+
}
|
|
13
|
+
reset() {}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const LoopType = {
|
|
17
|
+
LOOP_DEFAULT: 0,
|
|
18
|
+
LOOP_INFINITE: 1,
|
|
19
|
+
LOOP_FINITE: 2,
|
|
20
|
+
LOOP_PART: 3,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default LoopToolBase;
|
|
24
|
+
|
|
25
|
+
export { LoopType };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: ChenChanghua
|
|
3
|
+
* @Date: 2021-10-13 14:01:28
|
|
4
|
+
* @LastEditors: ChenChanghua
|
|
5
|
+
* @LastEditTime: 2021-10-13 14:13:17
|
|
6
|
+
* @Description: file content
|
|
7
|
+
*/
|
|
8
|
+
import LoopToolBase, { LoopType } from "./LoopToolBase";
|
|
9
|
+
|
|
10
|
+
class NormalLoopTool extends LoopToolBase {
|
|
11
|
+
constructor(loop_type, loop_num, frame_num) {
|
|
12
|
+
super();
|
|
13
|
+
this.mLoopType = loop_type;
|
|
14
|
+
this.mLoopNum = loop_num;
|
|
15
|
+
this.mFrameNum = frame_num;
|
|
16
|
+
this.mLoopCount = 0;
|
|
17
|
+
this.mFrameIndex = 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
getNextIndex() {
|
|
21
|
+
let next_index = -1;
|
|
22
|
+
switch (this.mLoopType) {
|
|
23
|
+
case LoopType.LOOP_DEFAULT:
|
|
24
|
+
if (this.mLoopNum <= 0) {
|
|
25
|
+
//默认无限循环
|
|
26
|
+
next_index = (this.mFrameIndex + 1) % this.mFrameNum;
|
|
27
|
+
} else {
|
|
28
|
+
if (this.mFrameIndex == this.mFrameNum - 1) {
|
|
29
|
+
this.mLoopCount++;
|
|
30
|
+
}
|
|
31
|
+
next_index =
|
|
32
|
+
this.mLoopCount >= this.mLoopNum
|
|
33
|
+
? -1
|
|
34
|
+
: (this.mFrameIndex + 1) % this.mFrameNum;
|
|
35
|
+
}
|
|
36
|
+
break;
|
|
37
|
+
case LoopType.LOOP_INFINITE:
|
|
38
|
+
next_index = (this.mFrameIndex + 1) % this.mFrameNum;
|
|
39
|
+
break;
|
|
40
|
+
case LoopType.LOOP_FINITE:
|
|
41
|
+
if (this.mFrameIndex == this.mFrameNum - 1) {
|
|
42
|
+
this.mLoopCount++;
|
|
43
|
+
}
|
|
44
|
+
next_index =
|
|
45
|
+
this.mLoopCount >= this.mLoopNum
|
|
46
|
+
? -1
|
|
47
|
+
: (this.mFrameIndex + 1) % this.mFrameNum;
|
|
48
|
+
break;
|
|
49
|
+
default:
|
|
50
|
+
}
|
|
51
|
+
this.mFrameIndex = next_index;
|
|
52
|
+
return next_index;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
reset() {
|
|
56
|
+
this.mFrameIndex = 0;
|
|
57
|
+
this.mLoopCount = 0;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export default NormalLoopTool;
|