diff --git a/src/main.jsx b/src/main.jsx
index 18684ec..bbaa0c7 100644
--- a/src/main.jsx
+++ b/src/main.jsx
@@ -5,8 +5,8 @@ import {
createBrowserRouter,
RouterProvider,
} from 'react-router-dom'
-import RootStore from '@/stores/Root'
-import { StoreContext } from '@/stores/StoreContext'
+import { AuthContext } from '@/stores/AuthContext'
+import Auth from '@/stores/Auth'
import App from '@/views/App'
import Standlone from '@/views/Standlone'
import OrderFollow from '@/views/OrderFollow'
@@ -53,21 +53,21 @@ const router = createBrowserRouter([
{
element: ,
children: [
- { path: "/dingding/qrcode", element: },
- { path: "/dingding/callback", element: },
+ { path: '/dingding/qrcode', element: },
+ { path: '/dingding/callback', element: },
]
}
])
-const rootStore = new RootStore();
+const auth = new Auth();
ReactDOM.createRoot(document.getElementById('root')).render(
//
-
+
Loading...
}
/>
-
+
//
)
diff --git a/src/stores/Auth.js b/src/stores/Auth.js
index 76b02a1..7cefdfd 100644
--- a/src/stores/Auth.js
+++ b/src/stores/Auth.js
@@ -1,24 +1,12 @@
-import { makeAutoObservable, runInAction } from 'mobx'
-
const KEY_USER_ID = 'KEY_USER_ID'
class Auth {
- constructor(root) {
- makeAutoObservable(this, { rootStore: false })
- this.root = root
- this.userId = root.getSession(KEY_USER_ID)
- }
-
- setup(userId) {
- runInAction(() => {
- this.userId = userId
- })
- this.root.putSession(KEY_USER_ID, userId)
+ constructor() {
}
// HT 账号 OP_SN
- userId = null
+ userId = 1
}
export default Auth
diff --git a/src/stores/AuthContext.js b/src/stores/AuthContext.js
new file mode 100644
index 0000000..2fd39c8
--- /dev/null
+++ b/src/stores/AuthContext.js
@@ -0,0 +1,7 @@
+import { createContext, useContext } from 'react'
+
+export const AuthContext = createContext(null)
+
+export function useAuth() {
+ return useContext(AuthContext)
+}
\ No newline at end of file
diff --git a/src/views/AccountProfile.jsx b/src/views/AccountProfile.jsx
index 40dafd3..f4add0a 100644
--- a/src/views/AccountProfile.jsx
+++ b/src/views/AccountProfile.jsx
@@ -1,25 +1,25 @@
-import { useNavigate } from 'react-router-dom'
-import { useRef, useEffect, useState } from 'react'
+import { useEffect } from 'react'
import { observer } from 'mobx-react'
import {
- Row, Col, Divider, Table, Card, Button, Input,
- Space, Segmented, Radio, Select, Descriptions, Spin, Typography, Flex, DatePicker, List, Avatar
+ Row, Col, Space, Descriptions, Avatar
} from 'antd'
-import {
- StarFilled, ZoomInOutlined, StarOutlined, BarsOutlined, AppstoreOutlined, SearchOutlined
-} from '@ant-design/icons'
-import { Conditional } from '@/components/Conditional'
-function AccountProfile() {
+import { useAuth } from '@/stores/AuthContext.js'
+
+function AccountProfile() {
+ const auth = useAuth()
+ console.info('useAuth: ' + auth.userId)
useEffect(() => {
+ // 测试错误捕获:
+ // throw new Error('💥 CABOOM 💥')
}, [])
return (
- 骆梅玉
+ 骆梅玉
+86-15878301602
christyluo@hainatravel.com
海纳业务组-GH事业部群-GH销售
diff --git a/src/views/App.jsx b/src/views/App.jsx
index cdf2fe3..f6bdfe3 100644
--- a/src/views/App.jsx
+++ b/src/views/App.jsx
@@ -10,7 +10,6 @@ import 'dayjs/locale/zh-cn';
import 'react-chat-elements/dist/main.css'
import '@/assets/App.css'
import AppLogo from '@/assets/logo-gh.png'
-import { useStore } from '@/stores/StoreContext.js'
import { isEmpty } from '@/utils/commons'
const { Header, Footer, Content } = Layout
@@ -19,9 +18,7 @@ const { Title } = Typography
function App() {
const href = useHref()
- const { authStore } = useStore()
- const { userId, website } = authStore
- const shouldBeLogin = (isEmpty(userId) || isEmpty(website)) && (href.indexOf('/authorise/') == -1)
+ //const shouldBeLogin = (isEmpty(userId) || isEmpty(website)) && (href.indexOf('/authorise/') == -1)
let defaultPath = 'follow'
if (href !== '/') {
diff --git a/src/views/DingdingCallbak.jsx b/src/views/DingdingCallbak.jsx
index 9a82575..72fa63c 100644
--- a/src/views/DingdingCallbak.jsx
+++ b/src/views/DingdingCallbak.jsx
@@ -1,40 +1,49 @@
import React, { useEffect } from 'react'
-import { useParams, useNavigate } from "react-router-dom"
+import { useParams, useNavigate } from 'react-router-dom'
import { Card, Typography, Flex, Result, Button } from 'antd'
import { useRequest } from 'ahooks'
const { Title } = Typography
const { Meta } = Card
+import { useAuth } from '@/stores/AuthContext.js'
+
function DingdingCallbak() {
+ const navigate = useNavigate()
const params = new URLSearchParams(window.location.search)
const code = params.get('code')
const state = params.get('state')
console.info('code: ' + code)
console.info('state: ' + state)
- const { data, error, loading } = useRequest(() => {
- return new Promise((resolve) => {
- setTimeout(() => {
- resolve('use Request data...');
- }, 1000);
- });
- });
+
+ const auth = useAuth()
+ console.info('useAuth: ' + auth.userId)
+
+ auth.userId = 3344343
+
+ // const { data, error, loading } = useRequest(() => {
+ // return new Promise((resolve) => {
+ // setTimeout(() => {
+ // resolve('use Request data...');
+ // }, 1000);
+ // });
+ // });
+ setTimeout(() => {
+ navigate('/s/account/profile')
+ }, 1000);
useEffect(() => {
}, [])
return (
-
- {error}
- {loading}
- {data}
+
正在获取你的权限,请稍等
)
diff --git a/src/views/Standlone.jsx b/src/views/Standlone.jsx
index 855f44a..1aa470b 100644
--- a/src/views/Standlone.jsx
+++ b/src/views/Standlone.jsx
@@ -28,20 +28,6 @@ const items = [
},
];
function Standlone() {
-
- const href = useHref()
- const { authStore } = useStore()
- const { userId, website } = authStore
- const shouldBeLogin = (isEmpty(userId) || isEmpty(website)) && (href.indexOf('/authorise/') == -1)
- let defaultPath = 'follow'
-
- if (href !== '/') {
- const splitPath = href.split('/')
-
- if (splitPath.length > 1) {
- defaultPath = splitPath[2]
- }
- }
const {
token: { colorBgContainer },
} = theme.useToken()