-
Notifications
You must be signed in to change notification settings - Fork 311
feat(config-provider): [config-provider] 支持合并主题配置 #3187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hashiqi12138
wants to merge
1
commit into
opentiny:dev
Choose a base branch
from
hashiqi12138:feat-merge-config
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
204 changes: 204 additions & 0 deletions
204
examples/sites/demos/pc/app/config-provider/merge-composition-api.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,204 @@ | ||
<template> | ||
<div> | ||
<h2>父主题配置</h2> | ||
|
||
<tiny-config-provider :design="parentDesign"> | ||
<h2>子主题配置</h2> | ||
<tiny-config-provider :design="childDesign1"> | ||
<div class="demo-form"> | ||
<tiny-alert type="warning" description="全局配置组件的默认行为"></tiny-alert> | ||
<tiny-form ref="ruleFormRef" :model="formData"> | ||
<tiny-form-item label="年龄" prop="age" required> | ||
<tiny-numeric v-model="formData.age"></tiny-numeric> | ||
</tiny-form-item> | ||
<tiny-form-item label="姓名" prop="name" required> | ||
<tiny-input v-model="formData.name"></tiny-input> | ||
</tiny-form-item> | ||
<tiny-form-item> | ||
<tiny-button @click="handleSubmitPromise" type="primary"> 校验 </tiny-button> | ||
</tiny-form-item> | ||
</tiny-form> | ||
</div> | ||
</tiny-config-provider> | ||
<h2>子主题配置</h2> | ||
<tiny-config-provider :design="childDesign2"> | ||
<div class="demo-form"> | ||
<tiny-alert type="warning" description="全局配置组件的默认行为"></tiny-alert> | ||
<tiny-form ref="ruleFormRef" :model="formData"> | ||
<tiny-form-item label="年龄" prop="age" required> | ||
<tiny-numeric v-model="formData.age"></tiny-numeric> | ||
</tiny-form-item> | ||
<tiny-form-item label="姓名" prop="name" required> | ||
<tiny-input v-model="formData.name"></tiny-input> | ||
</tiny-form-item> | ||
<tiny-form-item> | ||
<tiny-button @click="handleSubmitPromise" type="primary"> 校验 </tiny-button> | ||
</tiny-form-item> | ||
</tiny-form> | ||
</div> | ||
</tiny-config-provider> | ||
</tiny-config-provider> | ||
|
||
<h2>主题配置</h2> | ||
<tiny-config-provider :design="noParentDesign"> | ||
<div class="demo-form"> | ||
<tiny-alert type="warning" description="全局配置组件的默认行为"></tiny-alert> | ||
<tiny-form ref="ruleFormRef" :model="formData"> | ||
<tiny-form-item label="年龄" prop="age" required> | ||
<tiny-numeric v-model="formData.age"></tiny-numeric> | ||
</tiny-form-item> | ||
<tiny-form-item label="姓名" prop="name" required> | ||
<tiny-input v-model="formData.name"></tiny-input> | ||
</tiny-form-item> | ||
<tiny-form-item> | ||
<tiny-button @click="handleSubmitPromise" type="primary"> 校验 </tiny-button> | ||
</tiny-form-item> | ||
</tiny-form> | ||
</div> | ||
</tiny-config-provider> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import { ref } from 'vue' | ||
import { | ||
TinyConfigProvider, | ||
TinyAlert, | ||
TinyModal, | ||
TinyForm, | ||
TinyFormItem, | ||
TinyInput, | ||
TinyNumeric, | ||
TinyButton | ||
} from '@opentiny/vue' | ||
import { iconWarningTriangle } from '@opentiny/vue-icon' | ||
|
||
const ruleFormRef = ref() | ||
|
||
const parentDesign = ref({ | ||
name: 'x-design-p', // 设计规范名称 | ||
version: '1.0.0', // 设计规范版本号 | ||
components: { | ||
Button: { | ||
props: { | ||
round: true | ||
} | ||
} | ||
} | ||
}) | ||
const childDesign1 = ref({ | ||
name: 'x-design-1', // 设计规范名称 | ||
version: '1.0.0', // 设计规范版本号 | ||
components: { | ||
Button: { | ||
props: { | ||
resetTime: 0 | ||
} | ||
} | ||
} | ||
}) | ||
const childDesign2 = ref({ | ||
name: 'x-design-2', // 设计规范名称 | ||
version: '1.0.0', // 设计规范版本号 | ||
components: { | ||
Button: { | ||
props: { | ||
round: true | ||
} | ||
}, | ||
Alert: { | ||
icons: { | ||
warning: iconWarningTriangle() | ||
}, | ||
/** | ||
* | ||
* @param {*} props 组件属性集合 | ||
* @param {*} hooks vue2-->@composition-api,vue3-->vue | ||
* @param {*} param2 context | ||
* @param {*} api Alert 组件 renderless 层方法属性和方法集合 | ||
*/ | ||
renderless: (props, hooks, { emit }, api) => { | ||
const state = api.state | ||
return { | ||
handleClose() { | ||
state.show = false | ||
TinyModal.message('触发自定方法') | ||
emit('close') | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}) | ||
const noParentDesign = { | ||
name: 'x-design-n', // 设计规范名称 | ||
version: '1.0.0', // 设计规范版本号 | ||
components: { | ||
Button: { | ||
props: { | ||
round: true | ||
} | ||
}, | ||
Form: { | ||
props: { | ||
hideRequiredAsterisk: true | ||
} | ||
} | ||
} | ||
} | ||
|
||
const design = { | ||
name: 'x-design', // 设计规范名称 | ||
version: '1.0.0', // 设计规范版本号 | ||
components: { | ||
Form: { | ||
props: { | ||
hideRequiredAsterisk: true | ||
} | ||
}, | ||
Button: { | ||
props: { | ||
resetTime: 0, | ||
round: true | ||
} | ||
}, | ||
Alert: { | ||
icons: { | ||
warning: iconWarningTriangle() | ||
}, | ||
/** | ||
* | ||
* @param {*} props 组件属性集合 | ||
* @param {*} hooks vue2-->@composition-api,vue3-->vue | ||
* @param {*} param2 context | ||
* @param {*} api Alert 组件 renderless 层方法属性和方法集合 | ||
*/ | ||
renderless: (props, hooks, { emit }, api) => { | ||
const state = api.state | ||
return { | ||
handleClose() { | ||
state.show = false | ||
TinyModal.message('触发自定方法') | ||
emit('close') | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
const handleSubmitPromise = () => { | ||
ruleFormRef.value.validate().catch(() => {}) | ||
} | ||
|
||
const formData = ref({ | ||
name: '', | ||
age: '' | ||
}) | ||
</script> | ||
|
||
<style scoped> | ||
.demo-form { | ||
width: 380px; | ||
} | ||
</style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { test, expect } from '@playwright/test' | ||
|
||
test('测试自定义事件', async ({ page }) => { | ||
page.on('pageerror', (exception) => expect(exception).toBeNull()) | ||
await page.goto('config-provider#merge') | ||
|
||
// 验证自定义方法 | ||
const demo = page.locator('#merge') | ||
await demo.locator('.tiny-config-provider .tiny-alert > .tiny-alert__close').click() | ||
await page.waitForTimeout(500) | ||
await expect(page.locator('.tiny-modal > .tiny-modal__box').nth(1)).toHaveText('触发自定方法') | ||
|
||
// 验证必填星号 | ||
await expect(demo.locator('.tiny-form')).toBeVisible() | ||
const beforeElement = await page.evaluate(() => { | ||
const labelBefore = document.querySelector('.tiny-form .tiny-form-item__label') | ||
const { display, content } = window.getComputedStyle(labelBefore, '::before') | ||
return { display, content } | ||
}) | ||
expect(beforeElement.content).toBe('none') | ||
|
||
// 验证按钮点击禁用时间 | ||
await demo.locator('.tiny-button').click() | ||
await expect(demo.locator('.tiny-button')).not.toBeDisabled({ timeout: 300 }) | ||
}) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This comment was marked as duplicate.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.