设计器:Designer.cs 标签页默认隐藏

和 VS 里藏在窗体文件下面一样,平时不显示;在设计器里点"查看生成的代码"或点到其中的
编译错误时才临时出现,切走后收起。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
xuyueandClaude Opus 5.5 committed 2026-10-22 18:20:41 +08:00
1 parent 400814d1f6
commit a3eb563b70
2 files changed
+16 -2

No files matched your search

+9
View File
@@ -38,6 +38,8 @@ const emit = defineEmits<{
update: [designerText: string, codeText?: string] update: [designerText: string, codeText?: string]
/** 跳到窗体代码文件的某一行 */ /** 跳到窗体代码文件的某一行 */
openCode: [line: number] openCode: [line: number]
/** 查看设计器生成的 Designer.cs */
openDesignerFile: []
undo: [] undo: []
redo: [] redo: []
}>() }>()
@@ -431,6 +433,9 @@ const noop = () => {}
<button :disabled="!canUndo" title="撤销(Ctrl+Z)" @click="emit('undo')">↶ 撤销</button> <button :disabled="!canUndo" title="撤销(Ctrl+Z)" @click="emit('undo')">↶ 撤销</button>
<button :disabled="!canRedo" title="重做(Ctrl+Y)" @click="emit('redo')">↷ 重做</button> <button :disabled="!canRedo" title="重做(Ctrl+Y)" @click="emit('redo')">↷ 重做</button>
<span class="tips">拖动工具箱里的控件到窗体上;双击控件生成事件处理方法;Delete 删除</span> <span class="tips">拖动工具箱里的控件到窗体上;双击控件生成事件处理方法;Delete 删除</span>
<button class="view-code" title="设计器根据窗体上的控件自动生成的代码(Designer.cs)" @click="emit('openDesignerFile')">
查看生成的代码
</button>
</div> </div>
<div class="window" :class="{ selected: selected === '' }"> <div class="window" :class="{ selected: selected === '' }">
<div class="titlebar" @pointerdown="selected = ''"> <div class="titlebar" @pointerdown="selected = ''">
@@ -581,6 +586,10 @@ const noop = () => {}
cursor: default; cursor: default;
} }
.view-code {
margin-left: auto;
}
.tips { .tips {
min-width: 0; min-width: 0;
margin-left: 8px; margin-left: 8px;
+7 -2
View File
@@ -35,14 +35,18 @@ const forms = computed(() => {
// 启动窗体排在最前 // 启动窗体排在最前
.sort((a, b) => Number(b.code === `${startup}.cs`) - Number(a.code === `${startup}.cs`)) .sort((a, b) => Number(b.code === `${startup}.cs`) - Number(a.code === `${startup}.cs`))
}) })
/** 标签页按窗体分组:每个窗体依次是 [设计]、代码、Designer.cs;其他文件(Program.cs 等)放最后 */ /**
* 标签页按窗体分组:每个窗体依次是 [设计]、代码;其他文件(Program.cs 等)放最后。
* Designer.cs 由设计器生成,平时不显示(和 VS 里藏在窗体文件下面一样),
* 在设计器里点"查看生成的代码"或点到其中的编译错误时才临时出现,切走后收起。
*/
const tabs = computed(() => { const tabs = computed(() => {
const grouped = new Set(forms.value.flatMap((f) => [f.code, f.designer])) const grouped = new Set(forms.value.flatMap((f) => [f.code, f.designer]))
return [ return [
...forms.value.flatMap((f) => [ ...forms.value.flatMap((f) => [
{ name: f.tab, label: `${f.code} [设计]` }, { name: f.tab, label: `${f.code} [设计]` },
{ name: f.code, label: f.code }, { name: f.code, label: f.code },
{ name: f.designer, label: f.designer }, ...(activeTab.value === f.designer ? [{ name: f.designer, label: f.designer }] : []),
]), ]),
...files.value.filter((f) => !grouped.has(f.path)).map((f) => ({ name: f.path, label: f.path })), ...files.value.filter((f) => !grouped.has(f.path)).map((f) => ({ name: f.path, label: f.path })),
] ]
@@ -308,6 +312,7 @@ function run() {
@undo="designerHistory.undo(activeForm.designer, activeForm.code)" @undo="designerHistory.undo(activeForm.designer, activeForm.code)"
@redo="designerHistory.redo(activeForm.designer, activeForm.code)" @redo="designerHistory.redo(activeForm.designer, activeForm.code)"
@open-code="openCode" @open-code="openCode"
@open-designer-file="activeTab = activeForm.designer"
/> />
<CodeEditor <CodeEditor
v-show="!activeForm" v-show="!activeForm"