mirror of
https://github.com/responsively-org/responsively-app
synced 2024-11-10 14:54:12 +00:00
Merge pull request #122 from manojVivek/reload-css
shortcut to reload css only
This commit is contained in:
commit
0072e86322
5 changed files with 43 additions and 2 deletions
|
@ -10,7 +10,8 @@ import {
|
|||
SCREENSHOT_ALL_DEVICES,
|
||||
FLIP_ORIENTATION_ALL_DEVICES,
|
||||
ENABLE_INSPECTOR_ALL_DEVICES,
|
||||
DELETE_STORAGE,
|
||||
RELOAD_CSS,
|
||||
DELETE_STORAGE
|
||||
} from '../constants/pubsubEvents';
|
||||
|
||||
export const NEW_ADDRESS = 'NEW_ADDRESS';
|
||||
|
@ -387,3 +388,9 @@ export function deleteStorage() {
|
|||
]);
|
||||
};
|
||||
}
|
||||
|
||||
export function reloadCSS() {
|
||||
return (dispatch: Dispatch, getState: RootStateType) => {
|
||||
pubsub.publish(RELOAD_CSS);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ class NavigationControls extends Component {
|
|||
|
||||
componentDidMount() {
|
||||
ipcRenderer.on('reload-url', this.props.triggerNavigationReload);
|
||||
ipcRenderer.on('reload-css', this.props.reloadCSS);
|
||||
}
|
||||
|
||||
render() {
|
||||
|
|
|
@ -17,7 +17,8 @@ import {
|
|||
FLIP_ORIENTATION_ALL_DEVICES,
|
||||
ENABLE_INSPECTOR_ALL_DEVICES,
|
||||
DISABLE_INSPECTOR_ALL_DEVICES,
|
||||
DELETE_STORAGE,
|
||||
RELOAD_CSS,
|
||||
DELETE_STORAGE
|
||||
} from '../../constants/pubsubEvents';
|
||||
import {CAPABILITIES} from '../../constants/devices';
|
||||
|
||||
|
@ -79,6 +80,9 @@ class WebView extends Component {
|
|||
this.subscriptions.push(
|
||||
pubsub.subscribe(NAVIGATION_RELOAD, this.processNavigationReloadEvent)
|
||||
);
|
||||
this.subscriptions.push(
|
||||
pubsub.subscribe(RELOAD_CSS, this.processReloadCSSEvent)
|
||||
);
|
||||
this.subscriptions.push(
|
||||
pubsub.subscribe(DELETE_STORAGE, this.processDeleteStorageEvent)
|
||||
);
|
||||
|
@ -219,6 +223,20 @@ class WebView extends Component {
|
|||
this.webviewRef.current.reload();
|
||||
};
|
||||
|
||||
processReloadCSSEvent = () => {
|
||||
|
||||
this.webviewRef.current.executeJavaScript(`
|
||||
var elements = document.querySelectorAll('link[rel=stylesheet][href]');
|
||||
elements.forEach(element=>{
|
||||
var href = element.href;
|
||||
if(href){
|
||||
var href = href.replace(/[?&]invalidateCacheParam=([^&$]*)/,'');
|
||||
element.href = href + (href.indexOf('?')>=0?'&':'?') + 'invalidateCacheParam=' + (new Date().valueOf());
|
||||
}
|
||||
})
|
||||
`);
|
||||
}
|
||||
|
||||
processDeleteStorageEvent = ({storages}) => {
|
||||
this.getWebContents().session.clearStorageData({storages});
|
||||
};
|
||||
|
|
|
@ -3,6 +3,7 @@ export const SCROLL_UP = 'SCROLL_UP';
|
|||
export const NAVIGATION_BACK = 'NAVIGATION_BACK';
|
||||
export const NAVIGATION_FORWARD = 'NAVIGATION_FORWARD';
|
||||
export const NAVIGATION_RELOAD = 'NAVIGATION_RELOAD';
|
||||
export const RELOAD_CSS = 'RELOAD_CSS';
|
||||
export const DELETE_STORAGE = 'DELETE_STORAGE';
|
||||
export const SCREENSHOT_ALL_DEVICES = 'SCREENSHOT_ALL_DEVICES';
|
||||
export const FLIP_ORIENTATION_ALL_DEVICES = 'FLIP_ORIENTATION_ALL_DEVICES';
|
||||
|
|
|
@ -257,6 +257,13 @@ export default class MenuBuilder {
|
|||
this.mainWindow.webContents.reload();
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '&ReloadCSS',
|
||||
accelerator: 'Alt+R',
|
||||
click: () => {
|
||||
this.mainWindow.webContents.send('reload-css');
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Reload Ignoring Cache',
|
||||
accelerator: 'CommandOrControl+Shift+R',
|
||||
|
@ -291,6 +298,13 @@ export default class MenuBuilder {
|
|||
this.mainWindow.webContents.send('reload-url');
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '&ReloadCSS',
|
||||
accelerator: 'Alt+R',
|
||||
click: () => {
|
||||
this.mainWindow.webContents.send('reload-css');
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Reload Ignoring Cache',
|
||||
accelerator: 'CommandOrControl+Shift+R',
|
||||
|
|
Loading…
Reference in a new issue