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