perf: use relative position for entry editor to toggle fullscreen

This commit is contained in:
Lykin 2023-11-18 01:30:26 +08:00
parent 2a57248228
commit aafa0c5432
6 changed files with 83 additions and 75 deletions

View File

@ -218,11 +218,18 @@ const onSave = () => {
<style lang="scss" scoped> <style lang="scss" scoped>
.entry-editor { .entry-editor {
padding-left: 2px; padding-left: 2px;
box-sizing: border-box;
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
z-index: 100;
.editor-content { .editor-content {
&-item { &-item {
&:not(:last-child) { &:not(:last-child) {
margin-bottom: 18px; margin-bottom: 16px;
} }
&-label { &-label {

View File

@ -89,9 +89,6 @@ const inEdit = computed(() => {
return currentEditRow.no > 0 return currentEditRow.no > 0
}) })
const fullEdit = ref(false) const fullEdit = ref(false)
const inFullEdit = computed(() => {
return inEdit.value && fullEdit.value
})
const tableRef = ref(null) const tableRef = ref(null)
const fieldFilterOption = ref(null) const fieldFilterOption = ref(null)
@ -337,7 +334,6 @@ defineExpose({
<template> <template>
<div class="content-wrapper flex-box-v"> <div class="content-wrapper flex-box-v">
<content-toolbar <content-toolbar
v-show="!inFullEdit"
:db="props.db" :db="props.db"
:key-code="props.keyCode" :key-code="props.keyCode"
:key-path="props.keyPath" :key-path="props.keyPath"
@ -349,7 +345,7 @@ defineExpose({
@delete="emit('delete')" @delete="emit('delete')"
@reload="emit('reload')" @reload="emit('reload')"
@rename="emit('rename')" /> @rename="emit('rename')" />
<div v-show="!inFullEdit" class="tb2 value-item-part flex-box-h"> <div class="tb2 value-item-part flex-box-h">
<div class="flex-box-h"> <div class="flex-box-h">
<n-input-group> <n-input-group>
<n-select <n-select
@ -393,7 +389,6 @@ defineExpose({
<div id="content-table" class="value-wrapper value-item-part flex-box-h flex-item-expand"> <div id="content-table" class="value-wrapper value-item-part flex-box-h flex-item-expand">
<!-- table --> <!-- table -->
<n-data-table <n-data-table
v-show="!inFullEdit"
ref="tableRef" ref="tableRef"
:bordered="false" :bordered="false"
:bottom-bordered="false" :bottom-bordered="false"
@ -412,8 +407,12 @@ defineExpose({
@update:filters="onUpdateFilter" /> @update:filters="onUpdateFilter" />
<!-- edit pane --> <!-- edit pane -->
<content-entry-editor <div
v-show="inEdit" v-show="inEdit"
:style="{ position: fullEdit ? 'static' : 'relative' }"
class="entry-editor-container flex-item-expand"
style="width: 100%">
<content-entry-editor
v-model:fullscreen="fullEdit" v-model:fullscreen="fullEdit"
:decode="currentEditRow.decode" :decode="currentEditRow.decode"
:field="currentEditRow.key" :field="currentEditRow.key"
@ -426,6 +425,7 @@ defineExpose({
@close="resetEdit" @close="resetEdit"
@save="saveEdit" /> @save="saveEdit" />
</div> </div>
</div>
<div class="value-footer flex-box-h"> <div class="value-footer flex-box-h">
<n-text v-if="!isNaN(props.length)">{{ $t('interface.entries') }}: {{ entries }}</n-text> <n-text v-if="!isNaN(props.length)">{{ $t('interface.entries') }}: {{ entries }}</n-text>
<n-divider v-if="!isNaN(props.length)" vertical /> <n-divider v-if="!isNaN(props.length)" vertical />

View File

@ -75,9 +75,6 @@ const inEdit = computed(() => {
return currentEditRow.no > 0 return currentEditRow.no > 0
}) })
const fullEdit = ref(false) const fullEdit = ref(false)
const inFullEdit = computed(() => {
return inEdit.value && fullEdit.value
})
const displayCode = computed(() => { const displayCode = computed(() => {
return props.format === formatTypes.JSON return props.format === formatTypes.JSON
@ -280,7 +277,6 @@ defineExpose({
<template> <template>
<div class="content-wrapper flex-box-v"> <div class="content-wrapper flex-box-v">
<content-toolbar <content-toolbar
v-show="!inFullEdit"
:db="props.db" :db="props.db"
:key-code="props.keyCode" :key-code="props.keyCode"
:key-path="props.keyPath" :key-path="props.keyPath"
@ -292,7 +288,7 @@ defineExpose({
@delete="emit('delete')" @delete="emit('delete')"
@reload="emit('reload')" @reload="emit('reload')"
@rename="emit('rename')" /> @rename="emit('rename')" />
<div v-show="!inFullEdit" class="tb2 value-item-part flex-box-h"> <div class="tb2 value-item-part flex-box-h">
<div class="flex-box-h"> <div class="flex-box-h">
<n-input <n-input
v-model:value="filterValue" v-model:value="filterValue"
@ -328,7 +324,6 @@ defineExpose({
<div class="value-wrapper value-item-part flex-box-h flex-item-expand"> <div class="value-wrapper value-item-part flex-box-h flex-item-expand">
<!-- table --> <!-- table -->
<n-data-table <n-data-table
v-show="!inFullEdit"
:bordered="false" :bordered="false"
:bottom-bordered="false" :bottom-bordered="false"
:columns="columns" :columns="columns"
@ -346,8 +341,12 @@ defineExpose({
@update:filters="onUpdateFilter" /> @update:filters="onUpdateFilter" />
<!-- edit pane --> <!-- edit pane -->
<content-entry-editor <div
v-show="inEdit" v-show="inEdit"
:style="{ position: fullEdit ? 'static' : 'relative' }"
class="entry-editor-container flex-item-expand"
style="width: 100%">
<content-entry-editor
v-model:fullscreen="fullEdit" v-model:fullscreen="fullEdit"
:decode="currentEditRow.decode" :decode="currentEditRow.decode"
:field="currentEditRow.no" :field="currentEditRow.no"
@ -361,6 +360,7 @@ defineExpose({
@close="resetEdit" @close="resetEdit"
@save="saveEdit" /> @save="saveEdit" />
</div> </div>
</div>
<div class="value-footer flex-box-h"> <div class="value-footer flex-box-h">
<n-text v-if="!isNaN(props.length)">{{ $t('interface.entries') }}: {{ entries }}</n-text> <n-text v-if="!isNaN(props.length)">{{ $t('interface.entries') }}: {{ entries }}</n-text>
<n-divider v-if="!isNaN(props.length)" vertical /> <n-divider v-if="!isNaN(props.length)" vertical />

View File

@ -74,9 +74,6 @@ const inEdit = computed(() => {
return currentEditRow.no > 0 return currentEditRow.no > 0
}) })
const fullEdit = ref(false) const fullEdit = ref(false)
const inFullEdit = computed(() => {
return inEdit.value && fullEdit.value
})
const displayCode = computed(() => { const displayCode = computed(() => {
return props.format === formatTypes.JSON return props.format === formatTypes.JSON
@ -277,7 +274,6 @@ defineExpose({
<template> <template>
<div class="content-wrapper flex-box-v"> <div class="content-wrapper flex-box-v">
<content-toolbar <content-toolbar
v-show="!inFullEdit"
:db="props.db" :db="props.db"
:key-code="props.keyCode" :key-code="props.keyCode"
:key-path="props.keyPath" :key-path="props.keyPath"
@ -289,7 +285,7 @@ defineExpose({
@delete="emit('delete')" @delete="emit('delete')"
@reload="emit('reload')" @reload="emit('reload')"
@rename="emit('rename')" /> @rename="emit('rename')" />
<div v-show="!inFullEdit" class="tb2 value-item-part flex-box-h"> <div class="tb2 value-item-part flex-box-h">
<div class="flex-box-h"> <div class="flex-box-h">
<n-input <n-input
v-model:value="filterValue" v-model:value="filterValue"
@ -325,7 +321,6 @@ defineExpose({
<div class="value-wrapper value-item-part flex-box-h flex-item-expand"> <div class="value-wrapper value-item-part flex-box-h flex-item-expand">
<!-- table --> <!-- table -->
<n-data-table <n-data-table
v-show="!inFullEdit"
:bordered="false" :bordered="false"
:bottom-bordered="false" :bottom-bordered="false"
:columns="columns" :columns="columns"
@ -343,8 +338,12 @@ defineExpose({
@update:filters="onUpdateFilter" /> @update:filters="onUpdateFilter" />
<!-- edit pane --> <!-- edit pane -->
<content-entry-editor <div
v-show="inEdit" v-show="inEdit"
:style="{ position: fullEdit ? 'static' : 'relative' }"
class="entry-editor-container flex-item-expand"
style="width: 100%">
<content-entry-editor
v-model:fullscreen="fullEdit" v-model:fullscreen="fullEdit"
:decode="currentEditRow.decode" :decode="currentEditRow.decode"
:field="currentEditRow.no" :field="currentEditRow.no"
@ -358,6 +357,7 @@ defineExpose({
@close="resetEdit" @close="resetEdit"
@save="saveEdit" /> @save="saveEdit" />
</div> </div>
</div>
<div class="value-footer flex-box-h"> <div class="value-footer flex-box-h">
<n-text v-if="!isNaN(props.length)">{{ $t('interface.entries') }}: {{ entries }}</n-text> <n-text v-if="!isNaN(props.length)">{{ $t('interface.entries') }}: {{ entries }}</n-text>
<n-divider v-if="!isNaN(props.length)" vertical /> <n-divider v-if="!isNaN(props.length)" vertical />

View File

@ -88,9 +88,6 @@ const inEdit = computed(() => {
return currentEditRow.no > 0 return currentEditRow.no > 0
}) })
const fullEdit = ref(false) const fullEdit = ref(false)
const inFullEdit = computed(() => {
return inEdit.value && fullEdit.value
})
const scoreFilterOption = ref(null) const scoreFilterOption = ref(null)
const scoreColumn = computed(() => ({ const scoreColumn = computed(() => ({
@ -350,7 +347,6 @@ defineExpose({
<template> <template>
<div class="content-wrapper flex-box-v"> <div class="content-wrapper flex-box-v">
<content-toolbar <content-toolbar
v-show="!inFullEdit"
:db="props.db" :db="props.db"
:key-code="props.keyCode" :key-code="props.keyCode"
:key-path="props.keyPath" :key-path="props.keyPath"
@ -362,7 +358,7 @@ defineExpose({
@delete="emit('delete')" @delete="emit('delete')"
@reload="emit('reload')" @reload="emit('reload')"
@rename="emit('rename')" /> @rename="emit('rename')" />
<div v-show="!inFullEdit" class="tb2 value-item-part flex-box-h"> <div class="tb2 value-item-part flex-box-h">
<div class="flex-box-h"> <div class="flex-box-h">
<n-input-group> <n-input-group>
<n-select <n-select
@ -411,7 +407,6 @@ defineExpose({
<div class="value-wrapper value-item-part flex-box-h flex-item-expand"> <div class="value-wrapper value-item-part flex-box-h flex-item-expand">
<!-- table --> <!-- table -->
<n-data-table <n-data-table
v-show="!inFullEdit"
:bordered="false" :bordered="false"
:bottom-bordered="false" :bottom-bordered="false"
:columns="columns" :columns="columns"
@ -428,8 +423,12 @@ defineExpose({
@update:filters="onUpdateFilter" /> @update:filters="onUpdateFilter" />
<!-- edit pane --> <!-- edit pane -->
<content-entry-editor <div
v-show="inEdit" v-show="inEdit"
:style="{ position: fullEdit ? 'static' : 'relative' }"
class="entry-editor-container flex-item-expand"
style="width: 100%">
<content-entry-editor
v-model:fullscreen="fullEdit" v-model:fullscreen="fullEdit"
:decode="currentEditRow.decode" :decode="currentEditRow.decode"
:field="currentEditRow.score" :field="currentEditRow.score"
@ -442,6 +441,7 @@ defineExpose({
@close="resetEdit" @close="resetEdit"
@save="saveEdit" /> @save="saveEdit" />
</div> </div>
</div>
<div class="value-footer flex-box-h"> <div class="value-footer flex-box-h">
<n-text v-if="!isNaN(props.length)">{{ $t('interface.entries') }}: {{ entries }}</n-text> <n-text v-if="!isNaN(props.length)">{{ $t('interface.entries') }}: {{ entries }}</n-text>
<n-divider v-if="!isNaN(props.length)" vertical /> <n-divider v-if="!isNaN(props.length)" vertical />

View File

@ -86,6 +86,7 @@ body {
padding-top: 5px; padding-top: 5px;
//padding: 5px; //padding: 5px;
box-sizing: border-box; box-sizing: border-box;
position: relative;
.tb2 { .tb2 {
gap: 5px; gap: 5px;