Skip to content

Commit f3eae9f

Browse files
author
白唯
committed
docs(license): 添加了 LICENSE
1 parent 5b4c2c8 commit f3eae9f

File tree

3 files changed

+73
-26
lines changed

3 files changed

+73
-26
lines changed

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 ibaiwei
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

src/components/index.ts

+25-26
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
1-
import { kebabCase } from 'lodash'
2-
import { createApp } from 'vue'
3-
import { createFromIconfontCN } from '@ant-design/icons-vue'
4-
import { StaticConfig } from '@/config/app'
5-
// iconfont的使用姿势: 2x.antdv.com/components/icon-cn/#components-icon-demo-use-iconfont.cn
6-
const IconFont: any = createFromIconfontCN({
7-
scriptUrl: StaticConfig.IconfontURL
8-
})
9-
10-
/**
11-
* @description 自动将 ./src/components/global 下的组件注册成为全局组件
12-
* @param {vue} app 当前应用实例
13-
* @returns {void} void
14-
*/
15-
export function registeGlobalComponent(app: ReturnType<typeof createApp>): void {
16-
const files = require.context('./global', true, /\.(vue|ts)$/)
17-
files.keys().forEach(key => {
18-
const config = files(key)
19-
console.log(key)
20-
const name = kebabCase(key.replace(/^\.\//, '').replace(/\.\w+$/, ''))
21-
app.component(name, config.default || config)
22-
})
23-
24-
// 全局注册 iconfont
25-
app.component('IconFont', IconFont)
26-
}
1+
import { kebabCase } from 'lodash'
2+
import { createApp } from 'vue'
3+
import { createFromIconfontCN } from '@ant-design/icons-vue'
4+
import { StaticConfig } from '@/config/app'
5+
// iconfont的使用姿势: 2x.antdv.com/components/icon-cn/#components-icon-demo-use-iconfont.cn
6+
const IconFont: any = createFromIconfontCN({
7+
scriptUrl: StaticConfig.IconfontURL
8+
})
9+
10+
/**
11+
* @description 自动将 ./src/components/global 下的组件注册成为全局组件
12+
* @param {vue} app 当前应用实例
13+
* @returns {void} void
14+
*/
15+
export function registeGlobalComponent(app: ReturnType<typeof createApp>): void {
16+
const files = require.context('./global', true, /\.(vue|ts)$/)
17+
files.keys().forEach(key => {
18+
const config = files(key)
19+
const name = kebabCase(key.replace(/^\.\//, '').replace(/\.\w+$/, ''))
20+
app.component(name, config.default || config)
21+
})
22+
23+
// 全局注册 iconfont
24+
app.component('IconFont', IconFont)
25+
}

src/utils/hooks/index.ts

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { customRef } from 'vue'
2+
3+
/**
4+
* @description 使用自定义 ref 实现带防抖功能的 v-model :
5+
* @param {any} value 要更改的值
6+
* @param {number} delay
7+
* @returns {T}
8+
*/
9+
10+
export function useDebouncedRef<T>(value: T, delay = 200) {
11+
let timeout: any = null
12+
return customRef((track, trigger) => {
13+
return {
14+
get() {
15+
track()
16+
return value
17+
},
18+
set(newValue: T) {
19+
clearTimeout(timeout)
20+
timeout = setTimeout(() => {
21+
value = newValue
22+
trigger()
23+
}, delay)
24+
}
25+
}
26+
})
27+
}

0 commit comments

Comments
 (0)