@fairys/taro-tools-react 1.0.14 → 1.0.16
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.
- package/esm/components/MainPage/index.js +1 -1
- package/esm/components/Mesage/index.js +2 -2
- package/esm/components/Toast/index.js +2 -2
- package/esm/components/connectToastMessage/index.d.ts +12 -1
- package/esm/components/connectToastMessage/index.js +3 -3
- package/esm/context/{global.data.instance.d.ts → global.message.data.instance.d.ts} +10 -7
- package/esm/context/{global.data.instance.js → global.message.data.instance.js} +6 -6
- package/esm/context/index.d.ts +1 -1
- package/esm/context/index.js +1 -1
- package/esm/context/page.info.data.instance.js +2 -2
- package/esm/styles/index.css +0 -5
- package/esm/utils/request.js +8 -8
- package/lib/components/MainPage/index.js +1 -1
- package/lib/components/Mesage/index.js +2 -2
- package/lib/components/Toast/index.js +2 -2
- package/lib/components/connectToastMessage/index.d.ts +12 -1
- package/lib/components/connectToastMessage/index.js +2 -2
- package/lib/context/{global.data.instance.d.ts → global.message.data.instance.d.ts} +10 -7
- package/lib/context/{global.data.instance.js → global.message.data.instance.js} +14 -14
- package/lib/context/index.d.ts +1 -1
- package/lib/context/index.js +7 -7
- package/lib/context/page.info.data.instance.js +2 -2
- package/lib/styles/index.css +0 -5
- package/lib/utils/request.js +8 -8
- package/package.json +1 -1
- package/src/components/MainPage/index.tsx +1 -1
- package/src/components/Mesage/index.tsx +3 -3
- package/src/components/Toast/index.tsx +2 -2
- package/src/components/connectToastMessage/index.tsx +14 -3
- package/src/context/{global.data.instance.ts → global.message.data.instance.ts} +14 -13
- package/src/context/index.ts +1 -1
- package/src/context/page.info.data.instance.tsx +2 -2
- package/src/utils/request.ts +8 -8
|
@@ -4,7 +4,7 @@ import clsx from "clsx";
|
|
|
4
4
|
import { useMemo } from "react";
|
|
5
5
|
const FairysTaroMainPage = (props)=>{
|
|
6
6
|
const { className: itemClassName, children, ...rest } = props;
|
|
7
|
-
const cls = useMemo(()=>clsx('fairys_taro-ui-main-page
|
|
7
|
+
const cls = useMemo(()=>clsx('fairys_taro-ui-main-page fairystaro__box-border fairystaro__w-full fairystaro__h-full fairystaro__flex fairystaro__flex-col fairystaro__overflow-auto', itemClassName), [
|
|
8
8
|
itemClassName
|
|
9
9
|
]);
|
|
10
10
|
return /*#__PURE__*/ jsx(View, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Fragment, createElement, useMemo } from "react";
|
|
3
3
|
import { View } from "@tarojs/components";
|
|
4
|
-
import {
|
|
4
|
+
import { useGlobalMessageData } from "../../context/global.message.data.instance.js";
|
|
5
5
|
import { FairysTaroPortal } from "../Portal/index.js";
|
|
6
6
|
import clsx from "clsx";
|
|
7
7
|
const FairysTaroMessageItem = (props)=>{
|
|
@@ -99,7 +99,7 @@ const FairysTaroMessage = (props)=>{
|
|
|
99
99
|
};
|
|
100
100
|
const FairysTaroPortalMessage = (props)=>{
|
|
101
101
|
const { className: messageClassName, ...rest } = props;
|
|
102
|
-
const [state] =
|
|
102
|
+
const [state] = useGlobalMessageData();
|
|
103
103
|
const messageData = state.messageData;
|
|
104
104
|
const classNames = useMemo(()=>clsx('fairys_taro-ui-portal-message fairystaro__pointer-events-none fairystaro__position-fixed fairystaro__top-0 fairystaro__right-0 fairystaro__bottom-0 fairystaro__left-0', messageClassName), [
|
|
105
105
|
messageClassName
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Toast } from "@nutui/nutui-react-taro";
|
|
3
3
|
import { FairysTaroPortal } from "../Portal/index.js";
|
|
4
|
-
import {
|
|
4
|
+
import { useGlobalMessageData } from "../../context/global.message.data.instance.js";
|
|
5
5
|
const FairysTaroToast = ()=>{
|
|
6
|
-
const [state, proxyInstance] =
|
|
6
|
+
const [state, proxyInstance] = useGlobalMessageData();
|
|
7
7
|
const toastConfig = state.toastData;
|
|
8
8
|
return /*#__PURE__*/ jsx(FairysTaroPortal, {
|
|
9
9
|
children: /*#__PURE__*/ jsx(Toast, {
|
|
@@ -7,4 +7,15 @@ export interface ConnectToastMessageOptions {
|
|
|
7
7
|
*/
|
|
8
8
|
isRoot?: boolean;
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* 高阶组件,用于为 React 组件连接 Toast 和 Message 功能
|
|
12
|
+
*
|
|
13
|
+
* 根据不同的运行环境(H5/微信小程序)和组件层级(根页面/子页面),
|
|
14
|
+
* 决定是否渲染 Toast 和 Message 组件,以避免功能冲突和界面遮挡
|
|
15
|
+
*
|
|
16
|
+
* @param Component - 需要被包装的 React 组件
|
|
17
|
+
* @param options - 配置选项
|
|
18
|
+
* @param options.isRoot - 是否为根页面组件,默认为 false
|
|
19
|
+
* @returns 返回一个经过优化的 React 组件,根据环境条件选择性渲染 Toast 和 Message
|
|
20
|
+
*/
|
|
21
|
+
export declare const connectToastMessage: (Component: React.FC, options?: ConnectToastMessageOptions) => React.MemoExoticComponent<(props: any) => import("react/jsx-runtime").JSX.Element>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { FairysTaroPortalMessage } from "../Mesage/index.js";
|
|
3
3
|
import { FairysTaroToast } from "../Toast/index.js";
|
|
4
|
-
import { Fragment } from "react";
|
|
4
|
+
import { Fragment, memo } from "react";
|
|
5
5
|
const connectToastMessage = (Component, options = {})=>{
|
|
6
6
|
const { isRoot = false } = options;
|
|
7
|
-
return (props)=>{
|
|
7
|
+
return /*#__PURE__*/ memo((props)=>{
|
|
8
8
|
if ('weapp' === process.env.TARO_ENV) return /*#__PURE__*/ jsxs(Fragment, {
|
|
9
9
|
children: [
|
|
10
10
|
/*#__PURE__*/ jsx(Component, {
|
|
@@ -23,6 +23,6 @@ const connectToastMessage = (Component, options = {})=>{
|
|
|
23
23
|
isRoot ? /*#__PURE__*/ jsx(FairysTaroPortalMessage, {}) : /*#__PURE__*/ jsx(Fragment, {})
|
|
24
24
|
]
|
|
25
25
|
});
|
|
26
|
-
};
|
|
26
|
+
});
|
|
27
27
|
};
|
|
28
28
|
export { connectToastMessage };
|
|
@@ -17,7 +17,7 @@ export interface MessageDataType extends FairysTaroMessageItemProps {
|
|
|
17
17
|
}
|
|
18
18
|
export interface ToastDataType extends Partial<TaroToastProps> {
|
|
19
19
|
}
|
|
20
|
-
export interface
|
|
20
|
+
export interface GlobalMessageDataInstanceState {
|
|
21
21
|
/**弹框提示框*/
|
|
22
22
|
messageData?: MessageDataType[];
|
|
23
23
|
/**提示框数据*/
|
|
@@ -25,8 +25,11 @@ export interface GlobalDataInstanceState {
|
|
|
25
25
|
/**数据默认值不使用*/
|
|
26
26
|
__defaultValue?: string;
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
/**
|
|
29
|
+
* 全局消息数据实例
|
|
30
|
+
*/
|
|
31
|
+
export declare class GlobalMessageDataInstance extends ProxyInstanceObjectBase<GlobalMessageDataInstanceState> {
|
|
32
|
+
store: GlobalMessageDataInstanceState;
|
|
30
33
|
/**用于提示信息*/
|
|
31
34
|
showMessage: (options: Omit<MessageDataType, "__id"> & {
|
|
32
35
|
__id?: string;
|
|
@@ -45,10 +48,10 @@ export declare class GlobalDataInstance extends ProxyInstanceObjectBase<GlobalDa
|
|
|
45
48
|
toLoginPage: () => void;
|
|
46
49
|
}
|
|
47
50
|
/**
|
|
48
|
-
*
|
|
51
|
+
* 全局消息数据实例
|
|
49
52
|
*/
|
|
50
|
-
export declare const
|
|
53
|
+
export declare const globalMessageDataInstance: GlobalMessageDataInstance;
|
|
51
54
|
/**
|
|
52
|
-
*
|
|
55
|
+
* 全局消息数据状态管理
|
|
53
56
|
*/
|
|
54
|
-
export declare const
|
|
57
|
+
export declare const useGlobalMessageData: () => [GlobalMessageDataInstanceState, GlobalMessageDataInstance, string | undefined];
|
|
@@ -3,7 +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
|
-
class
|
|
6
|
+
class GlobalMessageDataInstance extends ProxyInstanceObjectBase {
|
|
7
7
|
store = proxy({
|
|
8
8
|
messageData: ref([]),
|
|
9
9
|
toastData: void 0
|
|
@@ -60,13 +60,13 @@ class GlobalDataInstance extends ProxyInstanceObjectBase {
|
|
|
60
60
|
});
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
const store = useSnapshot(
|
|
63
|
+
const globalMessageDataInstance = new GlobalMessageDataInstance();
|
|
64
|
+
const useGlobalMessageData = ()=>{
|
|
65
|
+
const store = useSnapshot(globalMessageDataInstance.store);
|
|
66
66
|
return [
|
|
67
67
|
store,
|
|
68
|
-
|
|
68
|
+
globalMessageDataInstance,
|
|
69
69
|
store.__defaultValue
|
|
70
70
|
];
|
|
71
71
|
};
|
|
72
|
-
export {
|
|
72
|
+
export { GlobalMessageDataInstance, globalMessageDataInstance, useGlobalMessageData };
|
package/esm/context/index.d.ts
CHANGED
package/esm/context/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { proxy, ref as external_valtio_ref, useSnapshot } from "valtio";
|
|
|
3
3
|
import { ProxyInstanceObjectBase } from "../utils/valtio/instance.js";
|
|
4
4
|
import { createContext, useContext, useEffect, useMemo, useRef } from "react";
|
|
5
5
|
import utils_navigate from "../utils/navigate.js";
|
|
6
|
-
import {
|
|
6
|
+
import { globalMessageDataInstance } from "./global.message.data.instance.js";
|
|
7
7
|
import { globalSettingDataInstance } from "./global.setting.data.instance.js";
|
|
8
8
|
import taro, { useDidShow } from "@tarojs/taro";
|
|
9
9
|
class page_info_data_instance_PageInfoDataInstance extends ProxyInstanceObjectBase {
|
|
@@ -92,7 +92,7 @@ class page_info_data_instance_PageInfoDataInstance extends ProxyInstanceObjectBa
|
|
|
92
92
|
taro.hideLoading();
|
|
93
93
|
this.updatedLoading(false);
|
|
94
94
|
if (result && result.code === globalSettingDataInstance.store.requestSuccessCode) {
|
|
95
|
-
if (this.requestSaveInfoConfig?.isShowSuccessMessage === false)
|
|
95
|
+
if (this.requestSaveInfoConfig?.isShowSuccessMessage === false) globalMessageDataInstance.showMessage({
|
|
96
96
|
content: result.message || "\u4FDD\u5B58\u6210\u529F"
|
|
97
97
|
});
|
|
98
98
|
else taro.showToast({
|
package/esm/styles/index.css
CHANGED
package/esm/utils/request.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import taro from "@tarojs/taro";
|
|
2
2
|
import { globalSettingDataInstance } from "../context/global.setting.data.instance.js";
|
|
3
|
-
import {
|
|
3
|
+
import { globalMessageDataInstance } from "../context/global.message.data.instance.js";
|
|
4
4
|
const codeMessage = {
|
|
5
5
|
400: "\u53D1\u51FA\u7684\u8BF7\u6C42\u9519\u8BEF",
|
|
6
6
|
401: "\u7528\u6237\u6CA1\u6709\u6743\u9650",
|
|
@@ -21,7 +21,7 @@ const requestResponseHandle = (result, options)=>{
|
|
|
21
21
|
const code = result?.data?.code;
|
|
22
22
|
if (401 === statusCode || 401 === code || code === globalSettingDataInstance.store.tokenExpiredCode) {
|
|
23
23
|
msg = "\u8BF7\u91CD\u65B0\u767B\u5F55";
|
|
24
|
-
|
|
24
|
+
globalMessageDataInstance.toLoginPage();
|
|
25
25
|
} else msg = [
|
|
26
26
|
globalSettingDataInstance.store.requestSuccessCode,
|
|
27
27
|
200
|
|
@@ -35,7 +35,7 @@ const requestResponseHandle = (result, options)=>{
|
|
|
35
35
|
duration: 3000,
|
|
36
36
|
icon: 'none'
|
|
37
37
|
});
|
|
38
|
-
else
|
|
38
|
+
else globalMessageDataInstance.showMessage({
|
|
39
39
|
content: msg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
40
40
|
type: 'error'
|
|
41
41
|
});
|
|
@@ -123,14 +123,14 @@ class RequestInstance {
|
|
|
123
123
|
duration: 3000,
|
|
124
124
|
icon: 'none'
|
|
125
125
|
});
|
|
126
|
-
else
|
|
126
|
+
else globalMessageDataInstance.showMessage({
|
|
127
127
|
content: "\u672A\u767B\u5F55",
|
|
128
128
|
type: 'error'
|
|
129
129
|
});
|
|
130
130
|
options?.fail?.({
|
|
131
131
|
errMsg: "\u672A\u767B\u5F55"
|
|
132
132
|
});
|
|
133
|
-
|
|
133
|
+
globalMessageDataInstance.toLoginPage();
|
|
134
134
|
return;
|
|
135
135
|
}
|
|
136
136
|
return {
|
|
@@ -161,7 +161,7 @@ class RequestInstance {
|
|
|
161
161
|
duration: 3000,
|
|
162
162
|
icon: 'none'
|
|
163
163
|
});
|
|
164
|
-
else
|
|
164
|
+
else globalMessageDataInstance.showMessage({
|
|
165
165
|
content: result.errMsg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
166
166
|
type: 'error'
|
|
167
167
|
});
|
|
@@ -255,7 +255,7 @@ class RequestInstance {
|
|
|
255
255
|
duration: 3000,
|
|
256
256
|
icon: 'none'
|
|
257
257
|
});
|
|
258
|
-
else
|
|
258
|
+
else globalMessageDataInstance.showMessage({
|
|
259
259
|
content: result.errMsg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
260
260
|
type: 'error'
|
|
261
261
|
});
|
|
@@ -306,7 +306,7 @@ class RequestInstance {
|
|
|
306
306
|
duration: 3000,
|
|
307
307
|
icon: 'none'
|
|
308
308
|
});
|
|
309
|
-
else
|
|
309
|
+
else globalMessageDataInstance.showMessage({
|
|
310
310
|
content: result.errMsg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
311
311
|
type: 'error'
|
|
312
312
|
});
|
|
@@ -45,7 +45,7 @@ var external_clsx_default = /*#__PURE__*/ __webpack_require__.n(external_clsx_na
|
|
|
45
45
|
const external_react_namespaceObject = require("react");
|
|
46
46
|
const FairysTaroMainPage = (props)=>{
|
|
47
47
|
const { className: itemClassName, children, ...rest } = props;
|
|
48
|
-
const cls = (0, external_react_namespaceObject.useMemo)(()=>external_clsx_default()('fairys_taro-ui-main-page
|
|
48
|
+
const cls = (0, external_react_namespaceObject.useMemo)(()=>external_clsx_default()('fairys_taro-ui-main-page fairystaro__box-border fairystaro__w-full fairystaro__h-full fairystaro__flex fairystaro__flex-col fairystaro__overflow-auto', itemClassName), [
|
|
49
49
|
itemClassName
|
|
50
50
|
]);
|
|
51
51
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(components_namespaceObject.View, {
|
|
@@ -40,7 +40,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
40
40
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
41
41
|
const external_react_namespaceObject = require("react");
|
|
42
42
|
const components_namespaceObject = require("@tarojs/components");
|
|
43
|
-
const
|
|
43
|
+
const global_message_data_instance_js_namespaceObject = require("../../context/global.message.data.instance.js");
|
|
44
44
|
const index_js_namespaceObject = require("../Portal/index.js");
|
|
45
45
|
const external_clsx_namespaceObject = require("clsx");
|
|
46
46
|
var external_clsx_default = /*#__PURE__*/ __webpack_require__.n(external_clsx_namespaceObject);
|
|
@@ -139,7 +139,7 @@ const FairysTaroMessage = (props)=>{
|
|
|
139
139
|
};
|
|
140
140
|
const FairysTaroPortalMessage = (props)=>{
|
|
141
141
|
const { className: messageClassName, ...rest } = props;
|
|
142
|
-
const [state] = (0,
|
|
142
|
+
const [state] = (0, global_message_data_instance_js_namespaceObject.useGlobalMessageData)();
|
|
143
143
|
const messageData = state.messageData;
|
|
144
144
|
const classNames = (0, external_react_namespaceObject.useMemo)(()=>external_clsx_default()('fairys_taro-ui-portal-message fairystaro__pointer-events-none fairystaro__position-fixed fairystaro__top-0 fairystaro__right-0 fairystaro__bottom-0 fairystaro__left-0', messageClassName), [
|
|
145
145
|
messageClassName
|
|
@@ -29,9 +29,9 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
29
29
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
30
|
const nutui_react_taro_namespaceObject = require("@nutui/nutui-react-taro");
|
|
31
31
|
const index_js_namespaceObject = require("../Portal/index.js");
|
|
32
|
-
const
|
|
32
|
+
const global_message_data_instance_js_namespaceObject = require("../../context/global.message.data.instance.js");
|
|
33
33
|
const FairysTaroToast = ()=>{
|
|
34
|
-
const [state, proxyInstance] = (0,
|
|
34
|
+
const [state, proxyInstance] = (0, global_message_data_instance_js_namespaceObject.useGlobalMessageData)();
|
|
35
35
|
const toastConfig = state.toastData;
|
|
36
36
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_js_namespaceObject.FairysTaroPortal, {
|
|
37
37
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(nutui_react_taro_namespaceObject.Toast, {
|
|
@@ -7,4 +7,15 @@ export interface ConnectToastMessageOptions {
|
|
|
7
7
|
*/
|
|
8
8
|
isRoot?: boolean;
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* 高阶组件,用于为 React 组件连接 Toast 和 Message 功能
|
|
12
|
+
*
|
|
13
|
+
* 根据不同的运行环境(H5/微信小程序)和组件层级(根页面/子页面),
|
|
14
|
+
* 决定是否渲染 Toast 和 Message 组件,以避免功能冲突和界面遮挡
|
|
15
|
+
*
|
|
16
|
+
* @param Component - 需要被包装的 React 组件
|
|
17
|
+
* @param options - 配置选项
|
|
18
|
+
* @param options.isRoot - 是否为根页面组件,默认为 false
|
|
19
|
+
* @returns 返回一个经过优化的 React 组件,根据环境条件选择性渲染 Toast 和 Message
|
|
20
|
+
*/
|
|
21
|
+
export declare const connectToastMessage: (Component: React.FC, options?: ConnectToastMessageOptions) => React.MemoExoticComponent<(props: any) => import("react/jsx-runtime").JSX.Element>;
|
|
@@ -32,7 +32,7 @@ const external_Toast_index_js_namespaceObject = require("../Toast/index.js");
|
|
|
32
32
|
const external_react_namespaceObject = require("react");
|
|
33
33
|
const connectToastMessage = (Component, options = {})=>{
|
|
34
34
|
const { isRoot = false } = options;
|
|
35
|
-
return (props)=>{
|
|
35
|
+
return /*#__PURE__*/ (0, external_react_namespaceObject.memo)((props)=>{
|
|
36
36
|
if ('weapp' === process.env.TARO_ENV) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_react_namespaceObject.Fragment, {
|
|
37
37
|
children: [
|
|
38
38
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Component, {
|
|
@@ -51,7 +51,7 @@ const connectToastMessage = (Component, options = {})=>{
|
|
|
51
51
|
isRoot ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_js_namespaceObject.FairysTaroPortalMessage, {}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_namespaceObject.Fragment, {})
|
|
52
52
|
]
|
|
53
53
|
});
|
|
54
|
-
};
|
|
54
|
+
});
|
|
55
55
|
};
|
|
56
56
|
exports.connectToastMessage = __webpack_exports__.connectToastMessage;
|
|
57
57
|
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
@@ -17,7 +17,7 @@ export interface MessageDataType extends FairysTaroMessageItemProps {
|
|
|
17
17
|
}
|
|
18
18
|
export interface ToastDataType extends Partial<TaroToastProps> {
|
|
19
19
|
}
|
|
20
|
-
export interface
|
|
20
|
+
export interface GlobalMessageDataInstanceState {
|
|
21
21
|
/**弹框提示框*/
|
|
22
22
|
messageData?: MessageDataType[];
|
|
23
23
|
/**提示框数据*/
|
|
@@ -25,8 +25,11 @@ export interface GlobalDataInstanceState {
|
|
|
25
25
|
/**数据默认值不使用*/
|
|
26
26
|
__defaultValue?: string;
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
/**
|
|
29
|
+
* 全局消息数据实例
|
|
30
|
+
*/
|
|
31
|
+
export declare class GlobalMessageDataInstance extends ProxyInstanceObjectBase<GlobalMessageDataInstanceState> {
|
|
32
|
+
store: GlobalMessageDataInstanceState;
|
|
30
33
|
/**用于提示信息*/
|
|
31
34
|
showMessage: (options: Omit<MessageDataType, "__id"> & {
|
|
32
35
|
__id?: string;
|
|
@@ -45,10 +48,10 @@ export declare class GlobalDataInstance extends ProxyInstanceObjectBase<GlobalDa
|
|
|
45
48
|
toLoginPage: () => void;
|
|
46
49
|
}
|
|
47
50
|
/**
|
|
48
|
-
*
|
|
51
|
+
* 全局消息数据实例
|
|
49
52
|
*/
|
|
50
|
-
export declare const
|
|
53
|
+
export declare const globalMessageDataInstance: GlobalMessageDataInstance;
|
|
51
54
|
/**
|
|
52
|
-
*
|
|
55
|
+
* 全局消息数据状态管理
|
|
53
56
|
*/
|
|
54
|
-
export declare const
|
|
57
|
+
export declare const useGlobalMessageData: () => [GlobalMessageDataInstanceState, GlobalMessageDataInstance, string | undefined];
|
|
@@ -33,9 +33,9 @@ var __webpack_require__ = {};
|
|
|
33
33
|
var __webpack_exports__ = {};
|
|
34
34
|
__webpack_require__.r(__webpack_exports__);
|
|
35
35
|
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
globalMessageDataInstance: ()=>globalMessageDataInstance,
|
|
37
|
+
GlobalMessageDataInstance: ()=>GlobalMessageDataInstance,
|
|
38
|
+
useGlobalMessageData: ()=>useGlobalMessageData
|
|
39
39
|
});
|
|
40
40
|
const external_valtio_namespaceObject = require("valtio");
|
|
41
41
|
const navigate_js_namespaceObject = require("../utils/navigate.js");
|
|
@@ -43,7 +43,7 @@ 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
|
-
class
|
|
46
|
+
class GlobalMessageDataInstance extends instance_js_namespaceObject.ProxyInstanceObjectBase {
|
|
47
47
|
store = (0, external_valtio_namespaceObject.proxy)({
|
|
48
48
|
messageData: (0, external_valtio_namespaceObject.ref)([]),
|
|
49
49
|
toastData: void 0
|
|
@@ -100,22 +100,22 @@ class GlobalDataInstance extends instance_js_namespaceObject.ProxyInstanceObject
|
|
|
100
100
|
});
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
|
-
const
|
|
104
|
-
const
|
|
105
|
-
const store = (0, external_valtio_namespaceObject.useSnapshot)(
|
|
103
|
+
const globalMessageDataInstance = new GlobalMessageDataInstance();
|
|
104
|
+
const useGlobalMessageData = ()=>{
|
|
105
|
+
const store = (0, external_valtio_namespaceObject.useSnapshot)(globalMessageDataInstance.store);
|
|
106
106
|
return [
|
|
107
107
|
store,
|
|
108
|
-
|
|
108
|
+
globalMessageDataInstance,
|
|
109
109
|
store.__defaultValue
|
|
110
110
|
];
|
|
111
111
|
};
|
|
112
|
-
exports.
|
|
113
|
-
exports.
|
|
114
|
-
exports.
|
|
112
|
+
exports.GlobalMessageDataInstance = __webpack_exports__.GlobalMessageDataInstance;
|
|
113
|
+
exports.globalMessageDataInstance = __webpack_exports__.globalMessageDataInstance;
|
|
114
|
+
exports.useGlobalMessageData = __webpack_exports__.useGlobalMessageData;
|
|
115
115
|
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
116
|
-
"
|
|
117
|
-
"
|
|
118
|
-
"
|
|
116
|
+
"GlobalMessageDataInstance",
|
|
117
|
+
"globalMessageDataInstance",
|
|
118
|
+
"useGlobalMessageData"
|
|
119
119
|
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
120
120
|
Object.defineProperty(exports, '__esModule', {
|
|
121
121
|
value: true
|
package/lib/context/index.d.ts
CHANGED
package/lib/context/index.js
CHANGED
|
@@ -3,10 +3,10 @@ var __webpack_modules__ = {
|
|
|
3
3
|
"./auth.data.instance": function(module) {
|
|
4
4
|
module.exports = require("./auth.data.instance.js");
|
|
5
5
|
},
|
|
6
|
-
"./global.data.instance": function(module) {
|
|
7
|
-
module.exports = require("./global.data.instance.js");
|
|
6
|
+
"./global.message.data.instance": function(module) {
|
|
7
|
+
module.exports = require("./global.message.data.instance.js");
|
|
8
8
|
},
|
|
9
|
-
"
|
|
9
|
+
"./global.setting.data.instance": function(module) {
|
|
10
10
|
module.exports = require("./global.setting.data.instance.js");
|
|
11
11
|
},
|
|
12
12
|
"./page.data.instance": function(module) {
|
|
@@ -59,10 +59,10 @@ function __webpack_require__(moduleId) {
|
|
|
59
59
|
var __webpack_exports__ = {};
|
|
60
60
|
(()=>{
|
|
61
61
|
__webpack_require__.r(__webpack_exports__);
|
|
62
|
-
var
|
|
62
|
+
var _global_message_data_instance__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./global.message.data.instance");
|
|
63
63
|
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
64
|
-
for(var __WEBPACK_IMPORT_KEY__ in
|
|
65
|
-
return
|
|
64
|
+
for(var __WEBPACK_IMPORT_KEY__ in _global_message_data_instance__WEBPACK_IMPORTED_MODULE_0__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
65
|
+
return _global_message_data_instance__WEBPACK_IMPORTED_MODULE_0__[key];
|
|
66
66
|
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
67
67
|
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
68
68
|
var _page_data_instance__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./page.data.instance");
|
|
@@ -83,7 +83,7 @@ var __webpack_exports__ = {};
|
|
|
83
83
|
return _auth_data_instance__WEBPACK_IMPORTED_MODULE_3__[key];
|
|
84
84
|
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
85
85
|
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
86
|
-
var _global_setting_data_instance__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("
|
|
86
|
+
var _global_setting_data_instance__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("./global.setting.data.instance");
|
|
87
87
|
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
88
88
|
for(var __WEBPACK_IMPORT_KEY__ in _global_setting_data_instance__WEBPACK_IMPORTED_MODULE_4__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
89
89
|
return _global_setting_data_instance__WEBPACK_IMPORTED_MODULE_4__[key];
|
|
@@ -46,7 +46,7 @@ const instance_js_namespaceObject = require("../utils/valtio/instance.js");
|
|
|
46
46
|
const external_react_namespaceObject = require("react");
|
|
47
47
|
const navigate_js_namespaceObject = require("../utils/navigate.js");
|
|
48
48
|
var navigate_js_default = /*#__PURE__*/ __webpack_require__.n(navigate_js_namespaceObject);
|
|
49
|
-
const
|
|
49
|
+
const external_global_message_data_instance_js_namespaceObject = require("./global.message.data.instance.js");
|
|
50
50
|
const external_global_setting_data_instance_js_namespaceObject = require("./global.setting.data.instance.js");
|
|
51
51
|
const taro_namespaceObject = require("@tarojs/taro");
|
|
52
52
|
var taro_default = /*#__PURE__*/ __webpack_require__.n(taro_namespaceObject);
|
|
@@ -136,7 +136,7 @@ class page_info_data_instance_PageInfoDataInstance extends instance_js_namespace
|
|
|
136
136
|
taro_default().hideLoading();
|
|
137
137
|
this.updatedLoading(false);
|
|
138
138
|
if (result && result.code === external_global_setting_data_instance_js_namespaceObject.globalSettingDataInstance.store.requestSuccessCode) {
|
|
139
|
-
if (this.requestSaveInfoConfig?.isShowSuccessMessage === false)
|
|
139
|
+
if (this.requestSaveInfoConfig?.isShowSuccessMessage === false) external_global_message_data_instance_js_namespaceObject.globalMessageDataInstance.showMessage({
|
|
140
140
|
content: result.message || "\u4FDD\u5B58\u6210\u529F"
|
|
141
141
|
});
|
|
142
142
|
else taro_default().showToast({
|
package/lib/styles/index.css
CHANGED
package/lib/utils/request.js
CHANGED
|
@@ -40,7 +40,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
40
40
|
const taro_namespaceObject = require("@tarojs/taro");
|
|
41
41
|
var taro_default = /*#__PURE__*/ __webpack_require__.n(taro_namespaceObject);
|
|
42
42
|
const global_setting_data_instance_js_namespaceObject = require("../context/global.setting.data.instance.js");
|
|
43
|
-
const
|
|
43
|
+
const global_message_data_instance_js_namespaceObject = require("../context/global.message.data.instance.js");
|
|
44
44
|
const codeMessage = {
|
|
45
45
|
400: "\u53D1\u51FA\u7684\u8BF7\u6C42\u9519\u8BEF",
|
|
46
46
|
401: "\u7528\u6237\u6CA1\u6709\u6743\u9650",
|
|
@@ -61,7 +61,7 @@ const requestResponseHandle = (result, options)=>{
|
|
|
61
61
|
const code = result?.data?.code;
|
|
62
62
|
if (401 === statusCode || 401 === code || code === global_setting_data_instance_js_namespaceObject.globalSettingDataInstance.store.tokenExpiredCode) {
|
|
63
63
|
msg = "\u8BF7\u91CD\u65B0\u767B\u5F55";
|
|
64
|
-
|
|
64
|
+
global_message_data_instance_js_namespaceObject.globalMessageDataInstance.toLoginPage();
|
|
65
65
|
} else msg = [
|
|
66
66
|
global_setting_data_instance_js_namespaceObject.globalSettingDataInstance.store.requestSuccessCode,
|
|
67
67
|
200
|
|
@@ -75,7 +75,7 @@ const requestResponseHandle = (result, options)=>{
|
|
|
75
75
|
duration: 3000,
|
|
76
76
|
icon: 'none'
|
|
77
77
|
});
|
|
78
|
-
else
|
|
78
|
+
else global_message_data_instance_js_namespaceObject.globalMessageDataInstance.showMessage({
|
|
79
79
|
content: msg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
80
80
|
type: 'error'
|
|
81
81
|
});
|
|
@@ -163,14 +163,14 @@ class RequestInstance {
|
|
|
163
163
|
duration: 3000,
|
|
164
164
|
icon: 'none'
|
|
165
165
|
});
|
|
166
|
-
else
|
|
166
|
+
else global_message_data_instance_js_namespaceObject.globalMessageDataInstance.showMessage({
|
|
167
167
|
content: "\u672A\u767B\u5F55",
|
|
168
168
|
type: 'error'
|
|
169
169
|
});
|
|
170
170
|
options?.fail?.({
|
|
171
171
|
errMsg: "\u672A\u767B\u5F55"
|
|
172
172
|
});
|
|
173
|
-
|
|
173
|
+
global_message_data_instance_js_namespaceObject.globalMessageDataInstance.toLoginPage();
|
|
174
174
|
return;
|
|
175
175
|
}
|
|
176
176
|
return {
|
|
@@ -201,7 +201,7 @@ class RequestInstance {
|
|
|
201
201
|
duration: 3000,
|
|
202
202
|
icon: 'none'
|
|
203
203
|
});
|
|
204
|
-
else
|
|
204
|
+
else global_message_data_instance_js_namespaceObject.globalMessageDataInstance.showMessage({
|
|
205
205
|
content: result.errMsg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
206
206
|
type: 'error'
|
|
207
207
|
});
|
|
@@ -295,7 +295,7 @@ class RequestInstance {
|
|
|
295
295
|
duration: 3000,
|
|
296
296
|
icon: 'none'
|
|
297
297
|
});
|
|
298
|
-
else
|
|
298
|
+
else global_message_data_instance_js_namespaceObject.globalMessageDataInstance.showMessage({
|
|
299
299
|
content: result.errMsg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
300
300
|
type: 'error'
|
|
301
301
|
});
|
|
@@ -346,7 +346,7 @@ class RequestInstance {
|
|
|
346
346
|
duration: 3000,
|
|
347
347
|
icon: 'none'
|
|
348
348
|
});
|
|
349
|
-
else
|
|
349
|
+
else global_message_data_instance_js_namespaceObject.globalMessageDataInstance.showMessage({
|
|
350
350
|
content: result.errMsg || "\u8BF7\u6C42\u53D1\u751F\u9519\u8BEF",
|
|
351
351
|
type: 'error'
|
|
352
352
|
});
|
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.
|
|
6
|
+
"version": "1.0.16",
|
|
7
7
|
"main": "esm/index.js",
|
|
8
8
|
"types": "esm/index.d.ts",
|
|
9
9
|
"module": "esm/index.js",
|
|
@@ -10,7 +10,7 @@ export const FairysTaroMainPage = (props: FairysTaroMainPageProps) => {
|
|
|
10
10
|
const cls = useMemo(
|
|
11
11
|
() =>
|
|
12
12
|
clsx(
|
|
13
|
-
'fairys_taro-ui-main-page
|
|
13
|
+
'fairys_taro-ui-main-page fairystaro__box-border fairystaro__w-full fairystaro__h-full fairystaro__flex fairystaro__flex-col fairystaro__overflow-auto',
|
|
14
14
|
itemClassName,
|
|
15
15
|
),
|
|
16
16
|
[itemClassName],
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { View, ViewProps } from '@tarojs/components';
|
|
2
2
|
import { Fragment, useMemo } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { useGlobalMessageData } from 'context/global.message.data.instance';
|
|
4
4
|
import { FairysTaroPortal } from 'components/Portal';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
|
-
import type { MessageDataType } from 'context/global.data.instance';
|
|
6
|
+
import type { MessageDataType } from 'context/global.message.data.instance';
|
|
7
7
|
|
|
8
8
|
export interface FairysTaroMessageItemProps extends Omit<ViewProps, 'style'> {
|
|
9
9
|
/**
|
|
@@ -190,7 +190,7 @@ export const FairysTaroMessage = (props: FairysTaroMessageProps) => {
|
|
|
190
190
|
export const FairysTaroPortalMessage = (props: FairysTaroMessageProps) => {
|
|
191
191
|
const { className: messageClassName, ...rest } = props;
|
|
192
192
|
|
|
193
|
-
const [state] =
|
|
193
|
+
const [state] = useGlobalMessageData();
|
|
194
194
|
const messageData = state.messageData;
|
|
195
195
|
const classNames = useMemo(
|
|
196
196
|
() =>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Toast } from '@nutui/nutui-react-taro';
|
|
2
2
|
import { FairysTaroPortal } from 'components/Portal';
|
|
3
|
-
import {
|
|
3
|
+
import { useGlobalMessageData } from 'context/global.message.data.instance';
|
|
4
4
|
|
|
5
5
|
export const FairysTaroToast = () => {
|
|
6
|
-
const [state, proxyInstance] =
|
|
6
|
+
const [state, proxyInstance] = useGlobalMessageData();
|
|
7
7
|
const toastConfig = state.toastData as any;
|
|
8
8
|
|
|
9
9
|
return (
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FairysTaroPortalMessage } from 'components/Mesage';
|
|
2
2
|
import { FairysTaroToast } from 'components/Toast';
|
|
3
|
-
import React, { Fragment } from 'react';
|
|
3
|
+
import React, { Fragment, memo } from 'react';
|
|
4
4
|
|
|
5
5
|
export interface ConnectToastMessageOptions {
|
|
6
6
|
/**
|
|
@@ -11,9 +11,20 @@ export interface ConnectToastMessageOptions {
|
|
|
11
11
|
isRoot?: boolean;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* 高阶组件,用于为 React 组件连接 Toast 和 Message 功能
|
|
16
|
+
*
|
|
17
|
+
* 根据不同的运行环境(H5/微信小程序)和组件层级(根页面/子页面),
|
|
18
|
+
* 决定是否渲染 Toast 和 Message 组件,以避免功能冲突和界面遮挡
|
|
19
|
+
*
|
|
20
|
+
* @param Component - 需要被包装的 React 组件
|
|
21
|
+
* @param options - 配置选项
|
|
22
|
+
* @param options.isRoot - 是否为根页面组件,默认为 false
|
|
23
|
+
* @returns 返回一个经过优化的 React 组件,根据环境条件选择性渲染 Toast 和 Message
|
|
24
|
+
*/
|
|
14
25
|
export const connectToastMessage = (Component: React.FC, options: ConnectToastMessageOptions = {}) => {
|
|
15
26
|
const { isRoot = false } = options;
|
|
16
|
-
return (props: any) => {
|
|
27
|
+
return memo((props: any) => {
|
|
17
28
|
// 在 h5 中,只有根页面才需要展示 message 组件 和 toast 组件,其他页面只是渲染组件就好
|
|
18
29
|
|
|
19
30
|
// 微信中,根目录不显示 message 组件 和 toast 组件,因为会遮挡页面内容
|
|
@@ -37,5 +48,5 @@ export const connectToastMessage = (Component: React.FC, options: ConnectToastMe
|
|
|
37
48
|
{isRoot ? <FairysTaroPortalMessage /> : <Fragment />}
|
|
38
49
|
</Fragment>
|
|
39
50
|
);
|
|
40
|
-
};
|
|
51
|
+
});
|
|
41
52
|
};
|
|
@@ -6,7 +6,6 @@ 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';
|
|
10
9
|
|
|
11
10
|
export interface MessageDataType extends FairysTaroMessageItemProps {
|
|
12
11
|
/**用于唯一标识提示框(默认自动生成)*/
|
|
@@ -24,7 +23,7 @@ export interface MessageDataType extends FairysTaroMessageItemProps {
|
|
|
24
23
|
|
|
25
24
|
export interface ToastDataType extends Partial<TaroToastProps> {}
|
|
26
25
|
|
|
27
|
-
export interface
|
|
26
|
+
export interface GlobalMessageDataInstanceState {
|
|
28
27
|
/**弹框提示框*/
|
|
29
28
|
messageData?: MessageDataType[];
|
|
30
29
|
/**提示框数据*/
|
|
@@ -32,9 +31,11 @@ export interface GlobalDataInstanceState {
|
|
|
32
31
|
/**数据默认值不使用*/
|
|
33
32
|
__defaultValue?: string;
|
|
34
33
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
/**
|
|
35
|
+
* 全局消息数据实例
|
|
36
|
+
*/
|
|
37
|
+
export class GlobalMessageDataInstance extends ProxyInstanceObjectBase<GlobalMessageDataInstanceState> {
|
|
38
|
+
store = proxy<GlobalMessageDataInstanceState>({
|
|
38
39
|
messageData: ref([]),
|
|
39
40
|
toastData: undefined,
|
|
40
41
|
});
|
|
@@ -101,18 +102,18 @@ export class GlobalDataInstance extends ProxyInstanceObjectBase<GlobalDataInstan
|
|
|
101
102
|
};
|
|
102
103
|
}
|
|
103
104
|
/**
|
|
104
|
-
*
|
|
105
|
+
* 全局消息数据实例
|
|
105
106
|
*/
|
|
106
|
-
export const
|
|
107
|
+
export const globalMessageDataInstance = new GlobalMessageDataInstance();
|
|
107
108
|
|
|
108
109
|
/**
|
|
109
|
-
*
|
|
110
|
+
* 全局消息数据状态管理
|
|
110
111
|
*/
|
|
111
|
-
export const
|
|
112
|
-
const store = useSnapshot(
|
|
113
|
-
return [store,
|
|
114
|
-
|
|
115
|
-
|
|
112
|
+
export const useGlobalMessageData = () => {
|
|
113
|
+
const store = useSnapshot(globalMessageDataInstance.store);
|
|
114
|
+
return [store, globalMessageDataInstance, store.__defaultValue] as [
|
|
115
|
+
GlobalMessageDataInstanceState,
|
|
116
|
+
GlobalMessageDataInstance,
|
|
116
117
|
string | undefined,
|
|
117
118
|
];
|
|
118
119
|
};
|
package/src/context/index.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { proxy, ref, useSnapshot } from 'valtio';
|
|
|
2
2
|
import { ProxyInstanceObjectBase } from 'utils/valtio/instance';
|
|
3
3
|
import { createContext, useContext, useEffect, useMemo, useRef } from 'react';
|
|
4
4
|
import navigate from '../utils/navigate';
|
|
5
|
-
import {
|
|
5
|
+
import { globalMessageDataInstance } from './global.message.data.instance';
|
|
6
6
|
import { globalSettingDataInstance } from './global.setting.data.instance';
|
|
7
7
|
import { useDidShow } from '@tarojs/taro';
|
|
8
8
|
import Taro from '@tarojs/taro';
|
|
@@ -146,7 +146,7 @@ export class PageInfoDataInstance<
|
|
|
146
146
|
this.updatedLoading(false);
|
|
147
147
|
if (result && result.code === globalSettingDataInstance.store.requestSuccessCode) {
|
|
148
148
|
if (this.requestSaveInfoConfig?.isShowSuccessMessage === false) {
|
|
149
|
-
|
|
149
|
+
globalMessageDataInstance.showMessage({ content: result.message || '保存成功' });
|
|
150
150
|
} else {
|
|
151
151
|
Taro.showToast({ title: result.message || '保存成功', icon: 'none' });
|
|
152
152
|
}
|
package/src/utils/request.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Taro from '@tarojs/taro';
|
|
2
2
|
import { globalSettingDataInstance } from 'context/global.setting.data.instance';
|
|
3
|
-
import {
|
|
3
|
+
import { globalMessageDataInstance } from 'context/global.message.data.instance';
|
|
4
4
|
|
|
5
5
|
const codeMessage = {
|
|
6
6
|
400: '发出的请求错误',
|
|
@@ -53,7 +53,7 @@ const requestResponseHandle = (
|
|
|
53
53
|
// 权限问题 ,重新登录
|
|
54
54
|
msg = '请重新登录';
|
|
55
55
|
/**重新跳转登录页面*/
|
|
56
|
-
|
|
56
|
+
globalMessageDataInstance.toLoginPage();
|
|
57
57
|
} else if (![globalSettingDataInstance.store.requestSuccessCode, 200].includes(code)) {
|
|
58
58
|
// 提示内容
|
|
59
59
|
// @ts-ignore
|
|
@@ -73,7 +73,7 @@ const requestResponseHandle = (
|
|
|
73
73
|
icon: 'none',
|
|
74
74
|
});
|
|
75
75
|
} else {
|
|
76
|
-
|
|
76
|
+
globalMessageDataInstance.showMessage({
|
|
77
77
|
content: msg || '请求发生错误',
|
|
78
78
|
type: 'error',
|
|
79
79
|
});
|
|
@@ -231,14 +231,14 @@ export class RequestInstance {
|
|
|
231
231
|
icon: 'none',
|
|
232
232
|
});
|
|
233
233
|
} else {
|
|
234
|
-
|
|
234
|
+
globalMessageDataInstance.showMessage({
|
|
235
235
|
content: '未登录',
|
|
236
236
|
type: 'error',
|
|
237
237
|
});
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
240
|
options?.fail?.({ errMsg: '未登录' });
|
|
241
|
-
|
|
241
|
+
globalMessageDataInstance.toLoginPage();
|
|
242
242
|
return undefined;
|
|
243
243
|
}
|
|
244
244
|
}
|
|
@@ -281,7 +281,7 @@ export class RequestInstance {
|
|
|
281
281
|
icon: 'none',
|
|
282
282
|
});
|
|
283
283
|
} else {
|
|
284
|
-
|
|
284
|
+
globalMessageDataInstance.showMessage({
|
|
285
285
|
content: result.errMsg || '请求发生错误',
|
|
286
286
|
type: 'error',
|
|
287
287
|
});
|
|
@@ -397,7 +397,7 @@ export class RequestInstance {
|
|
|
397
397
|
icon: 'none',
|
|
398
398
|
});
|
|
399
399
|
} else {
|
|
400
|
-
|
|
400
|
+
globalMessageDataInstance.showMessage({
|
|
401
401
|
content: result.errMsg || '请求发生错误',
|
|
402
402
|
type: 'error',
|
|
403
403
|
});
|
|
@@ -462,7 +462,7 @@ export class RequestInstance {
|
|
|
462
462
|
icon: 'none',
|
|
463
463
|
});
|
|
464
464
|
} else {
|
|
465
|
-
|
|
465
|
+
globalMessageDataInstance.showMessage({
|
|
466
466
|
content: result.errMsg || '请求发生错误',
|
|
467
467
|
type: 'error',
|
|
468
468
|
});
|