master
icechen 2022-02-22 20:23:44 +08:00
parent 3044a43a89
commit a7bd08ec79
5 changed files with 56 additions and 1 deletions

View File

@ -17,6 +17,7 @@
"mtproton": "6.0.0", "mtproton": "6.0.0",
"react": "^17.0.2", "react": "^17.0.2",
"react-dom": "^17.0.2", "react-dom": "^17.0.2",
"react-router-dom": "^6.2.1",
"react-scripts": "5.0.0", "react-scripts": "5.0.0",
"typescript": "^4.5.5", "typescript": "^4.5.5",
"web-vitals": "^2.1.4" "web-vitals": "^2.1.4"

View File

@ -2,10 +2,19 @@ import React from "react";
import ReactDOM from "react-dom"; import ReactDOM from "react-dom";
import App from "./App"; import App from "./App";
import reportWebVitals from "./reportWebVitals"; import reportWebVitals from "./reportWebVitals";
import Login from "./pages/login";
import { BrowserRouter, Routes, Route } from "react-router-dom";
import Home from "./pages/home";
ReactDOM.render( ReactDOM.render(
<React.StrictMode> <React.StrictMode>
<App /> <BrowserRouter>
<Routes>
<Route path="/" element={<Home />} />
<Route path="/home" element={<Home />} />
<Route path="/login" element={<Login />} />
</Routes>
</BrowserRouter>
</React.StrictMode>, </React.StrictMode>,
document.getElementById("root") document.getElementById("root")
); );

View File

@ -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;

View File

@ -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;

View File

@ -0,0 +1,9 @@
import Telegram from "./telegram";
async function getMe() {
return await Telegram.call("users.getUsers", {
id: [{ _: "inputPeerSelf" }],
});
}
export { getMe };