Skip to content

Commit

Permalink
feat: 版本升级
Browse files Browse the repository at this point in the history
  • Loading branch information
hocgin committed Dec 28, 2021
1 parent fd7a417 commit aa7bc8c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
5 changes: 5 additions & 0 deletions src/components/TextItem/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@
display: inline-block;
transition: all 2s;
text-align: center;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;

.value {
color: rgb(var(--textValueColor));
font-weight: 500;
font-size: 1.1em;
}

.title {
color: rgba(var(--smallTextColor), .8);
font-size: .45em;
Expand Down
4 changes: 2 additions & 2 deletions src/pages/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@ class index extends React.Component {
<Row gutter={16} className={styles.row}>
<Col span={6} className={styles.rowCol}><TextItem value={`${realtime.ultraviolet.desc}`} title={'紫外线'}/></Col>
<Col span={6} className={styles.rowCol}><TextItem value={`${realtime.comfort.desc}`} title={'舒适度'}/></Col>
<Col span={6} className={styles.rowCol}><TextItem value={`${aqi.text}`} sub={realtime.aqi} title={'AQI'}/></Col>
<Col span={6} className={styles.rowCol}><TextItem value={realtime.aqi} sub={`${aqi.text}`} title={'AQI'}/></Col>
<Col span={6} className={styles.rowCol}><TextItem value={`${Util.toPercent(realtime.humidity)}`} sub={`%`} title={'相对湿度'}/></Col>
</Row>
<Row gutter={16} className={styles.row}>
<Col span={6} className={styles.rowCol}><TextItem value={`${realtime.visibility}`} sub={`km`} title={'能见度'}/></Col>
<Col span={6} className={styles.rowCol}><TextItem value={`${realtime.cloudrate}`} title={'云量'}/></Col>
<Col span={6} className={styles.rowCol}><TextItem value={`${Util.toPercent(realtime.cloudrate)}`} sub={`%`} title={'云量'}/></Col>
<Col span={6} className={styles.rowCol}><TextItem value={`${realtime.wind.speed}`} sub={`m/h`}
title={<div>
<Icon type="arrow-up" style={{
Expand Down
12 changes: 8 additions & 4 deletions src/util/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,16 @@ export default class Util {

static toPercent(point) {
try {
let str = Number(point * 100).toFixed(2);
str += "%";
return str;

return Number(point * 100).toFixed(0);
} catch (e) {
return point;
}
}

static toText(str, maxLen) {
if (`${str}`.length <= maxLen) {
return str;
}
return str.substr(0, maxLen);
}
}

0 comments on commit aa7bc8c

Please sign in to comment.