mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-09 06:54:11 +08:00
新建命令正则匹配功能改为直接导入命令
This commit is contained in:
parent
897d597885
commit
545d4b3b31
@ -37,17 +37,17 @@
|
|||||||
"explain": "快速新建快捷命令",
|
"explain": "快速新建快捷命令",
|
||||||
"cmds": [
|
"cmds": [
|
||||||
"新建快捷命令",
|
"新建快捷命令",
|
||||||
"NewCommand",
|
"NewCommand"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"code": "importcommand",
|
||||||
|
"explain": "导入快捷命令",
|
||||||
|
"cmds": [
|
||||||
{
|
{
|
||||||
"type": "regex",
|
"type": "regex",
|
||||||
"label": "新建快捷命令",
|
"label": "导入命令",
|
||||||
"match": "/^\\{[\\s\\S]*\"program\" *: *\".*\"[\\s\\S]*\"cmd\" *: *\".*\"[\\s\\S]*\\}$/i",
|
"match": "/(^\\{[\\s\\S]*\"program\" *: *\".*\"[\\s\\S]*\"cmd\" *: *\".*\"[\\s\\S]*\\}$)|(^qc=e)/i",
|
||||||
"maxNum": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "regex",
|
|
||||||
"label": "新建快捷命令",
|
|
||||||
"match": "/^qc=eyJwcm9ncmFtIj/",
|
|
||||||
"maxNum": 1
|
"maxNum": 1
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -24,13 +24,21 @@
|
|||||||
<q-menu anchor="top end" self="top start">
|
<q-menu anchor="top end" self="top start">
|
||||||
<q-list>
|
<q-list>
|
||||||
<!-- 导入 -->
|
<!-- 导入 -->
|
||||||
<q-item clickable v-close-popup @click="importCommand">
|
<q-item
|
||||||
|
clickable
|
||||||
|
v-close-popup
|
||||||
|
@click="importCommand(importCommandFromFile())"
|
||||||
|
>
|
||||||
<q-item-section side>
|
<q-item-section side>
|
||||||
<q-icon name="text_snippet" />
|
<q-icon name="text_snippet" />
|
||||||
</q-item-section>
|
</q-item-section>
|
||||||
<q-item-section>从文件导入命令</q-item-section>
|
<q-item-section>从文件导入命令</q-item-section>
|
||||||
</q-item>
|
</q-item>
|
||||||
<q-item clickable v-close-popup @click="importCommand(false)">
|
<q-item
|
||||||
|
clickable
|
||||||
|
v-close-popup
|
||||||
|
@click="importCommand(importCommandFromClipboard())"
|
||||||
|
>
|
||||||
<q-item-section side>
|
<q-item-section side>
|
||||||
<q-icon name="content_paste" />
|
<q-icon name="content_paste" />
|
||||||
</q-item-section>
|
</q-item-section>
|
||||||
@ -515,8 +523,22 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// 导入命令且定位
|
// 导入命令且定位
|
||||||
importCommand(fromFile = true) {
|
importCommand(command) {
|
||||||
this.configurationPage.importCommand(fromFile);
|
this.configurationPage.importCommand(command);
|
||||||
|
},
|
||||||
|
// 从文件导入命令
|
||||||
|
importCommandFromFile() {
|
||||||
|
let options = {
|
||||||
|
type: "dialog",
|
||||||
|
argvs: { filters: [{ name: "json", extensions: ["json"] }] },
|
||||||
|
readfile: true,
|
||||||
|
};
|
||||||
|
let fileContent = window.getFileInfo(options);
|
||||||
|
return fileContent ? fileContent.data : false;
|
||||||
|
},
|
||||||
|
// 从剪贴板导入命令
|
||||||
|
importCommandFromClipboard() {
|
||||||
|
return window.clipboardReadText();
|
||||||
},
|
},
|
||||||
// 全部导出
|
// 全部导出
|
||||||
exportAllCommands() {
|
exportAllCommands() {
|
||||||
|
@ -4,21 +4,25 @@
|
|||||||
|
|
||||||
// 是否含有 quickcommand 键值
|
// 是否含有 quickcommand 键值
|
||||||
let isJsonQc = (obj, strict = true) => {
|
let isJsonQc = (obj, strict = true) => {
|
||||||
var keys = strict ? ["features", "program", "cmd", "output"] : ["program", "cmd"]
|
var keys = strict
|
||||||
if (keys.filter(x => typeof obj[x] == 'undefined').length) return false
|
? ["features", "program", "cmd", "output"]
|
||||||
return true
|
: ["program", "cmd"];
|
||||||
}
|
if (keys.filter((x) => typeof obj[x] == "undefined").length) return false;
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
// 判断是否为可导入的快捷命令
|
// 判断是否为可导入的快捷命令
|
||||||
let qcparser = (json, strict = true) => {
|
let qcparser = (json, strict = true) => {
|
||||||
try {
|
try {
|
||||||
var qc = JSON.parse(json)
|
if (json.slice(0, 3) === "qc=") json = window.base64Decode(json.slice(3));
|
||||||
} catch (error) {
|
var qc = JSON.parse(json);
|
||||||
return false
|
} catch (error) {
|
||||||
}
|
return false;
|
||||||
if (isJsonQc(qc, strict)) return { single: true, qc: qc }
|
}
|
||||||
else if (!Object.values(qc).filter(q => !isJsonQc(q, strict)).length) return { single: false, qc: qc }
|
if (isJsonQc(qc, strict)) return { single: true, qc: qc };
|
||||||
else return false
|
else if (!Object.values(qc).filter((q) => !isJsonQc(q, strict)).length)
|
||||||
}
|
return { single: false, qc: qc };
|
||||||
|
else return false;
|
||||||
|
};
|
||||||
|
|
||||||
export default qcparser
|
export default qcparser;
|
||||||
|
@ -202,7 +202,7 @@
|
|||||||
v-model="isCommandEditorShow"
|
v-model="isCommandEditorShow"
|
||||||
persistent
|
persistent
|
||||||
maximized
|
maximized
|
||||||
:transition-show="newCommandDirect ? '' : 'slide-up'"
|
:transition-show="fromNewCommand ? '' : 'slide-up'"
|
||||||
transition-hide="slide-down"
|
transition-hide="slide-down"
|
||||||
style="overflow: hidden"
|
style="overflow: hidden"
|
||||||
>
|
>
|
||||||
@ -318,9 +318,12 @@ export default {
|
|||||||
tabBarWidth() {
|
tabBarWidth() {
|
||||||
return this.commandCardStyle === "mini" ? "0" : "80px";
|
return this.commandCardStyle === "mini" ? "0" : "80px";
|
||||||
},
|
},
|
||||||
newCommandDirect() {
|
fromNewCommand() {
|
||||||
return this.$route.name === "newcommand";
|
return this.$route.name === "newcommand";
|
||||||
},
|
},
|
||||||
|
fromImportCommand() {
|
||||||
|
return this.$route.name === "importcommand";
|
||||||
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.initPage();
|
this.initPage();
|
||||||
@ -328,21 +331,12 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
// 初始化
|
// 初始化
|
||||||
initPage() {
|
initPage() {
|
||||||
// 如果从 newcommand 进入则直接新建命令
|
// newcommand 直接新建命令
|
||||||
if (this.newCommandDirect) {
|
if (this.fromNewCommand) this.addNewCommand();
|
||||||
if (this.$root.enterData.type === "text") {
|
// importcommand 导入命令
|
||||||
this.addNewCommand();
|
else if (this.fromImportCommand)
|
||||||
} else if (this.$root.enterData.payload.slice(0, 3) === "qc=") {
|
this.importCommand(this.$root.enterData.payload);
|
||||||
this.editCommand(
|
this.$router.push("/configuration");
|
||||||
JSON.parse(
|
|
||||||
window.base64Decode(this.$root.enterData.payload.slice(3))
|
|
||||||
)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
this.editCommand(JSON.parse(this.$root.enterData.payload));
|
|
||||||
}
|
|
||||||
this.$router.push("/configuration");
|
|
||||||
}
|
|
||||||
if (this.$route.params.tags) {
|
if (this.$route.params.tags) {
|
||||||
this.changeCurrentTag(window.hexDecode(this.$route.params.tags));
|
this.changeCurrentTag(window.hexDecode(this.$route.params.tags));
|
||||||
this.commandCardStyle = "mini";
|
this.commandCardStyle = "mini";
|
||||||
@ -450,29 +444,12 @@ export default {
|
|||||||
};
|
};
|
||||||
this.isCommandEditorShow = true;
|
this.isCommandEditorShow = true;
|
||||||
},
|
},
|
||||||
// 从文件导入命令
|
|
||||||
importCommandFromFile() {
|
|
||||||
let options = {
|
|
||||||
type: "dialog",
|
|
||||||
argvs: { filters: [{ name: "json", extensions: ["json"] }] },
|
|
||||||
readfile: true,
|
|
||||||
};
|
|
||||||
let fileContent = window.getFileInfo(options);
|
|
||||||
return fileContent ? fileContent.data : false;
|
|
||||||
},
|
|
||||||
// 从剪贴板导入命令
|
|
||||||
importCommandFromClipboard() {
|
|
||||||
return window.clipboardReadText();
|
|
||||||
},
|
|
||||||
// 是否为默认命令
|
// 是否为默认命令
|
||||||
isDefaultCommand(code) {
|
isDefaultCommand(code) {
|
||||||
return code.slice(0, 8) === "default_";
|
return code.slice(0, 8) === "default_";
|
||||||
},
|
},
|
||||||
// 导入命令
|
// 导入命令
|
||||||
importCommand(fromFile = true) {
|
importCommand(quickCommandInfo) {
|
||||||
let quickCommandInfo = fromFile
|
|
||||||
? this.importCommandFromFile()
|
|
||||||
: this.importCommandFromClipboard();
|
|
||||||
if (!quickCommandInfo)
|
if (!quickCommandInfo)
|
||||||
return quickcommand.showMessageBox("导入未完成!", "warning");
|
return quickcommand.showMessageBox("导入未完成!", "warning");
|
||||||
let parsedData = quickcommandParser(quickCommandInfo);
|
let parsedData = quickcommandParser(quickCommandInfo);
|
||||||
@ -619,7 +596,7 @@ export default {
|
|||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case "save":
|
case "save":
|
||||||
this.saveCommand(event.data);
|
this.saveCommand(event.data);
|
||||||
// this.isCommandEditorShow = false;
|
// this.isCommandEditorShow = false;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,63 +1,60 @@
|
|||||||
const routes = [{
|
const routes = [
|
||||||
path: '/configuration',
|
{
|
||||||
name: 'configuration',
|
path: "/configuration",
|
||||||
component: () =>
|
name: "configuration",
|
||||||
import ('pages/ConfigurationPage.vue')
|
component: () => import("pages/ConfigurationPage.vue"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/code',
|
path: "/code",
|
||||||
name: 'code',
|
name: "code",
|
||||||
component: () =>
|
component: () => import("pages/RunCodePage.vue"),
|
||||||
import ('pages/RunCodePage.vue')
|
},
|
||||||
},
|
{
|
||||||
{
|
path: "/newcommand",
|
||||||
path: '/newcommand',
|
name: "newcommand",
|
||||||
name: 'newcommand',
|
component: () => import("pages/ConfigurationPage.vue"),
|
||||||
component: () =>
|
},
|
||||||
import ('pages/ConfigurationPage.vue')
|
{
|
||||||
},
|
path: "/importcommand",
|
||||||
{
|
name: "importcommand",
|
||||||
path: '/:type(default|files|img|key|regex|over|window|professional)_:uid(\\w+)',
|
component: () => import("pages/ConfigurationPage.vue"),
|
||||||
name: 'command',
|
},
|
||||||
component: () =>
|
{
|
||||||
import ('pages/CommandPage.vue')
|
path: "/:type(default|files|img|key|regex|over|window|professional)_:uid(\\w+)",
|
||||||
},
|
name: "command",
|
||||||
{
|
component: () => import("pages/CommandPage.vue"),
|
||||||
path: '/panel_:tags(\\w+)',
|
},
|
||||||
name: 'panel',
|
{
|
||||||
component: () =>
|
path: "/panel_:tags(\\w+)",
|
||||||
import ('pages/ConfigurationPage.vue')
|
name: "panel",
|
||||||
},
|
component: () => import("pages/ConfigurationPage.vue"),
|
||||||
{
|
},
|
||||||
path: '/needupdate',
|
{
|
||||||
name: 'needupdate',
|
path: "/needupdate",
|
||||||
props: true,
|
name: "needupdate",
|
||||||
component: () =>
|
props: true,
|
||||||
import ('pages/updateWarningPage.vue')
|
component: () => import("pages/updateWarningPage.vue"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/',
|
path: "/",
|
||||||
name: 'loading',
|
name: "loading",
|
||||||
component: () =>
|
component: () => import("pages/LoadingPage.vue"),
|
||||||
import ('pages/LoadingPage.vue')
|
},
|
||||||
}, {
|
{
|
||||||
path: '/share',
|
path: "/share",
|
||||||
name: 'share',
|
name: "share",
|
||||||
component: () =>
|
component: () => import("pages/ShareCenterPage.vue"),
|
||||||
import ('pages/ShareCenterPage.vue')
|
},
|
||||||
},
|
{
|
||||||
{
|
path: "/feature_:featuretype(\\w+)",
|
||||||
path: '/feature_:featuretype(\\w+)',
|
name: "feature",
|
||||||
name: 'feature',
|
component: () => import("pages/FeaturesPage.vue"),
|
||||||
component: () =>
|
},
|
||||||
import ('pages/FeaturesPage.vue')
|
{
|
||||||
},
|
path: "/server",
|
||||||
{
|
name: "server",
|
||||||
path: '/server',
|
component: () => import("pages/ServerPage.vue"),
|
||||||
name: 'server',
|
},
|
||||||
component: () =>
|
];
|
||||||
import ('pages/ServerPage.vue')
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
export default routes
|
export default routes;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user