mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-09-24 04:53:31 +08:00
弃用lodash
This commit is contained in:
29
src/App.vue
29
src/App.vue
@@ -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: {
|
||||
|
@@ -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;
|
||||
},
|
||||
|
@@ -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");
|
||||
},
|
||||
|
@@ -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;
|
||||
},
|
||||
|
@@ -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,
|
||||
|
@@ -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
|
||||
);
|
||||
|
@@ -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();
|
||||
|
@@ -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) {
|
||||
|
@@ -87,7 +87,7 @@ export default defineComponent({
|
||||
return {
|
||||
step: 1,
|
||||
selectedActions: [],
|
||||
configs: _.cloneDeep(defaultUBrowserConfigs),
|
||||
configs: window.lodashM.cloneDeep(defaultUBrowserConfigs),
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
|
@@ -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);
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@@ -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>
|
||||
|
@@ -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("取消收藏成功");
|
||||
},
|
||||
},
|
||||
|
@@ -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("禁用成功");
|
||||
},
|
||||
},
|
||||
|
@@ -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")
|
||||
|
@@ -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("、")}』即可直接进入『${
|
||||
|
@@ -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"
|
||||
);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
@@ -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];
|
||||
},
|
||||
|
@@ -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}`)
|
||||
);
|
||||
|
@@ -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;
|
||||
});
|
||||
};
|
||||
|
@@ -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",
|
||||
|
@@ -27,7 +27,7 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
runCurrentCommand(command) {
|
||||
this.$refs.result.runCurrentCommand(_.cloneDeep(command));
|
||||
this.$refs.result.runCurrentCommand(window.lodashM.cloneDeep(command));
|
||||
},
|
||||
},
|
||||
};
|
||||
|
@@ -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
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
@@ -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);
|
||||
},
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user