mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-08 05:55:34 +08:00
退出时保存光标位置
This commit is contained in:
parent
8f479fa545
commit
d659fdcc88
20
src/App.vue
20
src/App.vue
@ -21,6 +21,7 @@ export default defineComponent({
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
window.root = this;
|
||||
window.utools = window.getuToolsLite();
|
||||
// 版本检测
|
||||
const requiredVersion = "2.6.1";
|
||||
@ -44,17 +45,26 @@ export default defineComponent({
|
||||
});
|
||||
// 退出插件
|
||||
utools.onPluginOut(() => {
|
||||
// 保存偏好
|
||||
this.saveProfile();
|
||||
// 切到空路由
|
||||
this.$router.push("loading");
|
||||
// 清空临时数据
|
||||
window.temporaryStoreSoldOut();
|
||||
// 保存偏好
|
||||
this.$utools.putDB(
|
||||
_.cloneDeep(this.$profile),
|
||||
this.$utools.DBPRE.CFG + "preferences"
|
||||
);
|
||||
});
|
||||
},
|
||||
saveProfile() {
|
||||
let commandEditor = this.$refs.view.$refs.commandEditor;
|
||||
if (commandEditor && commandEditor.action.type !== "edit") {
|
||||
let command = _.cloneDeep(commandEditor.quickcommandInfo);
|
||||
command.cursorPosition = commandEditor.$refs.editor.getCursorPosition();
|
||||
this.$profile.codeHistory[commandEditor.action.type] = command;
|
||||
}
|
||||
this.$utools.putDB(
|
||||
_.cloneDeep(this.$profile),
|
||||
this.$utools.DBPRE.CFG + "preferences"
|
||||
);
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
@ -209,22 +209,20 @@ export default {
|
||||
created() {},
|
||||
methods: {
|
||||
init() {
|
||||
window.commandEditor = this;
|
||||
let quickCommandInfo =
|
||||
this.action.type === "run"
|
||||
this.action.type !== "edit"
|
||||
? this.$utools.getDB(this.$utools.DBPRE.CFG + "preferences")
|
||||
?.codeHistory
|
||||
?.codeHistory[this.action.type]
|
||||
: this.action.data;
|
||||
_.merge(this.quickcommandInfo, quickCommandInfo);
|
||||
// monaco 相关
|
||||
this.$refs.editor.setEditorValue(this.quickcommandInfo.cmd);
|
||||
this.setLanguage(this.quickcommandInfo.program);
|
||||
this.$refs.editor.setCursorPosition(this.quickcommandInfo.cursorPosition)
|
||||
// 默认命令不可编辑
|
||||
if (this.quickcommandInfo.tags?.includes("默认") && !utools.isDev()) {
|
||||
this.canCommandSave = false;
|
||||
}
|
||||
if (this.action.type === "run")
|
||||
this.$profile.codeHistory = this.quickcommandInfo;
|
||||
},
|
||||
programChanged(value) {
|
||||
this.setLanguage(value);
|
||||
|
@ -67,9 +67,6 @@ export default {
|
||||
*/
|
||||
action: Object,
|
||||
},
|
||||
mounted() {
|
||||
window.runResult = this;
|
||||
},
|
||||
computed: {
|
||||
fromUtools() {
|
||||
return this.action.type === "input";
|
||||
|
@ -275,9 +275,6 @@ export default {
|
||||
quickcommandInfo: Object,
|
||||
canCommandSave: Boolean,
|
||||
},
|
||||
mounted() {
|
||||
window.CommandSideBar = this;
|
||||
},
|
||||
computed: {
|
||||
specialVarsOptions() {
|
||||
let x = Object.values(specialVars).filter(
|
||||
|
@ -213,9 +213,6 @@ export default {
|
||||
return this.configurationPage.activatedQuickCommandFeatureCodes.length;
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
window.configurationMenu = this;
|
||||
},
|
||||
props: {
|
||||
isTagStared: Boolean,
|
||||
currentTag: String,
|
||||
|
@ -176,6 +176,13 @@ export default {
|
||||
setEditorLanguage(language) {
|
||||
monaco.editor.setModelLanguage(this.rawEditor.getModel(), language);
|
||||
},
|
||||
getCursorPosition() {
|
||||
return this.rawEditor.getPosition();
|
||||
},
|
||||
setCursorPosition(pos) {
|
||||
if (!pos) return;
|
||||
this.rawEditor.setPosition(pos);
|
||||
},
|
||||
repacleEditorSelection(text) {
|
||||
var selection = this.rawEditor.getSelection();
|
||||
var range = new monaco.Range(
|
||||
|
@ -76,7 +76,6 @@ export default {
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
window.SelectList = this;
|
||||
window.temporaryStore.updateSelectList = (opt, id) => {
|
||||
if (typeof id === "undefined") this.items.push(opt);
|
||||
else this.items[id] = opt;
|
||||
|
@ -19,7 +19,6 @@ export default {
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
window.commandPage = this;
|
||||
this.runCurrentCommand();
|
||||
},
|
||||
computed: {
|
||||
|
@ -181,6 +181,7 @@
|
||||
>
|
||||
<q-card>
|
||||
<CommandEditor
|
||||
ref="commandEditor"
|
||||
:action="commandEditorAction"
|
||||
@editorEvent="editorEvent"
|
||||
></CommandEditor>
|
||||
@ -303,7 +304,6 @@ export default {
|
||||
methods: {
|
||||
// 初始化
|
||||
initPage() {
|
||||
window.configuration = this;
|
||||
// 已启用的 features
|
||||
let activatedFeatures = this.getActivatedFeatures();
|
||||
// 已启用的命令的 featureCode
|
||||
|
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div>
|
||||
<CommandEditor :action="action"></CommandEditor>
|
||||
<CommandEditor ref="commandEditor" :action="action"></CommandEditor>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user