Commit 18dd1f4c authored by Master Q's avatar Master Q

Finished

parent 9478927f
...@@ -46,7 +46,5 @@ ...@@ -46,7 +46,5 @@
"webpack-dev-server": "^4.11.1", "webpack-dev-server": "^4.11.1",
"webpack-merge": "^5.8.0" "webpack-merge": "^5.8.0"
}, },
"dependencies": { "dependencies": {}
"@lightfish/tools": "^1.0.5"
}
} }
This diff is collapsed.
...@@ -18,7 +18,7 @@ const defaultConfig: UsePreloadType = { ...@@ -18,7 +18,7 @@ const defaultConfig: UsePreloadType = {
resPreloadFunc: { resPreloadFunc: {
others: RES.getResAsync others: RES.getResAsync
}, },
loadingComponent: DreamDotAni, loadingComponent: function() {return new FYGE.Container()},
preAction: () => Promise.resolve() preAction: () => Promise.resolve()
} }
......
import { throttle } from "@lightfish/tools";
import { DreamContainer } from "../../components/DreamContainer/DreamContainer"; import { DreamContainer } from "../../components/DreamContainer/DreamContainer";
import { DreamSprite } from "../../components/DreamSprite/DreamSprite"; import { DreamSprite } from "../../components/DreamSprite/DreamSprite";
import { DreamTextField } from "../../components/DreamTextField/DreamTextField"; import { DreamTextField } from "../../components/DreamTextField/DreamTextField";
...@@ -7,6 +6,7 @@ import { DreamSpriteV2 } from "../../Dream/UI"; ...@@ -7,6 +6,7 @@ import { DreamSpriteV2 } from "../../Dream/UI";
import { RES } from "../../modules/RES"; import { RES } from "../../modules/RES";
import { UsePreload } from "../../modules/UseDecorator/usePreload"; import { UsePreload } from "../../modules/UseDecorator/usePreload";
import { sendTbNet, TbNetName } from "../../tools/TbNet"; import { sendTbNet, TbNetName } from "../../tools/TbNet";
import { throttle } from "../../tools/Tools";
@UsePreload({ @UsePreload({
preAction: async function() { preAction: async function() {
......
...@@ -21,9 +21,9 @@ export const BoxTypeList: BoxType[] = [ ...@@ -21,9 +21,9 @@ export const BoxTypeList: BoxType[] = [
] ]
export const GameConfig = { export const GameConfig = {
debugger: true, debugger: false,
GenerateSpace: [300, 400], // 生成间距 GenerateSpace: [300, 400], // 生成间距
finalGiftPart: 1, // 最终奖励 概率 100% finalGiftPart: 0.1, // 最终奖励 概率 100%
maxLen: 550, maxLen: 550,
totoalPart: 0, // 全部概率 totoalPart: 0, // 全部概率
PartList: [] as { PartList: [] as {
......
...@@ -7,3 +7,109 @@ export class Tools { ...@@ -7,3 +7,109 @@ export class Tools {
liveCard: 1 liveCard: 1
} }
} }
/**
* 函数防抖,如下拉菜单
* @param {Function} fn
* @param {Number} delay
* @returns
*/
export function debounce(fn: Function, delay: number=2000) {
let timer:any = null;
function invokeFunc(...args: any[]) {
let context = this;
if(timer) clearTimeout(timer)
timer = setTimeout(()=>{
fn.apply(context, args)
}, delay)
}
function cancel() {
if (timer !== undefined) {
clearTimeout(timer)
}
}
invokeFunc.cancel = cancel
return invokeFunc
}
/**
* 函数防抖的 装饰器版本
* @param time
* @returns
*/
export function debounceDecorator(time: number = 1000) {
return function (target: any, property: string, descriptor: PropertyDescriptor) {
const func = descriptor.value
if (typeof func !== 'function') {
throw new Error('debounceDecorator error: are u kidding me ?')
}
let timerId: any
function invokeFunc(...args: any[]) {
let context = this;
if(timerId) clearTimeout(timerId)
timerId = setTimeout(()=>{
func.apply(context, args)
}, time)
}
function cancel() {
if (timerId !== undefined) {
clearTimeout(timerId)
}
}
invokeFunc.cancel = cancel
descriptor.value = invokeFunc
}
}
/**
* 函数节流, 用作防连点
* @param {Function} fn
* @param {Number} delay
* @returns
*/
export function throttle(fn: Function, delay: number=2000) {
let flag: boolean = true,
timerId: any
return function (...args: any[]) {
if (!flag) return
flag = false
timerId && clearTimeout(timerId)
timerId = setTimeout(function() {
flag = true
}, delay)
const context = this
return fn.apply(context, args)
};
}
/**
* 函数节流的 装饰器版本
* @param time
* @returns
*/
export function throttleDecorator(time: number = 1000) {
return function(target: any, property: string, descriptor: PropertyDescriptor) {
const func: Function = descriptor.value
if (typeof func !== 'function') {
throw new Error('debounceDecorator error: are u kidding me ?')
}
let flag: boolean = true,
timerId: any
function invokeFunc(...args: any[]) {
if (!flag) return
flag = false
timerId && clearTimeout(timerId)
timerId = setTimeout(function() {
flag = true
}, time)
const context = this
return func.apply(context, args)
}
descriptor.value = invokeFunc
}
}
...@@ -940,13 +940,6 @@ ...@@ -940,13 +940,6 @@
"@babel/helper-validator-option" "^7.18.6" "@babel/helper-validator-option" "^7.18.6"
"@babel/plugin-transform-typescript" "^7.18.6" "@babel/plugin-transform-typescript" "^7.18.6"
"@babel/runtime@^7.17.2":
version "7.20.6"
resolved "http://npm.dui88.com:80/@babel%2fruntime/-/runtime-7.20.6.tgz#facf4879bfed9b5326326273a64220f099b0fce3"
integrity sha512-Q+8MqP7TiHMWzSfwiJwXCjyf4GYA4Dgw3emg/7xmwsdLJOZUp+nMqcOwOzzYheuM1rhDu8FSj2l0aoMygEuXuA==
dependencies:
regenerator-runtime "^0.13.11"
"@babel/runtime@^7.8.4": "@babel/runtime@^7.8.4":
version "7.19.0" version "7.19.0"
resolved "http://npm.dui88.com:80/@babel%2fruntime/-/runtime-7.19.0.tgz#22b11c037b094d27a8a2504ea4dcff00f50e2259" resolved "http://npm.dui88.com:80/@babel%2fruntime/-/runtime-7.19.0.tgz#22b11c037b094d27a8a2504ea4dcff00f50e2259"
...@@ -1046,13 +1039,6 @@ ...@@ -1046,13 +1039,6 @@
resolved "http://npm.dui88.com:80/@leichtgewicht%2fip-codec/-/ip-codec-2.0.4.tgz#b2ac626d6cb9c8718ab459166d4bb405b8ffa78b" resolved "http://npm.dui88.com:80/@leichtgewicht%2fip-codec/-/ip-codec-2.0.4.tgz#b2ac626d6cb9c8718ab459166d4bb405b8ffa78b"
integrity sha512-Hcv+nVC0kZnQ3tD9GVu5xSMR4VVYOteQIr/hwFPVEvPdlXqgGEuRjiheChHgdM+JyqdgNcmzZOX/tnl0JOiI7A== integrity sha512-Hcv+nVC0kZnQ3tD9GVu5xSMR4VVYOteQIr/hwFPVEvPdlXqgGEuRjiheChHgdM+JyqdgNcmzZOX/tnl0JOiI7A==
"@lightfish/tools@^1.0.5":
version "1.0.5"
resolved "http://npm.dui88.com:80/@lightfish%2ftools/-/tools-1.0.5.tgz#96aedb363d6b8a9d83fa6ae4d6d8a2fd4bc06582"
integrity sha512-APtNnurmB3jzWwFnYrb3uK9UppFjPTmOEowNMd+P6R4vadr/V2QNX+Xd/Wl/17dAkswnplLzsphXHtoeiIXX8g==
dependencies:
"@babel/runtime" "^7.17.2"
"@nicolo-ribaudo/chokidar-2@2.1.8-no-fsevents.3": "@nicolo-ribaudo/chokidar-2@2.1.8-no-fsevents.3":
version "2.1.8-no-fsevents.3" version "2.1.8-no-fsevents.3"
resolved "http://npm.dui88.com:80/@nicolo-ribaudo%2fchokidar-2/-/chokidar-2-2.1.8-no-fsevents.3.tgz#323d72dd25103d0c4fbdce89dadf574a787b1f9b" resolved "http://npm.dui88.com:80/@nicolo-ribaudo%2fchokidar-2/-/chokidar-2-2.1.8-no-fsevents.3.tgz#323d72dd25103d0c4fbdce89dadf574a787b1f9b"
...@@ -3428,11 +3414,6 @@ regenerate@^1.4.2: ...@@ -3428,11 +3414,6 @@ regenerate@^1.4.2:
resolved "http://npm.dui88.com:80/regenerate/-/regenerate-1.4.2.tgz#b9346d8827e8f5a32f7ba29637d398b69014848a" resolved "http://npm.dui88.com:80/regenerate/-/regenerate-1.4.2.tgz#b9346d8827e8f5a32f7ba29637d398b69014848a"
integrity sha1-uTRtiCfo9aMve6KWN9OYtpAUhIo= integrity sha1-uTRtiCfo9aMve6KWN9OYtpAUhIo=
regenerator-runtime@^0.13.11:
version "0.13.11"
resolved "http://npm.dui88.com:80/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz#f6dca3e7ceec20590d07ada785636a90cdca17f9"
integrity sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==
regenerator-runtime@^0.13.4: regenerator-runtime@^0.13.4:
version "0.13.9" version "0.13.9"
resolved "http://npm.dui88.com:80/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz#8925742a98ffd90814988d7566ad30ca3b263b52" resolved "http://npm.dui88.com:80/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz#8925742a98ffd90814988d7566ad30ca3b263b52"
......
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