Commit 27abb0cf by luyt

feat;新增ctlr+s

1 parent 5fa4ed0b
......@@ -16,6 +16,10 @@ export default defineComponent({
type: String as PropType<string>, //转为ts类型
default: "",
},
saveCodeFn: {
type: Function,
default: () => ({}),
},
},
emits: ["update:content"],
setup(props, { emit, expose }) {
......@@ -36,6 +40,10 @@ export default defineComponent({
// val = JSON.stringify(o, null, 2); // 4 is the indent size
// editorRef.value.session.setValue(val);
};
//保存更新
const saveContent = () => {
props.saveCodeFn();
};
// 获取内容
const getCode = () => {
const content = editorRef.value.getValue();
......@@ -81,6 +89,15 @@ export default defineComponent({
editorRef.value.session.setMode("ace/mode/javascript");
editorRef.value.setFontSize(18);
editorRef.value.session.setUseWorker(false);
// editorRef.value.execCommand("find"); // 编辑内容搜索 快捷键打开->ctrl+f
editorRef.value.commands.addCommand({
name: "saveCode",
bindKey: { win: "Ctrl-s", mac: "Command-s" },
exec: function () {
saveContent();
},
// readOnly: false,
});
//菜单提示
ace.require("ace/ext/language_tools");
......
......@@ -4,6 +4,7 @@
<AceEditor
class="ace_editor"
ref="editorDom"
:saveCodeFn="saveCodeFn"
v-model:content="editorContent"
/>
</div>
......@@ -186,6 +187,13 @@ export default defineComponent({
//添加到编辑器内容区
const addToEditor = () => {
if (!editorIp.value || !editorEnv.value) {
ElMessage({
type: "error",
message: "请输入IP,环境完整",
});
return;
}
const contentObj = eval("(" + editorContent.value + ")");
editorContent.value = JSON.stringify({
...contentObj,
......
......@@ -4,6 +4,7 @@
<AceEditor
class="ace_editor"
ref="editorDom"
:saveCodeFn="saveCodeFn"
v-model:content="editorContent"
/>
</div>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!