Use uuid to produce unique id

This commit is contained in:
jiaming743 2020-05-25 15:57:19 +08:00
parent 054854480a
commit 71a9be2a13
15 changed files with 71 additions and 46 deletions

View File

@ -216,6 +216,7 @@
<script> <script>
import autoResize from '../../../mixin/autoResize' import autoResize from '../../../mixin/autoResize'
import { uuid } from '../../../util/index'
import { deepMerge } from '@jiaminghi/charts/lib/util/index' import { deepMerge } from '@jiaminghi/charts/lib/util/index'
@ -245,10 +246,10 @@ export default {
} }
}, },
data () { data () {
const timestamp = Date.now() const id = uuid()
return { return {
ref: 'border-box-11', ref: 'border-box-11',
filterId: `border-box-11-filterId-${timestamp}`, filterId: `border-box-11-filterId-${id}`,
defaultColor: ['#8aaafb', '#1f33a2'], defaultColor: ['#8aaafb', '#1f33a2'],

View File

@ -92,6 +92,7 @@
<script> <script>
import autoResize from '../../../mixin/autoResize' import autoResize from '../../../mixin/autoResize'
import { uuid } from '../../../util/index'
import { deepMerge } from '@jiaminghi/charts/lib/util/index' import { deepMerge } from '@jiaminghi/charts/lib/util/index'
@ -113,10 +114,10 @@ export default {
} }
}, },
data () { data () {
const timestamp = +new Date() const id = uuid()
return { return {
ref: 'border-box-12', ref: 'border-box-12',
filterId: `borderr-box-12-filterId-${timestamp}`, filterId: `borderr-box-12-filterId-${id}`,
defaultColor: ['#2e6099', '#7ce7fd'], defaultColor: ['#2e6099', '#7ce7fd'],

View File

@ -61,7 +61,6 @@ export default {
} }
}, },
data () { data () {
const timestamp = +new Date()
return { return {
ref: 'border-box-13', ref: 'border-box-13',

View File

@ -65,6 +65,7 @@
<script> <script>
import autoResize from '../../../mixin/autoResize' import autoResize from '../../../mixin/autoResize'
import { uuid } from '../../../util/index'
import { deepMerge } from '@jiaminghi/charts/lib/util/index' import { deepMerge } from '@jiaminghi/charts/lib/util/index'
@ -92,12 +93,12 @@ export default {
} }
}, },
data () { data () {
const timestamp = Date.now() const id = uuid()
return { return {
ref: 'border-box-8', ref: 'border-box-8',
path: `border-box-8-path-${timestamp}`, path: `border-box-8-path-${id}`,
gradient: `border-box-8-gradient-${timestamp}`, gradient: `border-box-8-gradient-${id}`,
mask: `border-box-8-mask-${timestamp}`, mask: `border-box-8-mask-${id}`,
defaultColor: ['#235fa7', '#4fd2dd'], defaultColor: ['#235fa7', '#4fd2dd'],

View File

@ -125,6 +125,7 @@
<script> <script>
import autoResize from '../../../mixin/autoResize' import autoResize from '../../../mixin/autoResize'
import { uuid } from '../../../util/index'
import { deepMerge } from '@jiaminghi/charts/lib/util/index' import { deepMerge } from '@jiaminghi/charts/lib/util/index'
@ -144,12 +145,12 @@ export default {
} }
}, },
data () { data () {
const timestamp = Date.now() const id = uuid()
return { return {
ref: 'border-box-9', ref: 'border-box-9',
gradientId: `border-box-9-gradient-${timestamp}`, gradientId: `border-box-9-gradient-${id}`,
maskId: `border-box-9-mask-${timestamp}`, maskId: `border-box-9-mask-${id}`,
defaultColor: ['#11eefd', '#0078d2'], defaultColor: ['#11eefd', '#0078d2'],

View File

@ -5,6 +5,8 @@
</template> </template>
<script> <script>
import { uuid } from '../../../util/index'
import autoResize from '../../../mixin/autoResize' import autoResize from '../../../mixin/autoResize'
import Charts from '@jiaminghi/charts' import Charts from '@jiaminghi/charts'
@ -19,10 +21,10 @@ export default {
} }
}, },
data () { data () {
const timestamp = Date.now() const id = uuid()
return { return {
ref: `charts-container-${timestamp}`, ref: `charts-container-${id}`,
chartRef: `chart-${timestamp}`, chartRef: `chart-${id}`,
chart: null chart: null
} }

View File

@ -147,6 +147,7 @@
<script> <script>
import autoResize from '../../../mixin/autoResize' import autoResize from '../../../mixin/autoResize'
import { uuid } from '../../../util/index'
import { deepMerge } from '@jiaminghi/charts/lib/util/index' import { deepMerge } from '@jiaminghi/charts/lib/util/index'
@ -162,17 +163,17 @@ export default {
} }
}, },
data () { data () {
const timestamp = Date.now() const id = uuid()
return { return {
ref: 'decoration-10', ref: 'decoration-10',
animationId1: `d10ani1${timestamp}`, animationId1: `d10ani1${id}`,
animationId2: `d10ani2${timestamp}`, animationId2: `d10ani2${id}`,
animationId3: `d10ani3${timestamp}`, animationId3: `d10ani3${id}`,
animationId4: `d10ani4${timestamp}`, animationId4: `d10ani4${id}`,
animationId5: `d10ani5${timestamp}`, animationId5: `d10ani5${id}`,
animationId6: `d10ani6${timestamp}`, animationId6: `d10ani6${id}`,
animationId7: `d10ani7${timestamp}`, animationId7: `d10ani7${id}`,
defaultColor: ['#00c2ff', 'rgba(0, 194, 255, 0.3)'], defaultColor: ['#00c2ff', 'rgba(0, 194, 255, 0.3)'],

View File

@ -72,7 +72,6 @@ export default {
} }
}, },
data () { data () {
const timestamp = Date.now()
return { return {
ref: 'decoration-11', ref: 'decoration-11',

View File

@ -83,23 +83,26 @@ export default {
display: flex; display: flex;
overflow: hidden; overflow: hidden;
position: absolute; position: absolute;
flex: 1;
} }
.normal { .normal {
height: 0% !important;
animation: ani-height 3s ease-in-out infinite; animation: ani-height 3s ease-in-out infinite;
left: 50%; left: 50%;
margin-left: -2px; margin-left: -2px;
} }
.reverse { .reverse {
width: 0% !important;
animation: ani-width 3s ease-in-out infinite; animation: ani-width 3s ease-in-out infinite;
top: 50%; top: 50%;
margin-top: -2px; margin-top: -2px;
} }
@keyframes ani-height { @keyframes ani-height {
0% {
height: 0%;
}
70% { 70% {
height: 100%; height: 100%;
} }
@ -110,6 +113,10 @@ export default {
} }
@keyframes ani-width { @keyframes ani-width {
0% {
width: 0%;
}
70% { 70% {
width: 100%; width: 100%;
} }

View File

@ -85,6 +85,7 @@
<script> <script>
import autoResize from '../../../mixin/autoResize' import autoResize from '../../../mixin/autoResize'
import { uuid } from '../../../util/index'
import { deepMerge } from '@jiaminghi/charts/lib/util/index' import { deepMerge } from '@jiaminghi/charts/lib/util/index'
@ -106,11 +107,11 @@ export default {
} }
}, },
data () { data () {
const timestamp = Date.now() const id = uuid()
return { return {
ref: 'decoration-9', ref: 'decoration-9',
polygonId: `decoration-9-polygon-${timestamp}`, polygonId: `decoration-9-polygon-${id}`,
svgWH: [100, 100], svgWH: [100, 100],

View File

@ -153,7 +153,7 @@ import { deepMerge } from '@jiaminghi/charts/lib/util/index'
import { deepClone } from '@jiaminghi/c-render/lib/plugin/util' import { deepClone } from '@jiaminghi/c-render/lib/plugin/util'
import { randomExtend, getPointDistance } from '../../../util/index' import { randomExtend, getPointDistance, uuid } from '../../../util/index'
import autoResize from '../../../mixin/autoResize' import autoResize from '../../../mixin/autoResize'
@ -171,14 +171,14 @@ export default {
} }
}, },
data () { data () {
const timestamp = Date.now() const id = uuid()
return { return {
ref: 'dv-flyline-chart', ref: 'dv-flyline-chart',
unique: Math.random(), unique: Math.random(),
maskId: `flyline-mask-id-${timestamp}`, maskId: `flyline-mask-id-${id}`,
maskCircleId: `mask-circle-id-${timestamp}`, maskCircleId: `mask-circle-id-${id}`,
gradientId: `gradient-id-${timestamp}`, gradientId: `gradient-id-${id}`,
gradient2Id: `gradient2-id-${timestamp}`, gradient2Id: `gradient2-id-${id}`,
defaultConfig: { defaultConfig: {
/** /**

View File

@ -155,7 +155,7 @@ import { deepMerge } from '@jiaminghi/charts/lib/util/index'
import { deepClone } from '@jiaminghi/c-render/lib/plugin/util' import { deepClone } from '@jiaminghi/c-render/lib/plugin/util'
import { randomExtend, getPointDistance } from '../../../util/index' import { randomExtend, getPointDistance, uuid } from '../../../util/index'
import autoResize from '../../../mixin/autoResize' import autoResize from '../../../mixin/autoResize'
@ -173,12 +173,12 @@ export default {
} }
}, },
data () { data () {
const timestamp = Date.now() const id = uuid()
return { return {
ref: 'dv-flyline-chart-enhanced', ref: 'dv-flyline-chart-enhanced',
unique: Math.random(), unique: Math.random(),
flylineGradientId: `flyline-gradient-id-${timestamp}`, flylineGradientId: `flyline-gradient-id-${id}`,
haloGradientId: `halo-gradient-id-${timestamp}`, haloGradientId: `halo-gradient-id-${id}`,
/** /**
* @description Type Declaration * @description Type Declaration
* *

View File

@ -44,6 +44,8 @@
</template> </template>
<script> <script>
import { uuid } from '../../../util/index'
import { deepMerge } from '@jiaminghi/charts/lib/util/index' import { deepMerge } from '@jiaminghi/charts/lib/util/index'
import { deepClone } from '@jiaminghi/c-render/lib/plugin/util' import { deepClone } from '@jiaminghi/c-render/lib/plugin/util'
@ -57,10 +59,10 @@ export default {
} }
}, },
data () { data () {
const timestamp = Date.now() const id = uuid()
return { return {
gradientId1: `percent-pond-gradientId1-${timestamp}`, gradientId1: `percent-pond-gradientId1-${id}`,
gradientId2: `percent-pond-gradientId2-${timestamp}`, gradientId2: `percent-pond-gradientId2-${id}`,
width: 0, width: 0,
height: 0, height: 0,
@ -234,10 +236,10 @@ export default {
await $nextTick() await $nextTick()
const dom = $refs['percent-pond'] const { clientWidth, clientHeight } = $refs['percent-pond']
this.width = dom.clientWidth this.width = clientWidth
this.height = dom.clientHeight this.height = clientHeight
}, },
mergeConfig () { mergeConfig () {
const { config, defaultConfig } = this const { config, defaultConfig } = this

View File

@ -40,6 +40,8 @@
</template> </template>
<script> <script>
import { uuid } from '../../../util/index'
import { deepMerge } from '@jiaminghi/charts/lib/util/index' import { deepMerge } from '@jiaminghi/charts/lib/util/index'
import { deepClone } from '@jiaminghi/c-render/lib/plugin/util' import { deepClone } from '@jiaminghi/c-render/lib/plugin/util'
@ -53,9 +55,9 @@ export default {
default: () => ({}) default: () => ({})
}, },
data () { data () {
const timestamp = Date.now() const id = uuid()
return { return {
gradientId: `water-level-pond-${timestamp}`, gradientId: `water-level-pond-${id}`,
defaultConfig: { defaultConfig: {
/** /**

View File

@ -37,3 +37,11 @@ export function getPointDistance (pointOne, pointTwo) {
return Math.sqrt(minusX * minusX + minusY * minusY) return Math.sqrt(minusX * minusX + minusY * minusY)
} }
export function uuid () {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
const r = Math.random() * 16 | 0
const v = c == 'x' ? r : (r & 0x3 | 0x8)
return v.toString(16)
})
}