Skip to content

Commit

Permalink
perf: perf excel comp code
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Oct 20, 2020
1 parent 968f791 commit eecde4c
Show file tree
Hide file tree
Showing 14 changed files with 144 additions and 183 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.zh_CN.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Wip

### 🎫 Chores

- 表格默认不显示边框

### ⚡ Performance Improvements

- 优化首屏体积大小
Expand Down
12 changes: 7 additions & 5 deletions src/components/Authority/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@ export default defineComponent({
const getModeRef = computed(() => {
return appStore.getProjectConfig.permissionMode;
});

/**
* 渲染角色按钮
*/
function renderRoleAuth() {
const { value } = props;
if (!value) {
return getSlot(slots, 'default');
return getSlot(slots);
}
const { hasPermission } = usePermission();
return hasPermission(value) ? getSlot(slots, 'default') : null;
return hasPermission(value) ? getSlot(slots) : null;
}

/**
Expand All @@ -38,11 +39,12 @@ export default defineComponent({
function renderCodeAuth() {
const { value } = props;
if (!value) {
return getSlot(slots, 'default');
return getSlot(slots);
}
const { hasPermission } = usePermission();
return hasPermission(value) ? getSlot(slots, 'default') : null;
return hasPermission(value) ? getSlot(slots) : null;
}

return () => {
const mode = unref(getModeRef);
// 基于角色渲染
Expand All @@ -53,7 +55,7 @@ export default defineComponent({
if (mode === PermissionModeEnum.BACK) {
return renderCodeAuth();
}
return getSlot(slots, 'default');
return getSlot(slots);
};
},
});
48 changes: 0 additions & 48 deletions src/components/Drawer/src/BasicDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,7 @@ export default defineComponent({
props: basicProps,
emits: ['visible-change', 'ok', 'close', 'register'],
setup(props, { slots, emit, attrs }) {
// const { currentRoute } = useRouter();
const scrollRef = ref<any>(null);
// /**
// * @description: 获取配置ScrollContainer
// */
// const getScrollOptions = computed(
// (): ScrollContainerOptions => {
// return {
// ...(props.scrollOptions as any),
// };
// }
// );

const visibleRef = ref(false);
const propsRef = ref<Partial<DrawerProps> | null>(null);
Expand Down Expand Up @@ -85,7 +74,6 @@ export default defineComponent({
watch(
() => visibleRef.value,
(visible) => {
// appStore.commitLockMainScrollState(visible);
nextTick(() => {
emit('visible-change', visible);
});
Expand All @@ -95,27 +83,6 @@ export default defineComponent({
}
);

// function scrollBottom() {
// const scroll = unref(scrollRef);
// if (scroll) {
// scroll.scrollBottom();
// }
// }

// function scrollTo(to: number) {
// const scroll = unref(scrollRef);
// if (scroll) {
// scroll.scrollTo(to);
// }
// }

// function getScrollWrap() {
// const scroll = unref(scrollRef);
// if (scroll) {
// return scroll.getScrollWrap();
// }
// return null;
// }
// 取消事件
async function onClose(e: any) {
const { closeFunc } = unref(getProps);
Expand Down Expand Up @@ -219,12 +186,6 @@ export default defineComponent({
);
}

// const currentInstance = getCurrentInstance() as any;
// if (getCurrentInstance()) {
// currentInstance.scrollBottom = scrollBottom;
// currentInstance.scrollTo = scrollTo;
// currentInstance.getScrollWrap = getScrollWrap;
// }
const drawerInstance: DrawerInstance = {
setDrawerProps: setDrawerProps,
};
Expand Down Expand Up @@ -253,15 +214,6 @@ export default defineComponent({
class={[!unref(getProps).loading ? 'hidden' : '']}
tip="加载中..."
/>
{/* <ScrollContainer
ref={scrollRef}
{...{ ...attrs, ...unref(getScrollOptions) }}
style={{
height: `calc(100% - ${footerHeight})`,
}}
>
{() => getSlot(slots, 'default')}
</ScrollContainer> */}
<div
ref={scrollRef}
{...attrs}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Excel/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { default as ImportExcel } from './src/ImportExcel';
export { default as ImportExcel } from './src/ImportExcel.vue';
export { default as ExportExcelModel } from './src/ExportExcelModel.vue';

export { jsonToSheetXlsx, aoaToSheetXlsx } from './src/Export2Excel';
Expand Down
4 changes: 3 additions & 1 deletion src/components/Excel/src/ExportExcelModel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,13 @@
];
export default defineComponent({
components: { BasicModal, BasicForm },
emits: ['success', 'register'],
setup(_, { emit }) {
const [registerForm, { validateFields }] = useForm();
const [registerModal, { closeModal }] = useModalInner();
async function handleOk() {
const res: ExportModalResult = await validateFields();
const res = (await validateFields()) as ExportModalResult;
const { filename, bookType } = res;
emit('success', {
Expand All @@ -69,6 +70,7 @@
});
closeModal();
}
return {
schemas,
handleOk,
Expand Down
120 changes: 0 additions & 120 deletions src/components/Excel/src/ImportExcel.tsx

This file was deleted.

Loading

0 comments on commit eecde4c

Please sign in to comment.