提交 70fba7ec 作者: vben

perf: performance optimization

上级 8f4d51a7
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
- [Code contribution](#code-contribution) - [Code contribution](#code-contribution)
- [Finished features](#finished-features) - [Finished features](#finished-features)
- [Developing features](#developing-features) - [Developing features](#developing-features)
- [Browser support](#browser-support)
## Introduction ## Introduction
...@@ -238,3 +239,13 @@ yarn clean:lib # Delete node_modules, supported window ...@@ -238,3 +239,13 @@ yarn clean:lib # Delete node_modules, supported window
- [ ] System performance optimization - [ ] System performance optimization
If you have more components/functions/suggestions/bugs/, welcome to submit pr or issue. If you have more components/functions/suggestions/bugs/, welcome to submit pr or issue.
## Browser support
It is recommended to use the `Chrome` browser for local development. Development in the Firefox browser is relatively slow.
Support modern browsers, Not currently supported ie11,Follow-up consideration support ie11
| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>IE / Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Safari |
| :-: | :-: | :-: | :-: |
| Not currently supported | last 2 versions | last 2 versions | last 2 versions |
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
- [代码贡献](#代码贡献) - [代码贡献](#代码贡献)
- [已完成功能](#已完成功能) - [已完成功能](#已完成功能)
- [正在开发的功能](#正在开发的功能) - [正在开发的功能](#正在开发的功能)
- [浏览器支持](#浏览器支持)
- [加入我们](#加入我们) - [加入我们](#加入我们)
## 介绍 ## 介绍
...@@ -241,6 +242,16 @@ yarn clean:lib # 删除node_modules,兼容window系统 ...@@ -241,6 +242,16 @@ yarn clean:lib # 删除node_modules,兼容window系统
更多组件/功能/建议/bug/欢迎提交 pr 或者 issue 更多组件/功能/建议/bug/欢迎提交 pr 或者 issue
## 浏览器支持
本地开发推荐使用`Chrome`浏览器,在火狐浏览器进行开发相对卡顿。
支持现代浏览器, IE 暂不支持,后续考虑支持 ie11
| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>IE / Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Safari |
| :-: | :-: | :-: | :-: |
| not support | last 2 versions | last 2 versions | last 2 versions |
## 加入我们 ## 加入我们
`Vue-Vben-Aadmin` 是完全开源免费的项目,在帮助开发者更方便地进行中大型管理系统开发,同时也提供 QQ 交流群(项目刚起步,人数较少,有兴趣的可以加群一起讨论),使用问题欢迎在群内提问。 `Vue-Vben-Aadmin` 是完全开源免费的项目,在帮助开发者更方便地进行中大型管理系统开发,同时也提供 QQ 交流群(项目刚起步,人数较少,有兴趣的可以加群一起讨论),使用问题欢迎在群内提问。
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
import { useConfigProvider, useInitAppConfigStore, useListenerNetWork } from './useApp'; import { useConfigProvider, useInitAppConfigStore, useListenerNetWork } from './useApp';
import { useLockPage } from '/@/hooks/web/useLockPage'; import { useLockPage } from '/@/hooks/web/useLockPage';
import { useSetting } from '/@/hooks/core/useSetting';
moment.locale('zh-cn'); moment.locale('zh-cn');
export default defineComponent({ export default defineComponent({
name: 'App', name: 'App',
...@@ -23,8 +25,14 @@ ...@@ -23,8 +25,14 @@
useInitAppConfigStore(); useInitAppConfigStore();
useListenerNetWork(); useListenerNetWork();
createBreakpointListen(); createBreakpointListen();
const { projectSetting } = useSetting();
const { transformCellText } = useConfigProvider(); const { transformCellText } = useConfigProvider();
const { on: lockOn } = useLockPage();
let lockOn = {};
if (projectSetting.lockTime) {
const { on } = useLockPage();
lockOn = on;
}
return { return {
transformCellText, transformCellText,
zhCN, zhCN,
......
...@@ -6,12 +6,12 @@ import { ...@@ -6,12 +6,12 @@ import {
watchEffect, watchEffect,
watch, watch,
unref, unref,
getCurrentInstance, // getCurrentInstance,
nextTick, nextTick,
toRaw, toRaw,
} from 'vue'; } from 'vue';
import { BasicTitle } from '/@/components/Basic'; import { BasicTitle } from '/@/components/Basic';
import { ScrollContainer, ScrollContainerOptions } from '/@/components/Container/index'; // import { ScrollContainer, ScrollContainerOptions } from '/@/components/Container/index';
import { FullLoading } from '/@/components/Loading/index'; import { FullLoading } from '/@/components/Loading/index';
import { getSlot } from '/@/utils/helper/tsxHelper'; import { getSlot } from '/@/utils/helper/tsxHelper';
...@@ -35,16 +35,16 @@ export default defineComponent({ ...@@ -35,16 +35,16 @@ export default defineComponent({
setup(props, { slots, emit, attrs }) { setup(props, { slots, emit, attrs }) {
// const { currentRoute } = useRouter(); // const { currentRoute } = useRouter();
const scrollRef = ref<any>(null); const scrollRef = ref<any>(null);
/** // /**
* @description: 获取配置ScrollContainer // * @description: 获取配置ScrollContainer
*/ // */
const getScrollOptions = computed( // const getScrollOptions = computed(
(): ScrollContainerOptions => { // (): ScrollContainerOptions => {
return { // return {
...(props.scrollOptions as any), // ...(props.scrollOptions as any),
}; // };
} // }
); // );
const visibleRef = ref(false); const visibleRef = ref(false);
const propsRef = ref<Partial<DrawerProps> | null>(null); const propsRef = ref<Partial<DrawerProps> | null>(null);
...@@ -95,33 +95,27 @@ export default defineComponent({ ...@@ -95,33 +95,27 @@ export default defineComponent({
} }
); );
// watch( // function scrollBottom() {
// () => currentRoute.value.path, // const scroll = unref(scrollRef);
// () => { // if (scroll) {
// if (unref(visibleRef)) { // scroll.scrollBottom();
// visibleRef.value = false;
// } // }
// } // }
// );
function scrollBottom() { // function scrollTo(to: number) {
const scroll = unref(scrollRef); // const scroll = unref(scrollRef);
if (scroll) { // if (scroll) {
scroll.scrollBottom(); // scroll.scrollTo(to);
} // }
} // }
function scrollTo(to: number) {
const scroll = unref(scrollRef); // function getScrollWrap() {
if (scroll) { // const scroll = unref(scrollRef);
scroll.scrollTo(to); // if (scroll) {
} // return scroll.getScrollWrap();
} // }
function getScrollWrap() { // return null;
const scroll = unref(scrollRef); // }
if (scroll) {
return scroll.getScrollWrap();
}
return null;
}
// 取消事件 // 取消事件
async function onClose(e: any) { async function onClose(e: any) {
const { closeFunc } = unref(getProps); const { closeFunc } = unref(getProps);
...@@ -225,12 +219,12 @@ export default defineComponent({ ...@@ -225,12 +219,12 @@ export default defineComponent({
); );
} }
const currentInstance = getCurrentInstance() as any; // const currentInstance = getCurrentInstance() as any;
if (getCurrentInstance()) { // if (getCurrentInstance()) {
currentInstance.scrollBottom = scrollBottom; // currentInstance.scrollBottom = scrollBottom;
currentInstance.scrollTo = scrollTo; // currentInstance.scrollTo = scrollTo;
currentInstance.getScrollWrap = getScrollWrap; // currentInstance.getScrollWrap = getScrollWrap;
} // }
const drawerInstance: DrawerInstance = { const drawerInstance: DrawerInstance = {
setDrawerProps: setDrawerProps, setDrawerProps: setDrawerProps,
}; };
...@@ -259,7 +253,7 @@ export default defineComponent({ ...@@ -259,7 +253,7 @@ export default defineComponent({
class={[!unref(getProps).loading ? 'hidden' : '']} class={[!unref(getProps).loading ? 'hidden' : '']}
tip="加载中..." tip="加载中..."
/> />
<ScrollContainer {/* <ScrollContainer
ref={scrollRef} ref={scrollRef}
{...{ ...attrs, ...unref(getScrollOptions) }} {...{ ...attrs, ...unref(getScrollOptions) }}
style={{ style={{
...@@ -267,7 +261,19 @@ export default defineComponent({ ...@@ -267,7 +261,19 @@ export default defineComponent({
}} }}
> >
{() => getSlot(slots, 'default')} {() => getSlot(slots, 'default')}
</ScrollContainer> </ScrollContainer> */}
<div
ref={scrollRef}
{...attrs}
style={{
height: `calc(100% - ${footerHeight}px)`,
overflow: 'auto',
padding: '16px',
paddingBottom: '30px',
}}
>
{getSlot(slots, 'default')}
</div>
{renderFooter()} {renderFooter()}
</> </>
), ),
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
width: 100%; width: 100%;
height: 100%; height: 100%;
// background: rgba(255, 255, 255, 0.3); // background: rgba(255, 255, 255, 0.3);
background: rgba(241, 241, 246, 0.8); background: rgba(241, 241, 246, 0.7);
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
......
...@@ -162,9 +162,9 @@ ...@@ -162,9 +162,9 @@
// 层级样式 // 层级样式
&.ant-menu-dark { &.ant-menu-dark {
.ant-menu-item { // .ant-menu-item {
transition: unset; // transition: unset;
} // }
.ant-menu-item.ant-menu-item-selected.basic-menu-menu-item__level1, .ant-menu-item.ant-menu-item-selected.basic-menu-menu-item__level1,
.ant-menu-submenu-selected.basic-menu-menu-item__level1 { .ant-menu-submenu-selected.basic-menu-menu-item__level1 {
...@@ -206,9 +206,18 @@ ...@@ -206,9 +206,18 @@
} }
.ant-menu-submenu-title { .ant-menu-submenu-title {
height: @app-menu-item-height;
// margin: 0; // margin: 0;
line-height: @app-menu-item-height; // line-height: @app-menu-item-height;
display: flex;
height: @app-menu-item-height;
align-items: center;
}
&.ant-menu-inline-collapsed {
.ant-menu-item-selected {
background: unset !important;
box-shadow: none;
}
} }
} }
......
...@@ -8,21 +8,20 @@ ...@@ -8,21 +8,20 @@
opacity: 0; opacity: 0;
} }
// side-fade /* fade-transform */
.slide-fade-enter-active, .slide-fade-leave-active,
.slide-fade-leave-active { .slide-fade-enter-active {
transition: opacity 0.3s, transform 0.35s; transition: all 0.3s;
} }
.slide-enter-from, .slide-fade-enter-from {
.slide-fade-enter {
opacity: 0; opacity: 0;
transform: translateX(-30%); transform: translateX(-30px);
} }
.slide-fade-leave-to { .slide-fade-leave-to {
opacity: 0; opacity: 0;
transform: translateX(30%); transform: translateX(30px);
} }
// /////////////////////////////////////////////// // ///////////////////////////////////////////////
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
// zoom-fade // zoom-fade
.zoom-fade-enter-active, .zoom-fade-enter-active,
.zoom-fade-leave-active { .zoom-fade-leave-active {
transition: transform 0.1s, opacity 0.15s ease-out; transition: transform 0.15s, opacity 0.2s ease-out;
} }
.zoom-fade-enter-from { .zoom-fade-enter-from {
......
...@@ -45,8 +45,6 @@ export function useEvent({ ...@@ -45,8 +45,6 @@ export function useEvent({
if (v) { if (v) {
!unref(isAddRef) && addEventListener(v); !unref(isAddRef) && addEventListener(v);
cleanUp(() => { cleanUp(() => {
// @ts-ignore
window.a = v;
autoRemove && removeEventListener(v); autoRemove && removeEventListener(v);
}); });
} }
......
...@@ -21,6 +21,7 @@ export function useWindowSizeFn<T>(fn: Fn<T>, wait = 150, options?: WindowSizeOp ...@@ -21,6 +21,7 @@ export function useWindowSizeFn<T>(fn: Fn<T>, wait = 150, options?: WindowSizeOp
tryOnMounted(() => { tryOnMounted(() => {
window.addEventListener('resize', handler); window.addEventListener('resize', handler);
}); });
tryOnUnmounted(() => { tryOnUnmounted(() => {
window.removeEventListener('resize', handler); window.removeEventListener('resize', handler);
cancel(); cancel();
......
...@@ -14,6 +14,7 @@ export function useECharts( ...@@ -14,6 +14,7 @@ export function useECharts(
) { ) {
const chartInstanceRef = ref<Nullable<ECharts>>(null); const chartInstanceRef = ref<Nullable<ECharts>>(null);
let resizeFn: Fn = resize; let resizeFn: Fn = resize;
let removeResizeFn: Fn = () => {};
const [debounceResize] = useDebounce(resize, 200); const [debounceResize] = useDebounce(resize, 200);
resizeFn = debounceResize; resizeFn = debounceResize;
...@@ -25,11 +26,12 @@ export function useECharts( ...@@ -25,11 +26,12 @@ export function useECharts(
return; return;
} }
chartInstanceRef.value = echarts.init(el, theme); chartInstanceRef.value = echarts.init(el, theme);
useEvent({ const { removeEvent } = useEvent({
el: window, el: window,
name: 'resize', name: 'resize',
listener: resizeFn, listener: resizeFn,
}); });
removeResizeFn = removeEvent;
const { widthRef, screenEnum } = useBreakpoint(); const { widthRef, screenEnum } = useBreakpoint();
if (unref(widthRef) <= screenEnum.MD) { if (unref(widthRef) <= screenEnum.MD) {
useTimeout(() => { useTimeout(() => {
...@@ -37,6 +39,9 @@ export function useECharts( ...@@ -37,6 +39,9 @@ export function useECharts(
}, 30); }, 30);
} }
} }
tryOnUnmounted(() => {
removeResizeFn();
});
function setOptions(options: any, clear = true) { function setOptions(options: any, clear = true) {
nextTick(() => { nextTick(() => {
......
...@@ -15,11 +15,7 @@ type FSEPropName = ...@@ -15,11 +15,7 @@ type FSEPropName =
| 'msFullscreenElement' | 'msFullscreenElement'
| 'mozFullScreenElement' | 'mozFullScreenElement'
| 'fullscreenElement'; | 'fullscreenElement';
type ONFSCPropName = type ONFSCPropName = 'onfullscreenchange' | 'onwebkitfullscreenchange' | 'MSFullscreenChange';
| 'onfullscreenchange'
| 'onwebkitfullscreenchange'
| 'onmozfullscreenchange'
| 'MSFullscreenChange';
export function useFullscreen( export function useFullscreen(
target: Ref<Nullable<HTMLElement>> = ref(document.documentElement), target: Ref<Nullable<HTMLElement>> = ref(document.documentElement),
......
...@@ -3,6 +3,7 @@ import { useThrottle } from '/@/hooks/core/useThrottle'; ...@@ -3,6 +3,7 @@ import { useThrottle } from '/@/hooks/core/useThrottle';
import { appStore } from '/@/store/modules/app'; import { appStore } from '/@/store/modules/app';
import { userStore } from '/@/store/modules/user'; import { userStore } from '/@/store/modules/user';
export function useLockPage() { export function useLockPage() {
let timeId: ReturnType<typeof setTimeout>; let timeId: ReturnType<typeof setTimeout>;
......
...@@ -34,6 +34,12 @@ ...@@ -34,6 +34,12 @@
color: inherit; color: inherit;
} }
> div {
display: flex;
justify-content: center;
align-items: center;
}
svg { svg {
fill: @text-color-base; fill: @text-color-base;
} }
......
import { createApp } from 'vue'; import { createApp } from 'vue';
import { setupAntd } from '/@/setup/ant-design-vue';
import router, { setupRouter } from '/@/router'; import router, { setupRouter } from '/@/router';
import { setupStore } from '/@/store'; import { setupStore } from '/@/store';
import App from './App.vue'; import { setupAntd } from '/@/setup/ant-design-vue';
import { registerGlobComp } from '/@/components/registerGlobComp';
import { setupDirectives } from '/@/setup/directives/index'; import { setupDirectives } from '/@/setup/directives/index';
import { registerGlobComp } from '/@/components/registerGlobComp';
import { isDevMode, isProdMode, isUseMock } from '/@/utils/env'; import { isDevMode, isProdMode, isUseMock } from '/@/utils/env';
import { setupProdMockServer } from '../mock/_createProductionServer'; import { setupProdMockServer } from '../mock/_createProductionServer';
import App from './App.vue';
import '/@/design/index.less'; import '/@/design/index.less';
const app = createApp(App); const app = createApp(App);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论