action 后缀
action 会自动加上 .action ,例如
<form action="login">
</form>
...大约 2 分钟
action 会自动加上 .action ,例如
<form action="login">
</form>
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
switch (request.type) {
case 'fetchChromeXmlrpc':
(async () => {
const response = await fetch(request.apiUrl, request.fetchCORSParams);
const resText = await response.text()
// console.log("chrome.runtime.onMessage.addListener fetchChromeXmlrpc response:", resText)
sendResponse(resText);
})();
break;
case 'fetchChromeJson':
(async () => {
const response = await fetch(request.apiUrl, request.fetchCORSOptions);
const resJson = await response.json()
console.log("chrome.runtime.onMessage.addListener fetchChromeJson response:", resJson)
sendResponse(resJson);
})();
break;
// 你可以定义任意内容,使用sendResponse()来返回它
case 'test':
sendResponse({'msg': 'test'});
break;
}
return true; // keep the messaging channel open for sendResponse
});
目前在 Vite+Vue3 的项目中使用 fetch API 调用 siyuan 的 API 时候,如果加上 API 鉴权,就会返回 CORS 错误,如下:

根据 https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request 这篇文章的理解