!30 优化新建相册体验

Merge pull request !30 from sunjunxiong/master
This commit is contained in:
openharmony_ci 2021-12-03 09:29:27 +00:00 committed by Gitee
commit 8674e5f973
11 changed files with 31 additions and 30 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 258 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 127 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 131 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 127 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 140 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 135 KiB

View File

@ -19,35 +19,14 @@
import prompt from '@system.prompt';
// 新建相册命名随机数
const GET_RANDOM_NAME = 5;
// input输入框长度
const NAME_LENGTH = 51;
export default {
data: {
inputName: ''
},
/**
* 新建相册名
*/
onReady() {
let str = 'abcdefghijklmnopqrstuvwxyz';
for (let i = 0; i < GET_RANDOM_NAME; i++) {
this.inputName += str[this.getRandomInt(0, GET_RANDOM_NAME)];
}
},
/**
* 随机获取新建相册名
*
* @param {number} min - 随机最小数
* @param {number} max - 随机最大数
* @return {number} - 随机数
*/
getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
},
/**
* 弹框显示
*/
@ -68,7 +47,11 @@ export default {
* @param {string} value - 相册名
*/
valueChange(value) {
this.inputName = value.value;
if (value.value.length < NAME_LENGTH) {
this.inputName = value.value;
} else {
this.inputName = value.value.substring(0, NAME_LENGTH);
}
},
/**
@ -102,6 +85,9 @@ export default {
return false;
}
this.$emit('createDialogAlbum', this.inputName);
setTimeout(() => {
this.inputName = '';
}, NAME_LENGTH);
},
/**
@ -109,5 +95,8 @@ export default {
*/
cancel() {
this.close();
setTimeout(() => {
this.inputName = '';
}, NAME_LENGTH);
}
};

View File

@ -18,7 +18,8 @@
<dialog id="renameDialog" class="rename-dialog-main" oncancel="cancelDialog">
<div class="dialog-div">
<text class="title">{{ $t('strings.rename') }}</text>
<input class="input" type="text" value="{{ inputName }}" placeholder="{{ $t('strings.inputPlaceholder') }}">
<input class="input" type="text" value="{{ inputName }}" maxlength="50"
placeholder="{{ $t('strings.inputPlaceholder') }}" @change="valueChange">
</input>
<div class="bottom-div">
<text onclick="cancel" class="btn-txt">{{ $t('strings.cancel') }}</text>

View File

@ -54,6 +54,15 @@ export default {
return this.inputName;
},
/**
* 输入框改变事件
*
* @param {Object} e - 事件对象
*/
valueChange(e) {
this.inputName = e.value;
},
/**
* 重命名确定
*/

View File

@ -67,7 +67,7 @@
</stack>
</div>
</swiper>
<div class="scale-div" show="{{ showScale }}">
<div class="scale-div" if="{{ showScale }}">
<div class="scale-top" on:click="leftScale">
<image class="scale-image" if="{{ ! isScaleAddDisable }}" src="/common/image/svg/scaleadd.svg"></image>
<image class="scale-image" else style="opacity : 0.5;" src="/common/image/svg/scaleadd.svg"></image>

View File

@ -588,13 +588,15 @@ export default {
if (item.detail.id === MOVE_ID) {
let arrData = self.currentItem.name.split('.');
let firstName = arrData[0];
let lastName = arrData[1];
self.lastName = arrData[1];
if (self.currentItem.mediaType === PHOTO_TYPE) {
self.inputName = firstName + Math.round(Math.random() * RANDOM_NAME) + '.' + lastName;
self.inputName = firstName;
} else if (self.currentItem.mediaType === VIDEO_TYPE) {
self.inputName = lastName + Math.round(Math.random() * RANDOM_NAME) + '.' + lastName;
self.inputName = firstName;
}
self.$element('rename_dialog').show();
setTimeout(() => {
self.$element('rename_dialog').show();
}, POP_TIME);
} else if (item.detail.id === COPY_ID) {
self.currentItem.scale = 1;
self.isScaleAddDisable = false;