feat: 文本编辑器全屏高度处理 (#5760)

pull/5761/head
5 months ago committed by GitHub
parent c0b6a06fb7
commit bcfbbb656a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -10,7 +10,7 @@
:fullscreen="isFullscreen" :fullscreen="isFullscreen"
> >
<template #header> <template #header>
<div class="flex items-center justify-between"> <div ref="dialogHeader" class="flex items-center justify-between">
<span>{{ $t('commons.button.edit') + ' - ' + form.path }}</span> <span>{{ $t('commons.button.edit') + ' - ' + form.path }}</span>
<el-space alignment="center" :size="1" class="dialog-header-icon"> <el-space alignment="center" :size="1" class="dialog-header-icon">
<el-tooltip :content="loadTooltip()" placement="top"> <el-tooltip :content="loadTooltip()" placement="top">
@ -29,6 +29,7 @@
</el-space> </el-space>
</div> </div>
</template> </template>
<div ref="dialogForm">
<el-form :inline="true" :model="config" class="mt-1.5"> <el-form :inline="true" :model="config" class="mt-1.5">
<el-form-item :label="$t('file.theme')"> <el-form-item :label="$t('file.theme')">
<el-select v-model="config.theme" @change="changeTheme()" class="p-w-200"> <el-select v-model="config.theme" @change="changeTheme()" class="p-w-200">
@ -37,7 +38,12 @@
</el-form-item> </el-form-item>
<el-form-item :label="$t('file.language')"> <el-form-item :label="$t('file.language')">
<el-select v-model="config.language" @change="changeLanguage()" class="!w-32"> <el-select v-model="config.language" @change="changeLanguage()" class="!w-32">
<el-option v-for="lang in Languages" :key="lang.label" :value="lang.label" :label="lang.label" /> <el-option
v-for="lang in Languages"
:key="lang.label"
:value="lang.label"
:label="lang.label"
/>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item :label="$t('file.eol')"> <el-form-item :label="$t('file.eol')">
@ -52,6 +58,7 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-form> </el-form>
</div>
<div v-loading="loading"> <div v-loading="loading">
<div class="flex"> <div class="flex">
<div class="sm:w-48 w-1/3 monaco-editor-background tree-container" v-if="isShow"> <div class="sm:w-48 w-1/3 monaco-editor-background tree-container" v-if="isShow">
@ -139,10 +146,10 @@
</div> </div>
</div> </div>
<template #footer> <template #footer>
<span class="dialog-footer"> <div class="dialog-footer" ref="dialogFooter">
<el-button @click="handleReset">{{ $t('commons.button.reset') }}</el-button> <el-button @click="handleReset">{{ $t('commons.button.reset') }}</el-button>
<el-button type="primary" @click="saveContent()">{{ $t('commons.button.confirm') }}</el-button> <el-button type="primary" @click="saveContent()">{{ $t('commons.button.confirm') }}</el-button>
</span> </div>
</template> </template>
</el-dialog> </el-dialog>
</template> </template>
@ -226,13 +233,15 @@ const baseDir = ref();
const treeData = ref([]); const treeData = ref([]);
const codeBox = ref(); const codeBox = ref();
const defaultHeight = ref(55); const defaultHeight = ref(55);
const fullScreenHeight = ref(80);
const treeHeight = ref(0); const treeHeight = ref(0);
const codeHeight = ref('55vh'); const codeHeight = ref('55vh');
const codeReq = reactive({ path: '', expand: false, page: 1, pageSize: 100 }); const codeReq = reactive({ path: '', expand: false, page: 1, pageSize: 100 });
const isShow = ref(true); const isShow = ref(true);
const isEdit = ref(false); const isEdit = ref(false);
const oldFileContent = ref(''); const oldFileContent = ref('');
const dialogHeader = ref(null);
const dialogForm = ref(null);
const dialogFooter = ref(null);
const toggleShow = () => { const toggleShow = () => {
isShow.value = !isShow.value; isShow.value = !isShow.value;
@ -340,8 +349,14 @@ onMounted(() => {
const updateHeights = () => { const updateHeights = () => {
const vh = window.innerHeight / 100; const vh = window.innerHeight / 100;
if (isFullscreen.value) { if (isFullscreen.value) {
treeHeight.value = fullScreenHeight.value * vh - 31; let paddingHeight = 75;
codeHeight.value = `${fullScreenHeight.value}vh`; const headerHeight = dialogHeader.value.offsetHeight;
const formHeight = dialogForm.value.offsetHeight;
const footerHeight = dialogFooter.value.offsetHeight;
treeHeight.value = window.innerHeight - headerHeight - formHeight - footerHeight - paddingHeight - 31;
codeHeight.value = `${
((window.innerHeight - headerHeight - formHeight - footerHeight - paddingHeight) / window.innerHeight) * 100
}vh`;
} else { } else {
treeHeight.value = defaultHeight.value * vh - 31; treeHeight.value = defaultHeight.value * vh - 31;
codeHeight.value = `${defaultHeight.value}vh`; codeHeight.value = `${defaultHeight.value}vh`;

Loading…
Cancel
Save