Leon преди 1 година
родител
ревизия
b40e47e72b
променени са 4 файла, в които са добавени 18 реда и са изтрити 7 реда
  1. 1 1
      config/env.ts
  2. 10 4
      src/pages/clock/Clock.tsx
  3. 1 1
      src/services/http/request.ts
  4. 6 1
      src/utils/time_format.ts

+ 1 - 1
config/env.ts

@@ -1,3 +1,3 @@
 
 export const APP_VERSION = '1.0.0'
-export const WX_VERSION = '1.4.1'
+export const WX_VERSION = '1.4.2'

+ 10 - 4
src/pages/clock/Clock.tsx

@@ -52,6 +52,8 @@ import DayNightSwiper from "@/features/daynight/DayNightSwiper";
 import showAlert from "@/components/basic/Alert";
 import { APP_VERSION, WX_VERSION } from "@/services/http/api";
 import { title } from "process";
+import { wxPubFollow } from "@/services/permission";
+import { setWXFollow } from "@/store/permission";
 
 const utc = require('dayjs/plugin/utc')
 const timezone = require('dayjs/plugin/timezone')
@@ -125,7 +127,7 @@ export default function Page() {
     }
 
     useEffect(() => {
-        
+
         dispatch(staticResources() as any);
         timer = setInterval(() => {
             var now = new Date()
@@ -202,7 +204,7 @@ export default function Page() {
                 })
             }*/
 
-            
+
         }
 
     }, [])
@@ -219,7 +221,11 @@ export default function Page() {
             //检查用户是否添加过小程序
             checkAddToMini();
 
-            
+            if (process.env.TARO_ENV == 'weapp') {
+                wxPubFollow({ force_refresh: true }).then(res => {
+                    dispatch(setWXFollow((res as any).wx_pub_followed));
+                })
+            }
 
             if (process.env.TARO_ENV == 'rn') {
                 if (Taro.getSystemInfoSync().platform == 'ios') {
@@ -372,7 +378,7 @@ export default function Page() {
         updateNotificationStatus()
     };
 
-    function updateNotificationStatus(){
+    function updateNotificationStatus() {
         if (process.env.TARO_ENV == 'rn') {
             if (user.isLogin) {
                 if (Taro.getSystemInfoSync().platform == 'ios') {

+ 1 - 1
src/services/http/request.ts

@@ -84,7 +84,7 @@ export async function request<T>(param: RequestParam): Promise<T> {
         header['X-Client-Version'] = process.env.TARO_ENV == 'rn' ? APP_VERSION : WX_VERSION
         if (token.length > 0) {
             header['Authorization'] = `Bearer ${token}`;
-            header['Authorization'] = 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJhY2NvdW50Iiwic3ViIjoiMjZkOGE1YTg0MDMyYmExN2Q4NDk3MTlkNTljNGY1NzgiLCJpc3MiOiJmYXN0Iiwibmlja25hbWUiOiJCSyIsInR5cCI6IkJlYXJlciIsInNlc3Npb25fc3RhdGUiOiI1ZDU2NTkzYmNjNWFmNzM0OWNlZTMwZjlkNGYzMWIyMCIsImV4cCI6MTc0ODE3MDg5NSwiaWF0IjoxNzE2NjM0ODk1fQ.uaRm2vSNCX8fkFS63Oe-WNWIDHG_cRM-nQ5EGyUMaBg';
+            // header['Authorization'] = 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJhY2NvdW50Iiwic3ViIjoiMjZkOGE1YTg0MDMyYmExN2Q4NDk3MTlkNTljNGY1NzgiLCJpc3MiOiJmYXN0Iiwibmlja25hbWUiOiJCSyIsInR5cCI6IkJlYXJlciIsInNlc3Npb25fc3RhdGUiOiI1ZDU2NTkzYmNjNWFmNzM0OWNlZTMwZjlkNGYzMWIyMCIsImV4cCI6MTc0ODE3MDg5NSwiaWF0IjoxNzE2NjM0ODk1fQ.uaRm2vSNCX8fkFS63Oe-WNWIDHG_cRM-nQ5EGyUMaBg';
         }
 
 

+ 6 - 1
src/utils/time_format.ts

@@ -3,6 +3,11 @@ export class TimeFormatter {
 
   //获取时区偏移多少分钟
   static convertGMTtoOffset(gmtString) {
+    if (!gmtString || (gmtString.indexOf('+') == -1 && gmtString.indexOf('-') == -1)) {
+      console.error('gmtString error', gmtString)
+      // return 0
+      gmtString = 'GMT+0800'
+    }
     // 提取符号、小时和分钟
     var sign = gmtString.substring(3, 4); // 提取符号 "+" 或 "-"
     var hours = parseInt(gmtString.substring(4, 6)); // 提取小时部分
@@ -354,7 +359,7 @@ export class TimeFormatter {
       start = startTime.getTime()
       end = endTime.getTime()
     }
-    return TimeFormatter.calculateTimeDifference(start, end,showDays)
+    return TimeFormatter.calculateTimeDifference(start, end, showDays)
   }
 
   static durationFormate2(startTimestamp: number, endTimestamp: number) {