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