微信小程序编译
All checks were successful
Plugin Library CI / publish (00.BuildOriginality) (push) Successful in 13s
Plugin Library CI / publish (00.StaryEvo) (push) Successful in 17s
Plugin Library CI / publish (00.StaryEvoTools) (push) Successful in 35s
Plugin Library CI / publish (01.HybridCLR) (push) Successful in 15s
Plugin Library CI / publish (02.InformationSave) (push) Successful in 3s
Plugin Library CI / publish (03.YooAsset) (push) Successful in 33s
Plugin Library CI / publish (04.AudioCore) (push) Successful in 3s
Plugin Library CI / publish (05.TableTextConversion) (push) Successful in 5s
Plugin Library CI / publish (06.UIFarme) (push) Successful in 15s
Plugin Library CI / publish (07.RKTools) (push) Successful in 2s
Plugin Library CI / publish (08.UniTask) (push) Successful in 3s
Plugin Library CI / publish (09.CodeChecker) (push) Successful in 16s
Plugin Library CI / publish (10.StoryEditor) (push) Successful in 3s
Plugin Library CI / publish (10.XNode) (push) Successful in 3s
Plugin Library CI / publish (11.PointCloudTools) (push) Successful in 2s
Plugin Library CI / publish (12.WeixinMinigame) (push) Successful in 2m32s

This commit is contained in:
2026-04-19 00:16:03 +08:00
parent 4c78ed674c
commit 0d6faa56f4
646 changed files with 140709 additions and 12 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 56f962c7dd72c1247a1c448de2434c4c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,124 @@
/* eslint-disable no-param-reassign */
import { getCurrTime, promisify } from './utils';
const getFriendCloudStorage = promisify(wx.getFriendCloudStorage);
const getGroupCloudStorage = promisify(wx.getGroupCloudStorage);
const setUserCloudStorage = promisify(wx.setUserCloudStorage);
const getUserInfo = promisify(wx.getUserInfo);
/**
* 获取用户信息
* API文档可见https://developers.weixin.qq.com/minigame/dev/api/open-api/data/OpenDataContext-wx.getUserInfo.html
*/
export function getSelfData() {
return getUserInfo({
openIdList: ['selfOpenId'],
}).then((res) => res.data[0] || {});
}
let getSelfPromise;
/**
* 将 UserGameData 数据反序列化
* @param { UserGameData } item
* https://developers.weixin.qq.com/minigame/dev/api/open-api/data/UserGameData.html
*/
function getWxGameData(item) {
let source;
try {
source = JSON.parse(item.KVDataList[0].value);
}
catch (e) {
source = {
wxgame: {
score: 0,
update_time: getCurrTime(),
},
};
}
return source.wxgame;
}
/**
* 处理 getFriendCloudStorage 和 getGroupCloudStorage 返回的在玩好友数据
*/
function rankDataFilter(res, selfUserInfo = false) {
const data = (res.data || []).filter((item) => item.KVDataList && item.KVDataList.length);
return data
.map((item) => {
const { score, update_time: updateTime } = getWxGameData(item);
item.score = score;
item.update_time = updateTime;
/**
* 请注意,这里判断是否为自己并不算特别严谨的做法
* 比较严谨的做法是从游戏域将openid传进来示例为了简化简单通过 avatarUrl 来判断
*/
if (selfUserInfo && selfUserInfo.avatarUrl === item.avatarUrl) {
item.isSelf = true;
}
return item;
})
// 升序排序
.sort((a, b) => b.score - a.score);
}
/**
* 获取好友排行榜列表
* API文档可见https://developers.weixin.qq.com/minigame/dev/api/open-api/data/wx.getFriendCloudStorage.html
*/
export function getFriendRankData(key, needMarkSelf = true) {
console.log('[WX OpenData] getFriendRankData with key: ', key);
return getFriendCloudStorage({
keyList: [key],
}).then((res) => {
console.log('[WX OpenData] getFriendRankData success: ', res);
if (needMarkSelf) {
getSelfPromise = getSelfPromise || getSelfData();
return getSelfPromise.then(userInfo => rankDataFilter(res, userInfo));
}
return rankDataFilter(res);
});
}
/**
* 获取群同玩成员的游戏数据。小游戏通过群分享卡片打开的情况下才可以调用。该接口需要用户授权,且只在开放数据域下可用。
* API文档可见: https://developers.weixin.qq.com/minigame/dev/api/open-api/data/wx.getGroupCloudStorage.html
*/
export function getGroupFriendsRankData(shareTicket, key, needMarkSelf = true) {
console.log('[WX OpenData] getGroupFriendsRankData with shareTicket and key: ', shareTicket, key);
return getGroupCloudStorage({
shareTicket,
keyList: [key],
}).then((res) => {
console.log('[WX OpenData] getGroupFriendsRankData success: ', res);
if (needMarkSelf) {
getSelfPromise = getSelfPromise || getSelfData();
return getSelfPromise.then(userInfo => rankDataFilter(res, userInfo));
}
return rankDataFilter(res);
});
}
/**
* 写入用户排行榜数据value 的值一般只需要为 Object 经过 JSON.stringify 的字符串即可。
* 但排行榜支持展示在游戏中心,因此这里统一用游戏中心需要的数据结构执行上报,需要展示在游戏中心的数据可以经过以下操作:
* mp.weixin.qq.com 的小游戏管理后台“设置 - 游戏 - 排行榜设置”下配置对应的 key 以及相关排行榜属性。
* @param { String } key 排行榜对应的 key
* @param { Number } score 排行榜对应的分数
* @param { Object } extra 除了分数还需要写入的其他字段,不需要不填即可
* @example
* setUserRecord('user_rank', 100, { type: 'coin' })
*/
export function setUserRecord(key, score = 0, extra = {}) {
console.log('[WX OpenData] setUserRecord: ', score);
return setUserCloudStorage({
KVDataList: [
{
key,
value: JSON.stringify({
wxgame: {
score,
// 时间单位:秒
update_time: getCurrTime(),
},
// wxgame下开发者不可自定义其他字段 wxgame同级开发者可自由定义比如定义一个detail 字段,用于存储取得该分数的中间状态。
...extra,
}),
},
],
}).then((res) => {
console.log('[WX OpenData] setUserRecord success: ', res);
});
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: dec2f6877d102b34f9908168db1fc8e7
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,11 @@
export function getCurrTime() {
return Math.floor(Date.now() / 1000);
}
export function promisify(func) {
return (args = {}) => new Promise((resolve, reject) => {
func(Object.assign(args, {
success: resolve,
fail: reject,
}));
});
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 2bec39b7c712a2f41a41b1024422d9c9
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,153 @@
/* eslint-disable indent */
import { getFriendRankData, getGroupFriendsRankData, setUserRecord } from './data/index';
import getFriendRankXML from './render/tpls/friendRank';
import getFriendRankStyle from './render/styles/friendRank';
import getTipsXML from './render/tpls/tips';
import getTipsStyle from './render/styles/tips';
import { showLoading } from './loading';
const Layout = requirePlugin('Layout').default;
const RANK_KEY = 'user_rank';
const sharedCanvas = wx.getSharedCanvas();
const sharedContext = sharedCanvas.getContext('2d');
// test
setUserRecord(RANK_KEY, Math.ceil(Math.random() * 1000));
const MessageType = {
WX_RENDER: 'WXRender',
WX_DESTROY: 'WXDestroy',
WX_SHOW: 'WXShow',
SHOW_FRIENDS_RANK: 'showFriendsRank',
SHOW_GROUP_FRIENDS_RANK: 'showGroupFriendsRank',
SET_USER_RECORD: 'setUserRecord',
};
/**
* 绑定邀请好友事件
* 温馨提示,这里仅仅是示意,请注意修改 shareMessageToFriend 参数
*/
const initShareEvents = () => {
// 绑定邀请
const shareBtnList = Layout.getElementsByClassName('shareToBtn');
shareBtnList
&& shareBtnList.forEach((item) => {
item.on('click', () => {
if (item.dataset.isSelf === 'false') {
wx.shareMessageToFriend({
openId: item.dataset.id,
title: '最强战力排行榜!谁是第一?',
imageUrl: 'https://mmgame.qpic.cn/image/5f9144af9f0e32d50fb878e5256d669fa1ae6fdec77550849bfee137be995d18/0',
});
}
});
});
};
/**
* 初始化开放域,主要是使得 Layout 能够正确处理跨引擎的事件处理
* 如果游戏里面有移动开放数据域对应的 RawImage也需要抛事件过来执行Layout.updateViewPort
*/
const initOpenDataCanvas = async (data) => {
Layout.updateViewPort({
x: data.x / data.devicePixelRatio,
y: data.y / data.devicePixelRatio,
width: data.width / data.devicePixelRatio,
height: data.height / data.devicePixelRatio,
});
};
// 给定 xml 和 style渲染至 sharedCanvas
function LayoutWithTplAndStyle(xml, style) {
Layout.clear();
Layout.init(xml, style);
Layout.layout(sharedContext);
}
// 仅仅渲染一些提示,比如数据加载中、当前无授权等
function renderTips(tips = '') {
LayoutWithTplAndStyle(getTipsXML({
tips,
}), getTipsStyle({
width: sharedCanvas.width,
height: sharedCanvas.height,
}));
}
// 将好友排行榜数据渲染在 sharedCanvas
async function renderFriendsRank() {
showLoading();
try {
const data = await getFriendRankData(RANK_KEY);
if (!data.length) {
renderTips('暂无好友数据');
return;
}
LayoutWithTplAndStyle(getFriendRankXML({
data,
}), getFriendRankStyle({
width: sharedCanvas.width,
height: sharedCanvas.height,
}));
initShareEvents();
}
catch (e) {
console.error('renderFriendsRank error', e);
renderTips('请进入设置页允许获取微信朋友信息');
}
}
// 渲染群排行榜
async function renderGroupFriendsRank(shareTicket) {
showLoading();
try {
const data = await getGroupFriendsRankData(shareTicket, RANK_KEY);
if (!data.length) {
renderTips('暂无群同玩好友数据');
return;
}
LayoutWithTplAndStyle(getFriendRankXML({
data,
}), getFriendRankStyle({
width: sharedCanvas.width,
height: sharedCanvas.height,
}));
}
catch (e) {
renderTips('群同玩好友数据加载失败');
}
}
function main() {
wx.onMessage((data) => {
console.log('[WX OpenData] onMessage', data);
if (typeof data === 'string') {
try {
// eslint-disable-next-line no-param-reassign
data = JSON.parse(data);
}
catch (e) {
console.error('[WX OpenData] onMessage data is not a object');
return;
}
}
switch (data.type) {
// 来自 WX Unity SDK 的信息
case MessageType.WX_RENDER:
initOpenDataCanvas(data);
break;
// 来自 WX Unity SDK 的信息
case MessageType.WX_DESTROY:
Layout.clearAll();
break;
// 来自 WX Unity SDK 的信息
case MessageType.WX_SHOW:
Layout.repaint();
break;
// 下面为业务自定义消息
case MessageType.SHOW_FRIENDS_RANK:
renderFriendsRank();
break;
case MessageType.SHOW_GROUP_FRIENDS_RANK:
renderGroupFriendsRank(data.shareTicket);
break;
case MessageType.SET_USER_RECORD:
setUserRecord(RANK_KEY, data.score);
break;
default:
console.error(`[WX OpenData] onMessage type 「${data.type}」 is not supported`);
break;
}
});
}
main();

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: a08844c29c2412746ba35394ac2ec485
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
// 通过插件的方式引用 Layout
const Layout = requirePlugin('Layout').default;
const sharedCanvas = wx.getSharedCanvas();
const sharedContext = sharedCanvas.getContext('2d');
const style = {
container: {
width: '100%',
height: '100%',
justifyContent: 'center',
alignItems: 'center',
},
loading: {
width: 150,
height: 150,
borderRadius: 75,
},
};
const tpl = `
<view id="container">
<image src="open-data/render/image/loading.png" id="loading"></image>
</view>
`;
export function showLoading() {
Layout.clear();
Layout.init(tpl, style);
Layout.layout(sharedContext);
const image = Layout.getElementById('loading');
let degrees = 0;
Layout.ticker.add(() => {
degrees = (degrees + 2) % 360;
image.style.transform = `rotate(${degrees}deg)`;
});
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 2af787522e5a23c4d9f0b45ba02c6e93
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f51059be52e7d814bac1b854b5c2498d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bbd385ef3c66e474b83598b9999b3f7a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 76f3aa5f7a88bcb48ad675995ca25040
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 870 B

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: b53265a4c219940458124404827c8b7f
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 816 B

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 5bdd8dc7dfa6208448b1db7de8ae1035
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: c380ab0490cca9e4b859fd05ecd432d3
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 23ccde10cdd169f46a7ca7af523ae78f
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 339 B

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: f1928a65bcc528d4b8e74504ea133a1c
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: b9a2ea7a209cbfe47888811d04877f04
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 052ec80af0110f54d9e92de37648d06e
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 21dba4f68553b284fa730d26204ef9de
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 8f474123e68885c4b8502e2bc4d00859
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b91afffdab995a64d99e6b5e68dfe7a2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,142 @@
export default function getStyle(data) {
return {
container: {
width: data.width,
height: data.height,
borderRadius: 12,
paddingLeft: data.width * 0.03,
paddingRight: data.width * 0.03,
},
rankList: {
width: Math.ceil(data.width * 0.94),
height: data.height,
},
list: {
width: Math.ceil(data.width * 0.94),
height: data.height,
},
listItem: {
position: 'relative',
width: Math.ceil(data.width * 0.94),
height: data.height / 2 / 3,
flexDirection: 'row',
alignItems: 'center',
marginTop: 2,
},
rankBg: {
position: 'absolute',
top: 0,
left: 0,
width: Math.ceil(data.width * 0.94),
height: data.height / 2 / 3,
},
rankAvatarBg: {
position: 'absolute',
top: (data.height / 2 / 3) * 0.1,
left: data.width * 0.08,
width: (data.height / 2 / 3) * 0.8,
height: (data.height / 2 / 3) * 0.8,
},
rankAvatar: {
borderRadius: data.width * 0.06,
marginLeft: data.width * 0.08 + (data.height / 2 / 3) * 0.1,
width: (data.height / 2 / 3) * 0.6,
height: (data.height / 2 / 3) * 0.6,
},
rankNameView: {
position: 'relative',
marginLeft: data.width * 0.06,
width: data.width * 0.35,
height: data.height / 2 / 3,
},
rankNameBg: {
position: 'absolute',
top: (data.height / 2 / 3) * 0.14,
left: 0,
width: data.width * 0.35,
height: (data.height / 2 / 3) * 0.4,
},
rankName: {
position: 'absolute',
top: (data.height / 2 / 3) * 0.14,
left: 0,
width: data.width * 0.35,
height: (data.height / 2 / 3) * 0.4,
textAlign: 'center',
verticalAlign: 'center',
fontSize: data.width * 0.043,
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
color: '#fff',
},
rankScoreTip: {
position: 'absolute',
bottom: (data.height / 2 / 3) * 0.1,
left: 0,
width: data.width * 0.15,
height: (data.height / 2 / 3) * 0.3,
lineHeight: (data.height / 2 / 3) * 0.3,
fontSize: data.width * 0.042,
color: '#fff',
},
rankScoreVal: {
position: 'absolute',
bottom: (data.height / 2 / 3) * 0.1,
left: data.width * 0.15,
width: data.width * 0.18,
height: (data.height / 2 / 3) * 0.3,
lineHeight: (data.height / 2 / 3) * 0.3,
fontSize: data.width * 0.042,
color: '#fff',
},
shareNameView: {
position: 'relative',
marginLeft: data.width * 0.06,
width: data.width * 0.35,
height: (data.height / 2 / 3) * 0.4,
},
shareNameBg: {
position: 'absolute',
top: 0,
left: 0,
width: data.width * 0.35,
height: (data.height / 2 / 3) * 0.4,
},
shareName: {
position: 'absolute',
top: 0,
left: 0,
width: data.width * 0.35,
height: (data.height / 2 / 3) * 0.4,
textAlign: 'center',
lineHeight: (data.height / 2 / 3) * 0.4,
fontSize: data.width * 0.043,
textOverflow: 'ellipsis',
color: '#fff',
},
shareToBtn: {
position: 'relative',
marginLeft: data.width * 0.08,
width: data.width * 0.21,
height: data.height * 0.16,
},
shareBtnBg: {
position: 'absolute',
right: 0,
top: data.height * 0.16 * 0.25,
width: data.width * 0.21,
height: data.height * 0.16 * 0.5,
},
shareText: {
position: 'absolute',
right: 0,
top: data.height * 0.16 * 0.25,
width: data.width * 0.21,
height: data.height * 0.16 * 0.5,
lineHeight: data.height * 0.16 * 0.5,
textAlign: 'center',
fontSize: data.width * 0.043,
color: '#fff',
},
};
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 69ea146a8375a1a41adc227b814aac29
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
export default function getStyle(data) {
return {
container: {
flexDirection: 'row',
width: data.width,
height: data.height,
justifyContent: 'center',
alignItems: 'center',
},
tips: {
color: '#000000',
width: data.width,
height: 50,
fontSize: 50,
textAlign: 'center',
},
};
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 33c3d68483eb319468fcf6042b0b56ab
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f4a4363e0dc320f4385265c544f58a2b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,46 @@
/**
* 模板引擎使用教程可见https://wechat-miniprogram.github.io/minigame-canvas-engine/tutorial/templateengine.html
* xml经过doT.js编译出的模板函数
* 因为小游戏不支持new Function模板函数只能外部编译
* 可直接拷贝本函数到小游戏中使用
* 原始的模板如下:
*
<view class="container" id="main">
<view class="rankList">
<scrollview class="list" scrollY="true">
{{~it.data :item:index}}
<view class="listItem">
<image src="open-data/render/image/rankBg.png" class="rankBg"></image>
<image class="rankAvatarBg" src="open-data/render/image/rankAvatar.png"></image>
<image class="rankAvatar" src="{{= item.avatarUrl }}"></image>
<view class="rankNameView">
<image class="rankNameBg" src="open-data/render/image/nameBg.png"></image>
<text class="rankName" value="{{=item.nickname}}"></text>
<text class="rankScoreTip" value="战力值:"></text>
<text class="rankScoreVal" value="{{=item.score || 0}}"></text>
</view>
<view class="shareToBtn" data-isSelf="{{= item.isSelf ? true : false}}" data-id="{{= item.openid || ''}}">
<image src="open-data/render/image/{{= item.isSelf ? 'button3':'button2'}}.png" class="shareBtnBg"></image>
<text class="shareText" value="{{= item.isSelf ? '你自己' : '分享'}}"></text>
</view>
</view>
{{~}}
</scrollview>
</view>
</view>
*
*/
export default function tplFunc(it) {
var out = '<view class="container" id="main"> <view class="rankList"> <scrollview class="list" scrollY="true"> ';
var arr1 = it.data;
if (arr1) {
var item, index = -1, l1 = arr1.length - 1;
while (index < l1) {
item = arr1[index += 1];
out += ' <view class="listItem"> <image src="open-data/render/image/rankBg.png" class="rankBg"></image> <image class="rankAvatarBg" src="open-data/render/image/rankAvatar.png"></image> <image class="rankAvatar" src="' + (item.avatarUrl) + '"></image> <view class="rankNameView"> <image class="rankNameBg" src="open-data/render/image/nameBg.png"></image> <text class="rankName" value="' + (item.nickname) + '"></text> <text class="rankScoreTip" value="战力值:"></text> <text class="rankScoreVal" value="' + (item.score || 0) + '"></text> </view> <view class="shareToBtn" data-isSelf="' + (item.isSelf ? true : false) + '" data-id="' + (item.openid || '') + '"> <image src="open-data/render/image/' + (item.isSelf ? 'button3' : 'button2') + '.png" class="shareBtnBg"></image> <text class="shareText" value="' + (item.isSelf ? '你自己' : '分享') + '"></text> </view> </view> ';
}
}
out += ' </scrollview> </view></view>';
return out;
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 02a3592f7dacf20489d6e6615de94308
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,23 @@
/**
* 下面的内容分成两部分,第一部分是一个模板,模板的好处是能够有一定的语法
* 坏处是模板引擎一般都依赖 new Function 或者 eval 能力,小游戏下面是没有的
* 所以模板的编译需要在外部完成,可以将注释内的模板贴到下面的页面内,点击 "run"就能够得到编译后的模板函数
* https://wechat-miniprogram.github.io/minigame-canvas-engine/playground.html
* 如果觉得模板引擎使用过于麻烦,也可以手动拼接字符串,本文件对应函数的目标仅仅是为了创建出 xml 节点数
*/
/**
<view id="container">
<text class="tips" value="{{= it.tips || '' }}"></text>
</view>
*/
/**
* xml经过doT.js编译出的模板函数
* 因为小游戏不支持new Function模板函数只能外部编译
* 可直接拷贝本函数到小游戏中使用
*/
export default function anonymous(it) {
const out = `<view id="container"> <text class="tips" value="${it.tips || ''}"></text></view>`;
return out;
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 2ee33f73b412b4143a012d6d8ddb10f8
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: