mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-07-01 13:32:45 +08:00
完善devtools
This commit is contained in:
parent
8f2d332cda
commit
ba8a713a57
@ -1,51 +0,0 @@
|
|||||||
const nodeFns = {
|
|
||||||
AbortController,
|
|
||||||
AbortSignal,
|
|
||||||
Array,
|
|
||||||
ArrayBuffer,
|
|
||||||
Boolean,
|
|
||||||
Buffer,
|
|
||||||
DataView,
|
|
||||||
Date,
|
|
||||||
Error,
|
|
||||||
EvalError,
|
|
||||||
Float32Array,
|
|
||||||
Float64Array,
|
|
||||||
Function,
|
|
||||||
Int16Array,
|
|
||||||
Int32Array,
|
|
||||||
Int8Array,
|
|
||||||
Intl,
|
|
||||||
JSON,
|
|
||||||
Math,
|
|
||||||
Number,
|
|
||||||
Object,
|
|
||||||
RangeError,
|
|
||||||
ReferenceError,
|
|
||||||
RegExp,
|
|
||||||
String,
|
|
||||||
SyntaxError,
|
|
||||||
TypeError,
|
|
||||||
URIError,
|
|
||||||
URL,
|
|
||||||
URLSearchParams,
|
|
||||||
Uint16Array,
|
|
||||||
Uint32Array,
|
|
||||||
Uint8Array,
|
|
||||||
Uint8ClampedArray,
|
|
||||||
atob,
|
|
||||||
btoa,
|
|
||||||
decodeURI,
|
|
||||||
decodeURIComponent,
|
|
||||||
encodeURI,
|
|
||||||
encodeURIComponent,
|
|
||||||
escape,
|
|
||||||
isFinite,
|
|
||||||
isNaN,
|
|
||||||
parseFloat,
|
|
||||||
parseInt,
|
|
||||||
require,
|
|
||||||
unescape,
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = nodeFns
|
|
@ -1,7 +1,13 @@
|
|||||||
const nodeFns = require("./nodeFns")
|
|
||||||
window._ = require("lodash")
|
window._ = require("lodash")
|
||||||
window.utools = require("./utoolsLite")()
|
window.utools = require("./utoolsLite")()
|
||||||
|
window.exit = () => {
|
||||||
Object.keys(nodeFns).forEach(key => {
|
process.exit()
|
||||||
window[key] = nodeFns[key]
|
}
|
||||||
})
|
// 绕过限制
|
||||||
|
setTimeout(() => {
|
||||||
|
Object.assign(window, {
|
||||||
|
process,
|
||||||
|
Buffer,
|
||||||
|
require
|
||||||
|
})
|
||||||
|
}, 100);
|
||||||
|
@ -7,7 +7,6 @@ const path = require("path")
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const http = require('http');
|
const http = require('http');
|
||||||
const url = require('url')
|
const url = require('url')
|
||||||
const nodeFns = require("./lib/nodeFns")
|
|
||||||
const kill = require('tree-kill')
|
const kill = require('tree-kill')
|
||||||
require('ses')
|
require('ses')
|
||||||
|
|
||||||
@ -63,6 +62,7 @@ const shortCodes = [
|
|||||||
const ctlKey = utools.isMacOs() ? 'command' : 'control'
|
const ctlKey = utools.isMacOs() ? 'command' : 'control'
|
||||||
|
|
||||||
const createBrowserWindow = utools.createBrowserWindow
|
const createBrowserWindow = utools.createBrowserWindow
|
||||||
|
let browserWindow
|
||||||
window.quickcommand = {
|
window.quickcommand = {
|
||||||
// 模拟复制操作
|
// 模拟复制操作
|
||||||
simulateCopy: function() {
|
simulateCopy: function() {
|
||||||
@ -179,23 +179,19 @@ window.quickcommand = {
|
|||||||
|
|
||||||
// 显示一个全功能的 devTools
|
// 显示一个全功能的 devTools
|
||||||
showDevTools: function() {
|
showDevTools: function() {
|
||||||
const browserWindow = createBrowserWindow('lib/sandbox.html', {
|
if (!browserWindow || browserWindow.webContents.isDestroyed()) {
|
||||||
show: false,
|
browserWindow = createBrowserWindow('lib/sandbox.html', {
|
||||||
title: '快捷命令',
|
show: false,
|
||||||
webPreferences: {
|
title: '快捷命令',
|
||||||
preload: 'lib/sandbox.js',
|
webPreferences: {
|
||||||
},
|
preload: 'lib/sandbox.js',
|
||||||
}, () => {
|
},
|
||||||
browserWindow.webContents.openDevTools({
|
}, () => {})
|
||||||
mode: 'detach'
|
}
|
||||||
})
|
browserWindow.webContents.openDevTools({
|
||||||
let timer = setInterval(() => {
|
mode: 'detach'
|
||||||
if (!browserWindow.webContents.isDevToolsOpened()) {
|
|
||||||
clearInterval(timer)
|
|
||||||
browserWindow.destroy()
|
|
||||||
}
|
|
||||||
}, 1000)
|
|
||||||
})
|
})
|
||||||
|
// browserWindow.webContents.executeJavaScript(``)
|
||||||
return browserWindow
|
return browserWindow
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -482,6 +478,10 @@ let getSandboxFuns = () => {
|
|||||||
axios,
|
axios,
|
||||||
Audio,
|
Audio,
|
||||||
_,
|
_,
|
||||||
|
AbortController,
|
||||||
|
AbortSignal,
|
||||||
|
Buffer,
|
||||||
|
require,
|
||||||
// 兼容老版本
|
// 兼容老版本
|
||||||
fs,
|
fs,
|
||||||
path,
|
path,
|
||||||
@ -491,7 +491,7 @@ let getSandboxFuns = () => {
|
|||||||
shortCodes.forEach(f => {
|
shortCodes.forEach(f => {
|
||||||
sandbox[f.name] = f
|
sandbox[f.name] = f
|
||||||
})
|
})
|
||||||
Object.assign(sandbox, nodeFns)
|
// Object.assign(sandbox, nodeFns)
|
||||||
return sandbox
|
return sandbox
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user