Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

pixuireactutils

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pixuireactutils

pixui react script tools

latest
npmnpm
Version
1.1.8
Version published
Maintainers
1
Created
Source

脚本工具

1.MakeImage.js

React 里用于一键生成图集文件 用法有2个命令:

  • node MakeImage.js create path
  • node MakeImage.js update path

(path: 一个文件夹的路径,可以按绝对路径写法,形如:/Users/zhengyanan/Desktop/work_git/LgameVideoGameTest/src/asset/Textures/VideoGame;也可以按相对当前位置的路径,形如../../LgameVideoGameTest/src/asset/Textures/VideoGame。)

第一条命令是创建一个Images.tsx文件,可以直接代码中使用。如图:

第二条命令是更新Images.tsx文件,用于增加图片的时候,更新Images.tsx。如上图所示,创建之后按上面的要求,只能改Images的key值(这个已足够满足需求,因为这个key值,代码中才可能用到)。使用update可以保留这些你的改动,无需重新改代码中的引用。如果没改动的话,那就无所谓,直接重新create即可。

2. GenerateConstructorAndGeterSeter.js

先定义好类的字段后,一键生成该类的构造函数,getter方法 和 setter方法。

用法只有一个命令:

  • node GenerateConstructorAndGeterSeter.js xxx.tsx 110

其中,xxx.tsx指的是待生成的类文件;110是选项,3个bit位依次表示是否生成构造函数、setter、getter。

例如,先定义好类的字段,如下:

class RealTimeMatchInfo{
        bo: number // 赛制bo1, bo3, bo5
        location: string
        round: number // 当前是第几场, 从1开始
        matchId: number
        seasonId: number
        stageId: number
        status: number //  状态 0: 未开始; 1: 进行中; 2: 已结束
        teamA: number // 战队A id
        teamAScore: number // 战队A 获胜的游戏单局数
        teamB: number // 战队B id
        teamBScore: number // 战队B 获胜的游戏单局数
        winTeam: number // 系列赛胜利战队ID
    }

然后执行 上述命令,即可自动生成构造函数 和 setter方法,生成的结果如下:

class RealTimeMatchInfo{
    bo: number // 赛制bo1, bo3, bo5
    location: string
    round: number // 当前是第几场, 从1开始
    matchId: number
    seasonId: number
    stageId: number
    status: number //  状态 0: 未开始; 1: 进行中; 2: 已结束
    teamA: number // 战队A id
    teamAScore: number // 战队A 获胜的游戏单局数
    teamB: number // 战队B id
    teamBScore: number // 战队B 获胜的游戏单局数
    winTeam: number // 系列赛胜利战队ID

	constructor(){
		this.bo = -1
		this.location = ""
		this.round = -1
		this.matchId = -1
		this.seasonId = -1
		this.stageId = -1
		this.status = -1
		this.teamA = -1
		this.teamAScore = -1
		this.teamB = -1
		this.teamBScore = -1
		this.winTeam = -1
	}

	setBo(bo: number){
		this.bo = bo
	}

	setLocation(location: string){
		this.location = location
	}

	setRound(round: number){
		this.round = round
	}

	setMatchId(matchId: number){
		this.matchId = matchId
	}

	setSeasonId(seasonId: number){
		this.seasonId = seasonId
	}

	setStageId(stageId: number){
		this.stageId = stageId
	}

	setStatus(status: number){
		this.status = status
	}

	setTeamA(teamA: number){
		this.teamA = teamA
	}

	setTeamAScore(teamAScore: number){
		this.teamAScore = teamAScore
	}

	setTeamB(teamB: number){
		this.teamB = teamB
	}

	setTeamBScore(teamBScore: number){
		this.teamBScore = teamBScore
	}

	setWinTeam(winTeam: number){
		this.winTeam = winTeam
	}
}

FAQs

Package last updated on 15 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts