Commit 595aea93 authored by Edwise's avatar Edwise 🍷

hha

parents
# Created by .ignore support plugin (hsz.mobi)
### Node template
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
/**
* Created by rockyl on 2020/10/23.
*/
import {getPxToken} from "../src/projectx";
function sum(a, b) {
return a + b;
}
test('adds 1 + 2 to equal 3', () => {
expect(sum(1, 2)).toBe(3);
});
test('getPxToken', async () => {
expect.assertions(1);
const {type, payload} = await getPxToken();
expect(type).toBe('success');
});
{
"id": "animation",
"name": "动画库",
"desc": "一些公共的动画",
"exports": [
{
"id": "d1fd0205-a999-49f5-9d57-2d8af1e53e48",
"name": "动画测试",
"type": 4,
"data": {
"attrs": {
"loop": "0",
"time": "2.0",
"autoPlay": true,
"timingFunction": "linear"
},
"frame": [
{
"key": 0,
"style": {
"scaleX": "1",
"scaleY": 1,
"moveX": 0,
"moveY": 0,
"rotate": 0,
"opacity": 1
}
},
{
"key": 13.99999999,
"style": {
"scaleX": "1",
"scaleY": 1,
"moveX": 0,
"moveY": 0,
"rotate": 0,
"opacity": 1
}
},
{
"key": 14,
"style": {
"scaleX": "1.3",
"scaleY": "1.3",
"moveX": 0,
"moveY": "0",
"rotate": 0,
"opacity": 1
}
},
{
"key": 27.99999999,
"style": {
"scaleX": "1.3",
"scaleY": "1.3",
"moveX": 0,
"moveY": "0",
"rotate": 0,
"opacity": 1
}
},
{
"key": 28,
"style": {
"scaleX": "1",
"scaleY": 1,
"moveX": 0,
"moveY": 0,
"rotate": 0,
"opacity": 1
}
},
{
"key": 41.99999999,
"style": {
"scaleX": "1",
"scaleY": 1,
"moveX": 0,
"moveY": 0,
"rotate": 0,
"opacity": 1
}
},
{
"key": 42,
"style": {
"scaleX": "1.3",
"scaleY": "1.3",
"moveX": "0",
"moveY": 0,
"rotate": 0,
"opacity": 1
}
},
{
"key": 69.99999999,
"style": {
"scaleX": "1.3",
"scaleY": "1.3",
"moveX": "0",
"moveY": 0,
"rotate": 0,
"opacity": 1
}
},
{
"key": 70,
"style": {
"scaleX": "1",
"scaleY": 1,
"moveX": 0,
"moveY": 0,
"rotate": 0,
"opacity": 1
}
}
]
}
},
{
"id": "fcfeab33-2005-4d99-90c3-ead1075249e6",
"name": "123123",
"type": 4,
"data": {
"attrs": {
"loop": 0,
"time": "2.0",
"autoPlay": true,
"timingFunction": "linear"
},
"frame": [
{
"key": 10,
"style": {
"scaleX": 1,
"scaleY": 1,
"moveX": 0,
"moveY": 0,
"rotate": 0,
"opacity": 1
}
},
{
"key": 34.99999999,
"style": {
"scaleX": 1,
"scaleY": 1,
"moveX": 0,
"moveY": 0,
"rotate": 0,
"opacity": 1
}
},
{
"key": 35,
"style": {
"scaleX": 1,
"scaleY": "2",
"moveX": 0,
"moveY": 0,
"rotate": 0,
"opacity": 1
}
},
{
"key": 58.99999999,
"style": {
"scaleX": 1,
"scaleY": "2",
"moveX": 0,
"moveY": 0,
"rotate": 0,
"opacity": 1
}
},
{
"key": 59,
"style": {
"scaleX": 1,
"scaleY": 1,
"moveX": 0,
"moveY": 0,
"rotate": 0,
"opacity": 1
}
}
]
}
}
]
}
module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current',
},
},
],
],
};
This diff is collapsed.
{
"name": "packages",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"pack": "node scripts/pack.js",
"test": "jest"
},
"dependencies": {
"fyge": "^2.0.0",
"isuuid": "^0.1.0",
"svga-parser": "^1.1.0"
},
"devDependencies": {
"@babel/core": "^7.12.3",
"@babel/preset-env": "^7.12.1",
"@rollup/plugin-commonjs": "^15.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^9.0.0",
"babel-jest": "^26.6.0",
"chalk": "^4.1.0",
"jest": "^26.6.0",
"rollup": "^2.26.11",
"tslib": "^2.0.1"
}
}
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
export * from './log';
import isuuidImport from 'isuuid';
/**
* @type 1
* @name 判断是不是uuid
* @desc 判断是不是uuid
* @outputs {success:'是', failed:'不是'}
* @param {string} text 文本
*/
export function isuuid(text) {
return isuuidImport(text);
}
/**
* @type 1
* @name ua判断
* @desc 对ua进行正则判断,用于判断环境
* @outputs {success:'匹配成功', failed:'匹配失败'}
* @param {string|RegExp} reg 正则表达式
* @param {string} [flags] 正则标识
*/
export function testUA(reg, flags) {
let regexp = reg;
if (typeof reg === 'string') {
regexp = new RegExp(reg, flags);
}
return {
type: navigator.userAgent.match(regexp) ? 'success' : 'failed',
}
}
/**
* @type 1
* @name 返回前一个页面
* @desc 返回前一个历史记录的页面
*/
export function back() {
history.back();
}
/**
* @type 1
* @name 打印日志
* @desc 打印日志到控制台
* @outputs {success:'打印完成'}
* @param {*} [content] 内容
*/
export function log(content) {
console.log(content);
return {
type: 'success',
}
}
{
"id": "browser",
"name": "浏览器相关的过程",
"desc": "浏览器相关的一些过程"
}
/**
* Created by rockyl on 2020/8/26.
*
* @id duiba
* @name 兑吧相关的过程
* @desc 兑吧相关的过程
*/
/**
* @type 1
* @name 请求API接口
* @desc 请求api
* @outputs {success:'成功:响应内容', failed:'失败:错误信息'}
* @param {string} uri 地址
* @param {Object} [options] 请求配置
*/
export async function fetchApi(uri, options) {
const resp = await fetch(uri, options);
try {
const respObj = await resp.json();
return {
type: 'complete',
payload: respObj,
}
} catch (e) {
return {
type: 'exception',
payload: e,
}
}
}
This diff is collapsed.
import { Event, Sprite } from "fyge";
export class GameStage extends Sprite{
constructor(data){
super();
this.props = data;
this.addEventListener(Event.ADDED_TO_STAGE,this.addToViewPort,this);
}
addToViewPort(){
this.removeEventListener(Event.ADDED_TO_STAGE,this.addToViewPort,this);
const {
assets,
angleOffset,
speedRange,
initPosRange
} = this.props;
console.log("props", this.props)
console.log("ass", assets)
// console.log(TextureCache);
}
}
\ No newline at end of file
import { Sound } from "fyge";
import * as SvgaParser from "svga-parser";
export class Ins{
static stageW;
static stageH;
static normalCarArr;
static vipCarArr;
static speedX;
static speedY;
static minSpeedY = 10;
static maxLevel = 2;
static effectLayer;
static CarState = {
default:1,
goStage:2,
inStage:3,
turning:4,
wait:5,
turnOver:6
}
static leftStartX = 150;
static rightStartX = 600;
static canTouch = false;
static trackCarArr1 = [];
static trackCarArr2 = [];
static msg = {
trackTurnOver:"trackTurnOver",
oneTurnOver:"oneTurnOver",
vipStartTurn:"vipStartTurn"
}
static svgaSource = [
{src:'https://yun.duiba.com.cn/spark/assets/dedd4a9ac243add7a6d98832169d7cf9619b8ace.svga',pool:'vipWhite'}, //白色vip轨迹
{src:'https://yun.duiba.com.cn/spark/assets/408c7fef572cb91d72c61d6683fd58195bdb0d6b.svga',pool:'vipOrigen'}, //橙色vip轨迹
{src:'https://yun.duiba.com.cn/spark/assets/73ac94bd65aac58ae9aa579c5c002c2580ba1b4f.svga',pool:'vipRed'}, //红色vip轨迹
{src:'https://yun.duiba.com.cn/spark/assets/262dc08ac3d0854dd0a476ba8840831598d7f233.svga',pool:'vipBlue'}, //蓝色vip轨迹
{src:'https://yun.duiba.com.cn/spark/assets/1fd4eb658813a6662186ab6d867e80b5ea7d2860.svga',pool:'Wait'}, //等待尾气
{src:'https://yun.duiba.com.cn/spark/assets/64ce8e739f9fdc1718fb03401d170f413755ade5.svga',pool:'trailGas'}, //普通车转弯轨迹
{src:'https://yun.duiba.com.cn/spark/assets/753d6cd47b35a6da2065e902dfaa7820e7df5865.svga',pool:'turnFailed'} //右转弯失败
]
static svgaPool={
vipWhite:'',
vipOrigen:'',
vipRed:'',
vipBlue:'',
Wait:'',
trailGas:'',
turnFailed:''
};
static vipText = [
'智能安全模式',
'沉浸式座舱',
'宽敞舒适空间',
'动力强油耗低'
]
static levelInitTrackerTime = {
1:[30,100],
2:[30,100],
3:[30,100],
4:[30,100],
5:[30,100],
6:[30,90],
7:[30,90],
8:[30,90],
9:[30,90],
10:[30,90],
11:[40,60],
12:[40,60],
13:[40,60],
14:[40,60],
15:[40,60],
16:[40,50],
17:[40,50],
18:[40,50],
19:[40,50],
20:[40,50]
}
}
export function LoadSvgaToCache(callback, arr) {
let count = 0;
let countAll = arr.length;
// console.log(countAll)
if (!countAll) callback(true);
let mark = true;
for (let i = 0; i < countAll; i++) {
SvgaParser.loadSvga(
arr[i].src,
(v) => {
Ins.svgaPool[arr[i].pool] = v;
},
(err) => {
mark = false;
console.log(err);
}
)
if (++count == countAll) callback(mark);
}
}
export function loadSvgaList() {
console.log("开始加载svga资源")
let list = [];
for (let key in Ins.svgaSource) {
list.push(Ins.svgaSource[key]);
}
// console.log(list)
let p = new Promise((resolve, reject) => {
LoadSvgaToCache((s) => {
if (s) {
console.log("svgapool",Ins.svgaPool);
resolve()
} else {
reject();
}
}, list /*, resPath + name*/ )
})
Sound
return p;
}
export class vector {
x;
y;
constructor(x, y) {
this.x = x||0;
this.y = y||0;
}
sub(v) {
return new vector(this.x-v.x,this.y-v.y);
}
dot(v) {
return this.x * v.x + this.y * v.y;
}
}
export class OBB {
centerPoint;
extents;
axes;
w;
h;
rotation;
constructor(cenerPoint,w,h,r){
let radius = r*Math.PI/180;
this.centerPoint = cenerPoint;
this.extents = [w/2,h/2];
this.axes = [new vector(Math.cos(radius),Math.sin(radius)),new vector(-1*Math.sin(radius),Math.cos(radius))];
this.w=w;
this.h=h;
this.rotation = r;
}
getProjectionRadius(axis) {
return this.extents[0] * Math.abs(axis.dot(this.axes[0]))+this.extents[1]*Math.abs(axis.dot(this.axes[1]));
}
}
export function detectorOBBvsOBB(OBB1, OBB2) {
var nv = OBB1.centerPoint.sub(OBB2.centerPoint);
var axisA1 = OBB1.axes[0];
if (OBB1.getProjectionRadius(axisA1) + OBB2.getProjectionRadius(axisA1) <= Math.abs(nv.dot(axisA1))) return false;
var axisA2 = OBB1.axes[1];
if (OBB1.getProjectionRadius(axisA2) + OBB2.getProjectionRadius(axisA2) <= Math.abs(nv.dot(axisA2))) return false;
var axisB1 = OBB2.axes[0];
if (OBB1.getProjectionRadius(axisB1) + OBB2.getProjectionRadius(axisB1) <= Math.abs(nv.dot(axisB1))) return false;
var axisB2 = OBB2.axes[1];
if (OBB1.getProjectionRadius(axisB2) + OBB2.getProjectionRadius(axisB2) <= Math.abs(nv.dot(axisB2))) return false;
return true;
}
/**生成范围内的随机数 */
export function getRandomValue(min,max){
return Math.floor(Math.random()*(max-min+1)+min);
}
// 二次贝塞尔,用于做曲线运动
export function bezier(t, p0, p1, p2) {
// (1-t)^2 P0 + 2(1-t)tP1+ t^2P2
return Math.pow(1 - t, 2) * p0 + 2 * (1 - t) * t * p1 + Math.pow(t, 2) * p2;
}
\ No newline at end of file
import { Ins } from "./Ins";
export class LoadSvga {
static LoadSvgaToCache(callback, arr) {
let count = 0;
let countAll = arr.length;
// console.log(countAll)
if (!countAll) callback(true);
let mark = true;
// console.log("aaaa",arr);
for (let i = 0; i < countAll; i++) {
// SvgaParser.loadSvga(
// arr[i].src,
// (v) => {
// Ins.svgaPool[arr[i].pool]=v;
// },
// (err) => {
// mark = false;
// console.log(err);
// }
// )
if (++count == countAll) callback(mark);
}
}
static loadSvgaList() {
console.log("开始加载lottie资源")
let list = [];
for (let key in this.svgaSource) {
list.push(resList[key]);
}
console.log(list)
let p = new Promise((resolve, reject) => {
LoadSvgaToCache((s) => {
if (s) {
resolve()
} else {
reject();
}
}, list /*, resPath + name*/ )
})
return p;
}
}
export function initLottie(callback, arr) {
let count = 0;
let countAll = arr.length;
console.log(countAll)
if (!countAll) callback(true);
let mark = true;
for (let i = 0; i < countAll; i++) {
let textureJson = arr[i].json;
FYGE.GlobalLoader.loadImage((s, image) => {
if (s) {
FYGE.createTextureSheet(new FYGE.BaseTexture(image), textureJson);
} else {
mark = false
}
if (++count == countAll) callback(mark);
}, arr[i]["imgUrl"])
}
}
export function initLottieList(resList) {
console.log("开始加载lottie资源")
let list = [];
for (let key in resList) {
list.push(resList[key]);
}
console.log(list)
let p = new Promise((resolve, reject) => {
8
initLottie((s) => {
if (s) {
resolve()
} else {
reject();
}
}, list /*, resPath + name*/ )
})
return p;
}
\ No newline at end of file
import { Sprite, TextField, Tween } from "fyge";
export class ScoreTips extends Sprite{
score = 0;
scoreLabel;
constructor(){
super();
}
init(val,x,y){
this.score = val;
this.x = x;
this.y = y;
this.scoreLabel = new TextField();
this.scoreLabel.size = 32;
this.scoreLabel.strokeColor = "#66ccff"
this.scoreLabel.stroke = 2;
this.scoreLabel.text = '+'+this.score;
this.addChild(this.scoreLabel);
this.scoreLabel.x = -this.scoreLabel.textWidth*0.5;
this.scoreLabel.y = -this.scoreLabel.textHeight*0.5;
Tween.get(this).to({y:y-50},500).call(()=>{
if(this&&this.parent){
this.parent.removeChild(this);
}
})
}
}
\ No newline at end of file
import { Sprite, TextureCache, Tween } from "fyge";
export class Smoke extends Sprite{
smokeImg;
constructor(x,y,r){
super();
this.x = x;
this.y = y;
if(r){
this.rotation = r;
}
this.init();
}
init(){
this.smokeImg = new Sprite(TextureCache["13ef2773-e156-4bef-8730-37f3a0578a22"]);
this.addChild(this.smokeImg);
this.smokeImg.x = -this.smokeImg.width*0.5;
this.smokeImg.y = -this.smokeImg.height*0.5;
// this.rotation = 180;
// this.smokeImg.scaleX = this.smokeImg.scaleY = 0.5;
Tween.get(this).to({alpha:0},300).call(()=>{
if(this&&this.parent){
this.parent.removeChild(this);
}
})
}
}
\ No newline at end of file
/**
* 根据路径记录
*/
export const soundHash={};
export function cusPlaySound(src, loop = false) {
return playSound(src, loop);
}
/**
* 提前加载音频
* @param type
*/
export function preloadSound(src) {
soundHash[src] = new Howl({
src: src,
preload: true,
});
}
export function playSound(src, loop = false) {
let sound;
//循环的,且有缓存,取缓存的
if (soundHash[src] && loop) sound = soundHash[src]
//没有就新建
if (!sound) sound = new Howl({ src: [src], autoplay: false, loop });
//记录下,方便停止
soundHash[src] = sound;
//不循环删除缓存
if (!loop) sound.on('stop', function () { delete soundHash[src] });
//播放
sound.play();
//返回一个,可以自行控制
return sound;
}
export function stopSound(src) {
if (soundHash[src]) soundHash[src].stop();
}
export function stopAllSound() {
for (let key in soundHash) soundHash[key].stop();
}
export function playAllSound() {
for (let key in soundHash) soundHash[key].play();
}
//设置隐藏属性和改变可见属性的事件的名称
let hidden, visibilityChange;
if (typeof document.hidden !== 'undefined') {
hidden = 'hidden';
visibilityChange = 'visibilitychange';
} else if (typeof document['msHidden'] !== 'undefined') {
hidden = 'msHidden';
visibilityChange = 'msvisibilitychange';
} else if (typeof document['webkitHidden'] !== 'undefined') {
hidden = 'webkitHidden';
visibilityChange = 'webkitvisibilitychange';
}
const handleVisibilityChange = (e) => {
if (document.visibilityState == "visible") {
playAllSound();
console.log("网页显示")
}
else if (document.visibilityState == "hidden") {
stopAllSound()
console.log("网页隐藏")
}
};
document.addEventListener(
visibilityChange,
handleVisibilityChange,
false
);
window.onbeforeunload = function () {
//发接口
}
\ No newline at end of file
This diff is collapsed.
/**
* Created by rockyl on 2020/9/19.
*/
import {Sprite, Point, TextureCache} from 'fyge'
export class RedPack extends Sprite {
constructor() {
super();
this._pos = new Point();
this._globalPos = new Point();
}
get pos() {
return this._pos;
}
get globalPos() {
return this._globalPos;
}
init(data) {
this.data = data;
const {source, initPos, type} = data;
this.type = type;
this.texture = TextureCache[source];
this.x = this._pos.x = initPos;
this.y = this._pos.y = -this.height;
}
schedule() {
const {width, height, data: {angleOffset, speed}} = this;
let radian = (angleOffset + 90) * Math.PI / 180;
let speedX = Math.cos(radian) * speed;
let speedY = Math.sin(radian) * speed;
this.x = this._pos.x += speedX;
this.y = this._pos.y += speedY;
this.parent.localToGlobal(this._pos, this._globalPos);
const {_globalPos: {x, y}} = this;
if (y < -height || y > this.stage.stageHeight) {
return true;
}
if (angleOffset > 0) {
if (x < -width) {
return true;
}
} else if (angleOffset < 0) {
if (x > this.stage.width) {
return true;
}
}
}
}
/**
* Created by rockyl on 2020/9/19.
*/
import {RedPack} from "./RedPack";
import {WidgetBase, ObjectPool, Event, MouseEvent, injectProp, TextureCache} from "fyge";
const PoolName = 'pack';
ObjectPool.registerPool(PoolName, function () {
return new RedPack();
}, function (redPack, data) {
redPack.init(data);
});
export class RedPackRainWidget extends WidgetBase {
_status;
_intervalCounting;
constructor() {
super();
this.addEventListener(Event.ENTER_FRAME, this.onEnterFrame, this);
this.addEventListener(MouseEvent.CLICK, this.onTap, this);
}
onEvent(type, payload) {
switch (type) {
case 'reset':
this.reset();
break;
case 'start':
injectProp(this, payload);
// console.log("aa",payload)
this.start();
break;
case 'pause':
this.pause();
break;
case 'resume':
this.start();
break;
case 'stop':
this.stop();
break;
default:
console.log(type);
}
}
reset() {
this.pause();
while (this.children.length > 0) {
this.recycleOne(this.children[0]);
}
}
start() {
console.log(TextureCache)
console.log("props",this.props);
this._status = 1;
this._intervalCounting = this.props.intervalFrames;
}
pause() {
this._status = 0;
}
stop() {
this.reset();
}
recycleOne(child) {
this.removeChild(child);
ObjectPool.recycleObject(PoolName, child);
}
dropOne() {
const {assets, angleOffset, speedRange, initPosRange} = this.props;
console.log("Ass",assets);
let r = Math.random();
let targetAssetIndex;
for (let i = 0, li = assets.length; i < li; i++) {
const asset = assets[i];
r -= asset.ratio;
if (r <= 0) {
targetAssetIndex = i;
break;
}
}
let pack = ObjectPool.getObject(PoolName, {
type: targetAssetIndex,
source: assets[targetAssetIndex].source,
angleOffset,
speed: Math.random() * (speedRange.max - speedRange.min) + speedRange.min,
initPos: Math.random() * (initPosRange.max - initPosRange.min) + initPosRange.min,
});
this.addChild(pack);
};
onEnterFrame() {
if (this._status === 1) {
this._intervalCounting--;
if (this._intervalCounting <= 0) {
this._intervalCounting = this.props.intervalFrames;
this.dropOne();
}
for (let i = 0, li = this.children.length; i < li; i++) {
const child = this.children[i];
if (child.schedule()) {
i--;
li--;
this.recycleOne(child);
}
}
}
}
onTap(event) {
if (event.currentTarget instanceof RedPack) {
const {type, pos, globalPos} = event.currentTarget;
let payload = {type, pos, globalPos};
this.recycleOne(event.currentTarget);
this.dispatchOutEvent('hit', payload);
}
}
}
import {RedPackRainWidget} from "./RedPackRain";
import {CornerRacingWidget} from "./CornerRacing";
/**
* @type 3
* @name 红包雨
* @desc 红包雨模块的工厂方法
*/
export function RedPackRain() {
return new RedPackRainWidget();
}
/**
* @type 3
* @name 弯道赛车
* @desc 弯道赛车模块的工厂方法
*/
export function CornerRacing() {
return new CornerRacingWidget();
}
{
"id": "games",
"name": "游戏模块包",
"desc": "实现了各种游戏模块",
"config": {
"RedPackRain": {
"props": [
{
"name": "assets",
"alias": "素材UUID组",
"type": "string",
"default": [
{
"source": "a6b3f654-2c26-434a-a873-aabc12cd1d80",
"ratio": 1
}
]
},
{
"name": "angleOffset",
"alias": "角度偏移量",
"type": "number",
"default": 0
},
{
"name": "speedRange",
"alias": "速度范围",
"type": "range",
"default": "1,10",
"type_config": {
"min": 1,
"max": 50
}
},
{
"name": "initPosRange",
"alias": "初始坐标范围",
"type": "range",
"default": "0,750"
},
{
"name": "intervalFrames",
"alias": "红包生成间隔帧数",
"type": "number",
"default": "10"
}
],
"assets": [
{
"name": "红包",
"url": "//yun.duiba.com.cn/aurora/59ba44954450d7493ef5c630070808496c242f11.png",
"uuid": "a6b3f654-2c26-434a-a873-aabc12cd1d80",
"ext": ".png"
}
],
"events": {
"in": {
"reset": {
"alias": "重置"
},
"start": {
"alias": "开始",
"data": {
"assets": "素材列表[{source,ratio}]",
"speedRange": "速度范围{min,max}",
"initPosRange": "初始坐标范围{min,max}",
"angleOffset": "角度偏移量",
"intervalFrames": "掉落帧间隔"
}
},
"pause": {
"alias": "暂停"
},
"resume": {
"alias": "恢复"
},
"stop": {
"alias": "停止"
}
},
"out": {
"hit": {
"alias": "击中红包",
"data": {
"type": "类型",
"pos": "坐标",
"globalPos": "全局坐标"
}
}
}
}
}
}
}
/**
* Created by rockyl on 2020/10/13.
*
* @id porjectx
* @name 星速台相关的过程
* @desc 星速台相关的过程
*/
/**
* @type 1
* @name 获取token
* @desc 获取星速台防刷token
* @outputs {success:'成功:响应内容', failed:'失败:错误信息'}
*/
export function getPxToken() {
return new Promise(resolve => {
if (location.href.indexOf('.com.cn/projectx') < 0) { //本地环境测试
resolve({
type: 'success',
payload: {
token: 'test_token'
}
})
} else {
window.getPxToken((e, token) => {
if (e) {
resolve({
type: 'failed',
payload: e,
})
} else if (!token) {
resolve({
type: 'failed',
payload: new Error('empty token')
})
} else {
resolve({
type: 'success',
payload: {
token
}
})
}
});
}
})
}
/**
* Created by rockyl on 2020/8/26.
*
* @id ui
* @name 一些UI组件
* @desc 一些UI组件
*/
/**
* @type 3
* @name 下拉选择器
* @desc 下拉选择器,传入键值对options,例:{aaa:'哈哈',bbb:'嘿嘿'}即生成两个下拉选项}
*/
export class Select {
render() {
const {options, value, onValueChange} = this.props;
return (
<select value={value} onChange={e => onValueChange(e.target.value)}>
{Object.keys(options).map(key => (
<option key={key} value={key}>{options[key]}</option>
))}
</select>
)
}
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment