mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-09 23:16:18 +08:00
去除保存命令时的 dom 操作
This commit is contained in:
parent
de8dad1698
commit
596afcfed3
@ -11,7 +11,7 @@
|
|||||||
<!-- 开关 -->
|
<!-- 开关 -->
|
||||||
<div class="absolute" style="z-index: 1; left: 20px; bottom: 16px">
|
<div class="absolute" style="z-index: 1; left: 20px; bottom: 16px">
|
||||||
<q-toggle
|
<q-toggle
|
||||||
v-model="isCommandActivated"
|
:model-value="isCommandActivated"
|
||||||
checked-icon="flash_on"
|
checked-icon="flash_on"
|
||||||
color="orange-6"
|
color="orange-6"
|
||||||
@click="toggleCommandActivated"
|
@click="toggleCommandActivated"
|
||||||
@ -212,7 +212,6 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
allProgrammings: this.$programmings,
|
allProgrammings: this.$programmings,
|
||||||
isCommandActivated: this.activated,
|
|
||||||
maxCmdStingLen: 8,
|
maxCmdStingLen: 8,
|
||||||
commandTypes: commandTypes,
|
commandTypes: commandTypes,
|
||||||
cmdBadgeSheet: {
|
cmdBadgeSheet: {
|
||||||
@ -267,7 +266,7 @@ export default {
|
|||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
commandInfo: Object,
|
commandInfo: Object,
|
||||||
activated: Boolean,
|
isCommandActivated: Boolean,
|
||||||
cardStyle: Object,
|
cardStyle: Object,
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@ -311,8 +310,9 @@ export default {
|
|||||||
toggleCommandActivated() {
|
toggleCommandActivated() {
|
||||||
let event = {
|
let event = {
|
||||||
data: this.commandInfo.features.code,
|
data: this.commandInfo.features.code,
|
||||||
|
type:"toggle"
|
||||||
};
|
};
|
||||||
event.type = this.isCommandActivated ? "enable" : "disable";
|
event.type = this.isCommandActivated ? "disable" : "enable";
|
||||||
this.$emit("commandChanged", event);
|
this.$emit("commandChanged", event);
|
||||||
},
|
},
|
||||||
// 移除命令
|
// 移除命令
|
||||||
|
@ -340,26 +340,16 @@ export default {
|
|||||||
let updatedData = this.$refs.menu.SaveMenuData();
|
let updatedData = this.$refs.menu.SaveMenuData();
|
||||||
if (!updatedData) return;
|
if (!updatedData) return;
|
||||||
Object.assign(this.quickcommandInfo, _.cloneDeep(updatedData));
|
Object.assign(this.quickcommandInfo, _.cloneDeep(updatedData));
|
||||||
|
let newQuickcommandInfo = _.cloneDeep(this.quickcommandInfo);
|
||||||
this.$utools.putDB(
|
this.$utools.putDB(
|
||||||
_.cloneDeep(this.quickcommandInfo),
|
newQuickcommandInfo,
|
||||||
this.$utools.DBPRE.QC + this.quickcommandInfo.features.code
|
this.$utools.DBPRE.QC + this.quickcommandInfo.features.code
|
||||||
);
|
);
|
||||||
this.$emit("editorEvent", {
|
this.$emit("editorEvent", {
|
||||||
type: "save",
|
type: "save",
|
||||||
data: _.cloneDeep(this.quickcommandInfo),
|
data: newQuickcommandInfo,
|
||||||
});
|
});
|
||||||
this.closeEditor();
|
this.closeEditor();
|
||||||
this.$nextTick(() => {
|
|
||||||
// 先点一次,如果是停用状态则被启用
|
|
||||||
// 如果是启用状态则停用
|
|
||||||
let dom = document.getElementById(this.quickcommandInfo.features.code);
|
|
||||||
dom.querySelector(".q-toggle")?.click();
|
|
||||||
// 如果之前一次点击是启用则不点
|
|
||||||
// 如果之前一次点击是停用则再点一次启用,达到刷新目的
|
|
||||||
this.$nextTick(() => {
|
|
||||||
dom.querySelector(".q-toggle[aria-checked='false']")?.click();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
// 运行
|
// 运行
|
||||||
runCurrentCommand() {
|
runCurrentCommand() {
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
v-for="commandInfo in currentTagQuickCommands"
|
v-for="commandInfo in currentTagQuickCommands"
|
||||||
:key="commandInfo.features.code"
|
:key="commandInfo.features.code"
|
||||||
:commandInfo="commandInfo"
|
:commandInfo="commandInfo"
|
||||||
:activated="
|
:isCommandActivated="
|
||||||
activatedQuickCommandFeatureCodes.includes(
|
activatedQuickCommandFeatureCodes.includes(
|
||||||
commandInfo.features.code
|
commandInfo.features.code
|
||||||
)
|
)
|
||||||
@ -537,14 +537,24 @@ export default {
|
|||||||
};
|
};
|
||||||
this.isCommandEditorShow = true;
|
this.isCommandEditorShow = true;
|
||||||
},
|
},
|
||||||
|
saveCommand(command) {
|
||||||
|
let code = command.features.code;
|
||||||
|
this.allQuickCommands[code] = command;
|
||||||
|
//无论禁用还是启用都启用
|
||||||
|
if (!this.activatedQuickCommandFeatureCodes.includes(code))
|
||||||
|
this.activatedQuickCommandFeatureCodes.push(code);
|
||||||
|
// 先删除再添加,强制刷新
|
||||||
|
this.$utools.whole.removeFeature(code);
|
||||||
|
this.$utools.whole.setFeature(command.features);
|
||||||
|
this.locateToCommand(command.tags, code);
|
||||||
|
},
|
||||||
editorEvent(event) {
|
editorEvent(event) {
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case "close":
|
case "close":
|
||||||
this.isCommandEditorShow = false;
|
this.isCommandEditorShow = false;
|
||||||
return;
|
return;
|
||||||
case "save":
|
case "save":
|
||||||
this.allQuickCommands[event.data.features.code] = event.data;
|
this.saveCommand(event.data);
|
||||||
this.locateToCommand(event.data.tags, event.data.features.code);
|
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user