How to use targetTypeMap method in Playwright Internal

Best JavaScript code snippet using playwright-internal

ActionParser.js

Source:ActionParser.js Github

copy

Full Screen

1import Actions from '@/models/skill/index'2function targetAnalyzer (action, dependAction) {3 const targetAssignmentMap = {4 1: ['enemy', '【敌方】'],5 2: ['ally', '【己方】'],6 3: ['both', '【双方】'],7 default: ['unknown', '']8 }9 const targetTypeMap = {10 0: ['zero', '【最近的$1$2】'],11 1: ['none', '【被上一个效果影响的或最近的$1$2】'],12 2: ['random', '【随机$1】'],13 3: ['near', Number(action.target_number) === 0 || Number(action.target_count) === 1 ? '【最近的$1$2】' : '【$2近的$1】'],14 4: ['far', '【最远的$1$2】'],15 5: ['hpAscending', '【 HP 百分比最低的$1$2】'],16 6: ['hpDescending', '【 HP 百分比最高的$1$2】'],17 7: ['self', '【自身】'],18 8: ['randomOnce', '【首次随机】'],19 9: ['forward', '【最靠后的$1$2】'],20 10: ['backward', '【最靠前的$1$2】'],21 11: ['absolute', '【范围内的目标】'],22 12: ['tpDescending', '【 TP 最多的$1$2】'],23 13: ['tpAscending', '【 TP 最少的$1$2】'],24 14: ['atkDescending', '【物理攻击力最高的$1$2】'],25 15: ['atkAscending', '【物理攻击力最低的$1$2】'],26 16: ['magicSTRDescending', '【魔法攻击力最高的$1$2】'],27 17: ['magicSTRAscending', '【魔法攻击力最低的$1$2】'],28 18: ['summon', '【$1随从】'],29 19: ['tpReducing', '【 TP 最少的$1$2】'],30 20: ['physics', '【$1物理系】'],31 21: ['magic', '【$1法系】'],32 22: ['allSummonRandom', '【随机随从】'],33 23: ['selfSummonRandom', '【自己的随机随从】'],34 24: ['boss', '【$1首领级】'],35 25: ['hpAscendingOrNear', '【 HP 百分比最低的$1$2】'],36 26: ['hpDescendingOrNear', '【 HP 百分比最高的$1$2】'],37 27: ['tpDescendingOrNear', '【 TP 最多的$1$2】'],38 28: ['tpAscendingOrNear', '【 TP 最少的$1$2】'],39 29: ['atkDescendingOrNear', '【物理攻击力最高的$1$2】'],40 30: ['atkAscendingOrNear', '【物理攻击力最低的$1$2】'],41 31: ['magicSTRDescendingOrNear', '【魔法攻击力最高的$1$2】'],42 32: ['magicSTRAscendingOrNear', '【魔法攻击力最低的$1$2】'],43 33: ['shadow', '【$1暗影】'],44 34: ['nearWithoutOwner', '【除自己外最近的$1$2】'],45 default: ['unknown', '']46 }47 const targetCountMap = {48 0: ['zero', ''],49 1: ['one', '一个'],50 2: ['two', '两个'],51 3: ['three', '三个'],52 4: ['four', '四个'],53 99: ['all', '全部'],54 default: ['unknown', '']55 }56 const targetNumberMap = {57 0: ['first', '第一位'],58 1: ['second', '第二位'],59 2: ['third', '第三位'],60 3: ['fourth', '第四位'],61 4: ['fifth','第五位'],62 default: ['unknown', '']63 }64 const targetRangeMap = {65 infinite: [-1, -1],66 zero: [0, 0],67 finite: [1, 2159],68 all: [2160, Number.MAX_SAFE_INTEGER]69 }70 const targetAreaMap = {71 1: ['front', '【前方】'],72 2: ['frontAndBack', '【前方和后方】'],73 3: ['all', '【全体】'],74 default: ['unknown', '']75 }76 const targetAssignment = targetAssignmentMap[Number(action.target_assignment)] || targetAssignmentMap.default77 const targetType = targetTypeMap[Number(action.target_type)] || targetTypeMap.default78 const targetCount = targetCountMap[Number(action.target_count)] || targetCountMap.default79 const targetNumber = targetNumberMap[Number(action.target_number)] || targetNumberMap.default80 const targetRange = Object.keys(targetRangeMap).filter(range => Number(action.target_range) >= targetRangeMap[range][0] && Number(action.target_range) <= targetRangeMap[range][1])[0] || 'unknown'81 const targetArea = targetAreaMap[Number(action.target_area)] || targetAreaMap.default82 const hasRelationPhrase = !['self', 'absolute'].includes(targetType[0])83 const hasCountPhrase = !['self', 'none', 'zero'].includes(targetType[0])84 const hasRangePhrase = targetRange === 'finite'85 const hasPositionPhrase = ['second', 'third', 'fourth', 'fifth'].includes(targetNumber[0])86 const hasAreaPhrase = targetArea[0] === 'front' && (hasRangePhrase || targetCount[0] === 'all')87 const hasTargetType = !['unknown', 'magic', 'physics', 'summon', 'boss', 'nearWithoutOwner'].includes(targetType[0]) && targetCount[0] === 'all' ? false : true88 const hasDependAction = dependAction !== 0 && targetType[0] !== 'absolute' && [1, 3, 23, 28, 46].includes(Number(dependAction.action_type))89 const ignoresOne = !['unknown', 'random', 'randomOnce', 'absolute', 'summon', 'selfSummonRandom', 'allSummonRandom', 'magic', 'physics'].includes(targetType[0])90 const generatePhrase = () => {91 let targetPhraseTags = {92 custom: [],93 count: '',94 area: '',95 range: '',96 targetType: '',97 number: '',98 relation: ''99 }100 if (hasDependAction) {101 if ([1, 46].includes(Number(dependAction.action_type))) {102 targetPhraseTags.custom.push(`【被效果 ${dependAction.action_id % 10} 伤害到的】`)103 } else {104 targetPhraseTags.custom.push(`【效果 ${dependAction.action_id % 10} 的目标】`)105 }106 return targetPhraseTags107 }108 if (hasCountPhrase) {109 switch (targetCount) {110 case 'zero':111 break112 case 'one':113 if (!ignoresOne) targetPhraseTags.count = targetCount[1]114 break115 default:116 targetPhraseTags.count = targetCount[1]117 }118 }119 if (hasAreaPhrase) {120 if (targetArea[0] === 'front') {121 if (targetAssignment === 'ally') {122 targetPhraseTags.area = targetArea[1]123 } else {124 targetPhraseTags.custom.push('【前方】')125 }126 }127 }128 if (targetRange === 'finite') {129 targetPhraseTags.range = `【距离 ${action.target_range} 】`130 }131 if (hasTargetType) {132 targetPhraseTags.targetType = targetType[1]133 }134 if (hasPositionPhrase) {135 targetPhraseTags.number = targetNumber[1]136 }137 if (hasRelationPhrase) {138 targetPhraseTags.relation = targetAssignment[1]139 } else {140 targetPhraseTags = {141 custom: [],142 count: '',143 area: '',144 range: '',145 targetType: '',146 number: '',147 relation: ''148 }149 targetPhraseTags.targetType = targetType[1]150 }151 targetPhraseTags.custom.join('')152 return targetPhraseTags153 }154 const phrase = generatePhrase()155 phrase.targetType = phrase.targetType.replace(/\$1/, phrase.count)156 phrase.targetType = phrase.targetType.replace(/\$2/, phrase.number)157 const pattern = `${phrase.custom}${phrase.area}${phrase.range}${phrase.relation}${phrase.targetType}`158 return pattern159}160export default {161 getSkillActionDetails: ({ action, dependAction, unitAtk, unitMAtk, unitLevel, skillLevel }) => {162 let detail163 skillLevel = skillLevel || unitLevel164 switch (action.action_type) {165 case 1:166 detail = Actions.Type1.DealDamage(action, unitAtk, unitMAtk, unitLevel, skillLevel)167 break168 case 2:169 detail = Actions.Type2.Move(action)170 break171 case 3:172 detail = Actions.Type3.Knock(action)173 break174 case 4:175 detail = Actions.Type4.DealHeal(action, unitAtk, unitMAtk, unitLevel, skillLevel)176 break177 case 6:178 detail = Actions.Type6.SetBarrier(action, skillLevel)179 break180 case 7:181 detail = Actions.Type7.Reflexive(action)182 break183 case 8:184 detail = Actions.Type8.DealAilment(action, skillLevel)185 break186 case 9:187 detail = Actions.Type9.DealDamageOverTime(action, skillLevel)188 break189 case 10:190 detail = Actions.Type10.CastAura(action, skillLevel)191 break192 case 11:193 detail = Actions.Type11.CastCharm(action, skillLevel)194 break195 case 12:196 detail = Actions.Type12.CastDarkness(action, skillLevel)197 break198 case 13:199 detail = Actions.Type13.CastSilence(action, skillLevel)200 break201 case 14:202 detail = Actions.Type14.ChangeMode(action)203 break204 case 15:205 detail = Actions.Type15.Summon(action).detail206 break207 case 16:208 detail = Actions.Type16.ChangeEnergy(action, skillLevel)209 break210 case 17:211 detail = Actions.Type17.Trigger(action)212 break213 case 18:214 detail = Actions.Type18.ChargingDamage(action, skillLevel)215 break216 case 20:217 detail = Actions.Type20.SetDecoy(action, skillLevel)218 break219 case 21:220 detail = Actions.Type21.Invulnerable(action, skillLevel)221 break222 case 22:223 detail = Actions.Type22.ChangeAttackPattern(action)224 break225 case 23:226 detail = Actions.Type23.IfForChildren(action)227 break228 case 24:229 detail = Actions.Type24.CastResurrect(action)230 break231 case 26:232 detail = Actions.Type26.Additive(action, skillLevel)233 break234 case 27:235 detail = Actions.Type27.Multiple(action, skillLevel)236 break237 case 28:238 detail = Actions.Type28.IfForAll(action)239 break240 case 30:241 detail = Actions.Type30.CastInstantDeath()242 break243 case 32:244 detail = Actions.Type32.EnchantLifeSteal(action, skillLevel)245 break246 case 33:247 detail = Actions.Type33.SetCounterBackBarrier(action, skillLevel)248 break249 case 34: 250 detail = Actions.Type34.AccumulativeDamage(action, skillLevel)251 break252 case 35:253 detail = Actions.Type35.SetMark(action)254 break255 case 36:256 detail = Actions.Type36.DealFieldDamage(action, unitAtk, unitMAtk, unitLevel, skillLevel)257 break258 case 37:259 detail = Actions.Type37.DealFieldHeal(action, unitAtk, unitMAtk, unitLevel, skillLevel)260 break261 case 38:262 detail = Actions.Type38.CastFieldAura(action, skillLevel)263 break264 case 42:265 detail = Actions.Type42.LoopTrigger(action, skillLevel)266 break267 case 44:268 detail = Actions.Type44.Delayed(action)269 break270 case 45:271 detail = Actions.Type45.SkillCounter(action)272 break273 case 46:274 detail = Actions.Type46.DealRatioDamage(action, skillLevel)275 break276 case 47:277 detail = Actions.Type47.DealLimitedDamage(action, unitAtk, unitMAtk, unitLevel, skillLevel)278 break279 case 48:280 detail = Actions.Type48.DealRegeneration(action, unitAtk, unitMAtk, unitLevel, skillLevel)281 break282 case 49:283 detail = Actions.Type49.CastDispel(action, skillLevel)284 break285 case 50:286 detail = Actions.Type50.ChannelingAura(action, skillLevel)287 break288 case 52:289 detail = Actions.Type52.ChangeWidth(action)290 break291 case 53:292 detail = Actions.Type53.FieldCondition(action)293 break294 case 90:295 detail = Actions.Type90.PassiveSkill(action, skillLevel)296 break297 default:298 return299 }300 return {301 detail,302 target: targetAnalyzer(action, dependAction)303 }304 }...

Full Screen

Full Screen

relative.js

Source:relative.js Github

copy

Full Screen

...41// 工具方法 判断对象类型42function getTargetType(value) {43 return !Object.isExtensible(value)44 ? TargetType.INVALID45 : targetTypeMap(toTypeString(value))46}47// 工具方法 根据对象类型返回TargetType配置类型48function targetTypeMap(rawType) {49 switch (rawType) {50 case 'Object':51 case 'Array':52 return TargetType.COMMON53 case 'Map':54 case 'Set':55 case 'WeakMap':56 case 'WeakSet':57 return TargetType.COLLECTION58 default:59 return TargetType.INVALID60 }61}62// 工具方法 检查对象是否有ReactiveFlags.RAW属性,存在即返回该属性,否则返回原对象...

Full Screen

Full Screen

TMap.js

Source:TMap.js Github

copy

Full Screen

1import Map from 'ol/Map.js'2import View from 'ol/View.js'3import { getTopLeft } from 'ol/extent.js'4import { get as getProjection } from 'ol/proj.js'5import LayerGroup from 'ol/layer/Group'6import WMTS from 'ol/source/WMTS.js'7import WMTSTileGrid from 'ol/tilegrid/WMTS.js'8import TileLayer from 'ol/layer/Tile.js'9import fetchJsonp from './fetchJsonp'10import _without from 'lodash/without'11import _debounce from 'lodash/debounce'12// import TileWMS from 'ol/source/TileWMS.js';13let projection = getProjection('EPSG:4326')14let maxLevel = 2015export class TMap extends Map {16 layerArray=[];//地图图层数组17 events={};//地图事件列表18 constructor (id, center = [120.158, 30.267], level = 16, maptype = 'emap') {19 super({20 logo: false,21 target: id,22 // interactions: new ol.interaction.defaults({23 // pinchRotate: false24 // }),25 // controls: [26 // new ol.control.ScaleLine({ className: "scale-line", minWidth: "45" }),27 // new ol.control.Zoom({ className: "zoom-bar" })28 // ],29 // layers: [30 // new TileLayer({31 // source: new TileWMS({32 // url: 'https://ahocevar.com/geoserver/wms',33 // params: {34 // 'LAYERS': 'ne:NE1_HR_LC_SR_W_DR',35 // 'TILED': true36 // }37 // })38 // })39 // ],40 view: new View({41 center: center,42 projection: projection,43 zoom: level,44 maxZoom: maxLevel,45 minZoom: 246 }),47 moveTolerance: 1048 })49 this.maptype = maptype;50 this.level=level;51 this.center=center;52 this.setOnlineMapType(maptype, center, level)53 }54 getMapType() {55 return this.maptype;56 }57 setOnlineMapType (maptype, center, zoom) {58 //请求天地图图层59 var view = this.getView();60 var bbox = view.calculateExtent().join(',');61 //fetchJsonp("http://121.43.99.232:8899/api/maplayer/current",{62 fetchJsonp('http://www.zjditu.cn/api/maplayer/current', {63 bbox: bbox, zoom: zoom64 }, { jsonpCallback:'_cb', timeout: 20000 }).then((response) => {65 if (response.code === 200) {66 this.addOnlineMap(maptype, center, zoom, response.content);67 }68 }).catch((error) => {69 if(error.message.indexOf('abort')>=0) {70 console.log(error.message);71 }else {72 console.log(error.message);73 //如果请求超时,重新请求74 if(error.message.indexOf('time')>=0) {75 this.setOnlineMapType(maptype, center, zoom);76 }77 }78 });79 }80 //加载在线地图81 addOnlineMap(maptype, center, level, mapConfigArray) {82 //如果当前的地图类型不是目标类型,则切换83 let currentMapType =this.getMapType();84 let targetTypeMap=null;//目标图层85 let currentTypeMap=null;//当前图层86 let mapColle = this.getLayers().getArray();87 for (let i = 0; i < mapColle.length; i++) {88 if (mapColle[i].get('name')===currentMapType) {89 currentTypeMap=mapColle[i];90 }91 if(mapColle[i].get('name')===maptype) {92 targetTypeMap=mapColle[i];93 }94 }95 if (currentMapType !== maptype) {96 currentTypeMap.setVisible(false);97 }else {98 targetTypeMap=currentTypeMap;99 }100 if (targetTypeMap) {101 targetTypeMap.setVisible(true);102 } else {103 targetTypeMap = new LayerGroup({104 name: maptype,105 isBaseLayers: true,106 layers: []107 })108 this.addLayer(targetTypeMap);109 }110 //判断哪些图层是当前图层数组中没有的,没有的加上,如果配置文件中没有,在当前图层数组中存在,则删除图层,不再加载111 //如果执行请求current函数后,图层名称没有变化,则不进行下面的加载图层代码执行112 let templayerNameArray=[];113 for(let mapConfig of mapConfigArray) {114 templayerNameArray.push(mapConfig.id);115 }116 let targetLayerColle=targetTypeMap.getLayers();117 let targetLayers=targetLayerColle.getArray();118 for(let i=0;i< targetLayers.length;i++) {119 let layer=targetLayers[i];120 let layerid=layer.get('id');121 if(templayerNameArray.indexOf(layerid)>=0) {122 continue;123 }else {124 targetLayerColle.remove(layer);125 i--;126 this.layerArray=_without(this.layerArray, layerid);127 }128 }129 //建立图层130 var layerArray = [];131 var layerCount = mapConfigArray.length;132 for (let i = 0; i < layerCount; i++) {133 var mapConfig = mapConfigArray[i];134 //如果存在同名图层,不再加载,避免了函数遍历135 if (this.layerArray.indexOf(mapConfig.id)>=0) {136 continue;137 }138 var url=mapConfig.url139 if (url.indexOf('{s}') >= 0) {140 url=url.replace('{s}', '{0-6}');141 }142 //判断加载的图层143 var tagsFlag = -1;144 switch (maptype) {145 case 'img':146 tagsFlag = mapConfig.tags.search(/img(?!.)|(?:img,label)/);147 break;148 case 'img_2000':149 tagsFlag = mapConfig.tags.search(/img_2000/);150 break;151 case 'img_70':152 tagsFlag = mapConfig.tags.search(/img_70/);153 break;154 case 'img_60':155 tagsFlag = mapConfig.tags.search(/img_60/);156 break;157 default:158 tagsFlag = mapConfig.tags.search(/road(?!.)|(?:road,label)/);159 break;160 }161 if (tagsFlag >= 0) {162 //var minR = mapConfig.max; //最小分辨率163 //var maxR = mapConfig.min-1; //最大分辨率164 let source= new WMTS({165 url: url,166 id:mapConfig.id,167 style: mapConfig.style,168 format: mapConfig.format,169 layer: mapConfig.layer,170 matrixSet: mapConfig.wmts_tile_matrixset,171 projection:projection,172 tileGrid: new WMTSTileGrid({173 origin: this.origin,174 resolutions: this.resolutions,175 matrixIds: this.matrixIds176 })177 });178 source.on('tileloaderror', function(event) {179 console.log(event)180 //let tile=event.tile181 //let img=tile.getImage();182 //img.src=require('../assets/images/zjbg.png');183 });184 var newlayer = new TileLayer({185 name: mapConfig.name,186 id:mapConfig.id,187 group: maptype,188 isBaseLayers: mapConfig.baselayer,189 source:source,190 //minResolution: this.resolutions[minR],191 //maxResolution: this.resolutions[maxR],192 zIndex: mapConfig.zindex ? mapConfig.zindex : 0193 });194 layerArray.push(newlayer);195 //存储图层名称196 this.layerArray.push(mapConfig.id);197 }198 }199 //加入图层组200 targetTypeMap.getLayers().extend(layerArray);201 this.maptype = maptype;202 if (!this.events['moveend']) {203 this.events['moveend'] = this.on('moveend', _debounce((event) => {204 let view=this.getView();205 this.setOnlineMapType(this.getMapType(), view.getCenter(), view.getZoom());206 }, 500));207 }208 return targetTypeMap;209 }210}211Object.assign(TMap.prototype, {212 maxLevel: 20,213 projection: projection,214 origin: (function () {215 let projection = getProjection('EPSG:4326')216 let projectionExtent = projection.getExtent()217 return getTopLeft(projectionExtent)218 })(),219 resolutions: [1.40625, 0.703125, 0.3515625, 0.17578125, 0.087890625, 0.0439453125, 0.02197265625, 0.010986328125,220 0.0054931640625, 0.00274658203125, 0.001373291015625, 0.0006866455078125, 0.00034332275390625, 0.000171661376953125,221 0.0000858306884765625, 0.00004291534423828125, 0.000021457672119140625, 0.000010728836059570312, 0.000005364418029785156,222 0.000002682209014892578, 0.000001341104507446289],223 matrixIds: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]...

Full Screen

Full Screen

tree-modal-category.js

Source:tree-modal-category.js Github

copy

Full Screen

1import intl from 'react-intl-universal'2import {Component} from 'react'3import {action} from 'mobx'4import {observer} from 'mobx-react'5import {Modal, Button} from 'antd'6import {Time, debounce} from '../../common/util'7import {ModalForm, ModalDetail} from '../../component'8import {targetTypeMap, nameTypeMap, modalDefaultConfig} from './util'9@observer10class ModalCategory extends Component {11 constructor(props) {12 super(props)13 this.store = props.store14 }15 renderContent() {16 const {17 categoryModal: {editType},18 } = this.store19 // 查看详情20 if (editType === 'view') {21 return this.renderDetail()22 }23 // 编辑/添加24 return this.renderEditModal()25 }26 /*27 * @description 渲染编辑弹窗28 */29 renderEditModal() {30 const {31 categoryModal: {detail, editType, visible},32 confirmLoading,33 } = this.store34 const content = [35 {36 label: intl37 .get(38 'ide.src.page-manage.page-object-model.object-list.object-list.modal-category.aps4bfdj6ls'39 )40 .d('类目名称'),41 key: 'name',42 initialValue: detail.name,43 component: 'input',44 rules: [45 '@namePattern',46 '@nameUnderline',47 '@nameShuQi',48 '@transformTrim',49 '@required',50 '@max32',51 {validator: this.checkName},52 ],53 },54 {55 label: intl56 .get('ide.src.component.modal-stroage-detail.main.lyqo7nv5t9h')57 .d('描述'),58 key: 'descr',59 initialValue: detail.descr,60 component: 'textArea',61 rules: ['@max128'],62 },63 ]64 const modalConfig = {65 title:66 editType === 'edit'67 ? intl68 .get(69 'ide.src.page-manage.page-object-model.tree-modal-category.ccndgjgllw'70 )71 .d('编辑对象类目')72 : intl73 .get(74 'ide.src.page-manage.page-object-model.tree-action.znat69vvyk8'75 )76 .d('新建对象类目'),77 visible,78 onCancel: this.handleCancel,79 onOk: this.submit,80 confirmLoading,81 ...modalDefaultConfig,82 }83 const formConfig = {84 selectContent: visible && content,85 wrappedComponentRef: form => {86 this.form = form ? form.props.form : form87 },88 }89 return (90 <Modal {...modalConfig}>91 <ModalForm {...formConfig} />92 </Modal>93 )94 }95 /*96 * @description 渲染详情弹窗97 */98 renderDetail() {99 const {categoryModal} = this.store100 const {detail} = categoryModal101 const modalConfig = {102 title: intl103 .get(104 'ide.src.page-manage.page-object-model.tree-modal-category.gyvotw5kfow'105 )106 .d('对象类目详情'),107 visible: categoryModal.visible,108 onCancel: this.handleCancel,109 onOk: this.submit,110 footer: [111 <Button onClick={this.handleCancel}>112 {intl113 .get('ide.src.component.modal-stroage-detail.main.ph80bkiru5h')114 .d('关闭')}115 </Button>,116 ],117 ...modalDefaultConfig,118 }119 const content = [120 {121 name: intl122 .get(123 'ide.src.page-manage.page-object-model.object-list.object-list.modal-category.aps4bfdj6ls'124 )125 .d('类目名称'),126 value: detail.name,127 },128 {129 name: intl130 .get('ide.src.page-manage.page-common-tag.detail.main.hv8quje3qk')131 .d('创建者'),132 value: detail.creator,133 },134 {135 name: intl136 .get(137 'ide.src.page-manage.page-aim-source.source-detail.main.2vp94m4091h'138 )139 .d('创建时间'),140 value: <Time timestamp={detail.createTime} />,141 },142 {143 name: intl144 .get('ide.src.component.modal-stroage-detail.main.lyqo7nv5t9h')145 .d('描述'),146 value: detail.descr,147 },148 ]149 return (150 <Modal {...modalConfig}>151 <ModalDetail data={content} labelWidth={52} />152 </Modal>153 )154 }155 @action checkName = (rule, value, callback) => {156 const {157 categoryModal: {detail},158 } = this.store159 const params = {160 name: value,161 type: targetTypeMap.category, // 类型:0 类目 1 对象162 nameType: nameTypeMap[rule.field], // 名称类型: 1 中文名 2 英文名163 }164 // 编辑状态165 if (detail.aId) {166 params.id = detail.aId167 }168 debounce(() => this.store.checkName(params, callback), 500)169 // this.store.checkName(params, callback)170 }171 @action.bound handleCancel() {172 this.store.categoryModal.visible = false173 this.store.confirmLoading = false174 }175 submit = () => {176 const t = this177 const {store} = t178 const {179 categoryModal: {editType, detail, type},180 } = store181 this.form.validateFields((err, values) => {182 if (!err) {183 // 编辑184 if (editType === 'edit') {185 const params = {id: detail.id, ...values}186 store.editNode(params, type, () => {187 t.handleCancel()188 })189 } else {190 // 新增191 store.addNode(values, type, () => {192 t.handleCancel()193 })194 }195 }196 })197 }198 render() {199 return this.renderContent()200 }201}...

Full Screen

Full Screen

reactive.js

Source:reactive.js Github

copy

Full Screen

...10const reactiveMap = new WeakMap()11const readonlyMap = new WeakMap()12const shallowReadonlyMap = new WeakMap()13const shallowReactiveMap = new WeakMap()14function targetTypeMap(rawType) {15 switch (rawType) {16 case 'Object':17 case 'Array':18 return TargetType.COMMON19 case 'Map':20 case 'Set':21 case 'WeakMap':22 default:23 return TargetType.INVALID24 }25}26function getTargetType(value) {27 return value[SKIP] || !Object.isExtensible(value)28 ? TargetType.INVALID29 : targetTypeMap(toRawType(value))30}31function createGetter(isReadOnly = false, shallow = false) {32 return function get(target, key, receiver) {33 // 判断是否为reactive34 if(key === IS_REACTIVE) return !isReadOnly35 // 判断是否为readonly36 else if(key === IS_READONLY) return isReadOnly37 // toRaw操作判断38 else if(39 key === RAW &&40 receiver === 41 (42 isReadOnly43 ? shallow...

Full Screen

Full Screen

k8s-manifest.mjs

Source:k8s-manifest.mjs Github

copy

Full Screen

1import k8s from "@kubernetes/client-node";2import yaml from "yaml";3class K8sManifest {4 constructor(parsedYaml) {5 if (!parsedYaml || !parsedYaml.kind)6 throw new Error(`The parsed yaml couldn't be used to construct a k8s object.\n${yaml.stringify(parsedYaml)}`);7 this._yaml = parsedYaml;8 const objectPrefix = this._objectVersion(this._yaml.apiVersion);9 this._obj = this._k8sClientObject(`${objectPrefix}${this._yaml.kind}`, this._yaml);10 }11 get kind() {12 return this._obj.kind;13 }14 get metadata() {15 return this._obj.metadata;16 }17 toString() {18 return k8s.dumpYaml(this._obj);19 }20 k8sClientObject() {21 return this._obj;22 }23 _k8sClientObject(typeName, value) {24 if (this._baseType(typeName, value)) {25 if (this._dateType(typeName) && !!value) {26 return new Date(value);27 }28 return value;29 } else if (this._arrayType(typeName)) {30 return this._handleArrayType(typeName, value);31 } else if (this._mapType(typeName)) {32 return this._handleMap(typeName, value);33 } else {34 return this._handleClientObjectType(typeName, value);35 }36 }37 _baseType(typeName, value) {38 return (!this._mapType(typeName) && !this._arrayType(typeName) && !this._object(value)) || this._dateType(typeName);39 }40 _object(value) {41 return typeof value === 'object';42 }43 _dateType(typeName) {44 return typeName === 'Date';45 }46 _arrayType(typeName) {47 return typeName.includes('Array');48 }49 _mapType(typeName) {50 return typeName.includes('{');51 }52 _attributeTypeMap(typeName, attributeName) {53 const attributeTypeMaps = k8s[typeName]['getAttributeTypeMap']();54 let targetTypeMap = {};55 for (const prospectiveTypeMap of attributeTypeMaps) {56 if (prospectiveTypeMap.name === attributeName) {57 targetTypeMap = prospectiveTypeMap;58 }59 }60 if (this._emptyMap(targetTypeMap)) {61 throw new Error(`62 The attribute with name ${attributeName} and type ${typeName} wasn't found in the type map. Are you sure it's acceptible in kubernetes yaml configurations?63 `);64 }65 return targetTypeMap;66 }67 _handleArrayType(typeName, value) {68 let subject = [];69 const elementType = typeName.match(/(?<=Array\<)(.*?)(?=\>)/)[0];70 if (!elementType) {71 throw new Error(`Could not match array element type for type ${typeName}`);72 }73 for (const entry of value) {74 subject.push(this._k8sClientObject(elementType, entry));75 }76 return subject;77 }78 _handleMap(typeName, value) {79 let subject = {};80 const propertyType = typeName.match(/(?<=\{ \[key: \w+\]: )(.*?)(?=; \})/)[0];81 for (const attribute in value) {82 subject[attribute] = this._k8sClientObject(propertyType, value[attribute]);83 }84 return subject;85 }86 _handleClientObjectType(typeName, value) {87 let subject = new k8s[typeName]();88 for (const attribute in value) {89 const targetTypeMap = this._attributeTypeMap(typeName, attribute);90 subject[attribute] = this._k8sClientObject(targetTypeMap.type, value[attribute]);91 }92 return subject;93 }94 _objectVersion(apiVersion) {95 if (!apiVersion.includes('/')) {96 return this._capitalizeFirstLetter(apiVersion);97 } else {98 const parts = apiVersion.split('/');99 const lastPart = parts[parts.length - 1];100 return this._capitalizeFirstLetter(lastPart);101 }102 }103 _capitalizeFirstLetter(string) {104 return string.charAt(0).toUpperCase() + string.slice(1);105 }106 _emptyMap(map) {107 return Object.keys(map).length === 0;108 }109}...

Full Screen

Full Screen

util.js

Source:util.js Github

copy

Full Screen

1import treeUnfold from '../../icon/tree-unfold.svg'2import treeFold from '../../icon/tree-fold.svg'3export const deleteTipsMap = {4 category: {5 title: '删除对象类目',6 content: '对象类目被删除后不可恢复,确定删除?',7 },8 obj: {9 title: '删除对象',10 content: '对象被删除后不可恢复,确定删除?',11 },12}13// 类型映射:0 类目 1 对象14export const targetTypeMap = {15 obj: 1,16 category: 0,17}18// 名称类型映射: 1 中文名 2 英文名19export const nameTypeMap = {20 name: 1,21 enName: 2,22 objPk: 3,23}24export const TARGET_CATEGORY = 'category' // 对象类目25export const TARGET_OBJECT = 'obj' // 对象26export const REL_CODE = '3'27export const ENTITY_CODE = '4'28// 弹窗默认配置29export const modalDefaultConfig = {30 width: 525,31 maskClosable: false,32 destroyOnClose: true,33}34export const getIconNodeSrc = e => (e ? treeUnfold : treeFold)35// 对象类目带有对象数量提示36export const TreeNodeTitle = ({node}) => (37 <span>38 {39 node.parentId ? node.name : `${node.name} (${node.count || 0})`40 }41 </span>42)43export const judgeEditType = (data, editType) => (editType === 'edit' ? data : undefined)44//* --------------- 对象详情 ---------------*//45// 根据 实体/对象 类型code() 映射对应文字46export const typeCodeMap = {47 4: '实体',48 3: '关系',49 '4~': '关系',50 '3~': '实体',51}52// 对象发布状态值映射53export const objStatusMap = {54 release: 1,55 cancel: 0,56}57// 对象类型映射58export const objTypeMap = {59 0: '简单关系',60 1: '复杂关系',61 2: '实体',62}63export const objTypeList = [{64 name: '简单关系',65 value: 0,66}, {67 name: '复杂关系',68 value: 1,69}, {70 name: '实体',71 value: 2,...

Full Screen

Full Screen

ENUM.js

Source:ENUM.js Github

copy

Full Screen

1window.ENUM = {2 sysUserStatus: {3 freeze: '冻结',4 normal: '正常',5 cancel: '注销'6 },7 checkStatus: {8 saved: '存盘',9 wait_audit: '待审核',10 audited: '审核通过',11 unaudited: '审核不通过'12 },13 checkStatusMap: [14 {value: 'saved', label: '存盘'},15 {value: 'wait_audit', label: '待审核'},16 {value: 'audited', label: '审核通过'},17 {value: 'unaudited', label: '审核不通过'},18 ],19 obCheckStatus: {20 saved: '存盘',21 wait_audit: '待审核',22 audited: '审核通过',23 unaudited: '审核不通过',24 discard: '废弃'25 },26 obStatusTypeMap: [27 {value: 'saved', label: '存盘'},28 {value: 'wait_audit', label: '待审核'},29 {value: 'audited', label: '审核通过'},30 {value: 'unaudited', label: '审核不通过'},31 {value: 'discard', label: '废弃'}32 ],33 platformObStatusTypeMap: [34 {value: 'wait_audit', label: '待审核'},35 {value: 'audited', label: '审核通过'},36 {value: 'unaudited', label: '审核不通过'},37 {value: 'discard', label: '废弃'}38 ],39 targetType: {40 'platform': '平台',41 'merchant': '商户',42 'member': '会员',43 },44 targetTypeMap: [{45 value: 'platform',46 label: '平台'47 }, {48 value: 'merchant',49 label: '商户'50 }, {51 value: 'member',52 label: '会员'53 }],54 sex: {55 'female': '女',56 'male': '男'57 },58 borrowerType: {59 'personal': '个人',60 'enterprise': '企业'61 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 const targetTypeMap = await page.evaluate(() => window._targetTypeMap);7 console.log(targetTypeMap);8 await browser.close();9})();10{11}12const { chromium } = require('playwright');13(async () => {14 const browser = await chromium.launch();15 const context = await browser.newContext();16 const page = await context.newPage();17 console.log(page.target().targetType());18 await browser.close();19})();20const { chromium } = require('playwright');21(async () => {22 const browser = await chromium.launch();23 const context = await browser.newContext();24 const page = await context.newPage();25 console.log(page.mainFrame().target().targetType());26 await browser.close();27})();28const { chromium } = require('playwright');29(async () => {30 const browser = await chromium.launch();31 const context = await browser.newContext();32 const page = await context.newPage();33 const worker = await page.evaluateHandle(() => new Worker(URL.createObjectURL(new Blob(['console.log("hi")'], { type: 'application/javascript' }))));34 console.log(worker.asElement().contentFrame().target().targetType());35 await browser.close();36})();37const { chromium } = require('

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 const targetTypeMap = page._delegate.targetTypeMap();7 console.log(targetTypeMap);8 await browser.close();9})();10{11}12Example 2: Using targetTypeMap() method to get the target type of the current page13const { chromium } = require('playwright');14(async () => {15 const browser = await chromium.launch();16 const context = await browser.newContext();17 const page = await context.newPage();18 const targetTypeMap = page._delegate.targetTypeMap();19 const currentTargetType = targetTypeMap[page._delegate._targetInfo.type];20 console.log(currentTargetType);21 await browser.close();22})();23Example 3: Using targetTypeMap() method to get the target type of the current page in the browser context24const { chromium } = require('playwright');25(async () => {26 const browser = await chromium.launch();27 const context = await browser.newContext();28 const page = await context.newPage();29 const targetTypeMap = page._delegate.targetTypeMap();30 const currentTargetType = targetTypeMap[page._delegate._targetInfo.type];31 console.log(currentTargetType);32 await browser.close();33})();34Example 4: Using targetTypeMap() method to get the target type of the current page in the browser context35const { chromium } = require('playwright');36(async () => {37 const browser = await chromium.launch();38 const context = await browser.newContext();39 const page = await context.newPage();40 const targetTypeMap = page._delegate.targetTypeMap();41 const currentTargetType = targetTypeMap[page._delegate._targetInfo.type];42 console.log(currentTargetType);43 await browser.close();44})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2const { targetTypeMap } = require('playwright/lib/server/chromium/crBrowser');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 await page.fill('input[type="text"]', 'Playwright');8 await page.press('input[type="text"]', 'Enter');9 const target = await page.waitForTarget(t => t.url().includes('playwright.dev'));10 console.log(targetTypeMap[target.type()]);11 await target.page();12 await browser.close();13})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const path = require('path');2const playwright = require('playwright');3const { targetTypeMap } = require(path.join(4 path.dirname(require.resolve('playwright')),5));6(async () => {7 const browser = await playwright.chromium.launch();8 const page = await browser.newPage();9 console.log(targetTypeMap);10 await browser.close();11})();12{13}14const path = require('path');15const playwright = require('playwright');16const { targetTypeMap } = require(path.join(17 path.dirname(require.resolve('playwright')),18));19console.log(targetTypeMap);20{21}

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const page = await browser.newPage();5 console.log(page.targetTypeMap());6 await browser.close();7})();8const { chromium } = require('playwright');9(async () => {10 const browser = await chromium.launch();11 const page = await browser.newPage();12 console.log(page.targetTypeMap());13 await browser.close();14})();15const { chromium } = require('playwright');16(async () => {17 const browser = await chromium.launch();18 const page = await browser.newPage();19 console.log(page.targetTypeMap());20 await browser.close();21})();22const { chromium } = require('playwright');23(async () => {24 const browser = await chromium.launch();25 const page = await browser.newPage();26 console.log(page.targetTypeMap());27 await browser.close();28})();29const { chromium } = require('playwright');30(async () => {31 const browser = await chromium.launch();32 const page = await browser.newPage();33 console.log(page.targetTypeMap());34 await browser.close();35})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium, webkit, firefox } = require('playwright');2const { targetTypeMap } = require('playwright/lib/server/chromium/crBrowser');3(async () => {4 const browser = await chromium.launch();5 const page = await browser.newPage();6 console.log(targetTypeMap);7 await browser.close();8})();9{10}11const { chromium, webkit, firefox } = require('playwright');12const { targetTypeMap } = require('playwright/lib/server/chromium/crBrowser');13(async () => {14 const browser = await chromium.launch();15 const page = await browser.newPage();16 const pageTarget = browser.targets().find(target => target.type() === targetTypeMap.page);17 console.log(pageTarget);18 await browser.close();19})();20Target {21 _browserContext: BrowserContext {22 _pageBindings: Map(0) {},23 _ownedPages: Set(1) [ [Page] ],

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2const { targetTypeMap } = require('playwright/lib/server/chromium/crBrowser');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 const target = await page.target();8 const type = targetTypeMap.get(target._targetInfo.type);9 console.log(type);10 await browser.close();11})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { Internal } = require('playwright');2const { targetTypeMap } = new Internal();3const { Internal } = require('playwright');4const { targetTypeMap } = new Internal();5const { Internal } = require('playwright');6const { targetTypeMap } = new Internal();7const { Internal } = require('playwright');8const { targetTypeMap } = new Internal();9const { Internal } = require('playwright');10const { targetTypeMap } = new Internal();11const { Internal } = require('playwright');12const { targetTypeMap } = new Internal();13const { Internal } = require('playwright');14const { targetTypeMap } = new Internal();15const { Internal } = require('playwright');16const { targetTypeMap } = new Internal();17const { Internal } = require('playwright');18const { targetTypeMap } = new Internal();19const { Internal } = require('playwright');20const { targetTypeMap } = new Internal();21const { Internal } = require('playwright');22const { targetTypeMap } = new Internal();23const { Internal } = require('playwright');24const { targetTypeMap } = new Internal();25const { Internal } = require('playwright');26const { targetTypeMap } = new Internal();27const { Internal } = require('playwright');28const { targetTypeMap } = new Internal();29const { Internal } = require('

Full Screen

Using AI Code Generation

copy

Full Screen

1const path = require('path');2const playwright = require('playwright');3const { chromium } = require('playwright');4const { targetTypeMap } = require(path.join(5 path.dirname(require.resolve('playwright')),6));7(async () => {8 const browser = await chromium.launch();9 const page = await browser.newPage();10 const target = await page.target();11 const targetType = targetTypeMap.get(target._targetInfo.type);12 console.log(targetType);13 await browser.close();14})();

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful