Skip to content

Commit 2a9cdbf

Browse files
committed
🐞 fix: 低版本element环境信息说明
1 parent 264859b commit 2a9cdbf

File tree

11 files changed

+2741
-5158
lines changed

11 files changed

+2741
-5158
lines changed

.github/ISSUE_TEMPLATE/ui_library_request.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,4 @@ const result = await CommandModal(<UserForm />, {
4848

4949

5050

51+

.github/pull_request_template.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,4 @@
4444

4545

4646

47+

CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,7 @@ chore: 构建工具或依赖更新
114114

115115

116116

117+
118+
119+
120+

packages/core/dist/index.cjs.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/core/dist/index.es.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const Ar = (e = "") => e.slice(2).toLowerCase(), Sr = (e = "") => `on${e.charAt(
6767
}, $r = (e) => e == null, Ir = (e) => typeof e != "function" ? e : z(ee({ render: () => e() })), Mr = () => Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15), xe = Symbol("CommandComponentConsumerInjectKey"), fe = Symbol("CommandComponentStackInjectKey"), R = new Je(), le = /* @__PURE__ */ new Set(), X = (e) => T(T({}, e.parent ? X(e.parent) : {}), e.provides);
6868
function Qe(e, t, n) {
6969
var M;
70-
e || N(z({
70+
console.log(99999), e || N(z({
7171
setup() {
7272
return e = Z(), () => null;
7373
}

packages/core/src/core.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
nextTick,
88
provide,
99
render,
10-
Teleport
10+
Teleport,
1111
} from "vue";
1212
import {
1313
EVENT_NAME,
@@ -46,15 +46,19 @@ export function commandProviderWithRender(
4646
uiComponent: VNode,
4747
config: ICoreConfig,
4848
): IConsumer {
49+
console.log(99999);
4950

5051
// 某些情况下,我们可能需要在vue组件树之外的地方使用命令式组件,这个时候无法补货到组件实例,可以创建一个空的组件实例来代替,以免后续流程受到影响
5152
if (!parentInstance) {
52-
render(h({
53-
setup() {
54-
parentInstance = getCurrentInstance();
55-
return () => null
56-
}
57-
}), document.body);
53+
render(
54+
h({
55+
setup() {
56+
parentInstance = getCurrentInstance();
57+
return () => null;
58+
},
59+
}),
60+
document.body,
61+
);
5862
}
5963

6064
// 挂在点
@@ -160,6 +164,7 @@ export function commandProviderWithRender(
160164
...getProvidesChain(commandInstance!),
161165
...getProvidesChain(parentInstance!),
162166
};
167+
163168
for (const key in upStreamProvides) {
164169
provide(key, upStreamProvides[key]);
165170
}
Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
<script setup lang="ts">
22
import DefaultTheme from "vitepress/theme";
33
import { useData } from "vitepress";
4+
import { ElConfigProvider } from "element-plus";
5+
import zhCn from 'element-plus/es/locale/lang/zh-cn'
6+
import en from 'element-plus/es/locale/lang/en'
47
import { NConfigProvider, darkTheme, lightTheme } from "naive-ui";
58
import { ConfigProvider } from "vant";
6-
79
const { isDark } = useData();
810
</script>
911

1012
<template>
11-
<NConfigProvider :theme="isDark ? darkTheme : lightTheme">
12-
<ConfigProvider :theme="isDark ? 'dark' : 'light'">
13-
<DefaultTheme.Layout />
14-
</ConfigProvider>
15-
</NConfigProvider>
13+
<ElConfigProvider :locale="zhCn">
14+
<NConfigProvider :theme="isDark ? darkTheme : lightTheme">
15+
<ConfigProvider :theme="isDark ? 'dark' : 'light'">
16+
<DefaultTheme.Layout />
17+
</ConfigProvider>
18+
</NConfigProvider>
19+
</ElConfigProvider>
1620
</template>

packages/docs/components.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ declare module 'vue' {
1616
ElInput: typeof import('element-plus/es')['ElInput']
1717
ElInputNumber: typeof import('element-plus/es')['ElInputNumber']
1818
ElOption: typeof import('element-plus/es')['ElOption']
19+
ElPagination: typeof import('element-plus/es')['ElPagination']
1920
ElRadio: typeof import('element-plus/es')['ElRadio']
21+
ElRadioButton: typeof import('element-plus/es')['ElRadioButton']
2022
ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
2123
ElSelect: typeof import('element-plus/es')['ElSelect']
2224
ElSwitch: typeof import('element-plus/es')['ElSwitch']

packages/docs/guide/faq.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,56 @@ import { useDestroyAllOnRouteChange } from "@vue-cmd/hooks";
2828
const stop = useDestroyAllOnRouteChange();
2929
// stop();
3030
```
31+
## 低版本element-plus出现ElConfigProvider注入配置失效问题
32+
33+
最新版本的element-plus不会出现这个问题,可以自行手动注入一遍
34+
35+
可以抽离配置注入组件,然后在你原先注入的地方使用这个组件:
36+
```tsx
37+
import { ElConfigProvider } from "element-plus";
38+
import { computed, defineComponent, getCurrentInstance } from "vue";
39+
import zh from "element-plus/es/locale/lang/zh-cn";
40+
import en from "element-plus/lib/locale/lang/en";
41+
42+
export default defineComponent({
43+
setup(_, { slots }) {
44+
return () => (
45+
<ElConfigProvider locale={zh}>
46+
{slots}
47+
</ElConfigProvider>
48+
);
49+
}
50+
});
51+
```
52+
然后使用这个组件对命令组件进行包裹,所以我们需要稍微封装一下:
53+
```tsx
54+
import ElConfigProvider from "./ElConfigProvider";
55+
56+
import {
57+
useDrawer as useDrawerRaw,
58+
useDialog as useDialogRaw
59+
} from "@vue-cmd/element-plus";
60+
61+
export function useDrawer(config = {}) {
62+
const drawer = useDrawerRaw(config);
63+
return (VNode, config) => {
64+
drawer(<ElConfigProvider>{VNode}</ElConfigProvider>, config);
65+
};
66+
}
67+
68+
export function useDialog(config) {
69+
const drawer = useDialogRaw(config);
70+
return (VNode, config) => {
71+
drawer(<ElConfigProvider>{VNode}</ElConfigProvider>, config);
72+
};
73+
}
74+
```
75+
使用方式没有任何改变,改变的只是导入的地方:
76+
77+
```tsx
78+
import { useDrawer } from "@/components/VueCmd";
79+
80+
const drawer = useDrawer();
81+
82+
drawer(<div>hello</div>)
83+
```

packages/element-plus/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vue-cmd/element-plus",
3-
"version": "1.0.8",
3+
"version": "1.0.9",
44
"type": "module",
55
"description": "Element Plus命令式组件适配器 - 让Element Plus的Dialog、Drawer等组件支持命令式调用",
66
"homepage": "https://pandavips.github.io/Vue-Command-Component/",

0 commit comments

Comments
 (0)