浏览代码

Merge branch 'dev_1.1.5' of https://git.yishihui.com/DeNet/de-net into dev_1.1.5

jihuaqiang 2 年之前
父节点
当前提交
f9ee213247
共有 4 个文件被更改,包括 20 次插入16 次删除
  1. 4 1
      src/entry/background.js
  2. 10 14
      src/logic/background/twitter.js
  3. 6 1
      src/uilts/chromeExtension.js
  4. 二进制
      test_1.1.5.zip

+ 4 - 1
src/entry/background.js

@@ -88,11 +88,14 @@ chrome.action.onClicked.addListener(function (tab) {
 chrome.tabs.onActivated.addListener(function (activeInfo) {
     setPopupConfig(activeInfo);
 })
+
 function onInstalledMethod() {
     try {
         // 版本更新判断
         getChromeStorage('baseInfo', (info) => {
-            if (!info || !info.appVersionCode || appVersionCode != info.appVersionCode) {
+            if (!info || !info.appVersionCode) {
+                setChromeStorage({ baseInfo: JSON.stringify({ appVersionCode }) })
+            } else if (appVersionCode != info.appVersionCode) {
                 setChromeStorage({ baseInfo: JSON.stringify({ appVersionCode }) }, () => {
                     chrome.runtime.reload()
                 })

+ 10 - 14
src/logic/background/twitter.js

@@ -1,7 +1,7 @@
 import { fetchTtwitterRequestToken, fetchTwitterLogin, fetchTwitterShortUrl, fetchAllMessageInfo, fetchReadTaskAllMsg, getDiscordUserInfo, fetchGetTwitterNftPostPre, fetchPublish, fetchGetAllUnReadNotices } from '@/logic/background/fetch/twitter.js'
-import { LANDING_PAGE, LANDING_PAGE_MID, setChromeStorage, setChromeCookie, getChromeCookie, getChromeStorage, removeChromeCookie } from '@/uilts/chromeExtension.js'
+import { LANDING_PAGE, LANDING_PAGE_MID, setChromeStorage, setChromeCookie, getChromeCookie, getChromeStorage, removeChromeCookie, LANDING_PAGE_JUMP_INFO } from '@/uilts/chromeExtension.js'
 import { guid } from '@/uilts/help.js'
-import { pageUrl, discordAuthRedirectUri } from '@/http/configAPI'
+import { discordAuthRedirectUri } from '@/http/configAPI'
 import { setContentMessage } from '@/logic/background/help.js'
 
 let authToken = ''
@@ -250,13 +250,7 @@ function sendActivetabMessage(message = {}) {
  */
 
 export function onInstalledCreateTab() {
-    // 落地页参数
-    let cookiesParams = {
-        name: 'jump_info',
-        url: pageUrl
-    }
-    
-    getChromeCookie(cookiesParams, (res) => {
+    getChromeCookie(LANDING_PAGE_JUMP_INFO, (res) => {
         // jump_info
         if (!res || !res.jump_type) {
             chrome.tabs.create({
@@ -327,13 +321,13 @@ export function onInstalledCreateTab() {
                 break
         }
 
-        if(created_detail == false){
+        if (created_detail == false) {
             chrome.tabs.create({
                 url: "https://twitter.com",
             });
         }
 
-        removeChromeCookie(cookiesParams)
+        removeChromeCookie(LANDING_PAGE_JUMP_INFO)
     })
 }
 
@@ -530,9 +524,11 @@ export const checkShowPublishDialog = (params) => {
 }
 
 const createTabShowGiveaway = (params) => {
-    setChromeStorage({showGiveawayData : JSON.stringify({
-        show: true
-    })});
+    setChromeStorage({
+        showGiveawayData: JSON.stringify({
+            show: true
+        })
+    });
     chrome.tabs.create({
         url: params.url,
     });

+ 6 - 1
src/uilts/chromeExtension.js

@@ -11,6 +11,11 @@ export const LANDING_PAGE_MID = {
     url: pageUrl
 }
 
+export const LANDING_PAGE_JUMP_INFO = {
+    name: 'jump_info',
+    url: pageUrl
+}
+
 export function setChromeStorage(params, callback) {
     try {
         if (callback) {
@@ -81,7 +86,7 @@ export function getChromeCookie({ name = '', url = '' }, callback) {
             }
         })
     } catch (error) {
-        console.error('catch',error)
+        console.error('catch', error)
     }
 }
 

二进制
test_1.1.5.zip