15 changed files with 50136 additions and 10078 deletions
@ -1,38 +0,0 @@ |
|||||||
.App { |
|
||||||
text-align: center; |
|
||||||
} |
|
||||||
|
|
||||||
.App-logo { |
|
||||||
height: 40vmin; |
|
||||||
pointer-events: none; |
|
||||||
} |
|
||||||
|
|
||||||
@media (prefers-reduced-motion: no-preference) { |
|
||||||
.App-logo { |
|
||||||
animation: App-logo-spin infinite 20s linear; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
.App-header { |
|
||||||
background-color: #282c34; |
|
||||||
min-height: 100vh; |
|
||||||
display: flex; |
|
||||||
flex-direction: column; |
|
||||||
align-items: center; |
|
||||||
justify-content: center; |
|
||||||
font-size: calc(10px + 2vmin); |
|
||||||
color: white; |
|
||||||
} |
|
||||||
|
|
||||||
.App-link { |
|
||||||
color: #61dafb; |
|
||||||
} |
|
||||||
|
|
||||||
@keyframes App-logo-spin { |
|
||||||
from { |
|
||||||
transform: rotate(0deg); |
|
||||||
} |
|
||||||
to { |
|
||||||
transform: rotate(360deg); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,25 +0,0 @@ |
|||||||
import logo from './logo.svg'; |
|
||||||
import './App.css'; |
|
||||||
|
|
||||||
function App() { |
|
||||||
return ( |
|
||||||
<div className="App"> |
|
||||||
<header className="App-header"> |
|
||||||
<img src={logo} className="App-logo" alt="logo" /> |
|
||||||
<p> |
|
||||||
Edit <code>src/App.js</code> and save to reload. |
|
||||||
</p> |
|
||||||
<a |
|
||||||
className="App-link" |
|
||||||
href="https://reactjs.org" |
|
||||||
target="_blank" |
|
||||||
rel="noopener noreferrer" |
|
||||||
> |
|
||||||
Learn React |
|
||||||
</a> |
|
||||||
</header> |
|
||||||
</div> |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
export default App; |
|
||||||
@ -0,0 +1,80 @@ |
|||||||
|
import React from 'react'; |
||||||
|
import { |
||||||
|
Button, |
||||||
|
Form, |
||||||
|
Input, |
||||||
|
message |
||||||
|
} from 'antd'; |
||||||
|
import { axiosPostBody } from './util/Request'; |
||||||
|
import * as Params from './common/param/Params' |
||||||
|
|
||||||
|
class Login extends React.Component { |
||||||
|
constructor(props) { |
||||||
|
super(props) |
||||||
|
this.state = { |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
componentDidMount() { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
onFinish = (values) => { |
||||||
|
let data = { |
||||||
|
username: values.username, |
||||||
|
password: values.password |
||||||
|
} |
||||||
|
axiosPostBody(Params.LOGIN_URL, data) |
||||||
|
.then(response => { |
||||||
|
message.success("登录成功!"); |
||||||
|
localStorage.username = response.data.username |
||||||
|
this.props.history.push("panel/" + response.data.uuid) |
||||||
|
}); |
||||||
|
}; |
||||||
|
|
||||||
|
onFinishFailed = (errorInfo) => { |
||||||
|
console.log('Failed:', errorInfo); |
||||||
|
}; |
||||||
|
|
||||||
|
render() { |
||||||
|
|
||||||
|
return ( |
||||||
|
<div> |
||||||
|
<Form |
||||||
|
name="basic" |
||||||
|
labelCol={{ span: 9 }} |
||||||
|
wrapperCol={{ span: 6 }} |
||||||
|
onFinish={this.onFinish} |
||||||
|
onFinishFailed={this.onFinishFailed} |
||||||
|
autoComplete="off" |
||||||
|
style={{ marginTop: 150 }} |
||||||
|
> |
||||||
|
<Form.Item |
||||||
|
label="Username" |
||||||
|
name="username" |
||||||
|
rules={[{ required: true, message: 'Please input your username!' }]} |
||||||
|
> |
||||||
|
<Input /> |
||||||
|
</Form.Item> |
||||||
|
|
||||||
|
<Form.Item |
||||||
|
label="Password" |
||||||
|
name="password" |
||||||
|
rules={[{ required: true, message: 'Please input your password!' }]} |
||||||
|
> |
||||||
|
<Input.Password /> |
||||||
|
</Form.Item> |
||||||
|
|
||||||
|
<Form.Item wrapperCol={{ offset: 9, span: 6 }}> |
||||||
|
<Button type="primary" htmlType="submit"> |
||||||
|
Submit |
||||||
|
</Button> |
||||||
|
</Form.Item> |
||||||
|
</Form> |
||||||
|
</div> |
||||||
|
); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
export default Login; |
||||||
@ -0,0 +1,23 @@ |
|||||||
|
export const API_VERSION = "/api/v1/"; |
||||||
|
|
||||||
|
//local |
||||||
|
export const HOST = "http://local.deepsky.com:8888"; |
||||||
|
|
||||||
|
export const LOGIN_URL = HOST + '/user/login' |
||||||
|
export const USER_URL = HOST + '/user/' |
||||||
|
export const USER_LIST_URL = HOST + '/user' |
||||||
|
|
||||||
|
export const USER_FRIEND_URL = HOST + '/friend' |
||||||
|
|
||||||
|
export const MESSAGE_URL = HOST + '/message' |
||||||
|
|
||||||
|
export const GROUP_LIST_URL = HOST + '/group' |
||||||
|
export const GROUP_USER_URL = HOST + '/group/user/' |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export const FINANCIAL_PARAM_URL = HOST + API_VERSION + 'financial-param/'; |
||||||
|
export const AUTH_HEADER_KEY = "Authorization"; |
||||||
|
export const TOKEN_PREFIX = "Bearer "; |
||||||
|
|
||||||
@ -0,0 +1,15 @@ |
|||||||
|
syntax = "proto3"; |
||||||
|
package protocol; |
||||||
|
|
||||||
|
message Message { |
||||||
|
string avatar = 1; |
||||||
|
string fromUsername = 2; |
||||||
|
string from = 3; |
||||||
|
string to = 4; |
||||||
|
string content = 5; |
||||||
|
int32 contentType = 6; |
||||||
|
string type = 7; |
||||||
|
int32 messageType = 8; |
||||||
|
string url = 9; |
||||||
|
bytes file = 10; |
||||||
|
} |
||||||
@ -0,0 +1,58 @@ |
|||||||
|
/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/ |
||||||
|
// "use strict";
|
||||||
|
|
||||||
|
var $protobuf = require("protobufjs/light"); |
||||||
|
|
||||||
|
var $root = ($protobuf.roots["default"] || ($protobuf.roots["default"] = new $protobuf.Root())) |
||||||
|
.addJSON({ |
||||||
|
protocol: { |
||||||
|
nested: { |
||||||
|
Message: { |
||||||
|
fields: { |
||||||
|
avatar: { |
||||||
|
type: "string", |
||||||
|
id: 1 |
||||||
|
}, |
||||||
|
fromUsername: { |
||||||
|
type: "string", |
||||||
|
id: 2 |
||||||
|
}, |
||||||
|
from: { |
||||||
|
type: "string", |
||||||
|
id: 3 |
||||||
|
}, |
||||||
|
to: { |
||||||
|
type: "string", |
||||||
|
id: 4 |
||||||
|
}, |
||||||
|
content: { |
||||||
|
type: "string", |
||||||
|
id: 5 |
||||||
|
}, |
||||||
|
contentType: { |
||||||
|
type: "int32", |
||||||
|
id: 6 |
||||||
|
}, |
||||||
|
type: { |
||||||
|
type: "string", |
||||||
|
id: 7 |
||||||
|
}, |
||||||
|
messageType: { |
||||||
|
type: "int32", |
||||||
|
id: 8 |
||||||
|
}, |
||||||
|
url: { |
||||||
|
type: "string", |
||||||
|
id: 9 |
||||||
|
}, |
||||||
|
file: { |
||||||
|
type: "bytes", |
||||||
|
id: 10 |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
module.exports = $root; |
||||||
@ -0,0 +1,99 @@ |
|||||||
|
import axios from 'axios' |
||||||
|
import qs from 'qs' |
||||||
|
import { |
||||||
|
message |
||||||
|
} from 'antd'; |
||||||
|
|
||||||
|
function axiosPost(url, data, options = { dealError: false }) { |
||||||
|
return new Promise((resolve, reject) => { |
||||||
|
axios.post(url, qs.stringify(data), { |
||||||
|
headers: { |
||||||
|
// "Authorization": Params.TOKEN_PREFIX + localStorage.token, |
||||||
|
'content-type': 'application/x-www-form-urlencoded' |
||||||
|
} |
||||||
|
}).then(response => { |
||||||
|
if (response.data.code === 0) { |
||||||
|
resolve(response.data); |
||||||
|
} else { |
||||||
|
if (options.dealError) { |
||||||
|
reject(response); |
||||||
|
} else { |
||||||
|
message.error(response.data.msg); |
||||||
|
} |
||||||
|
} |
||||||
|
}).catch(_error => { |
||||||
|
message.error('网络错误,请稍候再试!'); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
function axiosPostBody(url, data, options = { dealError: false }) { |
||||||
|
return new Promise((resolve, reject) => { |
||||||
|
axios.post(url, data, { |
||||||
|
headers: { |
||||||
|
// "Authorization": Params.TOKEN_PREFIX + localStorage.token, |
||||||
|
} |
||||||
|
}).then(response => { |
||||||
|
if (response.data.code === 0) { |
||||||
|
resolve(response.data); |
||||||
|
} else { |
||||||
|
if (options.dealError) { |
||||||
|
reject(response); |
||||||
|
} else { |
||||||
|
message.error(response.data.msg); |
||||||
|
} |
||||||
|
} |
||||||
|
}).catch(_error => { |
||||||
|
message.error('网络错误,请稍候再试!'); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
function axiosPut(url, data = {}, options = { dealError: false }) { |
||||||
|
return new Promise((resolve, reject) => { |
||||||
|
axios.put(url, data, { |
||||||
|
headers: { |
||||||
|
// "Authorization": Params.TOKEN_PREFIX + localStorage.token |
||||||
|
} |
||||||
|
}).then(response => { |
||||||
|
if (response.data.code === 0) { |
||||||
|
resolve(response.data); |
||||||
|
} else { |
||||||
|
if (options.dealError) { |
||||||
|
reject(response); |
||||||
|
} else { |
||||||
|
message.error(response.data.msg); |
||||||
|
} |
||||||
|
} |
||||||
|
}).catch(_error => { |
||||||
|
message.error('网络错误,请稍候再试!'); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
function axiosGet(url, data = {}, options = { dealError: false }) { |
||||||
|
return new Promise((resolve, reject) => { |
||||||
|
axios.get(url, { |
||||||
|
params: { |
||||||
|
...data, |
||||||
|
}, |
||||||
|
headers: { |
||||||
|
// "Authorization": Params.TOKEN_PREFIX + localStorage.token |
||||||
|
} |
||||||
|
}).then(response => { |
||||||
|
if (response.data.code === 0) { |
||||||
|
resolve(response.data); |
||||||
|
} else { |
||||||
|
if (options.dealError) { |
||||||
|
reject(response); |
||||||
|
} else { |
||||||
|
message.error(response.data.msg); |
||||||
|
} |
||||||
|
} |
||||||
|
}).catch(_error => { |
||||||
|
message.error('网络错误,请稍候再试!'); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
export { axiosPost, axiosPut, axiosPostBody, axiosGet } |
||||||
Loading…
Reference in new issue