弃用lodash

This commit is contained in:
fofolee 2024-12-30 20:41:54 +08:00
parent 7a79d3a443
commit 1d3aa3c9ae
30 changed files with 597 additions and 152 deletions

View File

@ -32,7 +32,7 @@ const getUtoolsPlugins = () => {
return true;
});
});
if (!_.isEmpty(keyWordFeatures)) {
if (!window.lodashM.isEmpty(keyWordFeatures)) {
pluginInfo["keyWordFeatures"] = keyWordFeatures;
plugins[pluginInfo.pluginName] = pluginInfo;
}

352
plugin/lib/lodashMini.js Normal file
View File

@ -0,0 +1,352 @@
// 主要函数实现
const lodashMini = {
/**
* 创建一个新数组将array与任何数组或值连接在一起
* @param {Array} array - 要连接的第一个数组
* @param {...*} values - 要连接的其他值
* @returns {Array} 返回连接后的新数组
* @example
* concat([1], 2, [3], [[4]]) => [1, 2, 3, [4]]
*/
concat: function (array, ...values) {
return [].concat(array || [], ...values);
},
/**
* 深拷贝一个值支持大多数内置类型
* @param {*} value - 要深拷贝的值
* @returns {*} 返回深拷贝后的值
* @example
* cloneDeep([{ a: [1] }]) => [{ a: [1] }]
*/
cloneDeep: function (value) {
if (!this.isObject(value)) {
return value;
}
if (this.isArray(value)) {
return value.map((item) => this.cloneDeep(item));
}
if (this.isBuffer(value)) {
const result = Buffer.allocUnsafe(value.length);
value.copy(result);
return result;
}
if (value instanceof Date) return new Date(value);
if (value instanceof RegExp) return new RegExp(value.source, value.flags);
if (value instanceof Set) {
return new Set([...value].map((item) => this.cloneDeep(item)));
}
if (value instanceof Map) {
return new Map(
[...value].map(([k, v]) => [this.cloneDeep(k), this.cloneDeep(v)])
);
}
if (typeof value === "function") {
return value;
}
const result = {};
for (const key in value) {
if (Object.prototype.hasOwnProperty.call(value, key)) {
result[key] = this.cloneDeep(value[key]);
}
}
return result;
},
/**
* 遍历集合中的元素返回所有通过断言检查的元素组成的数组
* @param {Array|Object} collection - 要遍历的集合
* @param {Function|String|Array|Object} predicate - 每次迭代调用的断言函数
* @returns {Array} 返回过滤后的新数组
* @example
* filter([1, 2, 3], n => n > 1) => [2, 3]
* filter([{ a: 1 }, { a: 2 }], 'a') => [{ a: 1 }, { a: 2 }]
* filter([{ a: 1 }, { a: 2 }], ['a', 1]) => [{ a: 1 }]
*/
filter: function (collection, predicate) {
if (collection == null) return [];
const iteratee =
typeof predicate === "function"
? predicate
: function (obj) {
if (this.isArray(predicate)) {
return predicate.length
? obj[predicate[0]] === predicate[1]
: true;
}
if (typeof predicate === "object" && !this.isArray(predicate)) {
for (const key in predicate) {
if (!(key in obj) || obj[key] !== predicate[key]) {
return false;
}
}
return true;
}
return obj[predicate];
}.bind(this);
return Array.isArray(collection)
? collection.filter((value, index) => iteratee(value, index, collection))
: Object.entries(Object(collection))
.filter(([key, value]) => iteratee(value, key, collection))
.map(([_, value]) => value);
},
/**
* 遍历对象的自身和继承的可枚举属性
* @param {Object} object - 要遍历的对象
* @param {Function} iteratee - 每次迭代调用的函数
* @returns {Object} 返回对象本身
* @example
* forIn({ a: 1 }, (value, key) => console.log(key)) => 输出 'a'
*/
forIn: function (object, iteratee) {
if (object == null) return object;
object = Object(object);
for (const key in object) {
if (iteratee(object[key], key, object) === false) {
break;
}
}
return object;
},
/**
* 检查值是否为 Array 对象
* @param {*} value - 要检查的值
* @returns {boolean} 如果值为数组返回 true否则返回 false
* @example
* isArray([1, 2, 3]) => true
* isArray('abc') => false
*/
isArray: function (value) {
return Array.isArray(value);
},
/**
* 检查值是否为 Buffer 对象
* @param {*} value - 要检查的值
* @returns {boolean} 如果值为 Buffer 返回 true否则返回 false
* @example
* isBuffer(new Buffer(2)) => true
* isBuffer(new Uint8Array(2)) => false
*/
isBuffer: function (value) {
return value instanceof Buffer;
},
/**
* 检查值是否为空
* @param {*} value - 要检查的值
* @returns {boolean} 如果值为空返回 true否则返回 false
* @example
* isEmpty(null) => true
* isEmpty([1, 2, 3]) => false
* isEmpty('') => true
*/
isEmpty: function (value) {
if (value == null) return true;
if (
this.isArray(value) ||
typeof value === "string" ||
this.isBuffer(value) ||
value instanceof ArrayBuffer ||
(typeof value === "object" && "length" in value)
) {
return !value.length;
}
if (value instanceof Map || value instanceof Set) {
return !value.size;
}
if (value instanceof ArrayBuffer) {
return !value.byteLength;
}
if (typeof value === "object") {
return !Object.keys(Object(value)).length;
}
return true;
},
/**
* 检查值是否为 null undefined
* @param {*} value - 要检查的值
* @returns {boolean} 如果值为 null undefined 返回 true否则返回 false
* @example
* isNil(null) => true
* isNil(undefined) => true
* isNil(0) => false
*/
isNil: function (value) {
return value == null;
},
/**
* 检查值是否为对象
* @param {*} value - 要检查的值
* @returns {boolean} 如果值为对象返回 true否则返回 false
* @example
* isObject({}) => true
* isObject([1, 2, 3]) => true
* isObject(null) => false
*/
isObject: function (value) {
return value != null && typeof value === "object";
},
/**
* 创建一个对象过滤掉不满足断言检查的属性
* @param {Object} object - 来源对象
* @param {Function} predicate - 断言函数调用时传入 (value, key)
* @returns {Object} 返回过滤后的新对象
* @example
* omitBy({ a: 1, b: '2' }, value => typeof value === 'number') => { b: '2' }
*/
omitBy: function (object, predicate) {
if (object == null) return {};
object = Object(object);
const result = {};
for (const key in object) {
if (Object.prototype.hasOwnProperty.call(object, key)) {
const value = object[key];
if (!predicate(value, key)) {
result[key] = value;
}
}
}
return result;
},
/**
* 从对象中选取指定的属性
* @param {Object} object - 来源对象
* @param {...(string|string[])} paths - 要获取的属性路径
* @returns {Object} 返回新对象
* @example
* pick({ a: 1, b: '2', c: 3 }, ['a', 'c']) => { a: 1, c: 3 }
*/
pick: function (object, ...paths) {
if (object == null) return {};
object = Object(object);
return (Array.isArray(paths[0]) ? paths[0] : paths).reduce(
(result, path) => {
if (path != null && object[path] !== undefined) {
result[path] = object[path];
}
return result;
},
{}
);
},
/**
* 移除数组中所有给定值
* @param {Array} array - 要修改的数组
* @param {...*} values - 要移除的值
* @returns {Array} 返回数组本身
* @example
* pull([1, 2, 3, 1, 2, 3], 2, 3) => [1, 1]
*/
pull: function (array, ...values) {
if (!array || !array.length || !values.length) return array;
let i = 0;
while (i < array.length) {
if (values.includes(array[i])) {
array.splice(i, 1);
} else {
i++;
}
}
return array;
},
/**
* 截断字符串
* @param {string} [string=''] - 要截断的字符串
* @param {Object} [options={}] - 选项对象
* @param {number} [options.length=30] - 允许的最大长度
* @param {string} [options.omission='...'] - 省略符号
* @param {RegExp|string} [options.separator] - 截断点
* @returns {string} 返回截断后的字符串
* @example
* truncate('hi-diddly-ho there, neighborino') => 'hi-diddly-ho there, neighbo...'
*/
truncate: function (string = "", options = {}) {
const { length = 30, omission = "...", separator } = options;
if (string.length <= length) return string;
const strLength = length - omission.length;
if (strLength < 1) return omission;
let result = string.slice(0, strLength);
if (separator) {
const lastIndex =
typeof separator === "string"
? result.lastIndexOf(separator)
: result.split("").reverse().join("").search(separator);
if (lastIndex > -1) {
result = result.slice(0, lastIndex);
}
}
return result + omission;
},
/**
* 创建一个去重后的数组
* @param {...Array} arrays - 要合并的数组
* @returns {Array} 返回新的去重数组
* @example
* union([2], [1, 2]) => [2, 1]
*/
union: function (...arrays) {
return [
...new Set(
arrays.reduce((result, arr) => {
if (Array.isArray(arr)) {
result.push(...arr);
}
return result;
}, [])
),
];
},
/**
* 获取对象的所有值
* @param {Object} object - 要获取值的对象
* @returns {Array} 返回对象值的数组
* @example
* values({ a: 1, b: 2 }) => [1, 2]
*/
values: function (object) {
if (object == null) return [];
return Object.values(Object(object));
},
/**
* 创建一个不包含指定值的数组
* @param {Array} array - 要检查的数组
* @param {...*} values - 要排除的值
* @returns {Array} 返回过滤后的新数组
* @example
* without([2, 1, 2, 3], 1, 2) => [3]
*/
without: function (array, ...values) {
return array == null
? []
: array.filter((value) => !values.includes(value));
},
};
module.exports = lodashMini;

View File

@ -1,27 +1,36 @@
const getuToolsLite = () => {
var utoolsLite = Object.assign({}, _.cloneDeep(utools))
// if (utools.isDev()) return utoolsLite
const dbBlackList = [
"db",
"dbStorage",
"dbCryptoStorage",
"removeFeature",
"setFeature",
"onDbPull",
];
const payBlackList = ['fetchUserServerTemporaryToken', 'isPurchasedUser', 'openPurchase', 'getUserServerTemporaryToken', 'openPayment', 'fetchUserPayments']
const etcBlackList = [
"onPluginEnter",
"onPluginOut",
"onMainPush",
"createBrowserWindow",
"team",
];
_.concat(dbBlackList, payBlackList, etcBlackList).forEach(item => {
delete utoolsLite[item]
})
Object.freeze(utoolsLite)
return utoolsLite
}
var utoolsLite = Object.assign({}, window.lodashM.cloneDeep(utools));
// if (utools.isDev()) return utoolsLite
const dbBlackList = [
"db",
"dbStorage",
"dbCryptoStorage",
"removeFeature",
"setFeature",
"onDbPull",
];
const payBlackList = [
"fetchUserServerTemporaryToken",
"isPurchasedUser",
"openPurchase",
"getUserServerTemporaryToken",
"openPayment",
"fetchUserPayments",
];
const etcBlackList = [
"onPluginEnter",
"onPluginOut",
"onMainPush",
"createBrowserWindow",
"team",
];
window.lodashM
.concat(dbBlackList, payBlackList, etcBlackList)
.forEach((item) => {
delete utoolsLite[item];
});
Object.freeze(utoolsLite);
return utoolsLite;
};
module.exports = getuToolsLite
module.exports = getuToolsLite;

View File

@ -8,7 +8,6 @@
"axios": "^1.7.9",
"crypto-js": "^4.2.0",
"iconv-lite": "^0.6.3",
"lodash": "^4.17.21",
"node-forge": "^1.3.1",
"ses": "^1.10.0",
"sm-crypto": "^0.3.13",
@ -116,11 +115,6 @@
"integrity": "sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A==",
"license": "MIT"
},
"node_modules/lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
},
"node_modules/mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
@ -256,11 +250,6 @@
"resolved": "https://registry.npmjs.org/jsbn/-/jsbn-1.1.0.tgz",
"integrity": "sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A=="
},
"lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
},
"mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",

View File

@ -3,7 +3,6 @@
"axios": "^1.7.9",
"crypto-js": "^4.2.0",
"iconv-lite": "^0.6.3",
"lodash": "^4.17.21",
"node-forge": "^1.3.1",
"ses": "^1.10.0",
"sm-crypto": "^0.3.13",

View File

@ -15,7 +15,7 @@ const md5 = (input) => {
return crypto.createHash("md5").update(input, "utf8").digest("hex");
};
window._ = require("lodash");
window.lodashM = require("./lib/lodashMini");
const getCommandToLaunchTerminal = require("./lib/getCommandToLaunchTerminal");
const shortCodes = require("./lib/shortCodes");
@ -113,7 +113,6 @@ let getSandboxFuns = () => {
electron,
axios,
Audio,
_,
AbortController,
AbortSignal,
Buffer,
@ -142,7 +141,7 @@ let liteErr = (e) => {
// vm 模块将无法在渲染进程中使用,改用 ses 来执行代码
window.evalCodeInSandbox = (code, addVars = {}) => {
let sandboxWithAD = Object.assign(addVars, getSandboxFuns());
sandboxWithAD.quickcommand = _.cloneDeep(quickcommand);
sandboxWithAD.quickcommand = window.lodashM.cloneDeep(quickcommand);
try {
return new Compartment(sandboxWithAD).evaluate(code);
} catch (error) {
@ -163,7 +162,7 @@ window.runCodeInSandbox = (code, callback, addVars = {}) => {
},
};
let sandboxWithAD = Object.assign(addVars, sandbox);
sandboxWithAD.quickcommand = _.cloneDeep(quickcommand);
sandboxWithAD.quickcommand = window.lodashM.cloneDeep(quickcommand);
if (addVars.enterData) {
sandboxWithAD.quickcommand.enterData = addVars.enterData;
sandboxWithAD.quickcommand.payload = addVars.enterData.payload;
@ -229,7 +228,7 @@ window.runCodeFile = (cmd, option, terminal, callback, realTime = true) => {
} else {
cmdline = `${bin} ${argv} "${script}" ${scptarg}`;
}
let processEnv = _.cloneDeep(process.env);
let processEnv = window.lodashM.cloneDeep(process.env);
if (envPath) processEnv.PATH = envPath;
if (alias) cmdline = alias + "\n" + cmdline;
// 在终端中输出
@ -293,7 +292,9 @@ window.quickcommandHttpServer = () => {
httpServer = http.createServer();
httpServer.on("request", (req, res) => {
if (req.method === "GET") {
let parsedParams = _.cloneDeep(url.parse(req.url, true).query);
let parsedParams = window.lodashM.cloneDeep(
url.parse(req.url, true).query
);
runUserCode(res, parsedParams);
} else if (req.method === "POST") {
let data = [];
@ -307,7 +308,9 @@ window.quickcommandHttpServer = () => {
try {
parsedParams = JSON.parse(params);
} catch (error) {
parsedParams = _.cloneDeep(url.parse("?" + params, true).query);
parsedParams = window.lodashM.cloneDeep(
url.parse("?" + params, true).query
);
}
runUserCode(res, parsedParams);
});

View File

@ -85,16 +85,19 @@ export default defineComponent({
let nativeProfile = this.utools.getDB(
"cfg_" + utools.getNativeId() + "_profile"
);
this.profile = Object.assign(_.cloneDeep(this.profile), commonProfile);
this.profile = Object.assign(
window.lodashM.cloneDeep(this.profile),
commonProfile
);
this.nativeProfile = Object.assign(
_.cloneDeep(this.nativeProfile),
window.lodashM.cloneDeep(this.nativeProfile),
nativeProfile
);
},
saveProfile() {
this.utools.putDB(_.cloneDeep(this.profile), "cfg_profile");
this.utools.putDB(window.lodashM.cloneDeep(this.profile), "cfg_profile");
this.utools.putDB(
_.cloneDeep(this.nativeProfile),
window.lodashM.cloneDeep(this.nativeProfile),
"cfg_" + utools.getNativeId() + "_profile"
);
},
@ -103,9 +106,12 @@ export default defineComponent({
if (window.multiProcessDetection())
return console.log("multiProcess Detected");
//
_.forIn(this.nativeProfile.crontabs, (cronExp, featureCode) => {
this.runCronTask(featureCode, cronExp);
});
window.lodashM.forIn(
this.nativeProfile.crontabs,
(cronExp, featureCode) => {
this.runCronTask(featureCode, cronExp);
}
);
//
if (this.nativeProfile.serverStatus) {
window.quickcommandHttpServer().run(this.nativeProfile.serverPort);
@ -221,7 +227,7 @@ export default defineComponent({
window.showUb.help();
//
// let statisticsData = this.utools.getDB("cfg_statisticsData");
// _.forIn(statisticsData, (data, year) => {
// window.lodashM.forIn(statisticsData, (data, year) => {
// statisticsData[year] = data.map((x) => {
// if (!x.command) return x;
// let code =
@ -238,7 +244,12 @@ export default defineComponent({
this.utools.setStorage("st_v300Inited", true);
},
getOpacityColor(color, percent) {
return color + parseInt(0xff * percent).toString(16).padStart(2, "0");
return (
color +
parseInt(0xff * percent)
.toString(16)
.padStart(2, "0")
);
},
},
watch: {

View File

@ -49,7 +49,8 @@ export default {
computed: {
isPlatformSupported() {
let { platform } = this.commandInfo.features;
return !_.isEmpty(platform) && !platform.includes(window.processPlatform)
return !window.lodashM.isEmpty(platform) &&
!platform.includes(window.processPlatform)
? false
: true;
},

View File

@ -167,7 +167,10 @@ export default {
? this.$root.utools.getDB("cfg_codeHistory")
: this.action.data;
quickCommandInfo?.program &&
Object.assign(this.quickcommandInfo, _.cloneDeep(quickCommandInfo));
Object.assign(
this.quickcommandInfo,
window.lodashM.cloneDeep(quickCommandInfo)
);
//
if (this.quickcommandInfo.tags?.includes("默认") && !utools.isDev()) {
this.canCommandSave = false;
@ -230,8 +233,11 @@ export default {
saveCurrentCommand(message = "保存成功") {
let updatedData = this.$refs.sidebar?.SaveMenuData();
if (!updatedData) return;
Object.assign(this.quickcommandInfo, _.cloneDeep(updatedData));
let newQuickcommandInfo = _.cloneDeep(this.quickcommandInfo);
Object.assign(
this.quickcommandInfo,
window.lodashM.cloneDeep(updatedData)
);
let newQuickcommandInfo = window.lodashM.cloneDeep(this.quickcommandInfo);
this.$root.utools.putDB(
newQuickcommandInfo,
"qc_" + this.quickcommandInfo.features.code
@ -247,7 +253,7 @@ export default {
//
runCurrentCommand(cmd) {
this.saveToHistory(); //
let command = _.cloneDeep(this.quickcommandInfo);
let command = window.lodashM.cloneDeep(this.quickcommandInfo);
if (cmd) command.cmd = cmd;
command.output =
this.$refs.sidebar?.currentCommand.output ||
@ -257,7 +263,7 @@ export default {
},
saveCodeHistory() {
if (this.action.type !== "run") return;
let command = _.cloneDeep(this.quickcommandInfo);
let command = window.lodashM.cloneDeep(this.quickcommandInfo);
command.cursorPosition = this.$refs.editor.getCursorPosition();
this.$root.utools.putDB(command, "cfg_codeHistory");
},

View File

@ -1,31 +1,63 @@
<template>
<div>
<q-dialog v-model="isResultShow" :position="fromUtools ? 'top' : 'bottom'" @hide="stopRun" :maximized="fromUtools"
:transition-duration="fromUtools ? 0 : 200">
<q-card :style="{
maxWidth: fromUtools ? '100%' : '700px',
width: fromUtools ? '100%' : '700px',
overflow: 'hidden',
}">
<div v-if="!(enableHtml && fromUtools)" :style="{
height: headerHeight + 'px',
}" class="flex items-center justify-between">
<q-dialog
v-model="isResultShow"
:position="fromUtools ? 'top' : 'bottom'"
@hide="stopRun"
:maximized="fromUtools"
:transition-duration="fromUtools ? 0 : 200"
>
<q-card
:style="{
maxWidth: fromUtools ? '100%' : '700px',
width: fromUtools ? '100%' : '700px',
overflow: 'hidden',
}"
>
<div
v-if="!(enableHtml && fromUtools)"
:style="{
height: headerHeight + 'px',
}"
class="flex items-center justify-between"
>
<div>
<q-avatar :size="`${headerHeight}`">
<q-icon :class="runResultStatus ? 'text-green' : 'text-red'"
:name="runResultStatus ? 'task_alt' : 'error'" size="sm"></q-icon>
<q-icon
:class="runResultStatus ? 'text-green' : 'text-red'"
:name="runResultStatus ? 'task_alt' : 'error'"
size="sm"
></q-icon>
</q-avatar>
<span class="text-weight-bold text-h7">运行结果</span>
</div>
<ResultMenu class="no-shadow q-pa-sm" :stretch="true" :content="runResult.join('')" :closebtn="!fromUtools"
:textbtn="!enableHtml" :imagebtn="!enableHtml && isDataUrl" @showImg="showBase64Img" :style="{
height: headerHeight + 'px',
}" />
<ResultMenu
class="no-shadow q-pa-sm"
:stretch="true"
:content="runResult.join('')"
:closebtn="!fromUtools"
:textbtn="!enableHtml"
:imagebtn="!enableHtml && isDataUrl"
@showImg="showBase64Img"
:style="{
height: headerHeight + 'px',
}"
/>
</div>
<div :style="{ maxHeight: maxHeight - headerHeight + 'px' }" class="scroll">
<ResultArea v-if="isResultShow" @frameLoad="frameLoad" :frameInitHeight="frameInitHeight"
:enableHtml="enableHtml" :runResultStatus="runResultStatus" :runResult="runResult" :key="timeStamp"
@mouseup="selectHandler" />
<div
:style="{ maxHeight: maxHeight - headerHeight + 'px' }"
class="scroll"
>
<ResultArea
v-if="isResultShow"
@frameLoad="frameLoad"
:frameInitHeight="frameInitHeight"
:enableHtml="enableHtml"
:runResultStatus="runResultStatus"
:runResult="runResult"
:key="timeStamp"
@mouseup="selectHandler"
/>
<q-resize-observer @resize="autoHeight" debounce="0" />
</div>
<q-menu v-if="selectText" touch-position @before-hide="clearSelect">
@ -36,7 +68,6 @@
</div>
</template>
<script>
import outputTypes from "js/options/outputTypes.js";
import specialVars from "js/options/specialVars.js";
@ -158,14 +189,14 @@ export default {
},
escapeItem(item) {
// String
if (typeof item === 'object') {
if (typeof item === "object") {
try {
item = JSON.stringify(item)
item = JSON.stringify(item);
} catch (_) {
item = item.toString()
item = item.toString();
}
} else {
item = item.toString()
item = item.toString();
}
// JSON.stringify
item = JSON.stringify(item)
@ -174,19 +205,21 @@ export default {
//
.replace(/`|'/g, "\\$&")
//
.replace(/\{\{/g, "\\{\\{")
.replace(/\{\{/g, "\\{\\{");
// .replace("$", '$$$')
return item
return item;
},
//
assignSpecialVars(cmd) {
let userData = this.$root.utools.userData.all();
let spVars = _.filter(specialVars, (sp) => sp.repl);
_.forIn(spVars, (val, key) => {
let spVars = window.lodashM.filter(specialVars, (sp) => sp.repl);
window.lodashM.forIn(spVars, (val, key) => {
let label = val.label.slice(0, -2);
if (cmd.includes(label)) {
let replData = label === "{{usr:" ? userData : this.$root.enterData;
cmd = cmd.replace(val.match, (x) => this.escapeItem(val.repl(x, replData)));
cmd = cmd.replace(val.match, (x) =>
this.escapeItem(val.repl(x, replData))
);
}
});
return cmd;
@ -200,7 +233,7 @@ export default {
this.subInputValue = text;
}, placeholder);
let querySubInput = () => {
let command = _.cloneDeep(currentCommand);
let command = window.lodashM.cloneDeep(currentCommand);
command.cmd = currentCommand.cmd.replace(
specialVars.subinput.match,
this.subInputValue
@ -270,7 +303,7 @@ export default {
this.autoScroll();
},
async handleContent(content) {
if (!_.isArray(content)) content = [content];
if (!window.lodashM.isArray(content)) content = [content];
if (this.enableHtml) content = await this.cacheScript(content);
return content;
},

View File

@ -81,7 +81,7 @@ export default {
},
mounted() {
this.frameInit();
URL.revokeObjectURL(this.src)
URL.revokeObjectURL(this.src);
},
methods: {
frameInit() {
@ -109,8 +109,8 @@ export default {
quickcommand.showMessageBox(args.join(" "), "success", 0);
};
return {
quickcommand: _.cloneDeep(quickcommand),
utools: _.cloneDeep(utools),
quickcommand: window.lodashM.cloneDeep(quickcommand),
utools: window.lodashM.cloneDeep(utools),
parent: undefined,
console: {
log: showLog,

View File

@ -176,7 +176,7 @@ export default {
});
},
getRawCommand() {
let command = _.cloneDeep(this.commandInfo);
let command = window.lodashM.cloneDeep(this.commandInfo);
command.features.explain = window.removeHtmlTags(
command.features.explain
);

View File

@ -437,7 +437,7 @@ export default {
if (this.currentCommand.features.mainPush) return ["text"];
switch (this.$parent.quickcommandInfo.program) {
case "quickcommand":
return _.without(this.outputTypesOptions, "terminal");
return window.lodashM.without(this.outputTypesOptions, "terminal");
case "html":
return ["html"];
default:
@ -476,7 +476,14 @@ export default {
this.cmdMatch = currentQuickCommandCmds.match;
Object.assign(
this.currentCommand,
_.cloneDeep(_.pick(this.quickcommandInfo, "tags", "output", "features"))
window.lodashM.cloneDeep(
window.lodashM.pick(
this.quickcommandInfo,
"tags",
"output",
"features"
)
)
);
this.setIcon(this.quickcommandInfo.program);
this.platformVerify();

View File

@ -103,18 +103,18 @@ export default defineComponent({
},
created() {
//
this.localConfigs = _.cloneDeep(this.configs);
this.localConfigs = window.lodashM.cloneDeep(this.configs);
},
methods: {
updateConfigs() {
this.$emit("update:configs", _.cloneDeep(this.localConfigs));
this.$emit("update:configs", window.lodashM.cloneDeep(this.localConfigs));
},
},
watch: {
configs: {
deep: true,
handler(newConfigs) {
this.localConfigs = _.cloneDeep(newConfigs);
this.localConfigs = window.lodashM.cloneDeep(newConfigs);
},
},
selectedUA(value) {

View File

@ -87,7 +87,7 @@ export default defineComponent({
return {
step: 1,
selectedActions: [],
configs: _.cloneDeep(defaultUBrowserConfigs),
configs: window.lodashM.cloneDeep(defaultUBrowserConfigs),
};
},
methods: {

View File

@ -181,20 +181,20 @@ export default defineComponent({
emits: ["update:configs"],
data() {
return {
localConfigs: _.cloneDeep(this.configs),
localConfigs: window.lodashM.cloneDeep(this.configs),
};
},
methods: {
updateConfig(key, value) {
this.localConfigs.run[key] = value;
this.$emit("update:configs", _.cloneDeep(this.localConfigs));
this.$emit("update:configs", window.lodashM.cloneDeep(this.localConfigs));
},
},
watch: {
configs: {
deep: true,
handler(newConfigs) {
this.localConfigs = _.cloneDeep(newConfigs);
this.localConfigs = window.lodashM.cloneDeep(newConfigs);
},
},
},

View File

@ -14,7 +14,9 @@
style="width: 280px"
autofocus
v-model="$root.profile.quickFileTag"
@blur="$root.profile.quickFileTag || ($root.profile.quickFileTag = '文件')"
@blur="
$root.profile.quickFileTag || ($root.profile.quickFileTag = '文件')
"
type="text"
>
<template v-slot:append>
@ -25,7 +27,11 @@
color="primary"
/>
</template>
<q-tooltip>启用后选中文件可以通过超级面板快速将文件收藏到{{ $root.profile.quickFileTag }}标签</q-tooltip>
<q-tooltip
>启用后选中文件可以通过超级面板快速将文件收藏到{{
$root.profile.quickFileTag
}}标签</q-tooltip
>
</q-input>
</q-item>
<q-item>
@ -40,7 +46,9 @@
input-class="text-center"
style="width: 280px"
v-model="$root.profile.quickUrlTag"
@blur="$root.profile.quickUrlTag || ($root.profile.quickUrlTag = '网址')"
@blur="
$root.profile.quickUrlTag || ($root.profile.quickUrlTag = '网址')
"
type="text"
>
<template v-slot:append>
@ -51,7 +59,11 @@
color="primary"
/>
</template>
<q-tooltip>启用后在浏览器界面可以通过超级面板快速将网址收藏到{{ $root.profile.quickUrlTag }}标签</q-tooltip>
<q-tooltip
>启用后在浏览器界面可以通过超级面板快速将网址收藏到{{
$root.profile.quickUrlTag
}}标签</q-tooltip
>
</q-input>
</q-item>
<q-item>
@ -89,13 +101,19 @@
</q-item-section>
<q-field dense outlined style="width: 280px">
<template v-slot:control>
<div class="self-center full-width no-outline" tabindex="0">快捷命令服务</div>
<div class="self-center full-width no-outline" tabindex="0">
快捷命令服务
</div>
</template>
<template v-slot:append>
<q-btn flat @click="$router.push('server')" icon="open_in_new" />
</template>
<q-tooltip>
通过本地监听 {{ $root.nativeProfile.serverPort }} 端口的形式接收用户传送过来的参数然后根据参数执行不同的操作
通过本地监听
{{
$root.nativeProfile.serverPort
}}
端口的形式接收用户传送过来的参数然后根据参数执行不同的操作
<br />需要配置插件跟随 utools 启动和保留后台<br />也可在主输入框通过关键字快捷命令服务配置进入
</q-tooltip>
</q-field>
@ -106,7 +124,9 @@
</q-item-section>
<q-field dense outlined style="width: 280px">
<template v-slot:control>
<div class="self-center full-width no-outline" tabindex="0">运行代码</div>
<div class="self-center full-width no-outline" tabindex="0">
运行代码
</div>
</template>
<template v-slot:append>
<q-btn flat @click="$router.push('code')" icon="open_in_new" />
@ -124,13 +144,15 @@
import features from "js/options/quickFeatures.js";
export default {
name: 'UtilityFeaturesMenu',
name: "UtilityFeaturesMenu",
methods: {
toggleFeature(type, enable) {
enable
? this.$root.utools.whole.setFeature(_.cloneDeep(features[type]))
? this.$root.utools.whole.setFeature(
window.lodashM.cloneDeep(features[type])
)
: this.$root.utools.whole.removeFeature(features[type].code);
}
}
},
},
};
</script>

View File

@ -144,7 +144,10 @@ export default {
this.$root.utools.whole.removeFeature(
`panel_${window.hexEncode(this.currentTag)}`
);
_.pull(this.$root.$refs.view.activatedQuickPanels, this.currentTag);
window.lodashM.pull(
this.$root.$refs.view.activatedQuickPanels,
this.currentTag
);
quickcommand.showMessageBox("取消收藏成功");
},
},

View File

@ -93,7 +93,8 @@ export default {
},
computed: {
cronConverted() {
return _.values(this.cronDetail)
return window.lodashM
.values(this.cronDetail)
.map((x) => x.value)
.join(" ");
},
@ -129,7 +130,7 @@ export default {
window.showUb.help("#Q0e7s");
},
initValue() {
this.cronDetail = _.cloneDeep(this.default);
this.cronDetail = window.lodashM.cloneDeep(this.default);
if (!this.cronExp) return;
let splited = this.cronExp.split(" ");
Object.keys(this.cronDetail).forEach((key, index) => {
@ -149,7 +150,7 @@ export default {
},
delCrontab() {
this.$emit("delCrontab");
this.cronDetail = _.cloneDeep(this.default);
this.cronDetail = window.lodashM.cloneDeep(this.default);
quickcommand.showMessageBox("禁用成功");
},
},

View File

@ -47,12 +47,12 @@ export default {
if (item === null) return "null";
if (typeof item === "undefined") return "undefined";
if (typeof item === "string")
return _.truncate(item, { length: maxSize.txt });
return window.lodashM.truncate(item, { length: maxSize.txt });
if (typeof item === "number") return item;
if (typeof item === "function")
return `f ${item.name ? item.name + "()" : "anonymous()"}`;
if (typeof item !== "object") return item.toString();
if (_.isBuffer(item)) {
if (window.lodashM.isBuffer(item)) {
var bufferString = `[Buffer ${item
.slice(0, maxSize.buff)
.toString("hex")

View File

@ -71,7 +71,9 @@ export default {
},
methods: {
markTag() {
this.$root.utools.whole.setFeature(_.cloneDeep(this.features));
this.$root.utools.whole.setFeature(
window.lodashM.cloneDeep(this.features)
);
this.$root.$refs.view.activatedQuickPanels.push(this.currentTag);
quickcommand.showMessageBox(
`主输入框输入『${this.features.cmds.join("、")}』即可直接进入『${

View File

@ -170,7 +170,10 @@ export default {
return this.$root.utools.getDB("cfg_extraInfo");
},
saveYuQueInfo() {
this.$root.utools.putDB(_.cloneDeep(this.yuQueInfo), "cfg_extraInfo");
this.$root.utools.putDB(
window.lodashM.cloneDeep(this.yuQueInfo),
"cfg_extraInfo"
);
},
},
};

View File

@ -95,7 +95,7 @@ export default {
};
},
mounted() {
this.plugins = _.values(window.getUtoolsPlugins());
this.plugins = window.lodashM.values(window.getUtoolsPlugins());
this.plugin = this.plugins[0];
this.feature = this.features[0];
},

View File

@ -65,16 +65,16 @@ export default {
hints: [],
title: title,
};
if (!_.isObject(options))
if (!window.lodashM.isObject(options))
return reject(new TypeError(`应为 Object, 而非 ${typeof options}`));
if (_.isArray(options)) props.labels = options;
if (window.lodashM.isArray(options)) props.labels = options;
else Object.assign(props, options);
this.showUI(InputBox, props, false, reslove);
}),
showButtonBox: (labels = ["确定"], title = "") =>
new Promise((reslove, reject) => {
if (!_.isArray(labels))
if (!window.lodashM.isArray(labels))
return reject(new TypeError(`应为 Array, 而非 ${typeof labels}`));
this.showUI(ButtonBox, { labels, title }, false, reslove);
}),
@ -90,7 +90,7 @@ export default {
}),
showMessageBox: (message, icon = "success", time, position = "top") => {
message = _.truncate(message, { length: 1200 });
message = window.lodashM.truncate(message, { length: 1200 });
if (icon === "success") icon = "positive";
if (icon === "error") icon = "negative";
if (typeof time === "undefined")
@ -119,7 +119,7 @@ export default {
showSelectList: (initItems, options = {}) =>
new Promise((reslove, reject) => {
if (!_.isArray(initItems))
if (!window.lodashM.isArray(initItems))
return reject(
new TypeError(`应为 Array, 而非 ${typeof initItems}`)
);

View File

@ -33,10 +33,10 @@ const isPathMatched = (currentPath, targetPaths) => {
* @returns {Object} 处理后的对象
*/
const removeEmptyValues = (obj) => {
return _.omitBy(obj, (value) => {
if (_.isNil(value) || value === "") return true;
return window.lodashM.omitBy(obj, (value) => {
if (window.lodashM.isNil(value) || value === "") return true;
if (typeof value === "object")
return _.isEmpty(removeEmptyValues(value));
return window.lodashM.isEmpty(removeEmptyValues(value));
return false;
});
};

View File

@ -53,7 +53,7 @@ const commandTypes = {
disabledSpecialVars:
/{{input}}|{{SelectFile}}|{{pwd}}|{{WindowInfo.*?}}|{{MatchedFiles.*?}}/g,
matchToCmds: (rules, desc) => rules,
verify: (rules) => !_.isEmpty(rules) || "关键词不能为空",
verify: (rules) => !window.lodashM.isEmpty(rules) || "关键词不能为空",
},
regex: {
name: "regex",
@ -120,7 +120,7 @@ const commandTypes = {
},
},
],
verify: (rules) => !_.isEmpty(rules) || "进程名不能为空",
verify: (rules) => !window.lodashM.isEmpty(rules) || "进程名不能为空",
},
img: {
name: "img",

View File

@ -27,7 +27,7 @@ export default {
},
methods: {
runCurrentCommand(command) {
this.$refs.result.runCurrentCommand(_.cloneDeep(command));
this.$refs.result.runCurrentCommand(window.lodashM.cloneDeep(command));
},
},
};

View File

@ -102,7 +102,9 @@ export default {
computed: {
//
currentTagQuickCommands() {
let commands = Object.values(_.cloneDeep(this.allQuickCommands));
let commands = Object.values(
window.lodashM.cloneDeep(this.allQuickCommands)
);
// order
const sortByOrder = (cmds) => {
@ -197,7 +199,7 @@ export default {
},
//
getAllQuickCommands() {
this.allQuickCommands = _.cloneDeep(defaultCommands);
this.allQuickCommands = window.lodashM.cloneDeep(defaultCommands);
this.$root.utools.getAll("qc_").forEach((x) => {
if (x.data.features.code.includes("default_")) return;
this.allQuickCommands[x.data.features.code] = x.data;
@ -206,9 +208,8 @@ export default {
},
getAllQuickCommandTags() {
//
this.allQuickCommandTags = _.union(
...Object.values(this.allQuickCommands).map((x) => x.tags)
)
this.allQuickCommandTags = window.lodashM
.union(...Object.values(this.allQuickCommands).map((x) => x.tags))
.concat(["未分类"])
.filter((x) => x);
},
@ -236,13 +237,13 @@ export default {
},
runCommand(code) {
this.$refs.result.runCurrentCommand(
_.cloneDeep(this.allQuickCommands[code])
window.lodashM.cloneDeep(this.allQuickCommands[code])
);
},
//
enableCommand(code) {
this.$root.utools.whole.setFeature(
_.cloneDeep(this.allQuickCommands[code].features)
window.lodashM.cloneDeep(this.allQuickCommands[code].features)
);
this.activatedQuickCommandFeatureCodes.push(code);
},
@ -283,7 +284,7 @@ export default {
if (typeof command === "string") command = this.allQuickCommands[command];
this.commandEditorAction = {
type: "edit",
data: _.cloneDeep(command),
data: window.lodashM.cloneDeep(command),
};
this.isCommandEditorShow = true;
},
@ -356,7 +357,7 @@ export default {
},
],
};
let commandsToExport = _.cloneDeep(this.allQuickCommands);
let commandsToExport = window.lodashM.cloneDeep(this.allQuickCommands);
//
Object.keys(commandsToExport).forEach((code) => {
if (this.isDefaultCommand(code)) delete commandsToExport[code];
@ -379,7 +380,7 @@ export default {
this.exportAllCommands(false);
this.$root.utools.delAll("qc_");
this.clearAllFeatures();
this.allQuickCommands = _.cloneDeep(defaultCommands);
this.allQuickCommands = window.lodashM.cloneDeep(defaultCommands);
this.getAllQuickCommandTags();
this.changeCurrentTag("默认");
quickcommand.showMessageBox(
@ -498,7 +499,10 @@ export default {
//
Object.entries(tagCommands).forEach(([code, command]) => {
if (!this.isDefaultCommand(code)) {
this.$root.utools.putDB(_.cloneDeep(command), "qc_" + code);
this.$root.utools.putDB(
window.lodashM.cloneDeep(command),
"qc_" + code
);
}
});
},

View File

@ -21,7 +21,7 @@ export default {
},
methods: {
importCommand(command) {
command = _.cloneDeep(command);
command = window.lodashM.cloneDeep(command);
this.$root.utools.putDB(command, "qc_" + command.features.code);
this.$root.utools.whole.setFeature(command.features);
},

View File

@ -195,9 +195,9 @@ export default {
if (!code)
return quickcommand.showMessageBox("该命令格式有误!", "error");
this.installedCodes.push(code);
let pushData = _.cloneDeep(command);
let pushData = window.lodashM.cloneDeep(command);
pushData.fromShare = true;
this.$root.utools.putDB(_.cloneDeep(pushData), "qc_" + code);
this.$root.utools.putDB(window.lodashM.cloneDeep(pushData), "qc_" + code);
// 访
utools.ubrowser
.goto(`https://www.yuque.com/${this.releaseRepo}/${code}`)
@ -249,7 +249,7 @@ export default {
this.compareTime(y.content_updated_at, x.content_updated_at)
);
this.checkCommands();
this.matchedCommands = _.cloneDeep(this.remoteCommands);
this.matchedCommands = window.lodashM.cloneDeep(this.remoteCommands);
this.fetchCommandDetails(1);
});
},
@ -265,7 +265,7 @@ export default {
item.data.updateTime || "2022-04-01T00:00:00.000Z";
if (this.compareTime(remote.content_updated_at, localUpdateTime) > 0) {
needUpdate.push(code);
_.pull(this.remoteCommands, remote);
window.lodashM.pull(this.remoteCommands, remote);
this.remoteCommands.unshift(remote);
} else installed.push(code);
this.installedCodes = installed;