1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
| import { ref, onMounted, onUnmounted } from 'vue';
| import { getProtocol } from "@/api/modules/user";
|
| export const useProtocol = (protocolKey: string) => {
| const readTime = ref(7);
| const text = ref(null);
|
| const startReading = () => {
| getProtocol(protocolKey).then(res => {
| text.value = res.content;
| const interval = setInterval(() => {
| readTime.value--;
| if (readTime.value === 0) {
| clearInterval(interval);
| }
| }, 1000);
| });
| };
|
| return {
| readTime,
| text,
| startReading
| };
| };
|
|