[fix] 紅字
This commit is contained in:
		| @@ -90,7 +90,11 @@ export class MainControl extends BaseSingleton<MainControl>() { | ||||
| 		// fileUrl = "https://patch.sdegaming.com/slot2/patch/_Release/shared/jsons/" + fileUrl; | ||||
| 		// fileUrl = "http://patch-dev.online-bj.com/shared/jsons/" + fileUrl; | ||||
| 		// fileUrl = "http://jianmiau.tk/_BJ_Source/BJ-Internal-Dev/shared/jsons/" + fileUrl; | ||||
| 		if (import.meta.env.PROD) { | ||||
| 			fileUrl = "https://patch.sdegaming.com/slot2/patch/_Release/shared/jsons/" + fileUrl; | ||||
| 		} else { | ||||
| 			fileUrl = "./shared/jsons/" + fileUrl; | ||||
| 		} | ||||
| 		fileUrl = fileUrl + "?v=" + Date.now(); | ||||
| 		let isDownloading: boolean = true; | ||||
| 		let xhr: XMLHttpRequest = new XMLHttpRequest(); | ||||
|   | ||||
| @@ -1,53 +0,0 @@ | ||||
| import LoadMaskBase from "./Group/LoadMaskBase"; | ||||
|  | ||||
| export class CSMask { | ||||
| 	/** 遮罩Dic */ | ||||
| 	private static _dicMask: Map<CSMask.MaskType, LoadMaskBase> = new Map(); | ||||
| 	public static Initialize(masks: LoadMaskBase[]): void { | ||||
| 		this._dicMask.clear(); | ||||
| 		for (let i = 0; i < masks.length; i++) { | ||||
| 			const mask: LoadMaskBase = masks[i]; | ||||
| 			this._dicMask.set(mask.MaskType, mask); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	public static GetMask(type: CSMask.MaskType): LoadMaskBase { | ||||
| 		if (this._dicMask.has(type)) { | ||||
| 			return this._dicMask.get(type); | ||||
| 		} | ||||
| 		else { | ||||
| 			return null; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	public static ShowMask(type: CSMask.MaskType, ...param: any[]): void { | ||||
| 		let mask = this.GetMask(type); | ||||
| 		if (mask != null) { | ||||
| 			mask.Show(...param); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	public static HideMask(type: CSMask.MaskType, ...param: any[]): void { | ||||
| 		let mask = this.GetMask(type); | ||||
| 		if (mask != null) { | ||||
| 			mask.Hide(...param); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	public static HideAllMask(): void { | ||||
| 		this._dicMask.forEach((k, type) => { | ||||
| 			let mask: LoadMaskBase = this.GetMask(type); | ||||
| 			if (mask != null) { | ||||
| 				mask.Reset(); | ||||
| 			} | ||||
| 		}); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| export module CSMask { | ||||
| 	export enum MaskType { | ||||
| 		/** Loading */ | ||||
| 		LoadingMask | ||||
| 	} | ||||
| } | ||||
| export default CSMask; | ||||
| @@ -1,35 +0,0 @@ | ||||
| import { loadingModalObj } from "@/context/LoadingModalContext"; | ||||
| import CSMask from "../CSMask"; | ||||
|  | ||||
| export default abstract class LoadMaskBase { | ||||
| 	/** 一般遮罩記數 */ | ||||
| 	private _count: number = 0; | ||||
| 	public get MaskType(): CSMask.MaskType { throw new Error(`請初始化MaskType`); } | ||||
|  | ||||
| 	onLoad() { | ||||
| 		this._count = 0; | ||||
| 	} | ||||
|  | ||||
| 	public Show(...param: any[]): void { | ||||
| 		if (this._count == 0) { | ||||
| 			const { handleOpen } = loadingModalObj; | ||||
| 			handleOpen(); | ||||
| 		} | ||||
| 		this._count++; | ||||
| 	} | ||||
|  | ||||
| 	public Hide(...param: any[]): void { | ||||
| 		this._count--; | ||||
| 		if (this._count <= 0) { | ||||
| 			const { handleClose } = loadingModalObj; | ||||
| 			handleClose(); | ||||
| 			this._count = 0; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	public Reset(): void { | ||||
| 		this._count = 0; | ||||
| 		const { handleClose } = loadingModalObj; | ||||
| 		handleClose(); | ||||
| 	} | ||||
| } | ||||
| @@ -1,6 +0,0 @@ | ||||
| import CSMask from "../CSMask"; | ||||
| import LoadMaskBase from "./LoadMaskBase"; | ||||
|  | ||||
| export default class LoadingMask extends LoadMaskBase { | ||||
| 	public get MaskType(): CSMask.MaskType { return CSMask.MaskType.LoadingMask; } | ||||
| } | ||||
| @@ -1,92 +0,0 @@ | ||||
| import { ResourceInfo } from "@/define/resource"; | ||||
| import { ActionWithType } from "../../Engine/CatanEngine/CSharp/System/ActionWithType"; | ||||
| import IResourceItem from "./IResourceItem"; | ||||
| import CardCouponItem from "./Items/CardCouponItem"; | ||||
| import LpPointItem from "./Items/LpPointItem"; | ||||
| import MoneyItem from "./Items/MoneyItem"; | ||||
| import { ResourceItemType } from "./ResourceItemType"; | ||||
|  | ||||
|  | ||||
| class UpdateResourceEvent extends ActionWithType<ResourceItemType, any[]> { | ||||
| } | ||||
|  | ||||
| export default class CSResource { | ||||
| 	private static _event: UpdateResourceEvent; | ||||
|  | ||||
| 	/** 更新資源事件 */ | ||||
| 	public static get Event() { | ||||
| 		return CSResource._event; | ||||
| 	} | ||||
|  | ||||
| 	public static Initialize(): void { | ||||
| 		CSResource._event = new UpdateResourceEvent(); | ||||
| 		// Cocos.VicKing_Bridge.GetCSResourceEvent = () => { return CSResource._event; }; | ||||
| 		// Cocos.VicKing_Bridge.AddResourceItemFromServer = (data: JSON) => { return CSResource.AddResourceItemFromServer(data); }; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * 新增一筆資源(資料必須是從Server來的) | ||||
| 	 * @param data ex [1, 15] --> 新增元寶資源 | ||||
| 	 */ | ||||
| 	public static AddResourceItemFromServer(data: ResourceInfo | JSON): IResourceItem { | ||||
| 		let item = this.GetResourceItemFromServer(data); | ||||
| 		item.AddToResource(); | ||||
| 		return item; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * 新增多筆資源(資料必須是從Server來的) | ||||
| 	 * @param data ex: [[1, 15], [2, 30], [28, ["0000123", [124, 3, 0, 0, 0, 0, 0, 0, 0, 1000, 0, 0, 1, 1, 0.000, 0.00, 1, 0, 0, 0, 0, 0, 3]]]] --> 新增[元寶, 銀兩, 卡片]等資源 | ||||
| 	 */ | ||||
| 	public static AddResourceItemsFromServer(data: ResourceInfo[] | JSON): IResourceItem[] { | ||||
| 		let itemList: IResourceItem[] = []; | ||||
| 		for (let i = 0, count = Object.keys(data).length; i < count; i++) { | ||||
| 			let itemData: JSON = data[i]; | ||||
| 			itemList.push(this.AddResourceItemFromServer(itemData)); | ||||
| 		} | ||||
| 		return itemList; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * 從Server資料還原對應的資源物件 | ||||
| 	 * @param data ex: [1, 15] --> 元寶, [2, 30] --> 銀兩 | ||||
| 	 */ | ||||
| 	public static GetResourceItemFromServer(data: ResourceInfo | JSON): IResourceItem { | ||||
| 		let type = data[0]; | ||||
| 		switch (type) { | ||||
| 			case ResourceItemType.Money: | ||||
| 				return new MoneyItem(data); | ||||
| 			case ResourceItemType.Card_Coupon: | ||||
| 				return new CardCouponItem(data); | ||||
| 			case ResourceItemType.LpPoint: | ||||
| 				return new LpPointItem(data); | ||||
| 			default: | ||||
| 				throw new Error("沒有對應[" + type + "]類型的Server資源類別"); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * 從Server資料還原對應的資源物件 | ||||
| 	 * @param data ex: [[1, 15], [2, 30], [45, [1, 10], ...] --> [元寶, 銀兩, 節慶貨幣, ...] | ||||
| 	 */ | ||||
| 	public static GetResourceItemsFromServer(data: JSON): IResourceItem[] { | ||||
| 		let itemList: IResourceItem[] = []; | ||||
| 		for (let i = 0, count = Object.keys(data).length; i < count; i++) { | ||||
| 			let itemData: JSON = data[i]; | ||||
| 			itemList.push(this.GetResourceItemFromServer(itemData)); | ||||
| 		} | ||||
| 		return itemList; | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * 新增多筆資源(直接拿資料本身) | ||||
| 	 * @param items | ||||
| 	 */ | ||||
| 	public static AddResourceItems(items: IResourceItem[]): void { | ||||
| 		for (let item of items) { | ||||
| 			item.AddToResource(); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	// #endregion | ||||
| } | ||||
| @@ -1,16 +0,0 @@ | ||||
| import { ResourceItemType } from "./ResourceItemType"; | ||||
|  | ||||
| interface IResourceItem { | ||||
| 	/** 取得資源名稱 */ | ||||
| 	readonly Name: string; | ||||
| 	/** 取得資源類型 */ | ||||
| 	readonly ResourceType: ResourceItemType; | ||||
| 	/** 資源編號 */ | ||||
| 	readonly ID: number; | ||||
| 	/** 數量 */ | ||||
| 	Count: number; | ||||
|  | ||||
| 	/** 加入到玩家資源中 */ | ||||
| 	AddToResource(): void; | ||||
| } | ||||
| export default IResourceItem; | ||||
| @@ -1,28 +0,0 @@ | ||||
| import CSSettingsSDV3 from "@/FormTable/CSSettingsV3"; | ||||
| import { LanguageManager } from "@/FormTableExt/Manage/Language/LanguageManager"; | ||||
| import { ResourceInfo } from "@/define/resource"; | ||||
| import { backpackInfo } from "@/utils/setRPCData"; | ||||
| import CSResource from "../CSResource"; | ||||
| import IResourceItem from "../IResourceItem"; | ||||
| import { ResourceItemType } from "../ResourceItemType"; | ||||
|  | ||||
| export default class CardCouponItem implements IResourceItem { | ||||
| 	public get Name(): string { return CSSettingsSDV3.ItemSetting.StringDetail[+CSSettingsSDV3.ItemSetting.CouponSetting[this.ID].CardName][LanguageManager.GetMsgId()]; } | ||||
| 	public get ResourceType(): ResourceItemType { return ResourceItemType.Card_Coupon; } | ||||
| 	public ID: number; | ||||
| 	public Count: number; | ||||
|  | ||||
| 	public AddToResource(): void { | ||||
| 		backpackInfo([[this.ResourceType, [this.ID, this.Count]]], true); | ||||
| 		CSResource.Event.DispatchCallback(ResourceItemType.Card_Coupon, [this.ResourceType, [this.ID, this.Count]]); | ||||
| 	} | ||||
|  | ||||
| 	/** 從db來的格式建立可數資源物件 */ | ||||
| 	public constructor(db: ResourceInfo | JSON) { | ||||
| 		if (!db[1]) { | ||||
| 			return; | ||||
| 		} | ||||
| 		this.ID = db[1][0]; | ||||
| 		this.Count = <number>db[1][1]; | ||||
| 	} | ||||
| } | ||||
| @@ -1,10 +0,0 @@ | ||||
| { | ||||
|   "ver": "1.1.0", | ||||
|   "uuid": "0cab7ce7-c8b2-4c65-a80b-502bb8eddc53", | ||||
|   "importer": "typescript", | ||||
|   "isPlugin": false, | ||||
|   "loadPluginInWeb": true, | ||||
|   "loadPluginInNative": true, | ||||
|   "loadPluginInEditor": false, | ||||
|   "subMetas": {} | ||||
| } | ||||
| @@ -1,10 +0,0 @@ | ||||
| { | ||||
|   "ver": "1.1.0", | ||||
|   "uuid": "5a6fedda-63d3-4fb7-b8f7-7ca1889cf7db", | ||||
|   "importer": "typescript", | ||||
|   "isPlugin": false, | ||||
|   "loadPluginInWeb": true, | ||||
|   "loadPluginInNative": true, | ||||
|   "loadPluginInEditor": false, | ||||
|   "subMetas": {} | ||||
| } | ||||
| @@ -1,28 +0,0 @@ | ||||
| import CSSettingsSDV3 from "@/FormTable/CSSettingsV3"; | ||||
| import { Shop } from "@/define/formkey"; | ||||
| import { ResourceInfo } from "@/define/resource"; | ||||
| import Player from "@/modules/player"; | ||||
| import { State } from "@/modules/player/define/data"; | ||||
| import { NumberEx } from "@/utils/Number/NumberEx"; | ||||
| import CSResource from "../CSResource"; | ||||
| import IResourceItem from "../IResourceItem"; | ||||
| import { ResourceItemType } from "../ResourceItemType"; | ||||
|  | ||||
| export default class LpPointItem implements IResourceItem { | ||||
| 	public get Name(): string { return CSSettingsSDV3.prototype.ShopString(Shop.String.LpPoint); } | ||||
| 	public get ResourceType(): ResourceItemType { return ResourceItemType.LpPoint; } | ||||
| 	public ID: number; | ||||
| 	public Count: number; | ||||
|  | ||||
| 	public AddToResource(): void { | ||||
| 		const playerData: State = Player.data.getState(); | ||||
| 		playerData.account.lpPoint = NumberEx.plus(playerData.account.lpPoint, this.Count); | ||||
| 		Player.data.setState(playerData); | ||||
| 		CSResource.Event.DispatchCallback(ResourceItemType.LpPoint, [playerData.account.lpPoint, this.Count]); | ||||
| 	} | ||||
|  | ||||
| 	/** 從db來的格式建立可數資源物件 */ | ||||
| 	public constructor(db: ResourceInfo | JSON) { | ||||
| 		this.Count = <number>db[1]; | ||||
| 	} | ||||
| } | ||||
| @@ -1,10 +0,0 @@ | ||||
| { | ||||
|   "ver": "1.1.0", | ||||
|   "uuid": "db699d15-9603-4466-8ffd-d34fde6abb5f", | ||||
|   "importer": "typescript", | ||||
|   "isPlugin": false, | ||||
|   "loadPluginInWeb": true, | ||||
|   "loadPluginInNative": true, | ||||
|   "loadPluginInEditor": false, | ||||
|   "subMetas": {} | ||||
| } | ||||
| @@ -1,31 +0,0 @@ | ||||
| import CSSettingsSDV3 from "@/FormTable/CSSettingsV3"; | ||||
| import Config from "@/define/Config"; | ||||
| import { Shop } from "@/define/formkey"; | ||||
| import { ResourceInfo } from "@/define/resource"; | ||||
| import Player from "@/modules/player"; | ||||
| import { NumberEx } from "@/utils/Number/NumberEx"; | ||||
| import CSResource from "../CSResource"; | ||||
| import IResourceItem from "../IResourceItem"; | ||||
| import { ResourceItemType } from "../ResourceItemType"; | ||||
|  | ||||
| export default class MoneyItem implements IResourceItem { | ||||
| 	public get Name(): string { return CSSettingsSDV3.prototype.ShopString(Shop.String.Money); } | ||||
| 	public get ResourceType(): ResourceItemType { return ResourceItemType.Money; } | ||||
| 	public ID: number; | ||||
| 	public Count: number; | ||||
|  | ||||
| 	public AddToResource(): void { | ||||
| 		const playerData = Player.data.getState(); | ||||
| 		playerData.account.money = NumberEx.plus(playerData.account.money, this.Count); | ||||
| 		Player.data.setState(playerData); | ||||
| 		if (Config.ShowMoneyLog) { | ||||
| 			console.debug(String.Format("[{0}], {1}, {2}", "Money_" + ResourceItemType.Money, playerData.account.money, this.Count)); | ||||
| 		} | ||||
| 		CSResource.Event.DispatchCallback(ResourceItemType.Money, [playerData.account.money, this.Count]); | ||||
| 	} | ||||
|  | ||||
| 	/** 從db來的格式建立可數資源物件 */ | ||||
| 	public constructor(db: ResourceInfo | JSON) { | ||||
| 		this.Count = <number>db[1]; | ||||
| 	} | ||||
| } | ||||
| @@ -1,10 +0,0 @@ | ||||
| { | ||||
|   "ver": "1.1.0", | ||||
|   "uuid": "e03637c9-24be-42ff-960f-b3377e20efdc", | ||||
|   "importer": "typescript", | ||||
|   "isPlugin": false, | ||||
|   "loadPluginInWeb": true, | ||||
|   "loadPluginInNative": true, | ||||
|   "loadPluginInEditor": false, | ||||
|   "subMetas": {} | ||||
| } | ||||
| @@ -1,12 +0,0 @@ | ||||
| export enum ResourceItemType { | ||||
| 	/** 錢 */ | ||||
| 	Money = 1, | ||||
| 	/** 等級 */ | ||||
| 	Level = 2, | ||||
| 	/** 卡片 */ | ||||
| 	Card = 5, | ||||
| 	/** 卡片優惠券 */ | ||||
| 	Card_Coupon = 101, | ||||
| 	/** 來亨卷 */ | ||||
| 	LpPoint = 102, | ||||
| } | ||||
| @@ -1,18 +0,0 @@ | ||||
| import { ResourceItemType } from "@/Common/ResourceItem/ResourceItemType"; | ||||
| import { NetRequest } from "../../Engine/CatanEngine/NetManagerV2/NetRequest"; | ||||
| import { ItemInfo } from "../backpack/itemInfo"; | ||||
|  | ||||
| export type ResponseBackpackInfo = [ | ||||
| 	ResourceType: ResourceItemType, | ||||
| 	itemInfo: ItemInfo, | ||||
| ]; | ||||
|  | ||||
| /** 背包內容 */ | ||||
| export class BackpackInfo extends NetRequest<null, ResponseBackpackInfo[]> { | ||||
| 	get Method(): string { | ||||
| 		return "backpack.info"; | ||||
| 	} | ||||
| 	constructor() { | ||||
| 		super(); | ||||
| 	} | ||||
| } | ||||
| @@ -1,219 +0,0 @@ | ||||
| import { NetRequest } from "../../Engine/CatanEngine/NetManagerV2/NetRequest"; | ||||
| import { ResourceInfo } from "../resource"; | ||||
|  | ||||
| /** | ||||
|  * @link dlygo(得來購) https://docs.google.com/spreadsheets/d/1bm1FwHyY2X7JGkCqSeCUoZAgaMcT7fUB7K4SiDtkyig | ||||
|  */ | ||||
|  | ||||
| // #region Request | ||||
|  | ||||
| export type RpcDlygoListRequest = { t: DlygoMainType } | ||||
| export type RpcDlygoListResponse = TDlygoList[] | ||||
|  | ||||
| /** 商品清單 */ | ||||
| export class DlygoListRequest extends NetRequest<RpcDlygoListRequest, RpcDlygoListResponse> { | ||||
| 	get Method(): string { | ||||
| 		return "dlygo.list"; | ||||
| 	} | ||||
| 	constructor(type: DlygoMainType) { | ||||
| 		super(); | ||||
| 		this.Data = { | ||||
| 			t: type | ||||
| 		}; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| export type RpcDlygoSNRequest = { i: number; } | ||||
| export type RpcDlygoSNResponse = TDlygoSN | ||||
|  | ||||
| /** 商品明細 */ | ||||
| export class DlygoSNRequest extends NetRequest<RpcDlygoSNRequest, RpcDlygoSNResponse> { | ||||
| 	get Method(): string { | ||||
| 		return "dlygo.sn"; | ||||
| 	} | ||||
| 	constructor(id: number) { | ||||
| 		super(); | ||||
| 		this.Data = { | ||||
| 			i: id | ||||
| 		}; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| export type RpcDlygoRedeemRequest = { i: number; p: number; } | ||||
| export type RpcDlygoRedeemResponse = TDlygoRedeem | ||||
|  | ||||
| /** 商品兌換 */ | ||||
| export class DlygoRedeemRequest extends NetRequest<RpcDlygoRedeemRequest, RpcDlygoRedeemResponse> { | ||||
| 	get Method(): string { | ||||
| 		return "dlygo.redeem"; | ||||
| 	} | ||||
| 	constructor(id: number, p: number) { | ||||
| 		super(); | ||||
| 		this.Data = { | ||||
| 			i: id, | ||||
| 			p: p | ||||
| 		}; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| export type RpcDlygoExchangeRequest = RpcDlygoSNRequest | ||||
| export type RpcDlygoExchangeResponse = TDlygoExchange | ||||
|  | ||||
| /** 金幣兌換 */ | ||||
| export class DlygoExchangeRequest extends NetRequest<RpcDlygoExchangeRequest, RpcDlygoExchangeResponse> { | ||||
| 	get Method(): string { | ||||
| 		return "dlygo.exchange"; | ||||
| 	} | ||||
| 	constructor(id: number) { | ||||
| 		super(); | ||||
| 		this.Data = { | ||||
| 			i: id | ||||
| 		}; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| export type RpcDlygoLogRequest = { | ||||
| 	/** | ||||
| 	* @param u true: 使用時間, | ||||
| 	* @param u false: 領獎時間, | ||||
| 	*/ | ||||
| 	u: boolean; | ||||
| } | ||||
| export type RpcDlygoLogResponse = TDlygoLog[] | ||||
|  | ||||
| /** 商品記錄 */ | ||||
| export class DlygoLogRequest extends NetRequest<RpcDlygoLogRequest, RpcDlygoLogResponse> { | ||||
| 	get Method(): string { | ||||
| 		return "dlygo.log"; | ||||
| 	} | ||||
| 	constructor(u: boolean) { | ||||
| 		super(); | ||||
| 		this.Data = { | ||||
| 			u: u | ||||
| 		}; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| export type RpcDlygoUsedRequest = [productId: number, productSerialNumber: string] | ||||
| export type RpcDlygoUsedResponse = TDlygoUsed | ||||
|  | ||||
| /** 商品使用 */ | ||||
| export class DlygoUsedRequest extends NetRequest<RpcDlygoUsedRequest[], RpcDlygoUsedResponse> { | ||||
| 	get Method(): string { | ||||
| 		return "dlygo.used"; | ||||
| 	} | ||||
| 	constructor(arg: RpcDlygoUsedRequest[]) { | ||||
| 		super(); | ||||
| 		this.Data = arg; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // #endregion | ||||
|  | ||||
| // #region Type | ||||
|  | ||||
| export type TDlygoItem = [ | ||||
| 	dataType: DlygoDataType, | ||||
| 	productId: number, | ||||
| 	productName: string, | ||||
| 	productDisplayName: string, | ||||
| 	productSerialNumber: string, | ||||
| 	expiryDate: number, | ||||
| 	prizeRedemptionTime: number, | ||||
| ] | ||||
|  | ||||
| export type TDlygoList = [ | ||||
| 	id: number, | ||||
| 	name: string, | ||||
| 	price: number, | ||||
| 	discountPrice: number, | ||||
| 	tag: DlygoTag, | ||||
| 	remainQuantity: number, | ||||
| 	dayLimitAmount: number, | ||||
| ]; | ||||
|  | ||||
| export type TDlygoSN = { | ||||
| 	/** 本日已兌換數量 */ | ||||
| 	q: number, | ||||
|  | ||||
| 	/** 說明1 */ | ||||
| 	c1: string, | ||||
|  | ||||
| 	/** 說明2 */ | ||||
| 	c2: string, | ||||
| } | ||||
|  | ||||
| export type TDlygoRedeem = [TDlygoItem, ResourceInfo[]] | ||||
|  | ||||
| export type TDlygoExchange = [TDlygoItem, ResourceInfo[]] | ||||
|  | ||||
| export type TDlygoLog = [ | ||||
| 	dataType: DlygoDataType, | ||||
| 	productId: number, | ||||
| 	productName: string, | ||||
| 	productDisplayName: string, | ||||
| 	productSerialNumber: string, | ||||
| 	expiryDate: number, | ||||
| 	time: number, | ||||
| ] | ||||
|  | ||||
| export type TDlygoUsed = { | ||||
| 	/** 使用時間 */ | ||||
| 	t: number, | ||||
| } | ||||
|  | ||||
| // #endregion | ||||
|  | ||||
| // #region Server Error Enum | ||||
|  | ||||
| export enum DlygoRedeemStatus { | ||||
| 	NotEnough = 11, | ||||
| 	NoMoney = 12, | ||||
| 	ExceededDailyLimit = 13, | ||||
| 	DBError = 14, | ||||
| 	PriceUpdated = 15, | ||||
| } | ||||
|  | ||||
| export enum DlygoExchangeStatus { | ||||
| 	NoMoney = 11, | ||||
| 	DBError = 12, | ||||
| } | ||||
|  | ||||
| export enum DlygoUsedStatus { | ||||
| 	DBError = 11, | ||||
| } | ||||
|  | ||||
| // #endregion | ||||
|  | ||||
| // #region Enum | ||||
|  | ||||
| export enum DlygoMainType { | ||||
| 	/** 點子點數 */ | ||||
| 	Point = 1, | ||||
| 	/** 精緻餐飲 */ | ||||
| 	Food = 2, | ||||
| 	/** 超商禮券 */ | ||||
| 	Seven = 3, | ||||
| 	/** 生活百貨 */ | ||||
| 	Shop = 4, | ||||
| 	/** 其他品項 */ | ||||
| 	Other = 5, | ||||
| 	/** Coin */ | ||||
| 	Coin = 99 | ||||
| } | ||||
|  | ||||
| export enum DlygoDataType { | ||||
| 	/** 商品 */ | ||||
| 	Product = 1, | ||||
| 	/** 金幣 */ | ||||
| 	Coin = 2, | ||||
| } | ||||
|  | ||||
| export enum DlygoTag { | ||||
| 	None, | ||||
| 	New, | ||||
| 	Popular, | ||||
| 	SpecialOffer, | ||||
| } | ||||
|  | ||||
| // #endregion | ||||
| @@ -1,4 +1,3 @@ | ||||
| import { ResourceItemType } from "@/Common/ResourceItem/ResourceItemType"; | ||||
| import { NetRequest } from "@/Engine/CatanEngine/NetManagerV2/NetRequest"; | ||||
|  | ||||
| // #region Request | ||||
| @@ -41,22 +40,4 @@ export class GameLeaveRequest extends NetRequest<RpcGameLeaveRequest, RpcGameLea | ||||
| 	} | ||||
| } | ||||
|  | ||||
| export type RpcGameShareRewardRequest = null | ||||
| export type RpcGameShareRewardResponse = TGameShareReward | ||||
| export class GameShareReward extends NetRequest<RpcGameShareRewardRequest, RpcGameShareRewardResponse> { | ||||
| 	get Method(): string { | ||||
| 		return "game.share_reward"; | ||||
| 	} | ||||
|  | ||||
| 	constructor() { | ||||
| 		super(); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // #endregion | ||||
|  | ||||
| // #region Type | ||||
|  | ||||
| export type TGameShareReward = [ResourceType: ResourceItemType, Count: number] | ||||
|  | ||||
| // #endregion | ||||
| @@ -1,90 +0,0 @@ | ||||
| import { ResourceInfo } from "@/define/resource"; | ||||
| import { NetRequest } from "@/Engine/CatanEngine/NetManagerV2/NetRequest"; | ||||
|  | ||||
| // #region Request | ||||
|  | ||||
| export type RpcTaskInfoRequest = null | ||||
| export type RpcTaskInfoResponse = TaskInfo[] | ||||
| export class TaskInfoRequest extends NetRequest<RpcTaskInfoRequest, RpcTaskInfoResponse> { | ||||
| 	constructor() { | ||||
| 		super(); | ||||
| 	} | ||||
|  | ||||
| 	get Method(): string { | ||||
| 		return "task.info"; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| export type RpcTaskLogRequest = null | ||||
| export type RpcTaskLogResponse = TaskInfo[] | ||||
| export class TaskLogRequest extends NetRequest<RpcTaskLogRequest, RpcTaskLogResponse> { | ||||
| 	constructor() { | ||||
| 		super(); | ||||
| 	} | ||||
|  | ||||
| 	get Method(): string { | ||||
| 		return "task.log"; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| export type RpcTaskProcessRequest = { | ||||
| 	act: number; | ||||
| 	id: TaskAction; | ||||
| }; | ||||
| export type RpcTaskProcessResponse = TaskInfo | null | ResourceInfo[] | ||||
| export class TaskProcessRequest extends NetRequest<RpcTaskProcessRequest, RpcTaskProcessResponse> { | ||||
| 	constructor(act: TaskAction, id: number) { | ||||
| 		super(); | ||||
| 		this.Data = { | ||||
| 			act, | ||||
| 			id | ||||
| 		}; | ||||
| 	} | ||||
|  | ||||
| 	get Method(): string { | ||||
| 		return "task.process"; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // #endregion | ||||
|  | ||||
| // #region Type | ||||
|  | ||||
| export type TaskInfo = [ | ||||
| 	taskType: TaskType, | ||||
| 	taskID: number, | ||||
| 	taskProgress: number[], | ||||
| 	dailyTaskStatus: DailyTaskStatus[], | ||||
| 	receiveTaskTime: number, | ||||
| 	taskStatus: TaskStatus | undefined | ||||
| ]; | ||||
|  | ||||
| // #endregion | ||||
|  | ||||
| // #region Enum | ||||
|  | ||||
| export enum TaskType { | ||||
| 	Normal = 1, | ||||
| 	Advance | ||||
| } | ||||
|  | ||||
| export enum DailyTaskStatus { | ||||
| 	NotYetStarted, | ||||
| 	Success, | ||||
| 	Failure, | ||||
| 	InProgress | ||||
| } | ||||
|  | ||||
| export enum TaskStatus { | ||||
| 	Completed = 1, | ||||
| 	Failure, | ||||
| 	GiveUp, | ||||
| 	InProgress | ||||
| } | ||||
| export enum TaskAction { | ||||
| 	TakeTask, | ||||
| 	GiveUp, | ||||
| 	Complete | ||||
| } | ||||
|  | ||||
| // #endregion | ||||
| @@ -1,413 +0,0 @@ | ||||
| import { ResourceItemType } from "@/Common/ResourceItem/ResourceItemType"; | ||||
| import { NetRequest } from "../../Engine/CatanEngine/NetManagerV2/NetRequest"; | ||||
|  | ||||
| export namespace TxnRequest { | ||||
| 	/**贈禮資訊 */ | ||||
| 	export type TxnInfo = [ | ||||
| 		serialNum: number, | ||||
| 		time: number, | ||||
| 		giver: [aId: number, nickName: string], | ||||
| 		receiver: [aId: number, nickName: string], | ||||
| 		status: string, | ||||
| 		fee: number, | ||||
| 		goodsInfo: GoodsInfo[], | ||||
| 	]; | ||||
| 	/**物品資訊 */ | ||||
| 	export type GoodsInfo = [ | ||||
| 		itemType: ResourceItemType, | ||||
| 		id: number, | ||||
| 		count: number | ||||
| 	]; | ||||
| 	/**凍結資訊 */ | ||||
| 	export type FrozenInfo = [ | ||||
| 		time: number, | ||||
| 		type: StoredValueType, | ||||
| 		amount: number, | ||||
| 	]; | ||||
| 	/**儲值類型(凍結類別) */ | ||||
| 	export enum StoredValueType { | ||||
| 		StoredValue = 1, // wait for notifications on web functions | ||||
| 		StoredValueBonus, | ||||
| 		RewardsSharing, | ||||
| 		PackageSerialNumber, | ||||
| 		BindingRewards, | ||||
| 		InitialGoldCoins, | ||||
| 		FortuneGold, | ||||
| 		Family, | ||||
| 		Backpack, | ||||
| 		LineFriend | ||||
| 	} | ||||
| 	/**贈禮狀態 */ | ||||
| 	export enum Status { | ||||
| 		Applying = 0, | ||||
| 		GiverGift = 1, | ||||
| 		Authentication = 2, | ||||
| 		Receive = 3, | ||||
| 		Cancel = 11, | ||||
| 		Reject = 12, | ||||
| 		Timeout = 13, | ||||
| 		Done = 21, | ||||
| 		CancelComplete = 22, | ||||
| 		RefuseComplete = 23, | ||||
| 		TimeoutComplete = 24, | ||||
| 		Unknown = 25, | ||||
| 	} | ||||
| 	/**常用名單玩家資訊 */ | ||||
| 	export type PlayerInfo = [ | ||||
| 		aId: number, | ||||
| 		nickName: string, | ||||
| 		vip: number, | ||||
| 		/**上線狀態(0: 離線, 1: 在線) */ | ||||
| 		onlineStatus: 0 | 1, | ||||
| 	]; | ||||
| 	/**個人贈禮可使用額度 */ | ||||
| 	export interface UsageQuotaSelf { | ||||
| 		/**可送數量 */ | ||||
| 		msm: number; | ||||
| 		/**可送額度 */ | ||||
| 		sm: number; | ||||
| 		/**可送次數 */ | ||||
| 		sc: number; | ||||
| 		/**凍結總額 */ | ||||
| 		fm: number; | ||||
| 	} | ||||
| 	// ======================================================================================= | ||||
| 	/**贈禮中心 */ | ||||
| 	export class Center extends NetRequest<null, TxnInfo[]> { | ||||
| 		get Method(): string { | ||||
| 			return "txn.center"; | ||||
| 		} | ||||
| 		constructor() { | ||||
| 			super(); | ||||
| 		} | ||||
| 	} | ||||
| 	// ======================================================================================= | ||||
| 	/**個人贈禮資訊 */ | ||||
| 	export class GetInfoSelf extends NetRequest<null, UsageQuotaSelf> { | ||||
| 		get Method(): string { | ||||
| 			return "txn.info"; | ||||
| 		} | ||||
| 		constructor() { | ||||
| 			super(); | ||||
| 		} | ||||
| 	} | ||||
| 	// ======================================================================================= | ||||
| 	enum GetFrozenInfoError { | ||||
| 		PhoneNotBound = 11, | ||||
| 		GiftGivingPunishment, | ||||
| 		GettingGiftInfoError, | ||||
| 		StatusError, | ||||
| 		OTPRequestTimeTooShort, | ||||
| 		OTPSendingFailed, | ||||
| 	} | ||||
| 	/**凍結資訊 */ | ||||
| 	export class GetFrozenInfo extends NetRequest<null, FrozenInfo[]> { | ||||
| 		get Method(): string { | ||||
| 			return "txn.frozen"; | ||||
| 		} | ||||
| 		constructor() { | ||||
| 			super(); | ||||
| 		} | ||||
| 	} | ||||
| 	// ======================================================================================= | ||||
| 	enum CreateNewError { | ||||
| 		giftGivingPunishment = 11, | ||||
| 		UnboundMobilePhone, | ||||
| 		Unloaded, | ||||
| 		TargetNotExist, | ||||
| 		OnTargetGiftPenalty, | ||||
| 		TargetVIPLevel, | ||||
| 		TargetAIDError, | ||||
| 		AimIsPlayerItsSelf, | ||||
| 		ExceededNumbersOfGifts, | ||||
| 		GiftItems_resource, | ||||
| 		GiftItems_json_resource, | ||||
| 		MoneyMistakes, | ||||
| 		InsufficientAmount, | ||||
| 		ExceedingAvailableGiftAmount, | ||||
| 		BuildFailed, | ||||
| 		FailedGettingTargetCache, | ||||
| 	} | ||||
| 	interface CreateNewRequest { | ||||
| 		a?: number; | ||||
| 		n?: string; | ||||
| 		i: GoodsInfo[]; | ||||
| 		f?: CreateNewFlagType; | ||||
| 	} | ||||
| 	export enum CreateNewFlagType { | ||||
| 		/**新增常用名單 */ | ||||
| 		AddFrequentlyUsedList, | ||||
| 	} | ||||
| 	/**建立贈禮 */ | ||||
| 	export class CreateNew extends NetRequest<CreateNewRequest, TxnInfo> { | ||||
| 		get Method(): string { | ||||
| 			return "txn.new"; | ||||
| 		} | ||||
| 		constructor(name: string, i: GoodsInfo[], flag?: CreateNewFlagType) { | ||||
| 			super(); | ||||
| 			this.Data = { | ||||
| 				n: name, | ||||
| 				i: i, | ||||
| 				f: flag | ||||
| 			}; | ||||
| 		} | ||||
| 	} | ||||
| 	// ======================================================================================= | ||||
| 	interface TradeRequest { | ||||
| 		/**流水號 */ | ||||
| 		id: number; | ||||
| 		/**操作類型 */ | ||||
| 		t: TradeOperationType; | ||||
| 		/**密碼 */ | ||||
| 		c?: string; | ||||
| 	} | ||||
| 	/**贈禮操作類型 */ | ||||
| 	export enum TradeOperationType { | ||||
| 		/**同意(收禮方) */ | ||||
| 		Agree_Receiver = 1, | ||||
| 		/**認證(贈禮方) */ | ||||
| 		Authentication_Giver, | ||||
| 		/**取得(收禮方) */ | ||||
| 		Obtain_Receiver, | ||||
| 		/**取回(贈禮方) */ | ||||
| 		Retrieve_Giver, | ||||
| 		/**取消(贈禮方) */ | ||||
| 		Cancellation_Giver, | ||||
| 		/**拒絕(收禮方) */ | ||||
| 		Reject_Receiver, | ||||
| 	} | ||||
| 	export interface TradeResponse { | ||||
| 		id: number; | ||||
| 		s: Status; | ||||
| 		p: GoodsInfo[]; | ||||
| 	} | ||||
| 	export enum TradeError { | ||||
| 		TargetGiftInPenalty = 11, | ||||
| 		GiftInPenalty, | ||||
| 		GiftNotExist, | ||||
| 		OperationError, | ||||
| 		WrongPassword, | ||||
| 	} | ||||
| 	/**贈禮操作 */ | ||||
| 	export class Trade extends NetRequest<TradeRequest, TradeResponse> { | ||||
| 		get Method(): string { | ||||
| 			return "txn.trade"; | ||||
| 		} | ||||
| 		constructor(txn: number, type: TradeOperationType, c?: string) { | ||||
| 			super(); | ||||
| 			this.Data = { | ||||
| 				id: txn, | ||||
| 				t: type, | ||||
| 				c: c, | ||||
| 			}; | ||||
| 		} | ||||
| 	} | ||||
| 	// ======================================================================================= | ||||
| 	/**贈禮常用名單 */ | ||||
| 	export class GetUserList extends NetRequest<null, PlayerInfo[]> { | ||||
| 		get Method(): string { | ||||
| 			return "txn.user_list"; | ||||
| 		} | ||||
| 		constructor() { | ||||
| 			super(); | ||||
| 		} | ||||
| 	} | ||||
| 	// ======================================================================================= | ||||
| 	export type UserAddResponse = { | ||||
| 		u: PlayerInfo; | ||||
| 		/* | ||||
| 		 * 移除的玩家AID | ||||
| 		 * */ | ||||
| 		r?: number; | ||||
| 	}; | ||||
| 	export enum UserAddError { | ||||
| 		TargetIsUserItsSelf = 11, | ||||
| 		TargetHasAlreadyBeenExist, | ||||
| 		VIPLevel, | ||||
| 		TargetNotExist, | ||||
| 	} | ||||
| 	/**增加常用名單 */ | ||||
| 	export class UserAdd extends NetRequest<{ n: string }, UserAddResponse> { | ||||
| 		get Method(): string { | ||||
| 			return "txn.user_add"; | ||||
| 		} | ||||
| 		constructor(nickName: string) { | ||||
| 			super(); | ||||
| 			this.Data = { | ||||
| 				n: nickName | ||||
| 			}; | ||||
| 		} | ||||
| 	} | ||||
| 	// ======================================================================================= | ||||
| 	export enum UserDelError { | ||||
| 		TargetIsUserItsSelf = 11, | ||||
| 		TargetHasNotExist, | ||||
| 	} | ||||
| 	/**移除常用名單 */ | ||||
| 	export class UserDel extends NetRequest<{ a: number }, null> { | ||||
| 		get Method(): string { | ||||
| 			return "txn.user_del"; | ||||
| 		} | ||||
| 		constructor(aid: number) { | ||||
| 			super(); | ||||
| 			this.Data = { | ||||
| 				a: aid | ||||
| 			}; | ||||
| 		} | ||||
| 	} | ||||
| 	// ======================================================================================= | ||||
| 	interface AuthCodeResquest { | ||||
| 		id: number | ||||
| 	} | ||||
| 	export interface AuthCodeResponse { | ||||
| 		t: number; | ||||
| 		c: string; | ||||
| 	} | ||||
| 	export enum CodeError { | ||||
| 		PhoneNotBound = 11, | ||||
| 		GiftGivingPunishment, | ||||
| 		GettingGiftInfoError, | ||||
| 		StatusError, | ||||
| 		OTPRequestTimeTooShort, | ||||
| 		OTPSendingFailed, | ||||
| 	} | ||||
| 	/**請SERVER發送贈禮的簡訊OPT認證碼(未設定贈禮密碼) */ | ||||
| 	export class AuthCode extends NetRequest<AuthCodeResquest, AuthCodeResponse> { | ||||
| 		get Method(): string { | ||||
| 			return "txn.code"; | ||||
| 		} | ||||
| 		constructor(txn: number) { | ||||
| 			super(); | ||||
| 			this.Data = { | ||||
| 				id: txn, | ||||
| 			}; | ||||
| 		} | ||||
| 	} | ||||
| 	// ======================================================================================= | ||||
| 	export enum SetPassWordError { | ||||
| 		PasswordHasBeenSet = 11, | ||||
| 		PhoneNotBound, | ||||
| 		OTPError, | ||||
| 	} | ||||
| 	/**設定贈禮密碼(簡訊OTP驗證建立新密碼) */ | ||||
| 	export class SetPassWord extends NetRequest<{ pw: string; c: string; }, null> { | ||||
| 		get Method(): string { | ||||
| 			return "txn.pw"; | ||||
| 		} | ||||
| 		constructor(pw: string, c: string) { | ||||
| 			super(); | ||||
| 			this.Data = { | ||||
| 				pw: pw, | ||||
| 				c: c | ||||
| 			}; | ||||
| 		} | ||||
| 	} | ||||
| 	// ======================================================================================= | ||||
| 	enum ChangePassWordError { | ||||
| 		PasswordNotSet = 11, | ||||
| 		PhoneNotBound, | ||||
| 		WrongPasswordFormat, | ||||
| 		PasswordAuthenticationFailed, | ||||
| 	} | ||||
| 	/**變更贈禮密碼 */ | ||||
| 	export class ChangePassWord extends NetRequest<{ opw: string; pw: string; }, null> { | ||||
| 		get Method(): string { | ||||
| 			return "txn.pw_change"; | ||||
| 		} | ||||
| 		constructor(opw: string, pw: string) { | ||||
| 			super(); | ||||
| 			this.Data = { | ||||
| 				opw: opw, | ||||
| 				pw: pw | ||||
| 			}; | ||||
| 		} | ||||
| 	} | ||||
| 	// ======================================================================================= | ||||
| 	export enum GiftForgotError { | ||||
| 		PasswordHasNotBeenSetYet = 11, | ||||
| 		PhoneNotBound, | ||||
| 		OTPError, | ||||
| 	} | ||||
| 	/**忘記密碼(簡訊OTP驗證建立新密碼) */ | ||||
| 	export class GiftForgot extends NetRequest<{ pw: string; c: string; }, null> { | ||||
| 		get Method(): string { | ||||
| 			return "txn.pw_fg"; | ||||
| 		} | ||||
| 		constructor(pw: string, c: string) { | ||||
| 			super(); | ||||
| 			this.Data = { | ||||
| 				pw: pw, | ||||
| 				c: c | ||||
| 			}; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	// ======================================================================================= | ||||
| 	interface GetPassWordResponse { | ||||
| 		t: number; | ||||
| 		c: string; | ||||
| 	} | ||||
| 	export enum GetPassWordError { | ||||
| 		PasswordHasBeenSet = 11, | ||||
| 		PhoneNotBound, | ||||
| 		OTPRequestTimeTooShort, | ||||
| 		OTPSendingFailed, | ||||
| 	} | ||||
| 	/**取得贈禮密碼OTP */ | ||||
| 	export class GetPassWord extends NetRequest<null, GetPassWordResponse> { | ||||
| 		get Method(): string { | ||||
| 			return "txn.pw_code"; | ||||
| 		} | ||||
| 		constructor() { | ||||
| 			super(); | ||||
| 		} | ||||
| 	} | ||||
| 	// ======================================================================================= | ||||
| 	interface GetForgotPassWordResponse { | ||||
| 		t: number; | ||||
| 		c: string; | ||||
| 	} | ||||
| 	export enum GetForgotPassWordError { | ||||
| 		PasswordHasNotBeenSetYet = 11, | ||||
| 		PhoneNotBound, | ||||
| 		OTPRequestTimeTooShort, | ||||
| 		OTPSendingFailed, | ||||
| 	} | ||||
| 	/**取得贈禮忘記密碼OTP */ | ||||
| 	export class GetForgotPassWord extends NetRequest<null, GetForgotPassWordResponse> { | ||||
| 		get Method(): string { | ||||
| 			return "txn.pw_fg_code"; | ||||
| 		} | ||||
| 		constructor() { | ||||
| 			super(); | ||||
| 		} | ||||
| 	} | ||||
| 	// ======================================================================================= | ||||
| 	/**贈禮紀錄 */ | ||||
| 	export class Record extends NetRequest<null, TxnInfo[]> { | ||||
| 		get Method(): string { | ||||
| 			return "txn.record"; | ||||
| 		} | ||||
| 		constructor() { | ||||
| 			super(); | ||||
| 		} | ||||
| 	} | ||||
| 	// ======================================================================================= | ||||
| 	enum GetListError { | ||||
| 		NotExist = 11, | ||||
| 	} | ||||
| 	/**取得贈禮品項 */ | ||||
| 	export class GetTxnList extends NetRequest<{ t: number[] }, TxnInfo[]> { | ||||
| 		get Method(): string { | ||||
| 			return "txn.get"; | ||||
| 		} | ||||
| 		constructor(txn: number[]) { | ||||
| 			super(); | ||||
| 			this.Data = { | ||||
| 				t: txn, | ||||
| 			}; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	// ======================================================================================= | ||||
| } | ||||
| @@ -46,3 +46,4 @@ namespace cc { | ||||
| 		console.error(msg, ...subst); | ||||
| 	} | ||||
| } | ||||
| // export {}; | ||||
| @@ -1,47 +0,0 @@ | ||||
| import { CSSProperties } from "react"; | ||||
| import { sleep } from "."; | ||||
|  | ||||
| /** | ||||
|  * 動態創建iframe | ||||
|  * @param parent 容器節點 | ||||
|  * @param url 遊戲網址 | ||||
|  * @param style CSSProperties | ||||
|  */ | ||||
| export function createIframe(parent: string, url: string, style?: CSSProperties): HTMLIFrameElement { | ||||
| 	const iframe: HTMLIFrameElement = document.createElement("iframe"); | ||||
| 	iframe.src = url; | ||||
| 	iframe.frameBorder = "0"; | ||||
| 	iframe.scrolling = "0"; | ||||
| 	for (let i: number = 0, keys: string[] = Object.keys(style); i < keys.length; i++) { | ||||
| 		const key: string = keys[i]; | ||||
| 		iframe.style[key] = style[key]; | ||||
| 	} | ||||
| 	document.getElementById(parent).appendChild(iframe); | ||||
| 	return iframe; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * 銷毀 iframe | ||||
|  * @param parent 容器節點 | ||||
|  */ | ||||
| export async function destroyIframe(parent: string) { | ||||
| 	const iframeContent: HTMLElement = document.getElementById(parent); | ||||
| 	for (let i = 0; i < iframeContent.children.length; i++) { | ||||
| 		const iframeNode: HTMLIFrameElement = iframeContent.children[i] as HTMLIFrameElement; | ||||
| 		try { | ||||
| 			iframeNode.src = "about:blank"; | ||||
| 			await sleep(10); | ||||
| 			const iframeWindow = iframeNode.contentWindow; | ||||
| 			iframeWindow.document.open(); | ||||
| 			iframeWindow.document.write(""); | ||||
| 			iframeWindow.document.clear && iframeWindow.document.clear(); | ||||
| 			iframeWindow.document.close(); | ||||
| 		} catch (error) { | ||||
| 			console.warn(error); | ||||
| 		} | ||||
| 		iframeNode.remove(); | ||||
| 		iframeNode.parentNode && iframeContent.removeChild(iframeNode); | ||||
| 		// Cocos.CocosEventListener.RemoveAllCallbacks(); | ||||
| 		// await sleep(2000); | ||||
| 	} | ||||
| } | ||||
		Reference in New Issue
	
	Block a user