Skip to content

Commit 75b85e9

Browse files
dongruisunnywx
authored andcommitted
fix: App info screenshots error (#741)
1 parent 6dfd12f commit 75b85e9

4 files changed

Lines changed: 36 additions & 25 deletions

File tree

src/pages/Dashboard/Apps/Info/index.jsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export default class Info extends Component {
4242
const appId = _.get(match, 'params.appId', '');
4343

4444
if (appId) {
45-
// await appStore.fetch(appId);
45+
await appStore.fetch(appId);
4646

4747
// query this version relatived app info
4848
await appVersionStore.fetchAll({ app_id: appId });
@@ -85,8 +85,9 @@ export default class Info extends Component {
8585
} = appStore;
8686

8787
// todo: api screenshots is string, not array
88-
const { screenshots } = appDetail;
89-
const len = _.isArray(screenshots) ? screenshots.length : 0;
88+
const screenshotStr = _.get(appDetail, 'screenshots', '');
89+
const screenshots = screenshotStr ? screenshotStr.split(',') : [];
90+
const len = screenshots.length;
9091

9192
return (
9293
<div className={styles.screenshot}>

src/pages/Dashboard/Apps/Info/index.scss

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,19 +163,19 @@
163163

164164
.screenshot {
165165
margin-left: 270px;
166-
width: calc(100% - 270px);
167-
height: 170px;
166+
width: 512px;
168167
padding: 20px 0 20px 20px;
169168
border-radius: 2px;
170169
background-color: $background-color;
171170
overflow: hidden;
172171

173172
.pictrues {
174-
margin-bottom: 20px;
175-
width: 1150px;
173+
// margin-bottom: 20px;
174+
// width: 1150px;
176175
li {
177176
display: inline-block;
178177
margin-right: 20px;
178+
margin-bottom: 20px;
179179
width: 144px;
180180
height: 90px;
181181
line-height: 90px;

src/scss/partial/_grid.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
$content-width: 1280px;
2-
$page-min-width: 1200px;
2+
$page-min-width: 1280px;
33
$menu-nav-width: 64px;
44
$menu-sub-nav-width: 192px;
55
$menu-width: $menu-nav-width + $menu-sub-nav-width;

src/stores/app/index.js

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { observable, action } from 'mobx';
22
import _, { get, assign } from 'lodash';
33

44
import { useTableActions } from 'mixins';
5-
import { getProgress, getCookie } from 'utils';
5+
import { getProgress, getCookie, sleep } from 'utils';
66
import { formCheck, fieldCheck } from 'config/form-check';
77

88
import Store from '../Store';
@@ -38,7 +38,7 @@ class AppStore extends Store {
3838
readme: '',
3939
tos: '',
4040
icon: '',
41-
screenshots: []
41+
screenshots: ''
4242
};
4343

4444
@observable summaryInfo = {};
@@ -93,8 +93,6 @@ class AppStore extends Store {
9393

9494
@observable iconShow = '';
9595

96-
@observable screenshotsShow = '';
97-
9896
// menu actions logic
9997
@observable
10098
handleApp = {
@@ -471,34 +469,46 @@ class AppStore extends Store {
471469

472470
@action
473471
uploadScreenshot = async base64Str => {
474-
const { screenshots } = this.appDetail;
475-
const len = _.isArray(screenshots) ? screenshots.length : 0;
476-
if (len >= 6) {
472+
const screenshotStr = _.get(this.appDetail, 'screenshots', '');
473+
const screenshots = screenshotStr ? screenshotStr.split(',') : [];
474+
sequence = screenshots.length - 1;
475+
sequence++;
476+
477+
if (sequence >= 6) {
477478
return this.error('MAX_UPLOAD_SCREENSHOTS');
478479
}
479480

481+
this.appDetail.screenshots = sequence === 0 ? base64Str : `${screenshotStr},${base64Str}`;
482+
480483
const result = await this.attachment({
481484
app_id: this.appDetail.app_id,
482485
type: 'screenshot',
483486
attachment_content: base64Str,
484487
sequence
485488
});
489+
await sleep(sequence * 200);
486490

487-
if (result && result.errDetail) {
491+
if (result && result.err) {
492+
sequence--;
488493
return false;
489494
}
490-
491-
sequence++;
492-
if (_.isArray(screenshots)) {
493-
this.appDetail.screenshots.push(base64Str);
494-
} else {
495-
this.appDetail.screenshots = [base64Str];
496-
}
497495
};
498496

499497
@action
500-
deleteScreenshot = () => {
501-
this.appDetail.screenshots = [];
498+
deleteScreenshot = async () => {
499+
const screenshotStr = _.get(this.appDetail, 'screenshots', '');
500+
const screenshots = screenshotStr ? screenshotStr.split(',') : [];
501+
502+
this.appDetail.screenshots = '';
503+
for (let i = 0; i < screenshots.length; i++) {
504+
await this.attachment({
505+
app_id: this.appDetail.app_id,
506+
type: 'screenshot',
507+
attachment_content: '',
508+
sequence: 0
509+
});
510+
await sleep(200);
511+
}
502512
};
503513

504514
@action

0 commit comments

Comments
 (0)