@choerodon/master
Version:
A package of Master for Choerodon platform.
20 lines (18 loc) • 541 B
JavaScript
import { useCallback } from 'react';
import { useMount } from 'ahooks';
/**
* 为组件注入Notification授权的hook
*/
function useC7NNotification() {
var getNotificationPermission = useCallback(function () {
if (!('Notification' in window)) {
console.log('This browser does not support desktop notification');
} else if (Notification.permission !== 'denied') {
Notification.requestPermission();
}
}, []);
useMount(function () {
getNotificationPermission();
});
}
export default useC7NNotification;