11 changed files with 188 additions and 55 deletions
@ -0,0 +1,35 @@ |
|||||
|
<template> |
||||
|
<div class="adjust-line" ref="adjustLineEL"></div> |
||||
|
</template> |
||||
|
|
||||
|
<script lang="ts" setup> |
||||
|
import { onMounted, ref } from "vue" |
||||
|
const adjustLineEL = ref<HTMLElement>() |
||||
|
|
||||
|
onMounted(() => { |
||||
|
if (adjustLineEL.value) { |
||||
|
let el = adjustLineEL.value as HTMLElement |
||||
|
let container = el.parentElement as HTMLElement |
||||
|
let parentContainer = el.parentElement!.parentElement as HTMLElement |
||||
|
el.onmousedown = function (e) { |
||||
|
let owidth = parentContainer.clientWidth |
||||
|
let width = container.clientWidth |
||||
|
let startX = e.clientX |
||||
|
document.onmousemove = function (e) { |
||||
|
let nowX = e.clientX |
||||
|
let w = width + nowX - startX |
||||
|
if (Math.abs(w - owidth / 2) <= 5) { |
||||
|
w = owidth / 2 |
||||
|
} |
||||
|
parentContainer.style.pointerEvents = "none" |
||||
|
container.style.width = (w / owidth) * 100 + "%" |
||||
|
} |
||||
|
document.onmouseup = function (e) { |
||||
|
document.onmousemove = null |
||||
|
document.onmouseup = null |
||||
|
parentContainer.style.pointerEvents = "auto" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
|
</script> |
@ -1,9 +1,13 @@ |
|||||
<template> |
<template> |
||||
<div class="font-bold text-red-500"> |
<div class="font-bold text-red-500 h-1/1"> |
||||
<MonacoEditor></MonacoEditor> |
<div class="flex align-middle flex-col h-1/1"> |
||||
|
<MonacoEditor class="flex-1 !h-0"></MonacoEditor> |
||||
|
</div> |
||||
</div> |
</div> |
||||
</template> |
</template> |
||||
|
|
||||
<script lang="ts" setup> |
<script lang="ts" setup> |
||||
import MonacoEditor from '@/pagesUI/editor/editor.vue'; |
import MonacoEditor from "@/pagesUI/editor/editor.vue" |
||||
|
|
||||
|
|
||||
</script> |
</script> |
@ -1,20 +0,0 @@ |
|||||
import { useDefineRoutes, useRouteConfig } from "@/hook/useDefineRoute" |
|
||||
import { LAYOUT } from "@/router/constant" |
|
||||
|
|
||||
export default useDefineRoutes([ |
|
||||
{ |
|
||||
path: '', |
|
||||
redirect: '/home', |
|
||||
component: LAYOUT, |
|
||||
children: [ |
|
||||
{ |
|
||||
path: 'home', |
|
||||
name: "HOME", |
|
||||
component: ()=>import("@/pages/Home/Home.vue"), |
|
||||
meta: { |
|
||||
title: "HOME" |
|
||||
} |
|
||||
} |
|
||||
] |
|
||||
} |
|
||||
]) |
|
@ -0,0 +1,16 @@ |
|||||
|
import { reactive } from "vue" |
||||
|
|
||||
|
interface IFile{ |
||||
|
filename: "", |
||||
|
code: "" |
||||
|
} |
||||
|
|
||||
|
interface IData{ |
||||
|
filelist: IFile[] |
||||
|
} |
||||
|
|
||||
|
const data = reactive<IData>({ |
||||
|
filelist: [] |
||||
|
}) |
||||
|
|
||||
|
export default data |
@ -1,44 +1,101 @@ |
|||||
<template> |
<template> |
||||
<div class="ui-monaco-editor" ref="monacoEL"> |
<div class="ui-editor-wrapper"> |
||||
|
<Files></Files> |
||||
|
<div class="ui-editor"> |
||||
|
<div class="ui-monaco-editor__wrapper"> |
||||
|
<div class="ui-monaco-editor" ref="monacoEL"></div> |
||||
|
<div class="adjust-line" ref="adjustLineEL"></div> |
||||
|
<img class="ui-monaco-logo" src="/static/logo.png" alt="" /> |
||||
|
<AdjustWidth></AdjustWidth> |
||||
|
</div> |
||||
|
<div class="ui-preview">asdsa</div> |
||||
|
</div> |
||||
</div> |
</div> |
||||
</template> |
</template> |
||||
|
|
||||
<script lang="ts" setup> |
<script lang="ts" setup> |
||||
import 'monaco-editor/esm/vs/editor/editor.all.js'; |
import Files from "./files.vue" |
||||
import 'monaco-editor/esm/vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp.js'; |
|
||||
|
|
||||
import * as monaco from "monaco-editor/esm/vs/editor/editor.api" |
import * as monaco from "monaco-editor/esm/vs/editor/editor.api" |
||||
import { onMounted, ref } from "vue"; |
import "monaco-editor/esm/vs/editor/editor.main" |
||||
|
|
||||
|
import { onBeforeMount, onBeforeUnmount, onMounted, ref } from "vue" |
||||
import "./work" |
import "./work" |
||||
|
|
||||
let editor: monaco.editor.IStandaloneCodeEditor; |
let editor: monaco.editor.IStandaloneCodeEditor |
||||
const monacoEL = ref() |
const monacoEL = ref<HTMLElement>() |
||||
|
|
||||
onMounted(()=>{ |
onMounted(() => { |
||||
|
if (monacoEL.value) { |
||||
|
// @ts-ignore |
||||
|
window.monaco = monaco |
||||
// https://www.typescriptlang.org/dev/typescript-vfs/ |
// https://www.typescriptlang.org/dev/typescript-vfs/ |
||||
editor = monaco.editor.create(monacoEL.value, { |
editor = monaco.editor.create(monacoEL.value, { |
||||
value: "function hello() {\n\talert('Hello world!');\n}", |
|
||||
language: 'javascript', |
|
||||
automaticLayout: true, |
automaticLayout: true, |
||||
// folding: false, |
}) |
||||
// theme: 'vs-dark', |
let model: monaco.editor.ITextModel = monaco.editor.createModel(`function hello() {\n\talert('Hello world!');\n}`, "javascript") |
||||
// lineNumbers: 'off', |
editor.setModel(model) |
||||
// minimap: { |
} |
||||
// enabled: false |
}) |
||||
// } |
onBeforeUnmount(() => { |
||||
}); |
if (editor) { |
||||
window.onresize = () => { |
// @ts-ignore |
||||
console.log('Window resize'); |
window.monaco = undefined |
||||
editor.layout({} as monaco.editor.IDimension); |
editor.dispose() |
||||
} |
} |
||||
}) |
}) |
||||
|
|
||||
</script> |
</script> |
||||
|
|
||||
<style scoped lang="less"> |
<style scoped lang="less"> |
||||
.ui-monaco-editor{ |
.ui-editor-wrapper{ |
||||
|
display: flex; |
||||
|
flex-direction: column; |
||||
|
} |
||||
|
.ui-editor { |
||||
|
flex: 1; |
||||
|
height: 0; |
||||
|
display: flex; |
||||
|
align-items: center; |
||||
|
justify-content: center; |
||||
width: 100%; |
width: 100%; |
||||
height: 500px; |
height: 100%; |
||||
|
.ui-monaco-editor__wrapper { |
||||
|
width: 50%; |
||||
|
height: 100%; |
||||
|
position: relative; |
||||
|
.ui-monaco-logo { |
||||
|
position: absolute; |
||||
|
left: 50%; |
||||
|
top: 50%; |
||||
|
transform: translate(-50%, -50%); |
||||
|
pointer-events: none; |
||||
|
opacity: 0.3; |
||||
|
} |
||||
|
.ui-monaco-editor { |
||||
|
width: 100%; |
||||
|
height: 100%; |
||||
|
overflow: hidden; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
.ui-preview { |
||||
|
width: 0; |
||||
|
height: 100%; |
||||
|
flex: 1; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
.adjust-line { |
||||
|
position: absolute; |
||||
|
z-index: 99; |
||||
|
right: -2px; |
||||
|
top: 0; |
||||
|
bottom: 0; |
||||
|
width: 4px; |
||||
|
cursor: w-resize; |
||||
|
transition: background-color 0.5s ease; |
||||
|
&:hover, |
||||
|
&:active { |
||||
|
background: red; |
||||
|
} |
||||
} |
} |
||||
</style> |
</style> |
@ -0,0 +1,13 @@ |
|||||
|
<template> |
||||
|
<form action="/" :onSubmit="onSubmit"> |
||||
|
<input type="text" placeholder="请输入文件名" /> |
||||
|
<input type="submit" /> |
||||
|
</form> |
||||
|
</template> |
||||
|
|
||||
|
<script lang="ts" setup> |
||||
|
function onSubmit(e: Event) { |
||||
|
e.preventDefault() |
||||
|
console.log(123) |
||||
|
} |
||||
|
</script> |
@ -0,0 +1,19 @@ |
|||||
|
import { LAYOUT } from "@/router/constant" |
||||
|
import { RouteRecordRaw } from "vue-router" |
||||
|
|
||||
|
export default { |
||||
|
path: "", |
||||
|
redirect: "/home", |
||||
|
component: LAYOUT, |
||||
|
children: [ |
||||
|
{ |
||||
|
path: "home", |
||||
|
name: "HOME", |
||||
|
component: () => import("@/pages/Home/Home.vue"), |
||||
|
meta: { |
||||
|
hideSlideMenu: true, |
||||
|
title: "HOME" |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} as RouteRecordRaw |
Loading…
Reference in new issue