AI助手边栏改用固定宽度而不是百分比

This commit is contained in:
fofolee 2025-02-22 09:59:46 +08:00
parent 77709b39d6
commit cfb3ab32fe
2 changed files with 16 additions and 9 deletions

View File

@ -261,6 +261,7 @@ export default defineComponent({
const languageMap = { const languageMap = {
quickcommand: "NodeJS", quickcommand: "NodeJS",
javascript: "NodeJS", javascript: "NodeJS",
webjavascript: "前端JavaScript",
cmd: "windows 批处理脚本", cmd: "windows 批处理脚本",
shell: "liunx shell脚本", shell: "liunx shell脚本",
}; };

View File

@ -2,7 +2,9 @@
<div class="code-editor" :style="{ height: height }"> <div class="code-editor" :style="{ height: height }">
<div <div
class="editor-container" class="editor-container"
:class="{ 'with-assistant': showAIAssistant }" :style="{
width: showAIAssistant ? `calc(100% - ${aiAssistantWidth}px)` : '100%',
}"
> >
<div ref="editorContainer" class="monaco-container" /> <div ref="editorContainer" class="monaco-container" />
<div class="placeholder-wrapper" v-show="showPlaceholder"> <div class="placeholder-wrapper" v-show="showPlaceholder">
@ -15,8 +17,9 @@
<!-- AI助手侧边栏 --> <!-- AI助手侧边栏 -->
<Transition name="slide"> <Transition name="slide">
<AIAssistantSideBar <AIAssistantSideBar
v-if="showAIAssistant" v-if="showAIAssistant && hasAIAssistant"
class="ai-assistant-panel" class="ai-assistant-panel"
:style="{ width: aiAssistantWidth + 'px' }"
:code="modelValue" :code="modelValue"
:language="language" :language="language"
@close="toggleAIAssistant(false)" @close="toggleAIAssistant(false)"
@ -25,7 +28,7 @@
</Transition> </Transition>
<!-- AI助手按钮 --> <!-- AI助手按钮 -->
<div class="ai-button-wrapper"> <div class="ai-button-wrapper" v-if="hasAIAssistant">
<q-btn <q-btn
round round
dense dense
@ -110,6 +113,14 @@ export default defineComponent({
type: Object, type: Object,
default: () => ({}), default: () => ({}),
}, },
hasAIAssistant: {
type: Boolean,
default: true,
},
aiAssistantWidth: {
type: Number,
default: 320,
},
}, },
emits: [ emits: [
"update:modelValue", "update:modelValue",
@ -421,19 +432,14 @@ export default defineComponent({
transition: width 0.3s ease; transition: width 0.3s ease;
} }
.editor-container.with-assistant {
width: 55%;
}
.monaco-container { .monaco-container {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
.ai-assistant-panel { .ai-assistant-panel {
width: 45%;
height: 100%; height: 100%;
transition: transform 0.3s ease; transition: width 0.3s ease;
} }
.slide-enter-active, .slide-enter-active,