mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
refactor(projects): 代码优化
ISSUES CLOSED: \
This commit is contained in:
@ -52,6 +52,7 @@ function draw(dom: HTMLCanvasElement, width: number, height: number) {
|
||||
|
||||
ctx.fillStyle = randomColor(180, 230);
|
||||
ctx.fillRect(0, 0, width, height);
|
||||
|
||||
for (let i = 0; i < 4; i += 1) {
|
||||
const text = NUMBER_STRING[randomNum(0, NUMBER_STRING.length)];
|
||||
imgCode += text;
|
||||
@ -81,5 +82,6 @@ function draw(dom: HTMLCanvasElement, width: number, height: number) {
|
||||
ctx.fillStyle = randomColor(150, 200);
|
||||
ctx.fill();
|
||||
}
|
||||
|
||||
return imgCode;
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import useCountDown from './useCountDown';
|
||||
export default function useSmsCode() {
|
||||
const { loading, startLoading, endLoading } = useLoading();
|
||||
const { counts, start, isCounting } = useCountDown(60);
|
||||
|
||||
const initLabel = '获取验证码';
|
||||
const countingLabel = (second: number) => `${second}秒后重新获取`;
|
||||
const label = computed(() => {
|
||||
@ -40,6 +41,7 @@ export default function useSmsCode() {
|
||||
async function getSmsCode(phone: string) {
|
||||
const valid = isPhoneValid(phone);
|
||||
if (!valid || loading.value) return;
|
||||
|
||||
startLoading();
|
||||
const { data } = await fetchSmsCode(phone);
|
||||
if (data) {
|
||||
|
@ -13,9 +13,12 @@ export default function useReload() {
|
||||
async function handleReload(duration = 0) {
|
||||
setFalse();
|
||||
await nextTick();
|
||||
setTimeout(() => {
|
||||
setTrue();
|
||||
}, duration);
|
||||
|
||||
if (duration > 0) {
|
||||
setTimeout(() => {
|
||||
setTrue();
|
||||
}, duration);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
Reference in New Issue
Block a user