* 在background脚本中刷新微软翻译令牌
()
| 39 | * 在background脚本中刷新微软翻译令牌 |
| 40 | */ |
| 41 | async function refreshMicrosoftTokenInBackground(): Promise<string> { |
| 42 | try { |
| 43 | const response = await fetch("https://edge.microsoft.com/translate/auth"); |
| 44 | if (response.ok) { |
| 45 | return await response.text(); |
| 46 | } else { |
| 47 | throw new Error(`获取微软翻译令牌失败: ${response.status} ${response.statusText}`); |
| 48 | } |
| 49 | } catch (error) { |
| 50 | console.error('获取微软翻译令牌失败:', error); |
| 51 | throw error; |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | export default defineBackground({ |
| 56 | persistent: { |
no outgoing calls
no test coverage detected