本文整理汇总了TypeScript中@providers/app.CoreAppProvider.isDesktop方法的典型用法代码示例。如果您正苦于以下问题:TypeScript CoreAppProvider.isDesktop方法的具体用法?TypeScript CoreAppProvider.isDesktop怎么用?TypeScript CoreAppProvider.isDesktop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@providers/app.CoreAppProvider
的用法示例。
在下文中一共展示了CoreAppProvider.isDesktop方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(platform: Platform, device: Device, appProvider: CoreAppProvider, fileProvider: CoreFileProvider,
initDelegate: CoreInitDelegate, langProvider: CoreLangProvider, sitesProvider: CoreSitesProvider,
localNotificationsProvider: CoreLocalNotificationsProvider, pushNotificationsProvider: AddonPushNotificationsProvider) {
const currentSite = sitesProvider.getCurrentSite();
this.appName = appProvider.isDesktop() ? CoreConfigConstants.desktopappname : CoreConfigConstants.appname;
this.versionName = CoreConfigConstants.versionname;
this.versionCode = CoreConfigConstants.versioncode;
this.compilationTime = CoreConfigConstants.compilationtime;
this.lastCommit = CoreConfigConstants.lastcommit;
// Calculate the privacy policy to use.
this.privacyPolicy = (currentSite && (currentSite.getStoredConfig('tool_mobile_apppolicy') ||
currentSite.getStoredConfig('sitepolicy'))) || CoreConfigConstants.privacypolicy;
this.navigator = window.navigator;
if (window.location && window.location.href) {
const url = window.location.href;
this.locationHref = url.substr(0, url.indexOf('#'));
}
this.appReady = initDelegate.isReady() ? 'core.yes' : 'core.no';
this.deviceType = platform.is('tablet') ? 'core.tablet' : 'core.phone';
if (platform.is('android')) {
this.deviceOs = 'core.android';
} else if (platform.is('ios')) {
this.deviceOs = 'core.ios';
} else if (platform.is('windows')) {
this.deviceOs = 'core.windowsphone';
} else {
const matches = navigator.userAgent.match(/\(([^\)]*)\)/);
if (matches && matches.length > 1) {
this.deviceOs = matches[1];
} else {
this.deviceOs = 'core.unknown';
}
}
langProvider.getCurrentLanguage().then((lang) => {
this.currentLanguage = lang;
});
this.networkStatus = appProvider.isOnline() ? 'core.online' : 'core.offline';
this.wifiConnection = appProvider.isWifi() ? 'core.yes' : 'core.no';
this.deviceWebWorkers = !!window['Worker'] && !!window['URL'] ? 'core.yes' : 'core.no';
this.device = device;
if (fileProvider.isAvailable()) {
fileProvider.getBasePath().then((basepath) => {
this.fileSystemRoot = basepath;
this.fsClickable = fileProvider.usesHTMLAPI();
});
}
this.localNotifAvailable = localNotificationsProvider.isAvailable() ? 'core.yes' : 'core.no';
this.pushId = pushNotificationsProvider.getPushId();
}
示例2: getApplicationIconBadgeNumber
/**
* Get the current badge count visible when the app is not running
* successHandler gets called with an integer which is the current badge count
*/
getApplicationIconBadgeNumber(): Promise<number> {
if (!this.appProvider.isDesktop()) {
return Promise.reject('getApplicationIconBadgeNumber is not supported in browser');
}
try {
const app = require('electron').remote.app;
return Promise.resolve(app.getBadgeCount());
} catch (ex) {
return Promise.reject(ex);
}
}
示例3: open
/**
* Open an file.
*
* @param {string} filePath File path.
* @param {string} fileMIMEType File MIME type.
* @returns {Promise<any>} Promise resolved when done.
*/
open(filePath: string, fileMIMEType: string): Promise<any> {
if (this.appProvider.isDesktop()) {
// It's a desktop app, send an event so the file is opened.
// Opening the file from here (renderer process) doesn't focus the opened app, that's why an event is needed.
// Use sendSync so we can receive the result.
if (!require('electron').ipcRenderer.sendSync('openItem', filePath)) {
return Promise.reject('Error opening file');
}
} else {
window.open(filePath, '_blank');
}
return Promise.resolve();
}
示例4: constructor
constructor(appProvider: CoreAppProvider) {
super();
this.isDesktop = appProvider.isDesktop();
if (this.isDesktop) {
this.clipboard = require('electron').clipboard;
} else {
// In browser the text must be selected in order to copy it. Create a hidden textarea to put the text in it.
this.copyTextarea = document.createElement('textarea');
this.copyTextarea.className = 'core-browser-copy-area';
this.copyTextarea.setAttribute('aria-hidden', 'true');
document.body.appendChild(this.copyTextarea);
}
}
示例5: create
/**
* Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser.
*
* @param {string} url The URL to load.
* @param {string} [target] The target in which to load the URL, an optional parameter that defaults to _self.
* @param {string} [options] Options for the InAppBrowser.
* @return {any} The new instance.
*/
create(url: string, target?: string, options: string = 'location=yes'): any {
if (options && typeof options !== 'string') {
// Convert to string.
options = Object.keys(options).map((key) => {
return key + '=' + options[key];
}).join(',');
}
if (!this.appProvider.isDesktop()) {
return super.create(url, target, options);
}
return new InAppBrowserObjectMock(this.appProvider, this.fileProvider, this.urlUtils, url, target, options);
}
示例6: setApplicationIconBadgeNumber
/**
* Set the badge count visible when the app is not running
*
* The count is an integer indicating what number should show up in the badge.
* Passing 0 will clear the badge.
* Each notification event contains a data.count value which can be used to set the badge to correct number.
*
* @param count
*/
setApplicationIconBadgeNumber(count?: number): Promise<any> {
if (!this.appProvider.isDesktop()) {
return Promise.reject('setApplicationIconBadgeNumber is not supported in browser');
}
try {
const app = require('electron').remote.app;
if (app.setBadgeCount(count)) {
return Promise.resolve();
} else {
return Promise.reject(null);
}
} catch (ex) {
return Promise.reject(ex);
}
}
示例7: constructor
constructor(mainMenuDelegate: CoreMainMenuDelegate, mainMenuHandler: AddonNotificationsMainMenuHandler,
settingsDelegate: CoreSettingsDelegate, settingsHandler: AddonNotificationsSettingsHandler,
cronDelegate: CoreCronDelegate, cronHandler: AddonNotificationsCronHandler, zone: NgZone,
appProvider: CoreAppProvider, utils: CoreUtilsProvider, sitesProvider: CoreSitesProvider,
notificationsProvider: AddonNotificationsProvider, localNotifications: CoreLocalNotificationsProvider,
linkHelper: CoreContentLinksHelperProvider, pushNotificationsDelegate: AddonPushNotificationsDelegate) {
mainMenuDelegate.registerHandler(mainMenuHandler);
settingsDelegate.registerHandler(settingsHandler);
cronDelegate.register(cronHandler);
const notificationClicked = (notification: any): void => {
sitesProvider.isFeatureDisabled('CoreMainMenuDelegate_AddonNotifications', notification.site).then((disabled) => {
if (disabled) {
// Notifications are disabled, stop.
return;
}
notificationsProvider.invalidateNotificationsList().finally(() => {
linkHelper.goInSite(undefined, 'AddonNotificationsListPage', undefined, notification.site);
});
});
};
if (appProvider.isDesktop()) {
// Listen for clicks in simulated push notifications.
localNotifications.registerClick(AddonNotificationsProvider.PUSH_SIMULATION_COMPONENT, notificationClicked);
}
// Register push notification clicks.
pushNotificationsDelegate.on('click').subscribe((notification) => {
if (utils.isTrueOrOne(notification.notif)) {
// Execute the callback in the Angular zone, so change detection doesn't stop working.
zone.run(() => {
notificationClicked(notification);
});
return true;
}
});
}
示例8: constructor
constructor(mainMenuDelegate: CoreMainMenuDelegate, mainMenuHandler: AddonNotificationsMainMenuHandler,
settingsDelegate: CoreSettingsDelegate, settingsHandler: AddonNotificationsSettingsHandler,
cronDelegate: CoreCronDelegate, cronHandler: AddonNotificationsCronHandler, zone: NgZone,
appProvider: CoreAppProvider, utils: CoreUtilsProvider, sitesProvider: CoreSitesProvider,
notificationsProvider: AddonNotificationsProvider, localNotifications: CoreLocalNotificationsProvider,
linkHelper: CoreContentLinksHelperProvider, pushNotificationsDelegate: AddonPushNotificationsDelegate,
urlUtils: CoreUrlUtilsProvider, forumProvider: AddonModForumProvider) {
mainMenuDelegate.registerHandler(mainMenuHandler);
settingsDelegate.registerHandler(settingsHandler);
cronDelegate.register(cronHandler);
const notificationClicked = (notification: any): void => {
// Temporary fix to make forum notifications work. This will be improved in next release.
if (notification.moodlecomponent == 'mod_forum' && notification.name == 'posts') {
sitesProvider.isFeatureDisabled('CoreCourseModuleDelegate_AddonModForum', notification.site).then((disabled) => {
if (disabled) {
// Forum is disabled, stop.
return;
}
const contextUrlParams = urlUtils.extractUrlParams(notification.contexturl),
pageParams: any = {
courseId: Number(notification.courseid),
discussionId: Number(contextUrlParams.d),
};
if (contextUrlParams.urlHash) {
pageParams.postId = Number(contextUrlParams.urlHash.replace('p', ''));
}
forumProvider.invalidateDiscussionPosts(pageParams.discussionId).catch(() => {
// Ignore errors.
}).then(() => {
linkHelper.goInSite(undefined, 'AddonModForumDiscussionPage', pageParams, notification.site);
});
});
} else {
goToNotifications(notification);
}
};
const goToNotifications = (notification: any): void => {
sitesProvider.isFeatureDisabled('CoreMainMenuDelegate_AddonNotifications', notification.site).then((disabled) => {
if (disabled) {
// Notifications are disabled, stop.
return;
}
notificationsProvider.invalidateNotificationsList().finally(() => {
linkHelper.goInSite(undefined, 'AddonNotificationsListPage', undefined, notification.site);
});
});
};
if (appProvider.isDesktop()) {
// Listen for clicks in simulated push notifications.
localNotifications.registerClick(AddonNotificationsProvider.PUSH_SIMULATION_COMPONENT, notificationClicked);
}
// Register push notification clicks.
pushNotificationsDelegate.on('click').subscribe((notification) => {
if (utils.isTrueOrOne(notification.notif)) {
// Execute the callback in the Angular zone, so change detection doesn't stop working.
zone.run(() => {
notificationClicked(notification);
});
return true;
}
});
}
示例9: constructor
constructor(mainMenuDelegate: CoreMainMenuDelegate, mainmenuHandler: AddonMessagesMainMenuHandler,
contentLinksDelegate: CoreContentLinksDelegate, indexLinkHandler: AddonMessagesIndexLinkHandler,
discussionLinkHandler: AddonMessagesDiscussionLinkHandler, sendMessageHandler: AddonMessagesSendMessageUserHandler,
userDelegate: CoreUserDelegate, cronDelegate: CoreCronDelegate, syncHandler: AddonMessagesSyncCronHandler,
network: Network, zone: NgZone, messagesSync: AddonMessagesSyncProvider, appProvider: CoreAppProvider,
localNotifications: CoreLocalNotificationsProvider, messagesProvider: AddonMessagesProvider,
sitesProvider: CoreSitesProvider, linkHelper: CoreContentLinksHelperProvider, updateManager: CoreUpdateManagerProvider,
settingsHandler: AddonMessagesSettingsHandler, settingsDelegate: CoreSettingsDelegate,
pushNotificationsDelegate: AddonPushNotificationsDelegate, utils: CoreUtilsProvider,
addContactHandler: AddonMessagesAddContactUserHandler, blockContactHandler: AddonMessagesBlockContactUserHandler) {
// Register handlers.
mainMenuDelegate.registerHandler(mainmenuHandler);
contentLinksDelegate.registerHandler(indexLinkHandler);
contentLinksDelegate.registerHandler(discussionLinkHandler);
userDelegate.registerHandler(sendMessageHandler);
userDelegate.registerHandler(addContactHandler);
userDelegate.registerHandler(blockContactHandler);
cronDelegate.register(syncHandler);
cronDelegate.register(mainmenuHandler);
settingsDelegate.registerHandler(settingsHandler);
// Sync some discussions when device goes online.
network.onConnect().subscribe(() => {
// Execute the callback in the Angular zone, so change detection doesn't stop working.
zone.run(() => {
messagesSync.syncAllDiscussions(undefined, true);
});
});
const notificationClicked = (notification: any): void => {
messagesProvider.isMessagingEnabledForSite(notification.site).then(() => {
sitesProvider.isFeatureDisabled('CoreMainMenuDelegate_AddonMessages', notification.site).then((disabled) => {
if (disabled) {
// Messages are disabled, stop.
return;
}
messagesProvider.invalidateDiscussionsCache(notification.site).finally(() => {
linkHelper.goInSite(undefined, 'AddonMessagesIndexPage', undefined, notification.site);
});
});
});
};
if (appProvider.isDesktop()) {
// Listen for clicks in simulated push notifications.
localNotifications.registerClick(AddonMessagesProvider.PUSH_SIMULATION_COMPONENT, notificationClicked);
}
// Register push notification clicks.
pushNotificationsDelegate.on('click').subscribe((notification) => {
if (utils.isFalseOrZero(notification.notif)) {
notificationClicked(notification);
return true;
}
});
// Allow migrating the table from the old app to the new schema.
updateManager.registerSiteTableMigration({
name: 'mma_messages_offline_messages',
newName: AddonMessagesOfflineProvider.MESSAGES_TABLE,
fields: [
{
name: 'textformat',
delete: true
}
]
});
// Migrate the component name.
updateManager.registerLocalNotifComponentMigration('mmaMessagesPushSimulation',
AddonMessagesProvider.PUSH_SIMULATION_COMPONENT);
}