医学道
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
video/src/hooks/unique_ident.ts

44 lines
854 B

import Taro from "@tarojs/taro";
import {curriculum} from "@/api";
const KEY = 'unique_ident'
/** 设置学习记录缓存 */
function set(data: HourCacheParam) {
Taro.removeStorageSync(KEY)
Taro.setStorage({
key: KEY,
data
})
}
/**
*
* @param duration
* @param start_date
* @param upload
*/
function put(duration?: number, start_date?: number, upload = true) {
const data: HourCacheParam | undefined = Taro.getStorageSync(KEY)
if (data) {
data.duration = duration || data.duration
data.start_date = start_date || data.start_date
Taro.setStorageSync(KEY, data)
if (upload) {
curriculum.hourCache(data.courseId, data)
}
}
}
function del() {
Taro.removeStorageSync(KEY)
}
export default {
set,
put,
del
}