12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- // 此文件不要写具体逻辑,只调用函数
- import {
- twitterShortUrl,
- twitterPinLoginToken,
- twitterPinLoginCode,
- onInstalledMid,
- onInstalledUserSet,
- onInstalledCreateTab,
- checkPined,
- popupRePublish,
- setBadgeInfo,
- hideBadge,
- setMessageCount,
- getMessageInfo,
- readTaskAllMsg
- } from "@/logic/background/twitter";
- //加载bg.js 执行
- setMessageCount();
- // 消息通讯
- chrome.runtime.onConnect.addListener(function (port) {
- port.onMessage.addListener(function (res) {
- switch (res.state) {
- case "CONTENT_SEND_CODE":
- twitterPinLoginCode(port,res.code);
- break;
- case "CONTENT_TWITTER_LOGIN":
- twitterPinLoginToken();
- break;
- case "CONTENT_TWITTER_SHORT_LINK":
- twitterShortUrl(res.url)
- break
- }
- });
- if (port.name === "popup") {
- port.onDisconnect.addListener(function() {
- readTaskAllMsg(() => {
- getMessageInfo();
- })
- });
- }
- });
- chrome.runtime.onInstalled.addListener(onInstalledMethod);
- chrome.runtime.onMessage.addListener(onMessageMethod);
- function onInstalledMethod() {
- onInstalledCreateTab()
- onInstalledMid()
- onInstalledUserSet()
- }
- function onMessageMethod(req, sender, sendResponse) {
- sendResponse('');
- if (req) {
- switch (req.actionType) {
- case "POPUP_LOGIN":
- twitterPinLoginToken();
- break;
- case "POPUP_PUBLISH_TWITTER_RED_PACK":
- popupRePublish(req);
- break;
- case 'CONTENT_GET_PINED':
- checkPined();
- break;
- case 'CONTENT_SET_BADGE':
- setBadgeInfo(req);
- break;
- case 'CONTENT_HIDE_BADGE':
- hideBadge();
- break;
- }
- }
- }
|