Sfoglia il codice sorgente

bump version to 0.2.1

Acathur 4 anni fa
parent
commit
3ba9e83368

+ 1 - 1
dist/bridge/index.d.ts

@@ -12,7 +12,7 @@ declare class ProginnBridge {
     get isInApp(): boolean;
     get isLogined(): boolean;
     get uid(): string | null;
-    inject(name: string, cb: () => void, root?: string): void;
+    inject(name: string, cb: (...args: any) => void, root?: string): void;
     syncCookies(): void;
     invoke(fn: string, payload?: any): any;
     back(): void;

+ 1 - 1
dist/bridge/index.js

@@ -87,7 +87,7 @@ class ProginnBridge {
     }
     checkLogin(force = false) {
         if (force || !this.isLogined) {
-            this.notifier && this.notifier(MSG_REQUIRE_LOGIN);
+            this.notifier && this.notifier(MSG_REQUIRE_LOGIN, -99);
             this.login();
             return false;
         }

+ 5 - 4
dist/request/index.js

@@ -37,13 +37,14 @@ const factory = (opts) => {
             data: data && (dataType === 'form' ? qs.stringify(data) : JSON.stringify(data))
         });
         if (res.data) {
+            const { status, data } = res.data;
             // require login
-            if (res.data.status === -99) {
+            if (status === -99) {
                 bridge && bridge.checkLogin(true);
             }
-            else if (res.data.status !== 1 && res.data.status !== 200) {
-                const message = res.data.data && res.data.data.message || res.data.message || res.data.info;
-                message && notifier && notifier(message);
+            else if (status !== 1 && status !== 200) {
+                const message = data && data.message || res.data.message || res.data.info;
+                message && notifier && notifier(message, status);
             }
         }
         return res;

+ 1 - 1
dist/types/global.d.ts

@@ -1 +1 @@
-export declare type Notifier = (msg: string) => void;
+export declare type Notifier = (msg: string, status?: string | number) => void;

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "proginn-lib",
-  "version": "0.2.0",
+  "version": "0.2.1",
   "description": "Proginn front-end common library.",
   "main": "dist/index.js",
   "module": "dist/index.js",

+ 1 - 1
src/bridge/index.ts

@@ -112,7 +112,7 @@ class ProginnBridge {
 
   checkLogin(force = false) {
     if (force || !this.isLogined) {
-      this.notifier && this.notifier(MSG_REQUIRE_LOGIN)
+      this.notifier && this.notifier(MSG_REQUIRE_LOGIN, -99)
       this.login()
       return false
     }

+ 6 - 4
src/request/index.ts

@@ -54,13 +54,15 @@ const factory = (opts: {
     })
 
     if (res.data) {
+      const { status, data } = res.data
+
       // require login
-      if (res.data.status === -99) {
+      if (status === -99) {
         bridge && bridge.checkLogin(true)
-      } else if (res.data.status !== 1 && res.data.status !== 200) {
-        const message = res.data.data && res.data.data.message || res.data.message || res.data.info
+      } else if (status !== 1 && status !== 200) {
+        const message = data && data.message || res.data.message || res.data.info
 
-        message && notifier && notifier(message)
+        message && notifier && notifier(message, status)
       }
     }
 

+ 1 - 1
src/types/global.ts

@@ -1 +1 @@
-export type Notifier = (msg: string) => void
+export type Notifier = (msg: string, status?: string | number) => void