You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.5 KiB
51 lines
1.5 KiB
import PlatformManagerProxy from "./PlatformManagerProxy";
|
|
import { ShareInfo } from "./T/ShareInfo";
|
|
/**
|
|
* 分享管理器
|
|
*/
|
|
export default class ShareManagerAKhgfawgsda {
|
|
|
|
private static _instance;
|
|
public static get instance(): ShareManagerAKhgfawgsda {
|
|
if (this._instance == null) {
|
|
this._instance = new ShareManagerAKhgfawgsda();
|
|
}
|
|
return this._instance;
|
|
}
|
|
|
|
private _shareInfoList: ShareInfo[];
|
|
|
|
constructor() {
|
|
this._shareInfoList = [];
|
|
}
|
|
|
|
public AddShareInfo(shareInfo: ShareInfo) {
|
|
if(!shareInfo.Idx){
|
|
shareInfo.Idx = this._shareInfoList.length;
|
|
}
|
|
for (let getInfo of this._shareInfoList) {
|
|
if (getInfo.Idx == shareInfo.Idx) return this;
|
|
}
|
|
this._shareInfoList.push(shareInfo);
|
|
return this;
|
|
}
|
|
|
|
public GetShareInfo(id: number = null): ShareInfo {
|
|
if (this._shareInfoList.length == 0) {
|
|
let fakeShareInfo = new ShareInfo();
|
|
return fakeShareInfo;
|
|
}
|
|
if (id != null) {
|
|
for (let shareInfo of this._shareInfoList) {
|
|
if (shareInfo.Idx == id) return shareInfo;
|
|
}
|
|
}
|
|
let randomShare = this._shareInfoList[Math.floor(this._shareInfoList.length * Math.random())];
|
|
return randomShare;
|
|
}
|
|
|
|
public ShareAppMessage(shareInfo: ShareInfo) {
|
|
PlatformManagerProxy.instance.PlatformInstance.ShareAppMessage(shareInfo, (()=>{ console.log("分享成功");}).bind(this), null);
|
|
}
|
|
|
|
}
|