henryc-3 / d2n Goto Github PK
View Code? Open in Web Editor NEWD2N:将豆瓣书籍信息保存到 Notion
License: MIT License
D2N:将豆瓣书籍信息保存到 Notion
License: MIT License
完成设置同步成功,一旦添加一些数据库的属性例如个人评分后就会报错。
When using chrome.runtime.sendMessage
in vue-router guard router.forEach
it throws TypeError: Cannot read properties of undefined (reading 'sendMessage')
and <router-view/>
renders noting.
router.ts
router.beforeEach(() => {
sendToBackground(
{ checkAuthInfoExist: true },
{
successAction: () => {
return true;
},
failedAction: () => {
router.push("/auth");
},
}
);
});
sendToBackground.ts
import { BackgroundResponse, OneTimeMessage } from "../../types";
type SuccessAction = (input: NonNullable<BackgroundResponse["data"]>) => void;
type FailedAction = (input: NonNullable<BackgroundResponse["error"]>) => void;
export function sendToBackground(
input: OneTimeMessage,
actions: { successAction?: SuccessAction; failedAction?: FailedAction } = {}
) {
chrome.runtime.sendMessage<OneTimeMessage, BackgroundResponse>(
input,
(res) => {
if (res.data && actions.successAction) {
actions.successAction(res.data);
}
if (res.error && actions.failedAction) {
const err = res.error;
actions.failedAction(err);
}
}
);
}
Lines 16 to 19 in d278178
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.