-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(projects): page home & perf useEcharts
- Loading branch information
1 parent
0fae993
commit 62e4da0
Showing
8 changed files
with
511 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<script setup lang="ts"> | ||
import { computed, ref, watch } from 'vue'; | ||
import { TransitionPresets, useTransition } from '@vueuse/core'; | ||
defineOptions({ | ||
name: 'CountTo' | ||
}); | ||
const props = withDefaults(defineProps<Props>(), { | ||
startValue: 0, | ||
endValue: 2024, | ||
autoplay: true, | ||
decimals: 0, | ||
prefix: '', | ||
suffix: '', | ||
separator: ',', | ||
decimal: '.' | ||
}); | ||
interface Props { | ||
startValue?: number; | ||
endValue?: number; | ||
autoplay?: boolean; | ||
decimals?: number; | ||
prefix?: string; | ||
suffix?: string; | ||
separator?: string; | ||
decimal?: string; | ||
} | ||
const source = ref(0); | ||
const outputValue = useTransition(source, { | ||
disabled: false, | ||
duration: 1500, | ||
transition: TransitionPresets.easeOutCubic | ||
}); | ||
const value = computed(() => formatValue(outputValue.value)); | ||
function formatValue(num: number) { | ||
const { decimals, decimal, separator, suffix, prefix } = props; | ||
let number = num.toFixed(decimals); | ||
number = String(number); | ||
const x = number.split('.'); | ||
let x1 = x[0]; | ||
const x2 = x.length > 1 ? decimal + x[1] : ''; | ||
const rgx = /(\d+)(\d{3})/; | ||
if (separator) { | ||
while (rgx.test(x1)) { | ||
x1 = x1.replace(rgx, `$1${separator}$2`); | ||
} | ||
} | ||
return prefix + x1 + x2 + suffix; | ||
} | ||
watch( | ||
[() => props.startValue, () => props.endValue], | ||
() => { | ||
if (props.autoplay) { | ||
source.value = props.endValue; | ||
} | ||
}, | ||
{ immediate: true } | ||
); | ||
</script> | ||
|
||
<template> | ||
<span>{{ value }}</span> | ||
</template> | ||
|
||
<style scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<script setup lang="ts"> | ||
import { computed } from 'vue'; | ||
defineOptions({ | ||
name: 'GradientBg' | ||
}); | ||
const props = withDefaults(defineProps<Props>(), { | ||
startColor: '#56cdf3', | ||
endColor: '#719de3' | ||
}); | ||
interface Props { | ||
startColor?: string; | ||
endColor?: string; | ||
} | ||
const gradientStyle = computed(() => `linear-gradient(to bottom right, ${props.startColor}, ${props.endColor})`); | ||
</script> | ||
|
||
<template> | ||
<div class="px-16px pt-8px pb-4px rd-8px text-white" :style="{ backgroundImage: gradientStyle }"> | ||
<slot></slot> | ||
</div> | ||
</template> | ||
|
||
<style scoped></style> |
Oops, something went wrong.
62e4da0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
soybean-admin – ./
soybean-admin-soybeanjs.vercel.app
soybean-admin-eta.vercel.app
soybean-admin-git-main-soybeanjs.vercel.app