退出时保存光标位置

This commit is contained in:
fofolee 2022-04-13 16:49:47 +08:00
parent 8f479fa545
commit d659fdcc88
10 changed files with 27 additions and 23 deletions

View File

@ -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>

View File

@ -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);

View File

@ -67,9 +67,6 @@ export default {
*/
action: Object,
},
mounted() {
window.runResult = this;
},
computed: {
fromUtools() {
return this.action.type === "input";

View File

@ -275,9 +275,6 @@ export default {
quickcommandInfo: Object,
canCommandSave: Boolean,
},
mounted() {
window.CommandSideBar = this;
},
computed: {
specialVarsOptions() {
let x = Object.values(specialVars).filter(

View File

@ -213,9 +213,6 @@ export default {
return this.configurationPage.activatedQuickCommandFeatureCodes.length;
},
},
mounted() {
window.configurationMenu = this;
},
props: {
isTagStared: Boolean,
currentTag: String,

View File

@ -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(

View File

@ -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;

View File

@ -19,7 +19,6 @@ export default {
};
},
mounted() {
window.commandPage = this;
this.runCurrentCommand();
},
computed: {

View File

@ -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

View File

@ -1,6 +1,6 @@
<template>
<div>
<CommandEditor :action="action"></CommandEditor>
<CommandEditor ref="commandEditor" :action="action"></CommandEditor>
</div>
</template>