Compare commits

...

8 Commits

Author SHA1 Message Date
d7b6afccfe update changelog 2019-07-22 18:58:05 +08:00
a92e36067b Fix potential namespace conflicts 2019-07-22 18:56:49 +08:00
2d316d3629 Error caused by namespace conflict. 2019-07-22 18:50:42 +08:00
f0fcefd08a update changelog 2019-07-22 18:50:30 +08:00
38cb5e87de update version to 2.3.3 2019-07-22 18:50:22 +08:00
9699837d0e update publish process 2019-07-09 11:44:10 +08:00
132a817933 update readme 2019-07-05 16:25:54 +08:00
2408c821e7 update change log 2019-07-05 16:23:58 +08:00
9 changed files with 61 additions and 391 deletions

View File

@ -1,3 +1,10 @@
# 2.3.3-alpha (2019-07-22)
### Bug Fixes
- **waterPondLevel:** Potential namespace conflict.
- **digitalFlop:** Potential namespace conflict.
# 2.3.2-alpha (2019-07-05) # 2.3.2-alpha (2019-07-05)
### Perfect ### Perfect
@ -6,7 +13,7 @@
- **Introduced on demand** - **Introduced on demand**
```js ```js
import borderBox1 from '@jiaminghi/data-view' import { borderBox1 } from '@jiaminghi/data-view'
Vue.use(borderBox1) Vue.use(borderBox1)
``` ```

View File

@ -6,7 +6,7 @@
<a href="https://github.com/jiaming743/datav/blob/master/LICENSE"> <a href="https://github.com/jiaming743/datav/blob/master/LICENSE">
<img src="https://img.shields.io/github/license/jiaming743/datav.svg" alt="LICENSE" /> <img src="https://img.shields.io/github/license/jiaming743/datav.svg" alt="LICENSE" />
</a> </a>
<a href="https://www.npmjs.com/package/@jiaminghi/datav"> <a href="https://www.npmjs.com/package/@jiaminghi/data-view">
<img src="https://img.shields.io/npm/v/@jiaminghi/data-view.svg" alt="LICENSE" /> <img src="https://img.shields.io/npm/v/@jiaminghi/data-view.svg" alt="LICENSE" />
</a> </a>
</p> </p>

View File

@ -6,7 +6,7 @@
<a href="https://github.com/jiaming743/datav/blob/master/LICENSE"> <a href="https://github.com/jiaming743/datav/blob/master/LICENSE">
<img src="https://img.shields.io/github/license/jiaming743/datav.svg" alt="LICENSE" /> <img src="https://img.shields.io/github/license/jiaming743/datav.svg" alt="LICENSE" />
</a> </a>
<a href="https://www.npmjs.com/package/@jiaminghi/datav"> <a href="https://www.npmjs.com/package/@jiaminghi/data-view">
<img src="https://img.shields.io/npm/v/@jiaminghi/data-view.svg" alt="LICENSE" /> <img src="https://img.shields.io/npm/v/@jiaminghi/data-view.svg" alt="LICENSE" />
</a> </a>
</p> </p>

14
package-lock.json generated Normal file
View File

@ -0,0 +1,14 @@
{
"name": "@jiaminghi/data-view",
"version": "2.3.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@jiaminghi/fs": {
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/@jiaminghi/fs/-/fs-0.0.0.tgz",
"integrity": "sha512-hCVpiw5IBBAB2H73gKDxd0Xp5e7cnpqdpgLnrkXgVK29aIoowVUS1qklNP8kPohAxz6967aGp7yW+N4XQtrSWA==",
"dev": true
}
}
}

View File

@ -1,6 +1,6 @@
{ {
"name": "@jiaminghi/data-view", "name": "@jiaminghi/data-view",
"version": "2.3.2", "version": "2.3.3",
"author": "JiaMing <743192023@qq.com>", "author": "JiaMing <743192023@qq.com>",
"description": "Vue Large screen data display component library", "description": "Vue Large screen data display component library",
"main": "/lib/index.js", "main": "/lib/index.js",
@ -25,5 +25,8 @@
"dependencies": { "dependencies": {
"@jiaminghi/charts": "*" "@jiaminghi/charts": "*"
}, },
"homepage": "https://github.com/jiaming743/DataV#readme" "homepage": "https://github.com/jiaming743/DataV#readme",
"devDependencies": {
"@jiaminghi/fs": "0.0.1"
}
} }

View File

@ -1,4 +1,4 @@
const { copyDir, fileForEach, readFile, writeFile, unlinkDirFileByExtname, dirForEach } = require('./plugin/fs') const { copyDir, fileForEach, readFile, writeFile, unlinkDirFileByExtname, dirForEach } = require('@jiaminghi/fs')
const print = require('./plugin/print') const print = require('./plugin/print')
const path = require('path') const path = require('path')
const doExec = require('./plugin/exec') const doExec = require('./plugin/exec')

View File

@ -1,354 +0,0 @@
const fs = require('fs')
const path = require('path')
function readDir (src) {
return new Promise(resolve => {
fs.readdir(src, (err, paths) => {
if (err) {
console.error(err)
resolve(false)
}
resolve(paths)
})
})
}
function stat (src) {
return new Promise(resolve => {
fs.stat(src, (err, stats) => {
if (err) {
console.error(err)
resolve(false)
}
resolve(stats)
})
})
}
function mkdir (src) {
return new Promise(resolve => {
fs.mkdir(src, err => {
if (err) {
console.error(err)
resolve(false)
}
resolve(true)
})
})
}
function access (src, mode = fs.constants.F_OK) {
return new Promise(resolve => {
fs.access(src, mode, err => {
if (err) {
resolve(false)
return
}
resolve(true)
})
})
}
function unlink (src) {
return new Promise(resolve => {
fs.unlink(src, err => {
if (err) {
console.error(err)
resolve(false)
}
resolve(true)
})
})
}
function rmDir (src) {
return new Promise(resolve => {
fs.rmdir(src, err => {
if (err) {
resolve(false)
} else {
resolve(true)
}
})
})
}
async function clearDir (src) {
const isExists = await access(src)
if (!isExists) {
await mkdir(src)
return true
}
return await emptyDir(src)
}
async function emptyDir (src) {
const paths = await readDir(src)
if (!paths) {
console.error('Exception in emptyDir: paths!')
return false
}
for (let i = 0; i < paths.length; i++) {
const fullSrc = src + '/' + paths[i]
const stats = await stat(fullSrc)
if (!stats) {
console.error('Exception in emptyDir: stats!')
return false
}
if (stats.isFile()) {
const isUnlink = await unlink(fullSrc)
if (!isUnlink) {
console.error('Exception in emptyDir: isUnlink!')
return false
}
} else if (stats.isDirectory()) {
const isEmpty = await emptyDir(fullSrc)
if (!isEmpty) {
console.error('Exception in emptyDir: isEmpty!')
return false
}
if (!await rmDir(fullSrc)) {
console.error('Exception in emptyDir: rmDir!')
return false
}
}
}
return true
}
async function unlinkDirFileByExtname (src, extnames = []) {
const paths = await readDir(src)
if (!paths) {
console.error('Exception in unlinkDirFileByExtname: paths!')
return false
}
for (let i = 0; i < paths.length; i++) {
const fullSrc = src + '/' + paths[i]
const stats = await stat(fullSrc)
if (!stats) {
console.error('Exception in unlinkDirFileByExtname: stats!')
return false
}
if (stats.isFile()) {
const cxtname = path.extname(fullSrc)
if (extnames.findIndex(name => name === cxtname) === -1) continue
const isUnlink = await unlink(fullSrc)
if (!isUnlink) {
console.error('Exception in unlinkDirFileByExtname: isUnlink!')
return false
}
} else if (stats.isDirectory()) {
const recursive = await unlinkDirFileByExtname(fullSrc, extnames)
if (!recursive) {
console.error('Exception in unlinkDirFileByExtname: recursive!')
return false
}
}
}
return true
}
async function copyDir (src, target) {
if (!src || !target) {
console.error('copyDir missing parameters!')
return false
}
const isClear = await clearDir(target)
if (!isClear) {
console.error('Exception in copyDir: isClear!')
return false
}
const paths = await readDir(src)
if (!paths) {
console.error('Exception in copyDir: paths!')
return false
}
for (let i = 0; i < paths.length; i++) {
const fullSrc = src + '/' + paths[i]
const fullTarget = target + '/' + paths[i]
const stats = await stat(fullSrc)
if (!stats) {
console.error('Exception in copyDir: stats!')
return false
}
if (stats.isFile()) {
fs.createReadStream(fullSrc).pipe(fs.createWriteStream(fullTarget))
} else if (stats.isDirectory()) {
const isMkdir = await mkdir(fullTarget)
if (!isMkdir) {
console.error('Exception in copyDir: isMkdir!')
return false
}
const isCopy = await copyDir(fullSrc, fullTarget)
if (!isCopy) {
console.error('Exception in copyDir: isCopy!')
return false
}
}
}
return true
}
async function fileForEach (src, callback) {
if (!src || !callback) {
console.error('fileForEach missing parameters!')
return false
}
const paths = await readDir(src)
if (!paths) {
console.error('Exception in fileForEach: paths!')
return false
}
for (let i = 0; i < paths.length; i++) {
const fullSrc = src + '/' + paths[i]
const stats = await stat(fullSrc)
if (!stats) {
console.error('Exception in fileForEach: stats!')
return false
}
if (stats.isFile()) {
await callback(fullSrc)
} else if (stats.isDirectory()) {
const recursive = await fileForEach(fullSrc, callback)
if (!recursive) {
console.error('Exception in fileForEach: recursive!')
return false
}
}
}
return true
}
async function readFile (src, encoding = 'utf8') {
return new Promise(resolve => {
fs.readFile(src, encoding, (err, data) => {
if (err) {
console.error(err)
resolve(false)
} else {
resolve(data)
}
})
})
}
async function writeFile (src, string, encoding = 'utf8') {
return new Promise(resolve => {
fs.writeFile(src, string, encoding, err => {
if (err) {
console.error(err)
resolve(false)
} else {
resolve(true)
}
})
})
}
async function dirForEach (src, callback) {
if (!src || !callback) {
console.error('dirForEach missing parameters!')
return false
}
const paths = await readDir(src)
if (!paths) {
console.error('Exception in dirForEach: paths!')
return false
}
for (let i = 0; i < paths.length; i++) {
const fullSrc = src + '/' + paths[i]
const stats = await stat(fullSrc)
if (!stats) {
console.error('Exception in dirForEach: stats!')
return false
}
if (stats.isDirectory()) await callback(fullSrc)
}
return true
}
module.exports = {
readDir,
stat,
mkdir,
clearDir,
emptyDir,
unlinkDirFileByExtname,
copyDir,
fileForEach,
readFile,
writeFile,
dirForEach
}

View File

@ -23,7 +23,7 @@ export default {
}, },
data () { data () {
return { return {
render: null, renderer: null,
defaultConfig: { defaultConfig: {
/** /**
@ -100,7 +100,7 @@ export default {
initRender () { initRender () {
const { $refs } = this const { $refs } = this
this.render = new CRender($refs['digital-flop']) this.renderer = new CRender($refs['digital-flop'])
}, },
mergeConfig () { mergeConfig () {
const { defaultConfig, config } = this const { defaultConfig, config } = this
@ -108,14 +108,14 @@ export default {
this.mergedConfig = deepMerge(deepClone(defaultConfig, true), config || {}) this.mergedConfig = deepMerge(deepClone(defaultConfig, true), config || {})
}, },
initGraph () { initGraph () {
const { getShape, getStyle, render, mergedConfig } = this const { getShape, getStyle, renderer, mergedConfig } = this
const { animationCurve, animationFrame } = mergedConfig const { animationCurve, animationFrame } = mergedConfig
const shape = getShape() const shape = getShape()
const style = getStyle() const style = getStyle()
this.graph = render.add({ this.graph = renderer.add({
name: 'numberText', name: 'numberText',
animationCurve, animationCurve,
animationFrame, animationFrame,
@ -126,7 +126,7 @@ export default {
getShape () { getShape () {
const { number, content, toFixed, textAlign } = this.mergedConfig const { number, content, toFixed, textAlign } = this.mergedConfig
const [w, h] = this.render.area const [w, h] = this.renderer.area
const position = [w / 2, h / 2] const position = [w / 2, h / 2]

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="dv-water-pond-level"> <div class="dv-water-pond-level">
<svg v-if="render"> <svg v-if="renderer">
<defs> <defs>
<linearGradient :id="gradientId" x1="0%" y1="0%" x2="0%" y2="100%"> <linearGradient :id="gradientId" x1="0%" y1="0%" x2="0%" y2="100%">
<stop v-for="lc in svgBorderGradient" :key="lc[0]" <stop v-for="lc in svgBorderGradient" :key="lc[0]"
@ -10,28 +10,28 @@
</defs> </defs>
<text <text
v-if="render" v-if="renderer"
:stroke="`url(#${gradientId})`" :stroke="`url(#${gradientId})`"
:fill="`url(#${gradientId})`" :fill="`url(#${gradientId})`"
:x="render.area[0] / 2 + 8" :x="renderer.area[0] / 2 + 8"
:y="render.area[1] / 2 + 8" :y="renderer.area[1] / 2 + 8"
> >
{{ details }} {{ details }}
</text> </text>
<ellipse v-if="!shape || shape === 'round'" <ellipse v-if="!shape || shape === 'round'"
:cx="render.area[0] / 2 + 8" :cx="renderer.area[0] / 2 + 8"
:cy="render.area[1] / 2 + 8" :cy="renderer.area[1] / 2 + 8"
:rx="render.area[0] / 2 + 5" :rx="renderer.area[0] / 2 + 5"
:ry="render.area[1] / 2 + 5" :ry="renderer.area[1] / 2 + 5"
:stroke="`url(#${gradientId})`" /> :stroke="`url(#${gradientId})`" />
<rect v-else <rect v-else
x="2" y="2" x="2" y="2"
:rx="shape === 'roundRect' ? 10 : 0" :rx="shape === 'roundRect' ? 10 : 0"
:ry="shape === 'roundRect' ? 10 : 0" :ry="shape === 'roundRect' ? 10 : 0"
:width="render.area[0] + 12" :width="renderer.area[0] + 12"
:height="render.area[1] + 12" :height="renderer.area[1] + 12"
:stroke="`url(#${gradientId})`" /> :stroke="`url(#${gradientId})`" />
</svg> </svg>
@ -105,7 +105,7 @@ export default {
mergedConfig: {}, mergedConfig: {},
render: null, renderer: null,
svgBorderGradient: [], svgBorderGradient: [],
@ -138,9 +138,9 @@ export default {
}, },
watch: { watch: {
config () { config () {
const { calcData, render } = this const { calcData, renderer } = this
render.delAllGraph() renderer.delAllGraph()
this.waves = [] this.waves = []
@ -160,7 +160,7 @@ export default {
initRender () { initRender () {
const { $refs } = this const { $refs } = this
this.render = new CRender($refs['water-pond-level']) this.renderer = new CRender($refs['water-pond-level'])
}, },
calcData () { calcData () {
const { mergeConfig, calcSvgBorderGradient, calcDetails } = this const { mergeConfig, calcSvgBorderGradient, calcDetails } = this
@ -205,12 +205,12 @@ export default {
this.details = formatter.replace('{value}', maxValue) this.details = formatter.replace('{value}', maxValue)
}, },
addWave () { addWave () {
const { render, getWaveShapes, getWaveStyle, drawed } = this const { renderer, getWaveShapes, getWaveStyle, drawed } = this
const shapes = getWaveShapes() const shapes = getWaveShapes()
const style = getWaveStyle() const style = getWaveStyle()
this.waves = shapes.map(shape => render.add({ this.waves = shapes.map(shape => renderer.add({
name: 'smoothline', name: 'smoothline',
animationFrame: 300, animationFrame: 300,
shape, shape,
@ -219,11 +219,11 @@ export default {
})) }))
}, },
getWaveShapes () { getWaveShapes () {
const { mergedConfig, render, mergeOffset } = this const { mergedConfig, renderer, mergeOffset } = this
const { waveNum, waveHeight, data } = mergedConfig const { waveNum, waveHeight, data } = mergedConfig
const [w, h] = render.area const [w, h] = renderer.area
const pointsNum = waveNum * 4 + 4 const pointsNum = waveNum * 4 + 4
@ -249,9 +249,9 @@ export default {
return [x + ox, y + oy] return [x + ox, y + oy]
}, },
getWaveStyle () { getWaveStyle () {
const { render, mergedConfig } = this const { renderer, mergedConfig } = this
const h = render.area[1] const h = renderer.area[1]
return { return {
gradientColor: mergedConfig.colors, gradientColor: mergedConfig.colors,
@ -276,13 +276,13 @@ export default {
ctx.fill() ctx.fill()
}, },
async animationWave (repeat = 1) { async animationWave (repeat = 1) {
const { waves, render, animation } = this const { waves, renderer, animation } = this
if (animation) return if (animation) return
this.animation = true this.animation = true
const w = render.area[0] const w = renderer.area[0]
waves.forEach(graph => { waves.forEach(graph => {
graph.attr('style', { translate: [0, 0] }) graph.attr('style', { translate: [0, 0] })
@ -292,11 +292,11 @@ export default {
}, true) }, true)
}) })
await render.launchAnimation() await renderer.launchAnimation()
this.animation = false this.animation = false
if (!render.graphs.length) return if (!renderer.graphs.length) return
this.animationWave(repeat + 1) this.animationWave(repeat + 1)
} }
@ -307,9 +307,9 @@ export default {
init() init()
}, },
beforeDestroy () { beforeDestroy () {
const { render } = this const { renderer } = this
render.delAllGraph() renderer.delAllGraph()
this.waves = [] this.waves = []
} }