Skip to content

Commit

Permalink
fix(modal): height calc error #161
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Jan 5, 2021
1 parent 8d7d083 commit 144ab57
Show file tree
Hide file tree
Showing 26 changed files with 162 additions and 112 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- 恢复 table 的`isTreeTable`属性
- 修复表格内存溢出问题
- 修复`layout` 收缩展开功能在分割模式下失效
- 修复 modal 高度计算错误

## 2.0.0-rc.15 (2020-12-31)

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ yarn clean:lib # 删除node_modules,兼容window系统

如果这些插件对你有帮助,可以给一个 star 支持下

- [vite-plugin-mock](https://github.com/anncwb/vite-plugin-mock)
- [vite-plugin-html](https://github.com/anncwb/vite-plugin-html)
- [vite-plugin-mock](https://github.com/vbenjs/vite-plugin-mock)
- [vite-plugin-html](https://github.com/vbenjs/vite-plugin-html)

## 加入我们

Expand Down
1 change: 1 addition & 0 deletions src/components/Basic/src/BasicArrow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
export default defineComponent({
name: 'BasicArrow',
inheritAttrs: false,
components: { RightOutlined },
props: {
// Expand contract, expand by default
Expand Down
1 change: 1 addition & 0 deletions src/components/Basic/src/BasicHelp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import { useDesign } from '/@/hooks/web/useDesign';
export default defineComponent({
name: 'BasicHelp',
inheritAttrs: false,
components: { Tooltip },
props: {
// max-width
Expand Down
1 change: 1 addition & 0 deletions src/components/Basic/src/BasicTitle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
export default defineComponent({
name: 'BasicTitle',
inheritAttrs: false,
components: { BasicHelp },
props: {
helpMessage: {
Expand Down
1 change: 1 addition & 0 deletions src/components/Container/src/LazyContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
export default defineComponent({
name: 'LazyContainer',
inheritAttrs: false,
components: { Skeleton },
props: {
// Waiting time, if the time is specified, whether visible or not, it will be automatically loaded after the specified time
Expand Down
1 change: 1 addition & 0 deletions src/components/Container/src/ScrollContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
export default defineComponent({
name: 'ScrollContainer',
inheritAttrs: false,
components: { Scrollbar },
setup() {
const scrollbarRef = ref<Nullable<ScrollbarType>>(null);
Expand Down
17 changes: 15 additions & 2 deletions src/components/Markdown/src/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,23 @@
import { propTypes } from '/@/utils/propTypes';
import { useLocale } from '/@/hooks/web/useLocale';
import { useModalContext } from '../../Modal';
type Lang = 'zh_CN' | 'en_US' | 'ja_JP' | 'ko_KR' | undefined;
export default defineComponent({
emits: ['change'],
inheritAttrs: false,
props: {
height: propTypes.number.def(360),
value: propTypes.string.def(''),
},
emits: ['change', 'get'],
setup(props, { attrs, emit }) {
const wrapRef = ref<ElRef>(null);
const vditorRef = ref<Nullable<Vditor>>(null);
const initedRef = ref(false);
const modalFn = useModalContext();
const lang = ref<Lang>();
const { getLang } = useLocale();
Expand Down Expand Up @@ -66,10 +70,19 @@
initedRef.value = true;
}
const instance = {
getVditor: (): Vditor => vditorRef.value!,
};
onMounted(() => {
nextTick(() => {
init();
setTimeout(() => {
modalFn?.redoModalHeight?.();
}, 200);
});
emit('get', instance);
});
onUnmounted(() => {
Expand All @@ -82,7 +95,7 @@
return {
wrapRef,
getVditor: (): Vditor => vditorRef.value!,
...instance,
};
},
});
Expand Down
4 changes: 3 additions & 1 deletion src/components/Modal/src/BasicModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
:height="getProps.height"
:visible="visibleRef"
:modalFooterHeight="footer !== undefined && !footer ? 0 : undefined"
v-bind="omit(getProps.wrapperProps, 'visible')"
v-bind="omit(getProps.wrapperProps, 'visible', 'height')"
@ext-height="handleExtHeight"
@height-change="handleHeightChange"
>
Expand All @@ -51,6 +51,7 @@
watchEffect,
toRef,
getCurrentInstance,
nextTick,
} from 'vue';
import Modal from './components/Modal';
Expand All @@ -67,6 +68,7 @@
import { omit } from 'lodash-es';
export default defineComponent({
name: 'BasicModal',
inheritAttrs: false,
components: { Modal, ModalWrapper, ModalClose, ModalFooter, ModalHeader },
props: basicProps,
emits: ['visible-change', 'height-change', 'cancel', 'ok', 'register'],
Expand Down
10 changes: 7 additions & 3 deletions src/components/Modal/src/components/ModalWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
export default defineComponent({
name: 'ModalWrapper',
inheritAttrs: false,
components: { Spin, ScrollContainer },
props: {
loading: propTypes.bool,
Expand All @@ -51,6 +52,8 @@
const realHeightRef = ref(0);
const minRealHeightRef = ref(0);
let realHeight = 0;
let stopElResizeFn: Fn = () => {};
useWindowSizeFn(setModalHeight);
Expand Down Expand Up @@ -137,8 +140,9 @@
if (!spinEl) return;
const realHeight = spinEl.scrollHeight;
if (!realHeight) {
realHeight = spinEl.scrollHeight;
}
if (props.fullScreen) {
realHeightRef.value =
window.innerHeight - props.modalFooterHeight - props.modalHeaderHeight;
Expand All @@ -147,7 +151,7 @@
? props.height
: realHeight > maxHeight
? maxHeight
: realHeight + 16 + 30;
: realHeight + 46;
}
emit('height-change', unref(realHeightRef));
} catch (error) {
Expand Down
13 changes: 10 additions & 3 deletions src/components/Scrollbar/src/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
export default defineComponent({
name: 'Scrollbar',
inheritAttrs: false,
components: { Bar },
props: {
native: {
Expand Down Expand Up @@ -91,12 +92,18 @@
onMounted(() => {
if (props.native) return;
nextTick(update);
!props.noresize && addResizeListener(resize.value, update);
if (!props.noresize) {
addResizeListener(resize.value, update);
addResizeListener(wrap.value, update);
}
});
onBeforeUnmount(() => {
if (props.native) return;
!props.noresize && removeResizeListener(resize.value, update);
if (!props.noresize) {
removeResizeListener(resize.value, update);
removeResizeListener(wrap.value, update);
}
});
const style = computed(() => {
let style: any = props.wrapStyle;
Expand Down Expand Up @@ -127,7 +134,7 @@
&__wrap {
height: 100%;
overflow: scroll;
overflow: auto;
&--hidden-default {
scrollbar-width: none;
Expand Down
1 change: 1 addition & 0 deletions src/components/Tinymce/src/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
export default defineComponent({
name: 'Tinymce',
inheritAttrs: false,
props: basicProps,
emits: ['change', 'update:modelValue'],
setup(props, { emit, attrs }) {
Expand Down
11 changes: 9 additions & 2 deletions src/components/Tree/src/BasicTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { extendSlots } from '/@/utils/helper/tsxHelper';
import { basicProps } from './props';
import { useTree } from './useTree';
import { useExpose } from '/@/hooks/core/useExpose';
import { onMounted } from 'vue';

interface State {
expandedKeys: Keys;
Expand All @@ -25,7 +26,7 @@ const prefixCls = 'basic-tree';
export default defineComponent({
name: 'BasicTree',
props: basicProps,
emits: ['update:expandedKeys', 'update:selectedKeys', 'update:value'],
emits: ['update:expandedKeys', 'update:selectedKeys', 'update:value', 'get'],
setup(props, { attrs, slots, emit }) {
const state = reactive<State>({
expandedKeys: props.expandedKeys || [],
Expand Down Expand Up @@ -182,7 +183,7 @@ export default defineComponent({
state.checkedKeys = props.checkedKeys;
});

useExpose<TreeActionType>({
const instance: TreeActionType = {
setExpandedKeys,
getExpandedKeys,
setSelectedKeys,
Expand All @@ -195,6 +196,12 @@ export default defineComponent({
filterByLevel: (level: number) => {
state.expandedKeys = filterByLevel(level);
},
};

useExpose<TreeActionType>(instance);

onMounted(() => {
emit('get', instance);
});

return () => {
Expand Down
2 changes: 0 additions & 2 deletions src/hooks/component/usePageContext.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import type { InjectionKey, ComputedRef, Ref } from 'vue';
import { createContext, useContext } from '/@/hooks/core/useContext';

import {} from 'vue';

export interface PageContextProps {
contentHeight: ComputedRef<number>;
pageHeight: Ref<number>;
Expand Down
3 changes: 1 addition & 2 deletions src/layouts/default/sider/MixSider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@
const activePath = ref('');
const chilrenMenus = ref<Menu[]>([]);
const openMenu = ref(false);
const isInit = ref(false);
const dragBarRef = ref<ElRef>(null);
const sideRef = ref<ElRef>(null);
const currentRoute = ref<Nullable<RouteLocationNormalized>>(null);
Expand Down Expand Up @@ -251,8 +250,8 @@
}
function handleClickOutside() {
setActive(true);
closeMenu();
setActive();
}
function getItemEvents(item: Menu) {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export function isOperaFn() {
* set page Title
* @param {*} title :page Title
*/
const setDocumentTitle = (title: string) => {
function setDocumentTitle(title: string) {
document.title = title;
const ua = navigator.userAgent;
const regex = /\bMicroMessenger\/([\d.]+)/;
Expand All @@ -91,7 +91,7 @@ const setDocumentTitle = (title: string) => {
};
document.body.appendChild(i);
}
};
}

export function setTitle(title: string, appTitle?: string) {
if (title) {
Expand Down
Loading

0 comments on commit 144ab57

Please sign in to comment.