mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-19 02:19:31 +08:00
[v2] Remove common.js
This commit is contained in:
parent
d2e4a0b0d2
commit
4738a0e0a8
@ -13,56 +13,53 @@ The lightweight framework for web-like apps
|
||||
* Initialises platform specific code
|
||||
*/
|
||||
|
||||
// import * as common from './common';
|
||||
const common = require('./common');
|
||||
|
||||
export const System = {
|
||||
...common,
|
||||
Platform: () => "darwin",
|
||||
}
|
||||
AppType: 'desktop',
|
||||
Platform: () => 'darwin',
|
||||
};
|
||||
|
||||
export function SendMessage(message) {
|
||||
window.webkit.messageHandlers.external.postMessage(message);
|
||||
window.webkit.messageHandlers.external.postMessage(message);
|
||||
}
|
||||
|
||||
export function Init() {
|
||||
|
||||
// Setup drag handler
|
||||
// Based on code from: https://github.com/patr0nus/DeskGap
|
||||
window.addEventListener('mousedown', function (e) {
|
||||
let currentElement = e.target;
|
||||
while (currentElement != null) {
|
||||
if (currentElement.hasAttribute('data-wails-no-drag')) {
|
||||
break;
|
||||
} else if (currentElement.hasAttribute('data-wails-drag')) {
|
||||
window.webkit.messageHandlers.windowDrag.postMessage(null);
|
||||
break;
|
||||
}
|
||||
currentElement = currentElement.parentElement;
|
||||
}
|
||||
});
|
||||
// Setup drag handler
|
||||
// Based on code from: https://github.com/patr0nus/DeskGap
|
||||
window.addEventListener('mousedown', function (e) {
|
||||
let currentElement = e.target;
|
||||
while (currentElement != null) {
|
||||
if (currentElement.hasAttribute('data-wails-no-drag')) {
|
||||
break;
|
||||
} else if (currentElement.hasAttribute('data-wails-drag')) {
|
||||
window.webkit.messageHandlers.windowDrag.postMessage(null);
|
||||
break;
|
||||
}
|
||||
currentElement = currentElement.parentElement;
|
||||
}
|
||||
});
|
||||
|
||||
// Setup context menu hook
|
||||
window.addEventListener('contextmenu', function (e) {
|
||||
let currentElement = e.target;
|
||||
let contextMenuId;
|
||||
while (currentElement != null) {
|
||||
contextMenuId = currentElement.dataset['wails-context-menu-id'];
|
||||
if (contextMenuId != null) {
|
||||
break;
|
||||
}
|
||||
currentElement = currentElement.parentElement;
|
||||
}
|
||||
if (contextMenuId != null || window.disableWailsDefaultContextMenu) {
|
||||
e.preventDefault();
|
||||
}
|
||||
if( contextMenuId != null ) {
|
||||
let contextData = currentElement.dataset['wails-context-menu-data'];
|
||||
let message = {
|
||||
id: contextMenuId,
|
||||
data: contextData || "",
|
||||
};
|
||||
window.webkit.messageHandlers.contextMenu.postMessage(JSON.stringify(message));
|
||||
}
|
||||
});
|
||||
// Setup context menu hook
|
||||
window.addEventListener('contextmenu', function (e) {
|
||||
let currentElement = e.target;
|
||||
let contextMenuId;
|
||||
while (currentElement != null) {
|
||||
contextMenuId = currentElement.dataset['wails-context-menu-id'];
|
||||
if (contextMenuId != null) {
|
||||
break;
|
||||
}
|
||||
currentElement = currentElement.parentElement;
|
||||
}
|
||||
if (contextMenuId != null || window.disableWailsDefaultContextMenu) {
|
||||
e.preventDefault();
|
||||
}
|
||||
if( contextMenuId != null ) {
|
||||
let contextData = currentElement.dataset['wails-context-menu-data'];
|
||||
let message = {
|
||||
id: contextMenuId,
|
||||
data: contextData || '',
|
||||
};
|
||||
window.webkit.messageHandlers.contextMenu.postMessage(JSON.stringify(message));
|
||||
}
|
||||
});
|
||||
}
|
@ -14,28 +14,28 @@ The lightweight framework for web-like apps
|
||||
*/
|
||||
|
||||
export const System = {
|
||||
...common,
|
||||
Platform: () => "linux",
|
||||
}
|
||||
AppType: 'desktop',
|
||||
Platform: () => 'linux',
|
||||
};
|
||||
|
||||
export function SendMessage(message) {
|
||||
window.webkit.messageHandlers.external.postMessage(message);
|
||||
window.webkit.messageHandlers.external.postMessage(message);
|
||||
}
|
||||
|
||||
export function Init() {
|
||||
|
||||
// Setup drag handler
|
||||
// Based on code from: https://github.com/patr0nus/DeskGap
|
||||
window.addEventListener('mousedown', function (e) {
|
||||
let currentElement = e.target;
|
||||
while (currentElement != null) {
|
||||
if (currentElement.hasAttribute('data-wails-no-drag')) {
|
||||
break;
|
||||
} else if (currentElement.hasAttribute('data-wails-drag')) {
|
||||
window.webkit.messageHandlers.windowDrag.postMessage(null);
|
||||
break;
|
||||
}
|
||||
currentElement = currentElement.parentElement;
|
||||
}
|
||||
});
|
||||
// Setup drag handler
|
||||
// Based on code from: https://github.com/patr0nus/DeskGap
|
||||
window.addEventListener('mousedown', function (e) {
|
||||
let currentElement = e.target;
|
||||
while (currentElement != null) {
|
||||
if (currentElement.hasAttribute('data-wails-no-drag')) {
|
||||
break;
|
||||
} else if (currentElement.hasAttribute('data-wails-drag')) {
|
||||
window.webkit.messageHandlers.windowDrag.postMessage(null);
|
||||
break;
|
||||
}
|
||||
currentElement = currentElement.parentElement;
|
||||
}
|
||||
});
|
||||
}
|
@ -13,11 +13,8 @@ The lightweight framework for web-like apps
|
||||
* Initialises platform specific code
|
||||
*/
|
||||
|
||||
// import * as common from './common';
|
||||
const common = require('./common');
|
||||
|
||||
export const System = {
|
||||
...common,
|
||||
AppType: 'desktop',
|
||||
Platform: () => 'windows',
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user