extract infrastructure
This commit is contained in:
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -6,3 +6,6 @@
|
||||
path = src/react-lazyload
|
||||
url = https://github.com/xmcp/react-lazyload
|
||||
|
||||
[submodule "src/infrastructure"]
|
||||
path = src/infrastructure
|
||||
url = https://github.com/pkuhelper-web/infrastructure
|
||||
|
||||
@@ -1,39 +1,3 @@
|
||||
.centered-line {
|
||||
overflow: hidden;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.centered-line::before,
|
||||
.centered-line::after {
|
||||
background-color: #000;
|
||||
content: "";
|
||||
display: inline-block;
|
||||
height: 1px;
|
||||
position: relative;
|
||||
vertical-align: middle;
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.centered-line::before {
|
||||
right: 1em;
|
||||
margin-left: -50%;
|
||||
}
|
||||
|
||||
.centered-line::after {
|
||||
left: 1em;
|
||||
margin-right: -50%;
|
||||
}
|
||||
|
||||
.title-line {
|
||||
color: #fff;
|
||||
margin-top: 1em;
|
||||
}
|
||||
.title-line::before,
|
||||
.title-line::after {
|
||||
background-color: #fff;
|
||||
box-shadow: 0 1px 1px #000;
|
||||
}
|
||||
|
||||
.bg-img {
|
||||
position: fixed;
|
||||
z-index: -1;
|
||||
|
||||
@@ -1,20 +1,13 @@
|
||||
import React, {Component, PureComponent} from 'react';
|
||||
import {format_time,Time,TitleLine} from './infrastructure/widgets';
|
||||
import {PKUHELPER_ROOT} from './flows_api';
|
||||
|
||||
import TimeAgo from 'react-timeago';
|
||||
import chineseStrings from 'react-timeago/lib/language-strings/zh-CN';
|
||||
import buildFormatter from 'react-timeago/lib/formatters/buildFormatter';
|
||||
|
||||
import './Common.css';
|
||||
|
||||
const chinese_format=buildFormatter(chineseStrings);
|
||||
export {format_time,Time,TitleLine};
|
||||
|
||||
export const API_BASE=PKUHELPER_ROOT+'services/pkuhole';
|
||||
|
||||
function pad2(x) {
|
||||
return x<10 ? '0'+x : ''+x;
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex
|
||||
function escape_regex(string) {
|
||||
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
||||
@@ -24,29 +17,6 @@ export function build_highlight_re(txt,split) {
|
||||
return txt ? new RegExp(`(${txt.split(split).filter((x)=>!!x).map(escape_regex).join('|')})`,'g') : /^$/g;
|
||||
}
|
||||
|
||||
export function format_time(time) {
|
||||
return `${time.getMonth()+1}-${pad2(time.getDate())} ${time.getHours()}:${pad2(time.getMinutes())}:${pad2(time.getSeconds())}`;
|
||||
}
|
||||
|
||||
export function Time(props) {
|
||||
const time=new Date(props.stamp*1000);
|
||||
return (
|
||||
<span>
|
||||
<TimeAgo date={time} formatter={chinese_format} />
|
||||
|
||||
{format_time(time)}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export function TitleLine(props) {
|
||||
return (
|
||||
<p className="centered-line title-line aux-margin">
|
||||
<span className="black-outline">{props.text}</span>
|
||||
</p>
|
||||
)
|
||||
}
|
||||
|
||||
export class HighlightedText extends PureComponent {
|
||||
render() {
|
||||
function normalize_url(url) {
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
import React, {Component, PureComponent} from 'react';
|
||||
import {ISOP_APPKEY,ISOP_APPCODE,ISOP_SVCID} from './infrastructure/const';
|
||||
import copy from 'copy-to-clipboard';
|
||||
import {SafeTextarea} from './Common';
|
||||
import {API_VERSION_PARAM,PKUHELPER_ROOT,API,get_json} from './flows_api'
|
||||
import {API_BASE,SafeTextarea} from './Common';
|
||||
import {MessageViewer} from './Message';
|
||||
import {API_VERSION_PARAM,PKUHELPER_ROOT,API,get_json} from './flows_api';
|
||||
import md5 from 'md5';
|
||||
|
||||
import './UserAction.css';
|
||||
|
||||
import {API_BASE} from './Common';
|
||||
import {MessageViewer} from './Message';
|
||||
const LOGIN_BASE=PKUHELPER_ROOT+'services/login';
|
||||
const MAX_IMG_PX=2500;
|
||||
const MAX_IMG_FILESIZE=300000;
|
||||
|
||||
export const ISOP_APPKEY='0feb3a8a831e11e8933a0050568508a5';
|
||||
export const ISOP_APPCODE='0fec960a831e11e8933a0050568508a5';
|
||||
export const ISOP_SVCID='PERSON_BASE_INFO,STUDENT_SCORE,STUDENT_COURSE_TABLE,STUDENT_COURSE_TABLE_ROOM,CARD_BALANCE';
|
||||
export {ISOP_APPKEY,ISOP_APPCODE,ISOP_SVCID};
|
||||
|
||||
export const TokenCtx=React.createContext({
|
||||
value: null,
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
import {get_json} from './infrastructure/functions';
|
||||
import {PKUHELPER_ROOT} from './infrastructure/const';
|
||||
import {API_BASE} from './Common';
|
||||
|
||||
export const API_VERSION_PARAM='&PKUHelperAPI=3.0';
|
||||
export const PKUHELPER_ROOT='//pkuhelper.pku.edu.cn/';
|
||||
export {PKUHELPER_ROOT};
|
||||
|
||||
function token_param(token) {
|
||||
return API_VERSION_PARAM + (token ? ('&user_token='+token) : '');
|
||||
}
|
||||
|
||||
export function get_json(res) {
|
||||
if(!res.ok) throw Error(`网络错误 ${res.status} ${res.statusText}`);
|
||||
return res.json();
|
||||
}
|
||||
export {get_json};
|
||||
|
||||
export const API={
|
||||
load_replies: (pid,token,color_picker)=>{
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-size: cover;
|
||||
overflow-x: hidden;
|
||||
user-select: none;
|
||||
text-size-adjust: 100%;
|
||||
background-color: #124;
|
||||
}
|
||||
|
||||
@@ -15,24 +11,8 @@ html {
|
||||
scrollbar-width: none;
|
||||
}
|
||||
|
||||
body, textarea, pre {
|
||||
font-family: 'Segoe UI', '微软雅黑', 'Microsoft YaHei', sans-serif;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
word-wrap: break-word;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
p, pre {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: #00c;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
input, textarea {
|
||||
@@ -49,10 +29,6 @@ audio {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
pre {
|
||||
white-space: pre-line;
|
||||
}
|
||||
|
||||
button, .button {
|
||||
color: black;
|
||||
background-color: rgba(235,235,235,.5);
|
||||
@@ -70,7 +46,3 @@ button:hover, .button:hover {
|
||||
button:disabled, .button:disabled {
|
||||
background-color: rgba(128,128,128,.5);
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: Consolas, Courier, monospace;
|
||||
}
|
||||
1
src/infrastructure
Submodule
1
src/infrastructure
Submodule
Submodule src/infrastructure added at 68ae75e38e
Reference in New Issue
Block a user