本文整理匯總了TypeScript中@providers/sites.CoreSitesProvider.getSite方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript CoreSitesProvider.getSite方法的具體用法?TypeScript CoreSitesProvider.getSite怎麽用?TypeScript CoreSitesProvider.getSite使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@providers/sites.CoreSitesProvider
的用法示例。
在下文中一共展示了CoreSitesProvider.getSite方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: ionViewDidLoad
/**
* View loaded.
*/
ionViewDidLoad(): void {
if (this.siteConfig) {
this.identityProviders = this.loginHelper.getValidIdentityProviders(this.siteConfig);
}
this.sitesProvider.getSite(this.siteId).then((site) => {
this.site = {
id: site.id,
fullname: site.infos.fullname,
avatar: site.infos.userpictureurl
};
this.username = site.infos.username;
this.siteUrl = site.infos.siteurl;
this.siteName = site.infos.sitename;
// Check logoURL if user avatar is not set.
if (this.site.avatar.startsWith(site.infos.siteurl + '/theme/image.php')) {
this.site.avatar = false;
return site.getPublicConfig().then((config) => {
this.logoUrl = config.logourl || config.compactlogourl;
}).catch(() => {
// Ignore errors.
});
}
}).catch(() => {
// Shouldn't happen. Just leave the view.
this.cancel();
});
}
示例2: getEntry
/**
* Get an online or offline entry.
*
* @param {any} data Database.
* @param {number} entryId Entry ID.
* @param {any} [offlineActions] Offline data with the actions done. Required for offline entries.
* @param {string} [siteId] Site ID. If not defined, current site.
* @return {Promise<any>} Promise resolved with the entry.
*/
getEntry(data: any, entryId: number, offlineActions?: any, siteId?: string): Promise<any> {
if (entryId > 0) {
// It's an online entry, get it from WS.
return this.dataProvider.getEntry(data.id, entryId, siteId);
}
// It's an offline entry, search it in the offline actions.
return this.sitesProvider.getSite(siteId).then((site) => {
const offlineEntry = offlineActions.find((offlineAction) => offlineAction.action == 'add');
if (offlineEntry) {
const siteInfo = site.getInfo();
return {entry: {
id: offlineEntry.entryid,
canmanageentry: true,
approved: !data.approval || data.manageapproved,
dataid: offlineEntry.dataid,
groupid: offlineEntry.groupid,
timecreated: -offlineEntry.entryid,
timemodified: -offlineEntry.entryid,
userid: siteInfo.userid,
fullname: siteInfo.fullname,
contents: {}
}
};
}
});
}