MCPcopy
hub / github.com/InkTimeRecord/TTime / loadNewServiceInfo

Function loadNewServiceInfo

src/renderer/src/utils/memberUtil.ts:87–114  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

85}
86
87export const loadNewServiceInfo = (): void => {
88 if (!isMemberVipAndKey()) {
89 return
90 }
91 const key = cacheGet('translateServiceKey')
92 findNewByInfo({
93 key: key
94 }).then((data: any) => {
95 const translateInfo = data?.translateInfo
96 if (isNotNull(translateInfo)) {
97 setTranslateServiceMap(new Map(JSON.parse(translateInfo.info)))
98 // 更新翻译源通知
99 window.api.updateTranslateServiceNotify()
100 } else {
101 saveServiceInfoHandle(ServiceTypeEnum.TRANSLATE)
102 }
103 const ocrInfo = data?.ocrInfo
104 if (isNotNull(ocrInfo)) {
105 setOcrServiceMap(new Map(JSON.parse(ocrInfo.info)))
106 } else {
107 saveServiceInfoHandle(ServiceTypeEnum.OCR)
108 }
109 const refreshServiceInfoNotifyFun = window.api['refreshServiceInfoNotify']
110 if (isNotNull(refreshServiceInfoNotifyFun)) {
111 refreshServiceInfoNotifyFun()
112 }
113 })
114}

Callers

nothing calls this directly

Calls 7

cacheGetFunction · 0.90
findNewByInfoFunction · 0.90
isNotNullFunction · 0.90
setTranslateServiceMapFunction · 0.90
setOcrServiceMapFunction · 0.90
isMemberVipAndKeyFunction · 0.85
saveServiceInfoHandleFunction · 0.85

Tested by

no test coverage detected