mirror of
https://github.com/rubickCenter/rubick
synced 2025-06-20 11:12:44 +08:00
feat: linux version
This commit is contained in:
parent
64541ad651
commit
d38dcab9cc
@ -3,4 +3,4 @@ module.exports = () => ({
|
|||||||
separator: require("./separate")(),
|
separator: require("./separate")(),
|
||||||
superPanel: require("./superPanel")(),
|
superPanel: require("./superPanel")(),
|
||||||
main: require("./main")(),
|
main: require("./main")(),
|
||||||
});
|
})
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
const { BrowserWindow, protocol } = require("electron");
|
const { BrowserWindow, protocol } = require("electron")
|
||||||
module.exports = () => {
|
module.exports = () => {
|
||||||
let win;
|
let win
|
||||||
|
|
||||||
let init = (opts) => {
|
let init = (opts) => {
|
||||||
createWindow(opts);
|
createWindow(opts)
|
||||||
};
|
}
|
||||||
|
|
||||||
let createWindow = (opts) => {
|
let createWindow = (opts) => {
|
||||||
const winURL = process.env.NODE_ENV === 'development'
|
const winURL = process.env.NODE_ENV === 'development'
|
||||||
@ -23,6 +23,7 @@ module.exports = () => {
|
|||||||
webSecurity: false,
|
webSecurity: false,
|
||||||
enableRemoteModule: true,
|
enableRemoteModule: true,
|
||||||
backgroundThrottling: false,
|
backgroundThrottling: false,
|
||||||
|
contextIsolation: false,
|
||||||
webviewTag: true,
|
webviewTag: true,
|
||||||
nodeIntegration: true // 在网页中集成Node
|
nodeIntegration: true // 在网页中集成Node
|
||||||
}
|
}
|
||||||
@ -31,24 +32,24 @@ module.exports = () => {
|
|||||||
win.loadURL(winURL)
|
win.loadURL(winURL)
|
||||||
|
|
||||||
protocol.interceptFileProtocol('image', (req, callback) => {
|
protocol.interceptFileProtocol('image', (req, callback) => {
|
||||||
const url = req.url.substr(8);
|
const url = req.url.substr(8)
|
||||||
callback(decodeURI(url));
|
callback(decodeURI(url))
|
||||||
}, (error) => {
|
}, (error) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error('Failed to register protocol');
|
console.error('Failed to register protocol')
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
win.once('ready-to-show', () => win.show());
|
win.once('ready-to-show', () => win.show())
|
||||||
win.on("closed", () => {
|
win.on("closed", () => {
|
||||||
win = undefined;
|
win = undefined
|
||||||
});
|
})
|
||||||
};
|
}
|
||||||
|
|
||||||
let getWindow = () => win;
|
let getWindow = () => win
|
||||||
|
|
||||||
return {
|
return {
|
||||||
init: init,
|
init: init,
|
||||||
getWindow: getWindow,
|
getWindow: getWindow,
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
const { BrowserWindow, nativeImage } = require("electron");
|
const { BrowserWindow, nativeImage } = require("electron")
|
||||||
|
|
||||||
module.exports = () => {
|
module.exports = () => {
|
||||||
let win;
|
let win
|
||||||
|
|
||||||
let init = (x, y) => {
|
let init = (x, y) => {
|
||||||
if (win === null || win === undefined) {
|
if (win === null || win === undefined) {
|
||||||
createWindow();
|
createWindow()
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
let createWindow = () => {
|
let createWindow = () => {
|
||||||
win = new BrowserWindow({
|
win = new BrowserWindow({
|
||||||
@ -22,20 +22,21 @@ module.exports = () => {
|
|||||||
hasShadow: false,
|
hasShadow: false,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: true,
|
nodeIntegration: true,
|
||||||
|
contextIsolation: false,
|
||||||
devTools: false,
|
devTools: false,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
|
||||||
win.loadURL(`file://${__static}/plugins/picker/index.html`);
|
win.loadURL(`file://${__static}/plugins/picker/index.html`)
|
||||||
win.on("closed", () => {
|
win.on("closed", () => {
|
||||||
win = undefined;
|
win = undefined
|
||||||
});
|
})
|
||||||
};
|
}
|
||||||
|
|
||||||
let getWindow = () => win;
|
let getWindow = () => win
|
||||||
|
|
||||||
return {
|
return {
|
||||||
init: init,
|
init: init,
|
||||||
getWindow: getWindow,
|
getWindow: getWindow,
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
const { BrowserWindow } = require("electron");
|
const { BrowserWindow } = require("electron")
|
||||||
|
|
||||||
module.exports = () => {
|
module.exports = () => {
|
||||||
let win;
|
let win
|
||||||
|
|
||||||
let init = (opts) => {
|
let init = (opts) => {
|
||||||
createWindow(opts);
|
createWindow(opts)
|
||||||
};
|
}
|
||||||
|
|
||||||
let createWindow = (opts) => {
|
let createWindow = (opts) => {
|
||||||
const winURL = process.env.NODE_ENV === 'development'
|
const winURL = process.env.NODE_ENV === 'development'
|
||||||
@ -22,27 +22,28 @@ module.exports = () => {
|
|||||||
webSecurity: false,
|
webSecurity: false,
|
||||||
enableRemoteModule: true,
|
enableRemoteModule: true,
|
||||||
backgroundThrottling: false,
|
backgroundThrottling: false,
|
||||||
|
contextIsolation: false,
|
||||||
webviewTag: true,
|
webviewTag: true,
|
||||||
nodeIntegration: true // 在网页中集成Node
|
nodeIntegration: true // 在网页中集成Node
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
process.env.NODE_ENV === 'development' ? win.loadURL(winURL) : win.loadFile(winURL, {
|
process.env.NODE_ENV === 'development' ? win.loadURL(winURL) : win.loadFile(winURL, {
|
||||||
hash: `#/plugin`,
|
hash: `#/plugin`,
|
||||||
});
|
})
|
||||||
|
|
||||||
win.webContents.executeJavaScript(`window.setPluginInfo(${opts})`).then(() => {
|
win.webContents.executeJavaScript(`window.setPluginInfo(${opts})`).then(() => {
|
||||||
win.show()
|
win.show()
|
||||||
});
|
})
|
||||||
|
|
||||||
win.on("closed", () => {
|
win.on("closed", () => {
|
||||||
win = undefined;
|
win = undefined
|
||||||
});
|
})
|
||||||
};
|
}
|
||||||
|
|
||||||
let getWindow = () => win;
|
let getWindow = () => win
|
||||||
|
|
||||||
return {
|
return {
|
||||||
init: init,
|
init: init,
|
||||||
getWindow: getWindow,
|
getWindow: getWindow,
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import path from "path";
|
import path from "path"
|
||||||
import fs from 'fs';
|
import fs from 'fs'
|
||||||
import {getlocalDataFile} from "./utils";
|
import { getlocalDataFile } from "./utils"
|
||||||
import os from 'os';
|
import os from 'os'
|
||||||
|
|
||||||
const configPath = path.join(getlocalDataFile(), './rubick-config.json');
|
const configPath = path.join(getlocalDataFile(), './rubick-config.json')
|
||||||
|
|
||||||
let defaultConfig = {
|
let defaultConfig = {
|
||||||
Darwin: {
|
Darwin: {
|
||||||
@ -55,30 +55,55 @@ let defaultConfig = {
|
|||||||
mouseDownTime: 500
|
mouseDownTime: 500
|
||||||
},
|
},
|
||||||
global: []
|
global: []
|
||||||
|
},
|
||||||
|
Linux: {
|
||||||
|
version: 1,
|
||||||
|
perf: {
|
||||||
|
shortCut: {
|
||||||
|
showAndHidden: 'Option+R',
|
||||||
|
separate: 'Ctrl+D',
|
||||||
|
quit: 'Shift+Escape'
|
||||||
|
},
|
||||||
|
common: {
|
||||||
|
start: true,
|
||||||
|
space: true,
|
||||||
|
},
|
||||||
|
local: {
|
||||||
|
search: true,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
superPanel: {
|
||||||
|
baiduAPI: {
|
||||||
|
key: '',
|
||||||
|
appid: '',
|
||||||
|
},
|
||||||
|
mouseDownTime: 500
|
||||||
|
},
|
||||||
|
global: []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
global.opConfig = {
|
global.opConfig = {
|
||||||
config: null,
|
config: null,
|
||||||
get() {
|
get() {
|
||||||
const platform = os.type();
|
const platform = os.type()
|
||||||
try {
|
try {
|
||||||
if (!opConfig.config) {
|
if (!opConfig.config) {
|
||||||
opConfig.config = JSON.parse(fs.readFileSync(configPath) || JSON.stringify(defaultConfig[platform]));
|
opConfig.config = JSON.parse(fs.readFileSync(configPath) || JSON.stringify(defaultConfig[platform]))
|
||||||
}
|
}
|
||||||
// 重置
|
// 重置
|
||||||
if (!opConfig.version || opConfig.version < defaultConfig[platform].version) {
|
if (!opConfig.version || opConfig.version < defaultConfig[platform].version) {
|
||||||
opConfig.config = defaultConfig[platform];
|
opConfig.config = defaultConfig[platform]
|
||||||
fs.writeFileSync(configPath, JSON.stringify(opConfig.config));
|
fs.writeFileSync(configPath, JSON.stringify(opConfig.config))
|
||||||
}
|
}
|
||||||
return opConfig.config;
|
return opConfig.config
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
opConfig.config = defaultConfig[platform]
|
opConfig.config = defaultConfig[platform]
|
||||||
return opConfig.config;
|
return opConfig.config
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
set(key, value) {
|
set(key, value) {
|
||||||
opConfig.config[key] = value;
|
opConfig.config[key] = value
|
||||||
fs.writeFileSync(configPath, JSON.stringify(opConfig.config));
|
fs.writeFileSync(configPath, JSON.stringify(opConfig.config))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user