fix(editor): 初始化时如果浏览器切到后台编辑器列宽度计算出问题

This commit is contained in:
roymondchen 2024-03-26 15:20:41 +08:00
parent 15b88c97fc
commit 7049b1ff45
2 changed files with 9 additions and 1 deletions

View File

@ -169,6 +169,11 @@ const changeRight = ({ deltaX }: OnDrag) => {
defineExpose({
updateWidth() {
clientWidth = props.width ?? el.value?.clientWidth ?? clientWidth;
if (clientWidth <= 0) {
return;
}
const columnWidth = getCenterWidth(props.left, props.right);
emit('change', {

View File

@ -102,10 +102,13 @@ const RIGHT_COLUMN_WIDTH_STORAGE_KEY = '$MagicEditorRightColumnWidthData';
const getLeftColumnWidthCacheData = () =>
Number(globalThis.localStorage.getItem(LEFT_COLUMN_WIDTH_STORAGE_KEY)) || DEFAULT_LEFT_COLUMN_WIDTH;
const getRightColumnWidthCacheData = () =>
Number(globalThis.localStorage.getItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY)) || DEFAULT_RIGHT_COLUMN_WIDTH;
const columnWidth = ref<Partial<GetColumnWidth>>({
left: getLeftColumnWidthCacheData(),
center: 0,
right: Number(globalThis.localStorage.getItem(RIGHT_COLUMN_WIDTH_STORAGE_KEY)) || DEFAULT_RIGHT_COLUMN_WIDTH,
right: getRightColumnWidthCacheData(),
});
watch(pageLength, () => {