Skip to content

Commit

Permalink
style: 格式化代码,删除flow变量
Browse files Browse the repository at this point in the history
  • Loading branch information
duan602728596 committed Apr 14, 2019
1 parent 81b3869 commit c411baa
Show file tree
Hide file tree
Showing 34 changed files with 349 additions and 417 deletions.
22 changes: 4 additions & 18 deletions app/.sweetrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,22 @@ module.exports = {
externals: {
jquery: 'window.jQuery'
},
loaders: {
svg: {
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
use: [
{ loader: 'babel-loader' },
{
loader: '@svgr/webpack',
options: { babel: false, icon: true }
}
]
}
},
rules: [
{
test: /(dll\.js|appInit\.js|jquery)/,
test: /(appInit\.js|jquery)/,
use: [{
loader: 'file-loader',
options: {
name: isDevelopment ? '[name].[ext]' : '[hash:5].[ext]',
name: isDevelopment ? '[name].[hash:5].[ext]' : '[hash:5].[ext]',
outputPath: 'script/'
}
}]
}
],
js: {
ecmascript: true,
presets: ['@babel/preset-flow'],
plugins: [['import', { libraryName: 'antd', libraryDirectory: 'es', style: true }]],
exclude: /(dll\.js|appInit\.js|jquery|node_modules)/
exclude: /(appInit\.js|jquery|node_modules)/
},
sass: { include: /src/ },
css: {
Expand All @@ -66,8 +53,7 @@ module.exports = {
'@layout-body-background': '#fff',
'@layout-header-background': '@primary-color'
},
include: /node_modules[\\/]antd/,
publicPath: '../'
include: /node_modules[\\/]antd/
},
html: [{ template: path.join(__dirname, 'src/index.pug') }]
};
1 change: 0 additions & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"request": "^2.88.0"
},
"devDependencies": {
"@babel/preset-flow": "^7.0.0",
"@sweet/milktea": "github:duan602728596/sweet#build-milktea",
"@sweet/milktea-cli": "github:duan602728596/sweet#build-milktea-cli",
"@sweet/util-tools": "github:duan602728596/sweet#build-util-tools",
Expand Down
2 changes: 1 addition & 1 deletion app/src/components/kd48listerer/timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import $ from 'jquery';
import post from './post';
import { time } from '../../utils';
import store from '../../store/store';
import Kd48listenerWorker from 'worker-loader?name=script/[hash:5].worker.js!./kd48listener.worker';
import Kd48listenerWorker from 'worker-loader?name=[hash:5].worker.js!./kd48listener.worker';

let oldList = {}; // 旧列表

Expand Down
2 changes: 1 addition & 1 deletion app/src/components/modian/modianCb.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* 微打赏监听回调函数 */
import getModianInformation from './getModianInformation';
import { templateReplace } from '../../utils';
import ModianListWorker from 'worker-loader?name=script/[hash:5].worker.js!./modianList.worker';
import ModianListWorker from 'worker-loader?name=[hash:5].worker.js!./modianList.worker';

/* 发送信息 */
async function sendModianInfor(qq) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/modules/Help/Index/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Link } from 'react-router-dom';
import { Button } from 'antd';
import style from './style.sass';

const Index: Function = (props: Object): Array<React.Node> => {
const Index = (props) => {
return [
/* 返回 */
<Link key="0" className={ style.back } to="/">
Expand Down
2 changes: 1 addition & 1 deletion app/src/modules/Help/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Route, Switch } from 'react-router-dom';
import Index from './Index/index';

class ModuleLayout extends Component {
render(): React.Node {
render() {
return (
<Switch>
<Route path="/Help" component={ Index } exact={ true } />
Expand Down
2 changes: 1 addition & 1 deletion app/src/modules/Index/Index/Navs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Link } from 'react-router-dom';
import { Row, Col } from 'antd';
import style from './style.sass';

function Navs(props: Object): React.Node {
function Navs(props) {
return (
<Row type="flex" align="top" justify="start">
<Col xl={ 4 } lg={ 4 } md={ 6 } sm={ 8 } xs={ 12 }>
Expand Down
8 changes: 4 additions & 4 deletions app/src/modules/Index/Index/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import '../../../components/indexedDB/indexedDB-init';
import { handleOpenBrowser } from '../../../utils';
import Navs from './Navs';

function Index(props: Object): React.Node {
const upgradeReminder: string = localStorage.getItem('upgradeReminder');
const [isUpgradeReminder, setUpgradeReminder]: [boolean, Function] = useState(
function Index(props) {
const upgradeReminder = localStorage.getItem('upgradeReminder');
const [isUpgradeReminder, setUpgradeReminder] = useState(
upgradeReminder === 'true' || !upgradeReminder
);

// 状态变化
function handleUpgradeReminderChange(event: Event): void {
function handleUpgradeReminderChange(event) {
localStorage.setItem('upgradeReminder', String(!isUpgradeReminder));

setUpgradeReminder(!isUpgradeReminder);
Expand Down
2 changes: 1 addition & 1 deletion app/src/modules/Index/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Route, Switch } from 'react-router-dom';
import Index from './Index/index';

class ModuleLayout extends Component {
render(): React.Node {
render() {
return (
<Switch>
<Route path="/" component={ Index } exact={ true } />
Expand Down
4 changes: 2 additions & 2 deletions app/src/modules/KouDai48/Index/LoginInformation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React from 'react';
import { Card } from 'antd';
import style from './style.sass';

function LoginInformation(props: Object): Array<React.Node> | React.Node {
const item: ?Object = props.loginInformation;
function LoginInformation(props) {
const item = props.loginInformation;

return (
<Card title="登录信息">
Expand Down
29 changes: 14 additions & 15 deletions app/src/modules/KouDai48/Index/MemberInformation.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { getMemberInformation, addMemberInformation } from '../store/reducer';
import { requestMemberInformation } from '../../../components/kd48listerer/roomListener';

/* 初始化数据 */
const state: Function = createStructuredSelector({});
const state = createStructuredSelector({});

/* dispatch */
const dispatch: Function = (dispatch: Function): Object => ({
const dispatch = (dispatch) => ({
action: bindActionCreators({
getMemberInformation,
addMemberInformation
Expand All @@ -19,18 +19,19 @@ const dispatch: Function = (dispatch: Function): Object => ({

@connect(state, dispatch)
class MemberInformation extends Component {
constructor(): void {
constructor() {
super(...arguments);

this.state = {
memberName: null, // 成员姓名
roomId: null // 房间姓名
};
}
async componentDidMount(): Promise<void> {

async componentDidMount() {
try {
const memberId: number = this.props.item.memberId;
const infor: Object = await this.props.action.getMemberInformation({
const memberId = this.props.item.memberId;
const infor = await this.props.action.getMemberInformation({
query: memberId
});

Expand All @@ -42,8 +43,8 @@ class MemberInformation extends Component {
});
} else {
// 从接口获取数据
const data: Object = await requestMemberInformation(memberId);
let roomInfo: Object = data.content.roomInfo;
const data = await requestMemberInformation(memberId);
let roomInfo = data.content.roomInfo;

// 兼容
if (!(roomInfo && ('memberName' in roomInfo) && ('roomId' in roomInfo))) {
Expand All @@ -52,12 +53,9 @@ class MemberInformation extends Component {
roomInfo.roomId = '';
}

const { memberName, roomId }: {
memberName: string;
roomId: string;
} = roomInfo;
const memberName2: string = memberName.replace(/\s/g, '');
const value2: Object = {
const { memberName, roomId } = roomInfo;
const memberName2 = memberName.replace(/\s/g, '');
const value2 = {
memberId,
memberName: memberName2,
roomId
Expand All @@ -75,7 +73,8 @@ class MemberInformation extends Component {
console.error(err);
}
}
render(): ?(Array | Object) {

render() {
if (this.state.memberName !== null && this.state.roomId !== null) {
if (this.state.memberName !== '' && this.state.roomId !== '') {
return [
Expand Down
Loading

0 comments on commit c411baa

Please sign in to comment.