Skip to content

Commit

Permalink
fix(notice): config placement not effective
Browse files Browse the repository at this point in the history
  • Loading branch information
qmhc committed Jun 9, 2021
1 parent bfb4b96 commit 833933b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
13 changes: 13 additions & 0 deletions components/notice/__serve__/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,29 @@
<Button type="error" @on-click="$notice.error('提示的标题', '一条错误提示消息')">
错误提示
</Button>
<Button type="warning" @on-click="blNotice.warning('左下角提示', '一条左下角提示消息')">
左下提示
</Button>
</template>

<script lang="ts">
import { defineComponent } from 'vue'
import { Button } from '@/components/button'
import { Notice } from '..'
export default defineComponent({
name: 'App',
components: {
Button
},
setup() {
const blNotice = Notice.clone()
blNotice.config({ placement: 'bottom-left' })
return {
blNotice
}
}
})
</script>
Expand Down
2 changes: 1 addition & 1 deletion components/notice/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export class NoticeManager {

config({ placement, ...others }: { placement?: NoticePlacement, [x: string]: unknown }) {
if (placement) {
this._getInstance().$props.placement = placementWhiteList.includes(placement)
this._getInstance().placement = placementWhiteList.includes(placement)
? placement
: placementWhiteList[0]
}
Expand Down
12 changes: 2 additions & 10 deletions components/notice/notice.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,24 +85,15 @@ import '@/common/icons/times'
import type { Key, NoticePlacement } from './symbol'
const props = {
placement: {
default: 'top-right' as NoticePlacement,
validator: (value: NoticePlacement) => {
return ['top-right', 'top-left', 'bottom-right', 'bottom-left'].includes(value)
}
}
}
export default defineComponent({
name: 'Notice',
components: {
Icon,
Renderer,
Popup
},
props,
setup() {
const placement = ref<NoticePlacement>('top-right')
const popup = ref<InstanceType<typeof Popup> | null>(null)
async function add(options: Record<string, unknown>) {
Expand All @@ -120,6 +111,7 @@ export default defineComponent({
return {
prefix: 'vxp-notice',
effectiveTypes: ['info', 'success', 'warning', 'error'],
placement,
popup,
Expand Down
4 changes: 1 addition & 3 deletions components/notice/symbol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ export interface NoticeOptions extends Record<string, unknown> {
}

export interface NoticeInstance extends ComponentPublicInstance {
$props: {
placement: NoticePlacement
},
placement: NoticePlacement,
add: (options: NoticeOptions) => void,
remove: (key: string | number) => void,
clear: () => void
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@
"main": "dist/vexip-ui.cjs.js",
"module": "dist/vexip-ui.es.js",
"name": "vexip-ui",
"repository": {
"type": "git",
"url": "git+https://github.com/qmhc/vexip-ui.git"
},
"scripts": {
"build": "node scripts/build.js",
"build:clean": "yarn run clean && yarn run build",
Expand Down

0 comments on commit 833933b

Please sign in to comment.