File tree Expand file tree Collapse file tree 15 files changed +74
-10
lines changed Expand file tree Collapse file tree 15 files changed +74
-10
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " minigame-canvas-engine-devtools" ,
3
- "version" : " 1.1.0 " ,
3
+ "version" : " 1.1.1 " ,
4
4
"description" : " 一些工具函数和方法,在调试阶段用于提高效率" ,
5
5
"main" : " dist/index.js" ,
6
6
"scripts" : {
Original file line number Diff line number Diff line change @@ -66,13 +66,28 @@ export default defineComponent({
66
66
doTCompile() {
67
67
let xml = document .getElementById (" template" )?.innerHTML ;
68
68
69
+ if (process .env .NODE_ENV !== ' production' ) {
70
+ xml = (window as any ).layoutTpl ;
71
+ }
72
+
69
73
// 没有监听到模板的情况
70
74
if (! xml ) {
71
75
this .showNoXMLDialog = true ;
72
76
return ;
73
77
}
74
78
75
- let comment = ` /**\n * xml经过doT.js编译出的模板函数\n * 因为小游戏不支持new Function,模板函数只能外部编译\n * 可直接拷贝本函数到小游戏中使用\n */\n ` ;
79
+ let comment =
80
+ `
81
+ /**
82
+ * 模板引擎使用教程可见:https://wechat-miniprogram.github.io/minigame-canvas-engine/tutorial/templateengine.html
83
+ * xml经过doT.js编译出的模板函数
84
+ * 因为小游戏不支持new Function,模板函数只能外部编译
85
+ * 可直接拷贝本函数到小游戏中使用
86
+ * 原始的模板如下:
87
+ * ${xml }
88
+ *
89
+ */
90
+ ` ;
76
91
77
92
const tplFunc = String (template (xml ));
78
93
Original file line number Diff line number Diff line change @@ -35,6 +35,11 @@ export default defineComponent({
35
35
36
36
methods: {
37
37
init() {
38
+ // for devtools debug
39
+ if (process .env .NODE_ENV !== ' production' ) {
40
+ (window as any ).layoutTpl = tpl ;
41
+ }
42
+
38
43
const Layout = (window as any ).Layout ;
39
44
Layout .registBitMapFont (
40
45
" fnt_number-export" ,
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { defineComponent } from "vue";
4
4
5
5
// <image src="https://res.wx.qq.com/wechatgame/product/webpack/userupload/20191119/wegoing.jpeg" id="wegoing"></image>
6
6
7
- let template = `
7
+ let tpl = `
8
8
<view id="container">
9
9
<button id="testButton" value="邀请"></button>
10
10
</view>
@@ -31,8 +31,13 @@ export default defineComponent({
31
31
mounted() {},
32
32
methods: {
33
33
init() {
34
+ // for devtools debug
35
+ if (process .env .NODE_ENV !== ' production' ) {
36
+ (window as any ).layoutTpl = tpl ;
37
+ }
38
+
34
39
const Layout = (window as any ).Layout ;
35
- Layout .init (template , style );
40
+ Layout .init (tpl , style );
36
41
37
42
let canvas = document .getElementById (" button" ) as HTMLCanvasElement ;
38
43
let context = canvas .getContext (" 2d" );
Original file line number Diff line number Diff line change @@ -42,6 +42,11 @@ export default defineComponent({
42
42
mounted() {},
43
43
methods: {
44
44
init() {
45
+ // for devtools debug
46
+ if (process .env .NODE_ENV !== ' production' ) {
47
+ (window as any ).layoutTpl = tpl ;
48
+ }
49
+
45
50
const Layout = (window as any ).Layout ;
46
51
Layout .init (template (tpl )({}), style );
47
52
Original file line number Diff line number Diff line change 1
1
<script lang="ts">
2
2
import { defineComponent } from " vue" ;
3
3
4
- let template = `
4
+ let tpl = `
5
5
<view id="container">
6
6
<text id="testText" class="redText" value="Hello World"></text>
7
7
</view>
@@ -38,9 +38,13 @@ export default defineComponent({
38
38
mounted() {},
39
39
methods: {
40
40
init() {
41
+ // for devtools debug
42
+ if (process .env .NODE_ENV !== ' production' ) {
43
+ (window as any ).layoutTpl = tpl ;
44
+ }
41
45
const Layout = (window as any ).Layout ;
42
46
43
- Layout .init (template , style );
47
+ Layout .init (tpl , style );
44
48
let canvas = document .getElementById (" helloworld" ) as HTMLCanvasElement ;
45
49
let context = canvas .getContext (" 2d" );
46
50
document .body .append (canvas );
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ const renderRect = {
5
5
width: 400 ,
6
6
height: 600 ,
7
7
};
8
- const template = `
8
+ const tpl = `
9
9
<view class="container">
10
10
<text class="loading" value="加载中..."></text>
11
11
<scrollview class="scrollView" scrollY="true"></scrollview>
@@ -45,6 +45,10 @@ export default defineComponent({
45
45
mounted() {},
46
46
methods: {
47
47
init() {
48
+ // for devtools debug
49
+ if (process .env .NODE_ENV !== ' production' ) {
50
+ (window as any ).layoutTpl = tpl ;
51
+ }
48
52
let canvas = document .getElementById (" insertElement" ) as HTMLCanvasElement ;
49
53
let context = canvas .getContext (" 2d" );
50
54
canvas .style .width = 400 / 2 + ' px' ;
@@ -54,7 +58,7 @@ export default defineComponent({
54
58
55
59
const Layout = (window as any ).Layout ;
56
60
Layout .updateViewPort (canvas .getBoundingClientRect ());
57
- Layout .init (template , style );
61
+ Layout .init (tpl , style );
58
62
59
63
Layout .layout (context );
60
64
// 模拟数据加载
Original file line number Diff line number Diff line change @@ -95,6 +95,10 @@ export default defineComponent({
95
95
mounted() {},
96
96
methods: {
97
97
init() {
98
+ // for devtools debug
99
+ if (process .env .NODE_ENV !== ' production' ) {
100
+ (window as any ).layoutTpl = tpl ;
101
+ }
98
102
const Layout = (window as any ).Layout ;
99
103
let canvas = document .getElementById (" invite" ) as HTMLCanvasElement ;
100
104
let context = canvas .getContext (" 2d" );
Original file line number Diff line number Diff line change @@ -31,6 +31,10 @@ export default defineComponent({
31
31
mounted() {},
32
32
methods: {
33
33
init() {
34
+ // for devtools debug
35
+ if (process .env .NODE_ENV !== ' production' ) {
36
+ (window as any ).layoutTpl = tpl ;
37
+ }
34
38
const Layout = (window as any ).Layout ;
35
39
Layout .init (tpl , style );
36
40
Original file line number Diff line number Diff line change @@ -151,6 +151,10 @@ export default defineComponent({
151
151
mounted() {},
152
152
methods: {
153
153
init() {
154
+ // for devtools debug
155
+ if (process .env .NODE_ENV !== ' production' ) {
156
+ (window as any ).layoutTpl = tpl ;
157
+ }
154
158
const Layout = (window as any ).Layout ;
155
159
// 创建mock数据
156
160
let item = {
You can’t perform that action at this time.
0 commit comments