Skip to content

Commit 5aa1316

Browse files
authored
Merge branch 'main' into main
2 parents ea32895 + e6bfbce commit 5aa1316

File tree

30 files changed

+4762
-3826
lines changed

30 files changed

+4762
-3826
lines changed

.github/contributing.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@ Project maintainers have the right and responsibility to remove, edit, or reject
1919
- Checkout a topic branch from the relevant branch, e.g. main, and merge back against that branch.
2020

2121
- If adding a new feature:
22-
2322
- Provide a convincing reason to add this feature. Ideally, you should open a suggestion issue first and have it approved before working on it.
2423

2524
- If fixing bug:
26-
2725
- Provide a detailed description of the bug in the PR. Live demo preferred.
2826

2927
- It's OK to have multiple small commits as you work on the PR - GitHub can automatically squash them before merging.

apps/web-antd/src/adapter/component/index.ts

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,7 @@ import type { Component } from 'vue';
88
import type { BaseFormComponentType } from '@vben/common-ui';
99
import type { Recordable } from '@vben/types';
1010

11-
import {
12-
defineAsyncComponent,
13-
defineComponent,
14-
getCurrentInstance,
15-
h,
16-
ref,
17-
} from 'vue';
11+
import { defineAsyncComponent, defineComponent, h, ref } from 'vue';
1812

1913
import { ApiComponent, globalShareState, IconPicker } from '@vben/common-ui';
2014
import { $t } from '@vben/locales';
@@ -82,16 +76,15 @@ const withDefaultPlaceholder = <T extends Component>(
8276
$t(`ui.placeholder.${type}`);
8377
// 透传组件暴露的方法
8478
const innerRef = ref();
85-
const publicApi: Recordable<any> = {};
86-
expose(publicApi);
87-
const instance = getCurrentInstance();
88-
instance?.proxy?.$nextTick(() => {
89-
for (const key in innerRef.value) {
90-
if (typeof innerRef.value[key] === 'function') {
91-
publicApi[key] = innerRef.value[key];
92-
}
93-
}
94-
});
79+
expose(
80+
new Proxy(
81+
{},
82+
{
83+
get: (_target, key) => innerRef.value?.[key],
84+
has: (_target, key) => key in (innerRef.value || {}),
85+
},
86+
),
87+
);
9588
return () =>
9689
h(
9790
component,

apps/web-ele/src/adapter/component/index.ts

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,7 @@ import type { Component } from 'vue';
88
import type { BaseFormComponentType } from '@vben/common-ui';
99
import type { Recordable } from '@vben/types';
1010

11-
import {
12-
defineAsyncComponent,
13-
defineComponent,
14-
getCurrentInstance,
15-
h,
16-
ref,
17-
} from 'vue';
11+
import { defineAsyncComponent, defineComponent, h, ref } from 'vue';
1812

1913
import { ApiComponent, globalShareState, IconPicker } from '@vben/common-ui';
2014
import { $t } from '@vben/locales';
@@ -139,16 +133,15 @@ const withDefaultPlaceholder = <T extends Component>(
139133
$t(`ui.placeholder.${type}`);
140134
// 透传组件暴露的方法
141135
const innerRef = ref();
142-
const publicApi: Recordable<any> = {};
143-
expose(publicApi);
144-
const instance = getCurrentInstance();
145-
instance?.proxy?.$nextTick(() => {
146-
for (const key in innerRef.value) {
147-
if (typeof innerRef.value[key] === 'function') {
148-
publicApi[key] = innerRef.value[key];
149-
}
150-
}
151-
});
136+
expose(
137+
new Proxy(
138+
{},
139+
{
140+
get: (_target, key) => innerRef.value?.[key],
141+
has: (_target, key) => key in (innerRef.value || {}),
142+
},
143+
),
144+
);
152145
return () =>
153146
h(
154147
component,

apps/web-naive/src/adapter/component/index.ts

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,7 @@ import type { Component } from 'vue';
88
import type { BaseFormComponentType } from '@vben/common-ui';
99
import type { Recordable } from '@vben/types';
1010

11-
import {
12-
defineAsyncComponent,
13-
defineComponent,
14-
getCurrentInstance,
15-
h,
16-
ref,
17-
} from 'vue';
11+
import { defineAsyncComponent, defineComponent, h, ref } from 'vue';
1812

1913
import { ApiComponent, globalShareState, IconPicker } from '@vben/common-ui';
2014
import { $t } from '@vben/locales';
@@ -85,16 +79,15 @@ const withDefaultPlaceholder = <T extends Component>(
8579
$t(`ui.placeholder.${type}`);
8680
// 透传组件暴露的方法
8781
const innerRef = ref();
88-
const publicApi: Recordable<any> = {};
89-
expose(publicApi);
90-
const instance = getCurrentInstance();
91-
instance?.proxy?.$nextTick(() => {
92-
for (const key in innerRef.value) {
93-
if (typeof innerRef.value[key] === 'function') {
94-
publicApi[key] = innerRef.value[key];
95-
}
96-
}
97-
});
82+
expose(
83+
new Proxy(
84+
{},
85+
{
86+
get: (_target, key) => innerRef.value?.[key],
87+
has: (_target, key) => key in (innerRef.value || {}),
88+
},
89+
),
90+
);
9891
return () =>
9992
h(
10093
component,

apps/web-naive/src/views/demos/form/basic.vue

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<script lang="ts" setup>
2-
import { Page } from '@vben/common-ui';
2+
import { Page, useVbenModal } from '@vben/common-ui';
33
44
import { NButton, NCard, useMessage } from 'naive-ui';
55
66
import { useVbenForm } from '#/adapter/form';
77
import { getAllMenusApi } from '#/api';
88
9+
import modalDemo from './modal.vue';
10+
911
const message = useMessage();
1012
const [Form, formApi] = useVbenForm({
1113
commonConfig: {
@@ -143,6 +145,10 @@ function setFormValues() {
143145
date: Date.now(),
144146
});
145147
}
148+
149+
const [Modal, modalApi] = useVbenModal({
150+
connectedComponent: modalDemo,
151+
});
146152
</script>
147153
<template>
148154
<Page
@@ -152,8 +158,12 @@ function setFormValues() {
152158
<NCard title="基础表单">
153159
<template #header-extra>
154160
<NButton type="primary" @click="setFormValues">设置表单值</NButton>
161+
<NButton type="primary" @click="modalApi.open()" class="ml-2">
162+
打开弹窗
163+
</NButton>
155164
</template>
156165
<Form />
157166
</NCard>
167+
<Modal />
158168
</Page>
159169
</template>
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<script lang="ts" setup>
2+
import { useVbenModal } from '@vben/common-ui';
3+
4+
import { useVbenForm } from '#/adapter/form';
5+
6+
defineOptions({
7+
name: 'FormModelDemo',
8+
});
9+
10+
const [Form, formApi] = useVbenForm({
11+
schema: [
12+
{
13+
component: 'Input',
14+
componentProps: {
15+
placeholder: '请输入',
16+
},
17+
fieldName: 'field1',
18+
label: '字段1',
19+
rules: 'required',
20+
},
21+
{
22+
component: 'Input',
23+
componentProps: {
24+
placeholder: '请输入',
25+
},
26+
fieldName: 'field2',
27+
label: '字段2',
28+
rules: 'required',
29+
},
30+
{
31+
component: 'Select',
32+
componentProps: {
33+
options: [
34+
{ label: '选项1', value: '1' },
35+
{ label: '选项2', value: '2' },
36+
],
37+
placeholder: '请输入',
38+
},
39+
fieldName: 'field3',
40+
label: '字段3',
41+
rules: 'required',
42+
},
43+
],
44+
showDefaultActions: false,
45+
});
46+
47+
const [Modal, modalApi] = useVbenModal({
48+
fullscreenButton: false,
49+
onCancel() {
50+
modalApi.close();
51+
},
52+
onConfirm: async () => {
53+
await formApi.validateAndSubmitForm();
54+
// modalApi.close();
55+
},
56+
onOpenChange(isOpen: boolean) {
57+
if (isOpen) {
58+
const { values } = modalApi.getData<Record<string, any>>();
59+
if (values) {
60+
formApi.setValues(values);
61+
}
62+
}
63+
},
64+
title: '内嵌表单示例',
65+
});
66+
</script>
67+
<template>
68+
<Modal>
69+
<Form />
70+
</Modal>
71+
</template>

docs/src/en/guide/essentials/server.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ export async function saveUserApi(user: UserInfo) {
150150
```ts
151151
import { requestClient } from '#/api/request';
152152

153-
export async function deleteUserApi(user: UserInfo) {
154-
return requestClient.delete<boolean>(`/user/${user.id}`, user);
153+
export async function deleteUserApi(userId: number) {
154+
return requestClient.delete<boolean>(`/user/${userId}`);
155155
}
156156
```
157157

docs/src/en/guide/project/standard.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
- If you want to contribute code to the project, please ensure your code complies with the project's coding standards.
66
- If you are using `vscode`, you need to install the following plugins:
7-
87
- [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) - Script code checking
98
- [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) - Code formatting
109
- [Code Spell Checker](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker) - Word syntax checking
@@ -157,7 +156,6 @@ The most effective solution is to perform Lint checks locally before committing.
157156
The project defines corresponding hooks inside `lefthook.yml`:
158157

159158
- `pre-commit`: Runs before commit, used for code formatting and checking
160-
161159
- `code-workspace`: Updates VSCode workspace configuration
162160
- `lint-md`: Formats Markdown files
163161
- `lint-vue`: Formats and checks Vue files
@@ -167,7 +165,6 @@ The project defines corresponding hooks inside `lefthook.yml`:
167165
- `lint-json`: Formats other JSON files
168166

169167
- `post-merge`: Runs after merge, used for automatic dependency installation
170-
171168
- `install`: Runs `pnpm install` to install new dependencies
172169

173170
- `commit-msg`: Runs during commit, used for checking commit message format

docs/src/friend-links/index.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
### 友情链接
1919

2020
- 在您的网站上添加我们的友情链接,链接如下:
21-
2221
- 名称:Vben Admin
2322
- 链接:https://www.vben.pro
2423
- 描述:Vben Admin 企业级开箱即用的中后台前端解决方案

docs/src/guide/essentials/server.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ export async function saveUserApi(user: UserInfo) {
180180
```ts
181181
import { requestClient } from '#/api/request';
182182

183-
export async function deleteUserApi(user: UserInfo) {
184-
return requestClient.delete<boolean>(`/user/${user.id}`, user);
183+
export async function deleteUserApi(userId: number) {
184+
return requestClient.delete<boolean>(`/user/${userId}`);
185185
}
186186
```
187187

0 commit comments

Comments
 (0)