fix
This commit is contained in:
@@ -8,13 +8,15 @@
|
|||||||
:autosize="{ minRows: 3, maxRows: 8 }"
|
:autosize="{ minRows: 3, maxRows: 8 }"
|
||||||
placeholder="粘贴你发给外部 AI 的提示词..."
|
placeholder="粘贴你发给外部 AI 的提示词..."
|
||||||
/>
|
/>
|
||||||
<div class="field-label" style="margin-top: 12px">AI 代码</div>
|
<div class="code-field">
|
||||||
|
<div class="field-label" style="margin-top: 12px">完整的代码</div>
|
||||||
<n-input
|
<n-input
|
||||||
v-model:value="rawCode"
|
v-model:value="rawCode"
|
||||||
type="textarea"
|
type="textarea"
|
||||||
:autosize="{ minRows: 6, maxRows: 16 }"
|
class="code-input"
|
||||||
placeholder="粘贴外部 AI 返回的完整 HTML 代码..."
|
placeholder="粘贴完整的前端代码..."
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
<div v-if="splitResult" class="split-result">
|
<div v-if="splitResult" class="split-result">
|
||||||
<n-tag size="small" type="success"
|
<n-tag size="small" type="success"
|
||||||
>HTML · {{ splitResult.html.length }} 字符</n-tag
|
>HTML · {{ splitResult.html.length }} 字符</n-tag
|
||||||
@@ -128,6 +130,29 @@ async function submit() {
|
|||||||
min-height: 0;
|
min-height: 0;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.code-field {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.code-input {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.code-input :deep(.n-input__textarea) {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.code-input :deep(.n-input__textarea-el) {
|
||||||
|
height: 100%;
|
||||||
|
resize: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.field-label {
|
.field-label {
|
||||||
|
|||||||
@@ -18,6 +18,12 @@ const styleTheme = EditorView.baseTheme({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const bgColors: Record<string, string> = {
|
||||||
|
html: "#fff6f3",
|
||||||
|
css: "#f3f6ff",
|
||||||
|
js: "#fffdf0",
|
||||||
|
}
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
language?: "html" | "css" | "js"
|
language?: "html" | "css" | "js"
|
||||||
fontSize?: number
|
fontSize?: number
|
||||||
@@ -35,12 +41,22 @@ const lang = computed(() => {
|
|||||||
if (props.language === "css") return css()
|
if (props.language === "css") return css()
|
||||||
return javascript()
|
return javascript()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const bgTheme = computed(() => {
|
||||||
|
const bg = bgColors[props.language] ?? "#ffffff"
|
||||||
|
return EditorView.theme({
|
||||||
|
"&": { backgroundColor: bg },
|
||||||
|
".cm-gutters": { backgroundColor: bg },
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
const extensions = computed(() => [styleTheme, bgTheme.value, lang.value])
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<Codemirror
|
<Codemirror
|
||||||
v-model="code"
|
v-model="code"
|
||||||
indentWithTab
|
indentWithTab
|
||||||
:extensions="[styleTheme, lang]"
|
:extensions="extensions"
|
||||||
:tabSize="4"
|
:tabSize="4"
|
||||||
:style="{ height: '100%', fontSize: props.fontSize + 'px' }"
|
:style="{ height: '100%', fontSize: props.fontSize + 'px' }"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<div class="editors-root">
|
||||||
<n-tabs
|
<n-tabs
|
||||||
:value="tab"
|
:value="tab"
|
||||||
|
:class="`tab-active-${tab}`"
|
||||||
pane-class="pane"
|
pane-class="pane"
|
||||||
style="height: 100%"
|
style="height: 100%"
|
||||||
type="card"
|
type="card"
|
||||||
@@ -73,6 +75,7 @@
|
|||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</n-tabs>
|
</n-tabs>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { Icon } from "@iconify/vue"
|
import { Icon } from "@iconify/vue"
|
||||||
@@ -185,4 +188,28 @@ async function formatAndSubmit() {
|
|||||||
.label {
|
.label {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:deep(.n-tabs-nav .n-tabs-tab[data-name="html"]) {
|
||||||
|
background-color: #fff6f3 !important;
|
||||||
|
}
|
||||||
|
:deep(.n-tabs-nav .n-tabs-tab[data-name="css"]) {
|
||||||
|
background-color: #f3f6ff !important;
|
||||||
|
}
|
||||||
|
:deep(.n-tabs-nav .n-tabs-tab[data-name="js"]) {
|
||||||
|
background-color: #fffdf0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.editors-root {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.tab-active-html .n-tab-pane) {
|
||||||
|
background-color: #fff6f3;
|
||||||
|
}
|
||||||
|
:deep(.tab-active-css .n-tab-pane) {
|
||||||
|
background-color: #f3f6ff;
|
||||||
|
}
|
||||||
|
:deep(.tab-active-js .n-tab-pane) {
|
||||||
|
background-color: #fffdf0;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user