feat: 使用utools提供的isDev

This commit is contained in:
fofolee 2022-01-05 15:29:58 +08:00
parent 34814db352
commit 2b1f678bde
5 changed files with 12 additions and 11 deletions

View File

@ -22,7 +22,7 @@ let showCommandEditor = (readonly = false) => {
$("#options").append(qctemplates.command.commandEditor)
$("#program").append(programOpt)
$("#tags").html(tagsOpt)
if (readonly && !isDev()) $(".button .cmdBtn .save").remove()
if (readonly && !utools.isDev()) $(".button .cmdBtn .save").remove()
$("#icon").attr('src', 'logo/quickcommand.png');
getSpecialVars()
createEditor()
@ -45,9 +45,9 @@ let showCommandEditor = (readonly = false) => {
maximumSelectionLength: 3,
dropdownParent: $("#customize")
}).on("select2:unselecting", e => {
(e.params.args.data.text == "默认") && !isDev() && e.preventDefault();
(e.params.args.data.text == "默认") && !utools.isDev() && e.preventDefault();
}).on("select2:selecting", e => {
(e.params.args.data.text == "默认" || e.params.args.data.text == "未分类") && !isDev() && e.preventDefault();
(e.params.args.data.text == "默认" || e.params.args.data.text == "未分类") && !utools.isDev() && e.preventDefault();
})
}
@ -438,7 +438,7 @@ let SaveCurrentCommand = async () => {
rule = $('#rule').val(),
charset = $('#charset').data()
var cmd = window.editor.getValue();
if (tags && tags.includes("默认") && !isDev()) return
if (tags && tags.includes("默认") && !utools.isDev()) return
// 留空检测
if (type != "regex" && !rule) return quickcommand.showMessageBox(`${$('#ruleWord').text().replace(" ", "")} 不能留空!`, 'error')
if (!cmdCheck(type, cmd)) return

View File

@ -109,7 +109,7 @@ let getEveryFeature = (fts, currentFtsCode, tag) => {
</td>
<td>
<span class="Btn editBtn"><img src="img/${tag == "默认" ? "view" : "edit"}.svg"></span>
${(tag == "默认" && !window.isDev()) ? "" : `<span class="Btn exportBtn"><img src="img/export.svg"> </span><span class="Btn delBtn"><img src="img/del.svg"></span>`}
${(tag == "默认" && !utools.isDev()) ? "" : `<span class="Btn exportBtn"><img src="img/export.svg"> </span><span class="Btn delBtn"><img src="img/del.svg"></span>`}
</td>`
}
@ -367,7 +367,7 @@ let exportAll = (copy = false) => {
extensions: ['json']
},]
};
if (!window.isDev()) Object.keys(allQcs).forEach(k => {
if (!utools.isDev()) Object.keys(allQcs).forEach(k => {
if (k.includes('default_')) delete allQcs[k]
})
let stringifyQcs = JSON.stringify(allQcs)

View File

@ -1,6 +1,6 @@
// 禁用危险函数
let whole = window.utools
if (!window.isDev()) window.utools = window.getuToolsLite()
if (!utools.isDev()) window.utools = window.getuToolsLite()
// 数据库前缀
const DBPRE = {

3
src/node_modules/vm2/bin/.smbdeleteAAA118b14.4 generated vendored Normal file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env node
require(__dirname +'/../lib/cli.js');

View File

@ -435,12 +435,9 @@ pluginInfo = () => {
return JSON.parse(fs.readFileSync(path.join(__dirname, 'plugin.json')))
}
isDev = () => {
return /[a-zA-Z0-9\-]+\.asar/.test(__dirname) ? false : true
}
let GetFilePath = (Path, File) => {
if (isDev()) {
if (utools.isDev()) {
return path.join(__dirname, Path, File)
} else {
return path.join(__dirname.replace(/([a-zA-Z0-9\-]+\.asar)/, '$1.unpacked'), Path, File)
@ -465,6 +462,7 @@ let modWindowHeight = height => {
// 屏蔽危险函数
getuToolsLite = () => {
var utoolsLite = Object.assign({}, utools)
if (utools.isDev()) return utoolsLite
// 数据库相关接口
delete utoolsLite.db
delete utoolsLite.dbStorage