chore: reorganize utils

This commit is contained in:
07akioni 2020-10-08 15:07:33 +08:00
parent 70f9517a30
commit 22d2c9c9a9
11 changed files with 46 additions and 22 deletions

View File

@ -1,12 +1,14 @@
# 动态修改内容
你可以修改已经存在的通知
```html
<n-button @click="open">
打开它
</n-button>
<n-button @click="change" :disabled="!notification">
改它
</n-button>
<n-space>
<n-button @click="open">
打开它
</n-button>
<n-button @click="change" :disabled="!n">
改它
</n-button>
</n-space>
```
```js
import { h, resolveComponent } from 'vue'
@ -15,12 +17,12 @@ export default {
inject: ['notification'],
data () {
return {
notification: null
n: null
}
},
methods: {
open () {
this.notification = this.notification.create({
this.n = this.notification.create({
title: `Wouldn't it be Nice`,
description: 'From the Beach Boys',
content: `Wouldn't it be nice if we were older
@ -41,13 +43,13 @@ Hold each other close the whole night through`,
src:'https://07akioni.oss-cn-beijing.aliyuncs.com/07akioni.jpeg'
}),
onClose: () => {
this.notification = null
this.n = null
}
})
},
change () {
if (this.notification) {
this.notification.content = () => h('img', {
if (this.n) {
this.n.content = () => h('img', {
src: 'https://07akioni.oss-cn-beijing.aliyuncs.com/07akioni.jpeg',
style: 'width: 100%;'
})
@ -55,9 +57,4 @@ Hold each other close the whole night through`,
}
}
}
```
```css
.n-button {
margin: 0 12px 8px 0;
}
```

View File

@ -10,7 +10,7 @@ import addDays from 'date-fns/addDays'
import getDay from 'date-fns/getDay'
import parse from 'date-fns/parse'
import format from 'date-fns/format'
import { KEY_CODE } from '../event/keyCode'
import { KEY_CODE } from '../dom/key-code'
function getDerivedTimeFromKeyboardEvent (prevValue, event) {
const now = getTime(Date.now())

View File

@ -1,4 +1,4 @@
import { KEY_CODE } from '../event/keyCode'
import { KEY_CODE } from '../dom/key-code'
class KeyboardDelegate {
constructor () {

1
src/_utils/dom/index.js Normal file
View File

@ -0,0 +1 @@
export { KEY_CODE } from './key-code'

26
src/_utils/index.js Normal file
View File

@ -0,0 +1,26 @@
export {
call,
keep,
omit,
createId,
getVNodeChildren,
render
} from './vue'
export {
warn,
warnOnce,
debug
} from './naive'
export {
pxfy,
depx,
formatLength
} from './css'
export * from './composition'
export {
nextFrame,
isIos
} from './misc'
export {
KEY_CODE
} from './dom'

View File

@ -3,7 +3,7 @@ import {
locale
} from '../../../_mixins'
import keyboardDelegate from '../../../_utils/delegate/keyboardDelegate'
import { KEY_CODE } from '../../../_utils/event/keyCode'
import { KEY_CODE } from '../../../_utils'
const TIME_CONST = {
hours: ['00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23'],

View File

@ -5,7 +5,7 @@ import {
themeable,
usecssr
} from '../../_mixins'
import { KEY_CODE } from '../../_utils/event/keyCode'
import { KEY_CODE } from '../../_utils'
import keyboardDelegate from '../../_utils/delegate/keyboardDelegate'
import NPopover from '../../popover'
import NDropdownMenu from './DropdownMenu.js'

View File

@ -88,7 +88,7 @@ import themable from '../../_mixins/themeable'
import resizeObserverDelagate from '../../_utils/delegate/resizeObserverDelegate'
import usecssr from '../../_mixins/usecssr'
import styles from './styles/index.js'
import { isIos } from '../../_utils/browser/os'
import { isIos } from '../../_utils'
export default {
name: 'Scrollbar',

View File

@ -203,7 +203,7 @@ import getHours from 'date-fns/getHours'
import getSeconds from 'date-fns/getSeconds'
import { strictParse } from '../../_utils/component/datePicker'
import keyboardDelegate from '../../_utils/delegate/keyboardDelegate'
import { KEY_CODE } from '../../_utils/event/keyCode'
import { KEY_CODE } from '../../_utils'
import NBaseFocusDetector from '../../_base/focus-detector'
import TimeIcon from '../../_icons/time-outline.vue'
import styles from './styles'