Compare commits
8 Commits
V2.3.2-alp
...
V2.3.3-alp
Author | SHA1 | Date | |
---|---|---|---|
d7b6afccfe | |||
a92e36067b | |||
2d316d3629 | |||
f0fcefd08a | |||
38cb5e87de | |||
9699837d0e | |||
132a817933 | |||
2408c821e7 |
@ -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)
|
||||
|
||||
### Perfect
|
||||
@ -6,7 +13,7 @@
|
||||
- **Introduced on demand**
|
||||
|
||||
```js
|
||||
import borderBox1 from '@jiaminghi/data-view'
|
||||
import { borderBox1 } from '@jiaminghi/data-view'
|
||||
|
||||
Vue.use(borderBox1)
|
||||
```
|
||||
|
@ -6,7 +6,7 @@
|
||||
<a href="https://github.com/jiaming743/datav/blob/master/LICENSE">
|
||||
<img src="https://img.shields.io/github/license/jiaming743/datav.svg" alt="LICENSE" />
|
||||
</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" />
|
||||
</a>
|
||||
</p>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<a href="https://github.com/jiaming743/datav/blob/master/LICENSE">
|
||||
<img src="https://img.shields.io/github/license/jiaming743/datav.svg" alt="LICENSE" />
|
||||
</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" />
|
||||
</a>
|
||||
</p>
|
||||
|
14
package-lock.json
generated
Normal file
14
package-lock.json
generated
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@jiaminghi/data-view",
|
||||
"version": "2.3.2",
|
||||
"version": "2.3.3",
|
||||
"author": "JiaMing <743192023@qq.com>",
|
||||
"description": "Vue Large screen data display component library",
|
||||
"main": "/lib/index.js",
|
||||
@ -25,5 +25,8 @@
|
||||
"dependencies": {
|
||||
"@jiaminghi/charts": "*"
|
||||
},
|
||||
"homepage": "https://github.com/jiaming743/DataV#readme"
|
||||
"homepage": "https://github.com/jiaming743/DataV#readme",
|
||||
"devDependencies": {
|
||||
"@jiaminghi/fs": "0.0.1"
|
||||
}
|
||||
}
|
||||
|
@ -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 path = require('path')
|
||||
const doExec = require('./plugin/exec')
|
||||
|
@ -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
|
||||
}
|
@ -23,7 +23,7 @@ export default {
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
render: null,
|
||||
renderer: null,
|
||||
|
||||
defaultConfig: {
|
||||
/**
|
||||
@ -100,7 +100,7 @@ export default {
|
||||
initRender () {
|
||||
const { $refs } = this
|
||||
|
||||
this.render = new CRender($refs['digital-flop'])
|
||||
this.renderer = new CRender($refs['digital-flop'])
|
||||
},
|
||||
mergeConfig () {
|
||||
const { defaultConfig, config } = this
|
||||
@ -108,14 +108,14 @@ export default {
|
||||
this.mergedConfig = deepMerge(deepClone(defaultConfig, true), config || {})
|
||||
},
|
||||
initGraph () {
|
||||
const { getShape, getStyle, render, mergedConfig } = this
|
||||
const { getShape, getStyle, renderer, mergedConfig } = this
|
||||
|
||||
const { animationCurve, animationFrame } = mergedConfig
|
||||
|
||||
const shape = getShape()
|
||||
const style = getStyle()
|
||||
|
||||
this.graph = render.add({
|
||||
this.graph = renderer.add({
|
||||
name: 'numberText',
|
||||
animationCurve,
|
||||
animationFrame,
|
||||
@ -126,7 +126,7 @@ export default {
|
||||
getShape () {
|
||||
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]
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="dv-water-pond-level">
|
||||
<svg v-if="render">
|
||||
<svg v-if="renderer">
|
||||
<defs>
|
||||
<linearGradient :id="gradientId" x1="0%" y1="0%" x2="0%" y2="100%">
|
||||
<stop v-for="lc in svgBorderGradient" :key="lc[0]"
|
||||
@ -10,28 +10,28 @@
|
||||
</defs>
|
||||
|
||||
<text
|
||||
v-if="render"
|
||||
v-if="renderer"
|
||||
:stroke="`url(#${gradientId})`"
|
||||
:fill="`url(#${gradientId})`"
|
||||
:x="render.area[0] / 2 + 8"
|
||||
:y="render.area[1] / 2 + 8"
|
||||
:x="renderer.area[0] / 2 + 8"
|
||||
:y="renderer.area[1] / 2 + 8"
|
||||
>
|
||||
{{ details }}
|
||||
</text>
|
||||
|
||||
<ellipse v-if="!shape || shape === 'round'"
|
||||
:cx="render.area[0] / 2 + 8"
|
||||
:cy="render.area[1] / 2 + 8"
|
||||
:rx="render.area[0] / 2 + 5"
|
||||
:ry="render.area[1] / 2 + 5"
|
||||
:cx="renderer.area[0] / 2 + 8"
|
||||
:cy="renderer.area[1] / 2 + 8"
|
||||
:rx="renderer.area[0] / 2 + 5"
|
||||
:ry="renderer.area[1] / 2 + 5"
|
||||
:stroke="`url(#${gradientId})`" />
|
||||
|
||||
<rect v-else
|
||||
x="2" y="2"
|
||||
:rx="shape === 'roundRect' ? 10 : 0"
|
||||
:ry="shape === 'roundRect' ? 10 : 0"
|
||||
:width="render.area[0] + 12"
|
||||
:height="render.area[1] + 12"
|
||||
:width="renderer.area[0] + 12"
|
||||
:height="renderer.area[1] + 12"
|
||||
:stroke="`url(#${gradientId})`" />
|
||||
</svg>
|
||||
|
||||
@ -105,7 +105,7 @@ export default {
|
||||
|
||||
mergedConfig: {},
|
||||
|
||||
render: null,
|
||||
renderer: null,
|
||||
|
||||
svgBorderGradient: [],
|
||||
|
||||
@ -138,9 +138,9 @@ export default {
|
||||
},
|
||||
watch: {
|
||||
config () {
|
||||
const { calcData, render } = this
|
||||
const { calcData, renderer } = this
|
||||
|
||||
render.delAllGraph()
|
||||
renderer.delAllGraph()
|
||||
|
||||
this.waves = []
|
||||
|
||||
@ -160,7 +160,7 @@ export default {
|
||||
initRender () {
|
||||
const { $refs } = this
|
||||
|
||||
this.render = new CRender($refs['water-pond-level'])
|
||||
this.renderer = new CRender($refs['water-pond-level'])
|
||||
},
|
||||
calcData () {
|
||||
const { mergeConfig, calcSvgBorderGradient, calcDetails } = this
|
||||
@ -205,12 +205,12 @@ export default {
|
||||
this.details = formatter.replace('{value}', maxValue)
|
||||
},
|
||||
addWave () {
|
||||
const { render, getWaveShapes, getWaveStyle, drawed } = this
|
||||
const { renderer, getWaveShapes, getWaveStyle, drawed } = this
|
||||
|
||||
const shapes = getWaveShapes()
|
||||
const style = getWaveStyle()
|
||||
|
||||
this.waves = shapes.map(shape => render.add({
|
||||
this.waves = shapes.map(shape => renderer.add({
|
||||
name: 'smoothline',
|
||||
animationFrame: 300,
|
||||
shape,
|
||||
@ -219,11 +219,11 @@ export default {
|
||||
}))
|
||||
},
|
||||
getWaveShapes () {
|
||||
const { mergedConfig, render, mergeOffset } = this
|
||||
const { mergedConfig, renderer, mergeOffset } = this
|
||||
|
||||
const { waveNum, waveHeight, data } = mergedConfig
|
||||
|
||||
const [w, h] = render.area
|
||||
const [w, h] = renderer.area
|
||||
|
||||
const pointsNum = waveNum * 4 + 4
|
||||
|
||||
@ -249,9 +249,9 @@ export default {
|
||||
return [x + ox, y + oy]
|
||||
},
|
||||
getWaveStyle () {
|
||||
const { render, mergedConfig } = this
|
||||
const { renderer, mergedConfig } = this
|
||||
|
||||
const h = render.area[1]
|
||||
const h = renderer.area[1]
|
||||
|
||||
return {
|
||||
gradientColor: mergedConfig.colors,
|
||||
@ -276,13 +276,13 @@ export default {
|
||||
ctx.fill()
|
||||
},
|
||||
async animationWave (repeat = 1) {
|
||||
const { waves, render, animation } = this
|
||||
const { waves, renderer, animation } = this
|
||||
|
||||
if (animation) return
|
||||
|
||||
this.animation = true
|
||||
|
||||
const w = render.area[0]
|
||||
const w = renderer.area[0]
|
||||
|
||||
waves.forEach(graph => {
|
||||
graph.attr('style', { translate: [0, 0] })
|
||||
@ -292,11 +292,11 @@ export default {
|
||||
}, true)
|
||||
})
|
||||
|
||||
await render.launchAnimation()
|
||||
await renderer.launchAnimation()
|
||||
|
||||
this.animation = false
|
||||
|
||||
if (!render.graphs.length) return
|
||||
if (!renderer.graphs.length) return
|
||||
|
||||
this.animationWave(repeat + 1)
|
||||
}
|
||||
@ -307,9 +307,9 @@ export default {
|
||||
init()
|
||||
},
|
||||
beforeDestroy () {
|
||||
const { render } = this
|
||||
const { renderer } = this
|
||||
|
||||
render.delAllGraph()
|
||||
renderer.delAllGraph()
|
||||
|
||||
this.waves = []
|
||||
}
|
||||
|
Reference in New Issue
Block a user