From 5f8f43eb8768375b29a40020478a8b75adcd1923 Mon Sep 17 00:00:00 2001 From: TechQuery Date: Sun, 21 Jan 2024 10:39:53 +0800 Subject: [PATCH] [optimize] upgrade Session Box component & other Upstream packages --- .eslintrc.json | 3 +- package.json | 6 ++-- pnpm-lock.yaml | 27 +++++++++------ source/component/BGIcon.tsx | 28 ---------------- source/component/InputGroup.tsx | 34 ------------------- source/component/SessionBox.tsx | 58 ++++++++++++++++++++------------- source/page/Clinic/index.tsx | 5 ++- source/page/Factory/index.tsx | 2 +- source/page/Hospital/index.tsx | 8 ++--- source/page/Logistics/index.tsx | 10 ++++-- 10 files changed, 73 insertions(+), 108 deletions(-) delete mode 100644 source/component/BGIcon.tsx delete mode 100644 source/component/InputGroup.tsx diff --git a/.eslintrc.json b/.eslintrc.json index 0040e16..7838937 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -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" } } diff --git a/package.json b/package.json index dd2cf86..6ca6511 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 94970ae..0a89946 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,8 +6,8 @@ settings: dependencies: boot-cell: - specifier: ^2.0.0-beta.7 - version: 2.0.0-beta.7(typescript@5.3.3) + specifier: ^2.0.0-beta.8 + version: 2.0.0-beta.8(typescript@5.3.3) browser-unhandled-rejection: specifier: ^1.0.2 version: 1.0.2 @@ -27,8 +27,8 @@ dependencies: specifier: ^4.0.0-rc.1 version: 4.0.0-rc.1(typescript@5.3.3) js-base64: - specifier: ^3.7.5 - version: 3.7.5 + specifier: ^3.7.6 + version: 3.7.6 koajax: specifier: ^0.9.6 version: 0.9.6(typescript@5.3.3) @@ -77,8 +77,8 @@ devDependencies: specifier: ^6.19.0 version: 6.19.0(eslint@8.56.0)(typescript@5.3.3) buffer: - specifier: ^5.5.0||^6.0.0 - version: 5.7.1 + specifier: ^6.0.3 + version: 6.0.3 cross-env: specifier: ^7.0.3 version: 7.0.3 @@ -3238,8 +3238,8 @@ packages: resolution: {integrity: sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==} dev: true - /boot-cell@2.0.0-beta.7(typescript@5.3.3): - resolution: {integrity: sha512-W7m0hso7hRh86g+R9nNUL4iiBQpQP5rkX0adoZIhQmIliq671kpobAAvc7D0XBy+04teXc+TMlLeGvzP7UZfdg==} + /boot-cell@2.0.0-beta.8(typescript@5.3.3): + resolution: {integrity: sha512-qSxE0+N3XGjzYIXrO3j1nPvuVmgfApONcRD9hTqQzjn36W/QBgW4eYdqnOcdUqu1vMs8E6FpS2SXEk3thbQS3Q==} peerDependencies: '@fortawesome/fontawesome-free': ^6 '@nuintun/qrcode': ^3 @@ -3324,6 +3324,13 @@ packages: ieee754: 1.2.1 dev: true + /buffer@6.0.3: + resolution: {integrity: sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==} + dependencies: + base64-js: 1.5.1 + ieee754: 1.2.1 + dev: true + /builtin-modules@3.3.0: resolution: {integrity: sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==} engines: {node: '>=6'} @@ -4912,8 +4919,8 @@ packages: supports-color: 7.2.0 dev: true - /js-base64@3.7.5: - resolution: {integrity: sha512-3MEt5DTINKqfScXKfJFrRbxkrnk2AxPWGBL/ycjz4dK8iqiSJ06UxD8jh8xuh6p10TX4t2+7FsBYVxxQbMg+qA==} + /js-base64@3.7.6: + resolution: {integrity: sha512-NPrWuHFxFUknr1KqJRDgUQPexQF0uIJWjeT+2KjEePhitQxQEx5EJBG1lVn5/hc8aLycTpXrDOgPQ6Zq+EDiTA==} dev: false /js-tokens@4.0.0: diff --git a/source/component/BGIcon.tsx b/source/component/BGIcon.tsx deleted file mode 100644 index 77024c0..0000000 --- a/source/component/BGIcon.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import { Icon, IconProps } from 'boot-cell'; -import classNames from 'classnames'; -import { FC } from 'web-cell'; - -export interface BGIconProps extends IconProps { - type?: 'square' | 'circle'; -} - -export const BGIcon: FC = ({ - className = '', - type = 'square', - color = 'primary', - children, - ...props -}) => ( - - - -); diff --git a/source/component/InputGroup.tsx b/source/component/InputGroup.tsx deleted file mode 100644 index 0d1eab2..0000000 --- a/source/component/InputGroup.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import classNames from 'classnames'; -import { FC, WebCellProps } from 'web-cell'; - -export interface InputGroupProps extends WebCellProps { - size?: 'sm' | 'lg'; -} - -export const InputGroup: FC = ({ - className = '', - size, - children, - ...props -}) => ( -
- {children} -
-); - -export const InputGroupText: FC> = ({ - className = '', - children, - ...props -}) => ( - - {children} - -); diff --git a/source/component/SessionBox.tsx b/source/component/SessionBox.tsx index 66e1e91..2ea43eb 100644 --- a/source/component/SessionBox.tsx +++ b/source/component/SessionBox.tsx @@ -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); } @@ -56,13 +55,12 @@ export class SessionBox extends mixin() { else this.classList.add(...Classes); } - render() { + renderForm() { const { countDown } = this; - return session.user ? ( - this.defaultSlot - ) : ( + return (
登录 - - -
); } + + render() { + return ( + <> + + {session.user ? : this.renderForm()} + + ); + } } diff --git a/source/page/Clinic/index.tsx b/source/page/Clinic/index.tsx index b5914fb..afbdd5a 100644 --- a/source/page/Clinic/index.tsx +++ b/source/page/Clinic/index.tsx @@ -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' }) diff --git a/source/page/Factory/index.tsx b/source/page/Factory/index.tsx index b58d546..66ef978 100644 --- a/source/page/Factory/index.tsx +++ b/source/page/Factory/index.tsx @@ -57,7 +57,7 @@ export class FactoryPage extends CardsPage {
物资产能
    {supplies.map(({ name, count, remark }) => ( -
  1. +
  2. {name} {count}个
  3. ))} diff --git a/source/page/Hospital/index.tsx b/source/page/Hospital/index.tsx index 021ab67..ea4d248 100644 --- a/source/page/Hospital/index.tsx +++ b/source/page/Hospital/index.tsx @@ -4,7 +4,8 @@ import { CardFooter, Button, DropdownButton, - DropdownItem + DropdownItem, + Badge } from 'boot-cell'; import { suppliesRequirement, SuppliesRequirement } from '../../model'; @@ -36,9 +37,8 @@ export class HospitalPage extends CardsPage { >
      {supplies.map(({ name, count, remark }) => ( -
    1. - {name}{' '} - {count}个 +
    2. + {name} {count}个
    3. ))}
    diff --git a/source/page/Logistics/index.tsx b/source/page/Logistics/index.tsx index fe06652..f81d41e 100644 --- a/source/page/Logistics/index.tsx +++ b/source/page/Logistics/index.tsx @@ -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';