Skip to content

Commit

Permalink
[optimize] upgrade Session Box component & other Upstream packages
Browse files Browse the repository at this point in the history
  • Loading branch information
TechQuery committed Jan 21, 2024
1 parent dac9c96 commit 5f8f43e
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 108 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"no-unused-vars": "warn",
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/no-unsafe-declaration-merging": "warn",
"@typescript-eslint/explicit-module-boundary-types": "off"
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/ban-ts-comment": "warn"
}
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
"url": "https://github.com/EasyWebApp/wuhan2020/issues"
},
"dependencies": {
"boot-cell": "^2.0.0-beta.7",
"boot-cell": "^2.0.0-beta.8",
"browser-unhandled-rejection": "^1.0.2",
"cell-router": "^3.0.0-rc.5",
"classnames": "^2.5.1",
"dom-renderer": "^2.0.6",
"echarts": "^5.4.3",
"github-web-widget": "^4.0.0-rc.1",
"js-base64": "^3.7.5",
"js-base64": "^3.7.6",
"koajax": "^0.9.6",
"marked": "^11.1.1",
"mobx": "^6.12.0",
Expand All @@ -38,7 +38,7 @@
"@types/node": "^18.19.8",
"@typescript-eslint/eslint-plugin": "^6.19.0",
"@typescript-eslint/parser": "^6.19.0",
"buffer": "^5.5.0||^6.0.0",
"buffer": "^6.0.3",
"cross-env": "^7.0.3",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
Expand Down
27 changes: 17 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 0 additions & 28 deletions source/component/BGIcon.tsx

This file was deleted.

34 changes: 0 additions & 34 deletions source/component/InputGroup.tsx

This file was deleted.

58 changes: 36 additions & 22 deletions source/component/SessionBox.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
import { component, mixin, watch, createCell } from 'web-cell';
import { observer } from 'mobx-web-cell';
import { InputGroup } from 'boot-cell/source/Form/InputGroup';
import { Field } from 'boot-cell/source/Form/Field';
import { Button } from 'boot-cell/source/Form/Button';
import { WebCell, attribute, component, observer } from 'web-cell';
import { observable } from 'mobx';
import { InputGroup, FormControl, Button } from 'boot-cell';

import { User } from '../service';
import { session } from '../model';

@observer
export interface SessionBox extends WebCell {}

@component({
tagName: 'session-box',
renderTarget: 'children'
mode: 'open'
})
export class SessionBox extends mixin() {
@watch
countDown = 0;
@observer
export class SessionBox extends HTMLElement implements WebCell {
@attribute
@observable
accessor countDown = 0;

emitSignIn = (user: User) => this.emit('signin', user, {});

connectedCallback() {
super.connectedCallback();

if (session.user) this.emitSignIn(session.user);
else session.getProfile().then(this.emitSignIn);
}
Expand Down Expand Up @@ -56,50 +55,65 @@ export class SessionBox extends mixin() {
else this.classList.add(...Classes);
}

render() {
renderForm() {
const { countDown } = this;

return session.user ? (
this.defaultSlot
) : (
return (
<form
// @ts-ignore
className="mx-auto my-3 p-3 border rounded"
style={{ maxWidth: '20rem' }}
onSubmit={this.handleSignIn}
>
<h2 className="text-center mb-3">登录</h2>

<InputGroup size="lg" className="mb-3">
<Field
<FormControl
type="tel"
name="phone"
maxLength="11"
maxLength={11}
required
placeholder="手机号"
/>
</InputGroup>

<InputGroup size="lg" className="mb-3">
<Field
<FormControl
name="code"
required
placeholder="短信验证码"
autocomplete="off"
/>
<Button
outline
color="secondary"
variant="outline-secondary"
onClick={this.handleSMSCode}
disabled={!!countDown}
>
{countDown ? countDown + 's' : '获取'}
</Button>
</InputGroup>

<Button type="submit" block color="primary" size="lg">
<Button
type="submit"
className="d-block w-100"
variant="primary"
size="lg"
>
登录
</Button>
</form>
);
}

render() {
return (
<>
<link
rel="stylesheet"
href="https://unpkg.com/[email protected]/dist/css/bootstrap.min.css"
/>
{session.user ? <slot /> : this.renderForm()}
</>
);
}
}
5 changes: 2 additions & 3 deletions source/page/Clinic/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { component, observer } from 'web-cell';
import { Badge, Card, CardTitle } from 'boot-cell';
import { Badge, BGIcon, Card, CardTitle } from 'boot-cell';

import { CardsPage } from '../../component/CardsPage';
import { AuditBar } from '../../component/AuditBar';
import { BGIcon } from '../../component/BGIcon';
import { Clinic, clinic } from '../../model';
import { clinic, Clinic } from '../../model';
import { getIsLive } from './time';

@component({ tagName: 'clinic-list' })
Expand Down
2 changes: 1 addition & 1 deletion source/page/Factory/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class FactoryPage extends CardsPage<Factory> {
<h6>物资产能</h6>
<ol>
{supplies.map(({ name, count, remark }) => (
<li key={remark} title={remark}>
<li key={name} title={remark}>
{name} <Badge bg="danger">{count}</Badge>
</li>
))}
Expand Down
8 changes: 4 additions & 4 deletions source/page/Hospital/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import {
CardFooter,
Button,
DropdownButton,
DropdownItem
DropdownItem,
Badge
} from 'boot-cell';

import { suppliesRequirement, SuppliesRequirement } from '../../model';
Expand Down Expand Up @@ -36,9 +37,8 @@ export class HospitalPage extends CardsPage<SuppliesRequirement> {
>
<ol>
{supplies.map(({ name, count, remark }) => (
<li title={remark}>
{name}{' '}
<span className="badge badge-danger">{count}</span>
<li key={name} title={remark}>
{name} <Badge bg="danger">{count}</Badge>
</li>
))}
</ol>
Expand Down
10 changes: 8 additions & 2 deletions source/page/Logistics/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { component, observer } from 'web-cell';
import { Badge, Card, CardBody, CardFooter, CardTitle } from 'boot-cell';
import { BGIcon } from '../../component/BGIcon';
import {
Badge,
Card,
CardBody,
CardFooter,
CardTitle,
BGIcon
} from 'boot-cell';

import { AuditBar } from '../../component/AuditBar';
import { CardsPage } from '../../component/CardsPage';
Expand Down

1 comment on commit 5f8f43e

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for wuhan2020 ready!

✅ Preview
https://wuhan2020-663t1wie2-techquery.vercel.app

Built with commit 5f8f43e.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.