宜呗小程序--微信小程序
Lzk
2025-08-05 b7bcaf556aa2424e808b6e6426ab22df9cfe11c1
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
  };
};