mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-10 07:48:37 +01:00
fix ai message + add typer
This commit is contained in:
36
dashboard/composables/useTextType.ts
Normal file
36
dashboard/composables/useTextType.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
|
||||
|
||||
|
||||
|
||||
export function useTextType(options: { ms: number, increase: number }, onTickAction?: () => any) {
|
||||
|
||||
let interval: any;
|
||||
const index = ref<number>(0);
|
||||
|
||||
function onTick() {
|
||||
index.value += options.increase;
|
||||
onTickAction?.();
|
||||
}
|
||||
|
||||
function pause() {
|
||||
if (interval) clearInterval(interval);
|
||||
}
|
||||
|
||||
function resume() {
|
||||
if (interval) clearInterval(interval);
|
||||
interval = setInterval(() => onTick(), options.ms);
|
||||
}
|
||||
|
||||
function stop() {
|
||||
if (interval) clearTimeout(interval);
|
||||
}
|
||||
|
||||
function start() {
|
||||
index.value = 0;
|
||||
if (interval) clearInterval(interval);
|
||||
interval = setInterval(() => onTick(), options.ms);
|
||||
}
|
||||
|
||||
return { start, stop, resume, pause, index, interval }
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user