update
parent
3044a43a89
commit
a7bd08ec79
|
@ -17,6 +17,7 @@
|
|||
"mtproton": "6.0.0",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"react-router-dom": "^6.2.1",
|
||||
"react-scripts": "5.0.0",
|
||||
"typescript": "^4.5.5",
|
||||
"web-vitals": "^2.1.4"
|
||||
|
|
|
@ -2,10 +2,19 @@ import React from "react";
|
|||
import ReactDOM from "react-dom";
|
||||
import App from "./App";
|
||||
import reportWebVitals from "./reportWebVitals";
|
||||
import Login from "./pages/login";
|
||||
import { BrowserRouter, Routes, Route } from "react-router-dom";
|
||||
import Home from "./pages/home";
|
||||
|
||||
ReactDOM.render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
<BrowserRouter>
|
||||
<Routes>
|
||||
<Route path="/" element={<Home />} />
|
||||
<Route path="/home" element={<Home />} />
|
||||
<Route path="/login" element={<Login />} />
|
||||
</Routes>
|
||||
</BrowserRouter>
|
||||
</React.StrictMode>,
|
||||
document.getElementById("root")
|
||||
);
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
import Telegram from "../../telegram/telegram";
|
||||
|
||||
function Home() {
|
||||
Telegram.call("sendMessage", {
|
||||
chat_id: "",
|
||||
text: "Hello World",
|
||||
});
|
||||
return (
|
||||
<div>
|
||||
<h1>Hello Next.js</h1>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default Home;
|
|
@ -0,0 +1,21 @@
|
|||
import { useEffect } from "react";
|
||||
import { getMe } from "../../telegram/user";
|
||||
|
||||
function Login() {
|
||||
useEffect(function () {
|
||||
getMe()
|
||||
.then(function (user) {
|
||||
console.log(user);
|
||||
})
|
||||
.catch(function (error) {
|
||||
if (error.code === 401) {
|
||||
// Unauthorized
|
||||
}
|
||||
console.log(error);
|
||||
});
|
||||
}, []);
|
||||
|
||||
return <div>登录</div>;
|
||||
}
|
||||
|
||||
export default Login;
|
|
@ -0,0 +1,9 @@
|
|||
import Telegram from "./telegram";
|
||||
|
||||
async function getMe() {
|
||||
return await Telegram.call("users.getUsers", {
|
||||
id: [{ _: "inputPeerSelf" }],
|
||||
});
|
||||
}
|
||||
|
||||
export { getMe };
|
Loading…
Reference in New Issue