@fairys/taro-tools-react 1.0.22 → 1.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -44,6 +44,7 @@ export declare class GlobalMessageDataInstance extends ProxyInstanceObjectBase<G
44
44
  * 跳转登录页面前执行
45
45
  */
46
46
  onBeforetToLoginPage?: () => boolean | void;
47
+ toRedirect: () => void;
47
48
  /**跳转登录页面*/
48
49
  toLoginPage: () => void;
49
50
  }
@@ -3,6 +3,7 @@ import utils_navigate from "../utils/navigate.js";
3
3
  import { createUseId } from "../utils/useId.js";
4
4
  import { ProxyInstanceObjectBase } from "../utils/valtio/instance.js";
5
5
  import { globalSettingDataInstance } from "./global.setting.data.instance.js";
6
+ import taro from "@tarojs/taro";
6
7
  class GlobalMessageDataInstance extends ProxyInstanceObjectBase {
7
8
  store = proxy({
8
9
  messageData: ref([]),
@@ -46,17 +47,24 @@ class GlobalMessageDataInstance extends ProxyInstanceObjectBase {
46
47
  });
47
48
  };
48
49
  onBeforetToLoginPage;
50
+ toRedirect = ()=>{
51
+ const currentPath = taro.getCurrentInstance().router?.params?.redirect || '';
52
+ if (currentPath) utils_navigate.navigateTo({
53
+ url: currentPath
54
+ });
55
+ };
49
56
  toLoginPage = ()=>{
50
57
  if (this.onBeforetToLoginPage) {
51
58
  const f = this.onBeforetToLoginPage();
52
59
  if (false === f) return;
53
60
  }
61
+ const currentPath = taro.getCurrentInstance().router?.path || '';
54
62
  const loginPageRoute = globalSettingDataInstance.store.loginPageRoute || '';
55
63
  const isLoginPage = utils_navigate.isCurrentPage(loginPageRoute || '');
56
64
  const _loginPageRoute = `${loginPageRoute || ''}`.replace(/^\//, '');
57
65
  if (isLoginPage) return;
58
66
  utils_navigate.navigateTo({
59
- url: `/${_loginPageRoute}`
67
+ url: `/${_loginPageRoute}?redirect=${currentPath}`
60
68
  });
61
69
  };
62
70
  }
@@ -44,6 +44,7 @@ export declare class GlobalMessageDataInstance extends ProxyInstanceObjectBase<G
44
44
  * 跳转登录页面前执行
45
45
  */
46
46
  onBeforetToLoginPage?: () => boolean | void;
47
+ toRedirect: () => void;
47
48
  /**跳转登录页面*/
48
49
  toLoginPage: () => void;
49
50
  }
@@ -43,6 +43,8 @@ var navigate_js_default = /*#__PURE__*/ __webpack_require__.n(navigate_js_namesp
43
43
  const useId_js_namespaceObject = require("../utils/useId.js");
44
44
  const instance_js_namespaceObject = require("../utils/valtio/instance.js");
45
45
  const external_global_setting_data_instance_js_namespaceObject = require("./global.setting.data.instance.js");
46
+ const taro_namespaceObject = require("@tarojs/taro");
47
+ var taro_default = /*#__PURE__*/ __webpack_require__.n(taro_namespaceObject);
46
48
  class GlobalMessageDataInstance extends instance_js_namespaceObject.ProxyInstanceObjectBase {
47
49
  store = (0, external_valtio_namespaceObject.proxy)({
48
50
  messageData: (0, external_valtio_namespaceObject.ref)([]),
@@ -86,17 +88,24 @@ class GlobalMessageDataInstance extends instance_js_namespaceObject.ProxyInstanc
86
88
  });
87
89
  };
88
90
  onBeforetToLoginPage;
91
+ toRedirect = ()=>{
92
+ const currentPath = taro_default().getCurrentInstance().router?.params?.redirect || '';
93
+ if (currentPath) navigate_js_default().navigateTo({
94
+ url: currentPath
95
+ });
96
+ };
89
97
  toLoginPage = ()=>{
90
98
  if (this.onBeforetToLoginPage) {
91
99
  const f = this.onBeforetToLoginPage();
92
100
  if (false === f) return;
93
101
  }
102
+ const currentPath = taro_default().getCurrentInstance().router?.path || '';
94
103
  const loginPageRoute = external_global_setting_data_instance_js_namespaceObject.globalSettingDataInstance.store.loginPageRoute || '';
95
104
  const isLoginPage = navigate_js_default().isCurrentPage(loginPageRoute || '');
96
105
  const _loginPageRoute = `${loginPageRoute || ''}`.replace(/^\//, '');
97
106
  if (isLoginPage) return;
98
107
  navigate_js_default().navigateTo({
99
- url: `/${_loginPageRoute}`
108
+ url: `/${_loginPageRoute}?redirect=${currentPath}`
100
109
  });
101
110
  };
102
111
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "author": "SunLxy <1011771396@qq.com>",
4
4
  "description": "框架组件库",
5
5
  "homepage": "https://github.com/autumn-fairy-tales/fairys-taro-react",
6
- "version": "1.0.22",
6
+ "version": "1.0.23",
7
7
  "main": "esm/index.js",
8
8
  "types": "esm/index.d.ts",
9
9
  "module": "esm/index.js",
@@ -6,6 +6,7 @@ import React from 'react';
6
6
  import type { FairysTaroMessageItemProps } from 'components/Mesage';
7
7
  import { ProxyInstanceObjectBase } from 'utils/valtio/instance';
8
8
  import { globalSettingDataInstance } from './global.setting.data.instance';
9
+ import Taro from '@tarojs/taro';
9
10
 
10
11
  export interface MessageDataType extends FairysTaroMessageItemProps {
11
12
  /**用于唯一标识提示框(默认自动生成)*/
@@ -81,6 +82,16 @@ export class GlobalMessageDataInstance extends ProxyInstanceObjectBase<GlobalMes
81
82
  * 跳转登录页面前执行
82
83
  */
83
84
  onBeforetToLoginPage?: () => boolean | void;
85
+ // 跳转 redirect 路由
86
+ toRedirect = () => {
87
+ // 获取当前路由参数
88
+ const currentPath = Taro.getCurrentInstance().router?.params?.redirect || '';
89
+ if (currentPath) {
90
+ // 跳转 redirect 路由
91
+ navigate.navigateTo({ url: currentPath });
92
+ }
93
+ };
94
+
84
95
  /**跳转登录页面*/
85
96
  toLoginPage = () => {
86
97
  if (this.onBeforetToLoginPage) {
@@ -90,6 +101,9 @@ export class GlobalMessageDataInstance extends ProxyInstanceObjectBase<GlobalMes
90
101
  return;
91
102
  }
92
103
  }
104
+ // 当前路由
105
+ const currentPath = Taro.getCurrentInstance().router?.path || '';
106
+
93
107
  const loginPageRoute = globalSettingDataInstance.store.loginPageRoute || '';
94
108
  const isLoginPage = navigate.isCurrentPage(loginPageRoute || '');
95
109
  const _loginPageRoute = `${loginPageRoute || ''}`.replace(/^\//, '');
@@ -98,7 +112,7 @@ export class GlobalMessageDataInstance extends ProxyInstanceObjectBase<GlobalMes
98
112
  return;
99
113
  }
100
114
  // 跳转登录页面
101
- navigate.navigateTo({ url: `/${_loginPageRoute}` });
115
+ navigate.navigateTo({ url: `/${_loginPageRoute}?redirect=${currentPath}` });
102
116
  };
103
117
  }
104
118
  /**