-
+
drawerApi.open()">
diff --git a/packages/effects/plugins/README.md b/packages/effects/plugins/README.md
new file mode 100644
index 00000000..c394c9ce
--- /dev/null
+++ b/packages/effects/plugins/README.md
@@ -0,0 +1,28 @@
+# @vben/plugins
+
+该目录用于存放项目中集成的第三方库及其相关插件。每个插件都包含了可重用的逻辑、配置和组件,方便在项目中进行统一管理和调用。
+
+## 注意
+
+所有的第三方插件都必须以 `subpath` 形式引入,例:
+
+以 `echarts` 为例,引入方式如下:
+
+**packages.json**
+
+```json
+"exports": {
+ "./echarts": {
+ "types": "./src/echarts/index.ts",
+ "default": "./src/echarts/index.ts"
+ }
+ }
+```
+
+**使用方式**
+
+```ts
+import { useEcharts } from '@vben/plugins/echarts';
+```
+
+这样做的好处是,应用可以自行选择是否使用插件,而不会因为插件的引入及副作用而导致打包体积增大,只引入需要的插件即可。
diff --git a/packages/effects/chart-ui/package.json b/packages/effects/plugins/package.json
similarity index 74%
rename from packages/effects/chart-ui/package.json
rename to packages/effects/plugins/package.json
index 0526afc8..39fa7f5a 100644
--- a/packages/effects/chart-ui/package.json
+++ b/packages/effects/plugins/package.json
@@ -1,12 +1,12 @@
{
- "name": "@vben/chart-ui",
+ "name": "@vben/plugins",
"version": "5.1.2",
"homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": {
"type": "git",
"url": "git+https://github.com/vbenjs/vue-vben-admin.git",
- "directory": "packages/effects/chart-ui"
+ "directory": "packages/effects/plugins"
},
"license": "MIT",
"type": "module",
@@ -14,9 +14,9 @@
"**/*.css"
],
"exports": {
- ".": {
- "types": "./src/index.ts",
- "default": "./src/index.ts"
+ "./echarts": {
+ "types": "./src/echarts/index.ts",
+ "default": "./src/echarts/index.ts"
}
},
"dependencies": {
diff --git a/packages/effects/chart-ui/src/echarts/echarts-ui.vue b/packages/effects/plugins/src/echarts/echarts-ui.vue
similarity index 100%
rename from packages/effects/chart-ui/src/echarts/echarts-ui.vue
rename to packages/effects/plugins/src/echarts/echarts-ui.vue
diff --git a/packages/effects/chart-ui/src/echarts/echarts.ts b/packages/effects/plugins/src/echarts/echarts.ts
similarity index 100%
rename from packages/effects/chart-ui/src/echarts/echarts.ts
rename to packages/effects/plugins/src/echarts/echarts.ts
diff --git a/packages/effects/chart-ui/src/echarts/index.ts b/packages/effects/plugins/src/echarts/index.ts
similarity index 100%
rename from packages/effects/chart-ui/src/echarts/index.ts
rename to packages/effects/plugins/src/echarts/index.ts
diff --git a/packages/effects/chart-ui/src/echarts/use-echarts.ts b/packages/effects/plugins/src/echarts/use-echarts.ts
similarity index 86%
rename from packages/effects/chart-ui/src/echarts/use-echarts.ts
rename to packages/effects/plugins/src/echarts/use-echarts.ts
index 071138fa..d4282cd4 100644
--- a/packages/effects/chart-ui/src/echarts/use-echarts.ts
+++ b/packages/effects/plugins/src/echarts/use-echarts.ts
@@ -5,11 +5,12 @@ import type EchartsUI from './echarts-ui.vue';
import type { Ref } from 'vue';
import { computed, nextTick, watch } from 'vue';
-import { preferences, usePreferences } from '@vben/preferences';
+import { usePreferences } from '@vben/preferences';
import {
tryOnUnmounted,
useDebounceFn,
+ useResizeObserver,
useTimeoutFn,
useWindowSize,
} from '@vueuse/core';
@@ -86,6 +87,8 @@ function useEcharts(chartRef: Ref) {
resizeHandler?.();
});
+ useResizeObserver(chartRef as never, resizeHandler);
+
watch(isDark, () => {
if (chartInstance) {
chartInstance.dispose();
@@ -95,21 +98,6 @@ function useEcharts(chartRef: Ref) {
}
});
- watch(
- [
- () => preferences.sidebar.collapsed,
- () => preferences.sidebar.extraCollapse,
- () => preferences.sidebar.hidden,
- () => preferences.app.contentCompact,
- ],
- () => {
- // 折叠动画200ms
- setTimeout(() => {
- resize();
- }, 200);
- },
- );
-
tryOnUnmounted(() => {
// 销毁实例,释放资源
chartInstance?.dispose();
diff --git a/packages/effects/chart-ui/tsconfig.json b/packages/effects/plugins/tsconfig.json
similarity index 100%
rename from packages/effects/chart-ui/tsconfig.json
rename to packages/effects/plugins/tsconfig.json
diff --git a/packages/locales/src/langs/en-US.json b/packages/locales/src/langs/en-US.json
index 90afe51b..b8408644 100644
--- a/packages/locales/src/langs/en-US.json
+++ b/packages/locales/src/langs/en-US.json
@@ -182,6 +182,7 @@
"position": {
"title": "Preferences Postion",
"header": "Header",
+ "auto": "Auto",
"fixed": "Fixed"
},
"sidebar": {
diff --git a/packages/locales/src/langs/zh-CN.json b/packages/locales/src/langs/zh-CN.json
index 16cee8fd..46ceb599 100644
--- a/packages/locales/src/langs/zh-CN.json
+++ b/packages/locales/src/langs/zh-CN.json
@@ -182,6 +182,7 @@
"position": {
"title": "偏好设置位置",
"header": "顶栏",
+ "auto": "自动",
"fixed": "固定"
},
"sidebar": {
diff --git a/packages/utils/src/helpers/get-popup-container.ts b/packages/utils/src/helpers/get-popup-container.ts
new file mode 100644
index 00000000..ca5a72dd
--- /dev/null
+++ b/packages/utils/src/helpers/get-popup-container.ts
@@ -0,0 +1,6 @@
+/**
+ * Returns the parent node of the given element or the document body if the element is not provided.it
+ */
+export function getPopupContainer(node?: HTMLElement): HTMLElement {
+ return (node?.parentNode as HTMLElement) ?? document.body;
+}
diff --git a/packages/utils/src/helpers/index.ts b/packages/utils/src/helpers/index.ts
index 90c45a24..da2cd8d7 100644
--- a/packages/utils/src/helpers/index.ts
+++ b/packages/utils/src/helpers/index.ts
@@ -2,6 +2,7 @@ export * from './find-menu-by-path';
export * from './generate-menus';
export * from './generate-routes-backend';
export * from './generate-routes-frontend';
+export * from './get-popup-container';
export * from './merge-route-modules';
export * from './reset-routes';
export * from './unmount-global-loading';
diff --git a/playground/package.json b/playground/package.json
index 9560e13d..51a7fbad 100644
--- a/playground/package.json
+++ b/playground/package.json
@@ -27,13 +27,13 @@
},
"dependencies": {
"@vben/access": "workspace:*",
- "@vben/chart-ui": "workspace:*",
"@vben/common-ui": "workspace:*",
"@vben/constants": "workspace:*",
"@vben/hooks": "workspace:*",
"@vben/icons": "workspace:*",
"@vben/layouts": "workspace:*",
"@vben/locales": "workspace:*",
+ "@vben/plugins": "workspace:*",
"@vben/preferences": "workspace:*",
"@vben/request": "workspace:*",
"@vben/stores": "workspace:*",
diff --git a/playground/src/views/dashboard/analytics/analytics-trends.vue b/playground/src/views/dashboard/analytics/analytics-trends.vue
index 261c847c..35e90276 100644
--- a/playground/src/views/dashboard/analytics/analytics-trends.vue
+++ b/playground/src/views/dashboard/analytics/analytics-trends.vue
@@ -1,7 +1,11 @@