mirror of
https://gitee.com/openharmony/applications_dlp_manager
synced 2024-11-24 02:19:49 +00:00
复制粘贴功能问题单
Signed-off-by: li-li-wang <wangliliang5@huawei.com>
This commit is contained in:
parent
54398b7969
commit
42dcc997fb
41
entry/src/main/ets/common/FileUtils.ets
Normal file
41
entry/src/main/ets/common/FileUtils.ets
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export interface FileMsg {
|
||||
fileName: string;
|
||||
filePath: string;
|
||||
fileType: string;
|
||||
}
|
||||
|
||||
export default class FileUtils {
|
||||
|
||||
static getSuffixFileMsgByUri(uri: string): FileMsg {
|
||||
let strArray: string[] = uri.split('/');
|
||||
let len: number = strArray.length;
|
||||
let fileName: string = strArray[len - 1];
|
||||
let filePath: string = strArray.slice(0, len - 1).join('/');
|
||||
let pointIndex: number = fileName.lastIndexOf('.');
|
||||
if (pointIndex < 0) {
|
||||
pointIndex = fileName.length;
|
||||
}
|
||||
let fileType: string = fileName.slice(pointIndex, fileName.length);
|
||||
let result: FileMsg = {
|
||||
fileName: fileName.slice(0, pointIndex),
|
||||
filePath: filePath,
|
||||
fileType: fileType,
|
||||
};
|
||||
return result;
|
||||
}
|
||||
}
|
@ -43,7 +43,7 @@ function inputMessageText() {
|
||||
struct AddStaff {
|
||||
@State succ: number = 0;
|
||||
@State fail: number = 0;
|
||||
@State isAccountCheckSuccess: boolean = true;
|
||||
@Link isAccountCheckSuccess: boolean;
|
||||
@State staffArrayLength: boolean = false;
|
||||
@State @Watch('onErrorStyleChange') isInputInvalid: boolean = false;
|
||||
@State isNetworkInvalid: boolean = false;
|
||||
@ -85,9 +85,7 @@ struct AddStaff {
|
||||
this.controller.deleteSpans({ start: startOffset, end: endOffset });
|
||||
return;
|
||||
}
|
||||
if (!this.isAccountCheckSuccess) {
|
||||
return;
|
||||
}
|
||||
this.isAccountCheckSuccess = false;
|
||||
let regex: RegExp = new RegExp('(\r|\n)*', 'g');
|
||||
let inputString = inputId.replace(regex, '');
|
||||
this.inputArray = inputString.split(';');
|
||||
@ -104,7 +102,6 @@ struct AddStaff {
|
||||
if (GlobalContext.load('domainAccount')) {
|
||||
await this.createStaffByDomain(i);
|
||||
} else {
|
||||
this.isAccountCheckSuccess = true;
|
||||
let o2: Staff = {
|
||||
authAccount: this.inputArray[i],
|
||||
textContent: this.inputArray[i]
|
||||
@ -115,6 +112,7 @@ struct AddStaff {
|
||||
this.addBuildSpan(i, inputId);
|
||||
}
|
||||
}
|
||||
this.isAccountCheckSuccess = true;
|
||||
if (this.staffArray.length < Constants.ENCRYPTION_ADD_STAFF_LENGTH_MAX) {
|
||||
this.controller.addTextSpan(this.errInput.join(';'));
|
||||
if (this.errInput.length && this.isInputInvalidFlag) {
|
||||
@ -125,7 +123,6 @@ struct AddStaff {
|
||||
|
||||
private createStaffByDomain(i: number) {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
this.isAccountCheckSuccess = false;
|
||||
let accountDomain: string = GlobalContext.load('accountDomain');
|
||||
let domainAccountInfo: osAccount.DomainAccountInfo = {
|
||||
domain: accountDomain,
|
||||
@ -133,7 +130,6 @@ struct AddStaff {
|
||||
};
|
||||
account_osAccount.DomainAccountManager.hasAccount(domainAccountInfo,
|
||||
async (error: BusinessError, isExist: boolean) => {
|
||||
this.isAccountCheckSuccess = true;
|
||||
if (isExist) {
|
||||
await this.createStaffItem(i);
|
||||
} else {
|
||||
@ -175,7 +171,6 @@ struct AddStaff {
|
||||
|
||||
private showErrInput(i: number, error: BusinessError) {
|
||||
this.errInput.push(this.inputArray[i]);
|
||||
this.isAccountCheckSuccess = true;
|
||||
this.fail = GlobalContext.load('hiAccountVerifyFail') + 1;
|
||||
GlobalContext.store('hiAccountVerifyFail', this.fail);
|
||||
if ([
|
||||
@ -265,7 +260,9 @@ struct AddStaff {
|
||||
endOffset.push(buildSpan.spanPosition.spanRange[1]);
|
||||
}
|
||||
}
|
||||
this.onSubmitMock(inputId, startOffset[0], endOffset.slice(-1)[0]);
|
||||
if (this.isAccountCheckSuccess) {
|
||||
this.onSubmitMock(inputId, startOffset[0], endOffset.slice(-1)[0]);
|
||||
};
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -304,7 +301,7 @@ struct AddStaff {
|
||||
.opacity(this.focusFlag ? Constants.FOOTER_OPACITY_SEPC : Constants.FOOTER_OPACITY_ONE);
|
||||
|
||||
Flex({ direction: FlexDirection.Row }) {
|
||||
if (this.isInputInvalid) {
|
||||
if (this.isInputInvalid && !this.isNetworkInvalid) {
|
||||
Text((GlobalContext
|
||||
.load('domainAccount') as boolean) ? $r('app.string.incorrect_work_ID') : $r('app.string.incorrect_account'))
|
||||
.inputMessageText()
|
||||
|
@ -52,12 +52,6 @@ interface DLPInfo {
|
||||
versionCode: string;
|
||||
}
|
||||
|
||||
export interface FileMsg {
|
||||
fileName: string;
|
||||
filePath: string;
|
||||
fileType: string;
|
||||
}
|
||||
|
||||
function getFileUriByPath(filePath: string): string {
|
||||
try {
|
||||
let uri = fileUri.getUriFromPath(filePath);
|
||||
@ -304,27 +298,6 @@ function getTime() {
|
||||
return `${year}/${month}/${day} ${hour}:${minute}`;
|
||||
}
|
||||
|
||||
function getFileMsgByUri(uri: string): FileMsg {
|
||||
let strArray: string[] = uri.split('/');
|
||||
let len: number = strArray.length;
|
||||
if (len < 1) {
|
||||
throw new Error('getFileMsgByUri,srcfile name len is 0');
|
||||
}
|
||||
let fileName: string = strArray[len - 1];
|
||||
let filePath: string = strArray.slice(0, len - 1).join();
|
||||
let pointIndex: number = fileName.indexOf('.');
|
||||
if (pointIndex < 0) {
|
||||
throw new Error('getFileMsgByUri,srcfile name invalid');
|
||||
}
|
||||
let fileType: string = fileName.slice(pointIndex, fileName.length);
|
||||
let result: FileMsg = {
|
||||
fileName: fileName.split('.')[0],
|
||||
filePath: filePath,
|
||||
fileType: fileType
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
async function getFileSizeByUri(uri: string): Promise<number> {
|
||||
let inFile: fs.File;
|
||||
|
||||
@ -494,7 +467,6 @@ export {
|
||||
goToAlertMessagePage,
|
||||
getAppId,
|
||||
getTime,
|
||||
getFileMsgByUri,
|
||||
getFileSizeByUri,
|
||||
getDLPInfo,
|
||||
sendDlpManagerAccountLogin,
|
||||
|
@ -33,8 +33,6 @@ import {
|
||||
toggleShow,
|
||||
directionStatus,
|
||||
getTime,
|
||||
getFileMsgByUri,
|
||||
FileMsg,
|
||||
isPC,
|
||||
sendDlpManagerFileConfiguration,
|
||||
colorStatus
|
||||
@ -47,6 +45,7 @@ import { AccountTipsConfig } from '../common/AccountTipsConfig';
|
||||
import { EncryptingPanel } from '../common/encryptionComponents/encrypting';
|
||||
import { GetAlertMessage } from '../common/GetAlertMessage';
|
||||
import { HiLog } from '../common/HiLog';
|
||||
import FileUtils, { FileMsg } from '../common/FileUtils';
|
||||
|
||||
const TAG = 'ModEnc';
|
||||
|
||||
@ -217,7 +216,7 @@ struct changeEncryption {
|
||||
HiLog.info(TAG, `Decrypt DLP file: ${this.srcFileName}`);
|
||||
try {
|
||||
let srcFileUri: string = GlobalContext.load('uri');
|
||||
let srcFileMsg: FileMsg = getFileMsgByUri(srcFileUri);
|
||||
let srcFileMsg: FileMsg = FileUtils.getSuffixFileMsgByUri(srcFileUri);
|
||||
let documentSaveOptions = new picker.DocumentSaveOptions();
|
||||
documentSaveOptions.newFileNames = [plaintextFile];
|
||||
let fileSuffixChoicesName = this.srcFileName.split('.')[1];
|
||||
|
@ -19,7 +19,6 @@ import dlpPermission from '@ohos.dlpPermission';
|
||||
import hiSysEvent from '@ohos.hiSysEvent';
|
||||
import router from '@ohos.router';
|
||||
import picker from '@ohos.file.picker';
|
||||
import fileio from '@ohos.fileio';
|
||||
import fileUri from '@ohos.file.fileuri';
|
||||
import fs from '@ohos.file.fs';
|
||||
import osAccount from '@ohos.account.osAccount';
|
||||
@ -36,8 +35,6 @@ import {
|
||||
directionStatus,
|
||||
AuthAccount,
|
||||
getFileUriByPath,
|
||||
getFileMsgByUri,
|
||||
FileMsg,
|
||||
isPC,
|
||||
sendDlpFileCreateEvent,
|
||||
sendDlpManagerFileConfiguration,
|
||||
@ -55,6 +52,7 @@ import HomeFeature from '../feature/HomeFeature';
|
||||
import emitter from '@ohos.events.emitter';
|
||||
import { GetAlertMessage } from '../common/GetAlertMessage';
|
||||
import { HiLog } from '../common/HiLog';
|
||||
import FileUtils, { FileMsg } from '../common/FileUtils';
|
||||
|
||||
const TAG = 'Encrypt';
|
||||
let abilityResult: ability.AbilityResult = {
|
||||
@ -135,7 +133,7 @@ struct DlpDialog {
|
||||
value: $r('app.string.PERMISSION_TYPE_SELECT_SELF'), data: 'self', index: 2
|
||||
} as PermissionType
|
||||
];
|
||||
|
||||
@State isAccountCheckSuccess: boolean = true;
|
||||
@State staffDataArrayReadOnly: AuthAccount[] = [];
|
||||
@State staffDataArrayEdit: AuthAccount[] = [];
|
||||
@State selectedPermissionTypeReadOnly: PermissionType =
|
||||
@ -406,7 +404,7 @@ struct DlpDialog {
|
||||
await this.setUserStat();
|
||||
try {
|
||||
let srcFileUri: string = GlobalContext.load('uri');
|
||||
let srcFileMsg: FileMsg = getFileMsgByUri(srcFileUri);
|
||||
let srcFileMsg: FileMsg = FileUtils.getSuffixFileMsgByUri(srcFileUri);
|
||||
let srcFileSize: number = await getFileSizeByUri(srcFileUri);
|
||||
GlobalContext.store('hiFileSize', srcFileSize);
|
||||
GlobalContext.store('hiFileType', srcFileMsg.fileType);
|
||||
@ -790,6 +788,7 @@ struct DlpDialog {
|
||||
Row() {
|
||||
if (!['all', 'self'].includes(this.selectedPermissionTypeReadOnly?.data ?? '')) {
|
||||
AddStaff({
|
||||
isAccountCheckSuccess: $isAccountCheckSuccess,
|
||||
staffArray: $staffDataArrayReadOnly,
|
||||
isDisable: this.selectedPermissionTypeEdit?.data === 'all',
|
||||
})
|
||||
@ -837,6 +836,7 @@ struct DlpDialog {
|
||||
Row() {
|
||||
if (!['all', 'self'].includes(this.selectedPermissionTypeEdit?.data ?? '')) {
|
||||
AddStaff({
|
||||
isAccountCheckSuccess: $isAccountCheckSuccess,
|
||||
staffArray: $staffDataArrayEdit,
|
||||
isDisable: false
|
||||
})
|
||||
@ -940,7 +940,13 @@ struct DlpDialog {
|
||||
.width(Constants.HEADER_TEXT_WIDTH)
|
||||
.focusable(false)
|
||||
.fontColor($r('sys.color.ohos_id_color_text_primary_activated'))
|
||||
.enabled((this.staffDataArrayReadOnly.length > 0 || this.staffDataArrayEdit.length > 0 || ['all', 'self'].includes(this.selectedPermissionTypeReadOnly.data ?? '') || ['all', 'self'].includes(this.selectedPermissionTypeEdit.data ?? '')))
|
||||
.enabled(
|
||||
this.isAccountCheckSuccess &&
|
||||
(this.staffDataArrayReadOnly.length > 0 ||
|
||||
this.staffDataArrayEdit.length > 0 ||
|
||||
['all', 'self'].includes(this.selectedPermissionTypeReadOnly.data ?? '') ||
|
||||
['all', 'self'].includes(this.selectedPermissionTypeEdit.data ?? ''))
|
||||
)
|
||||
.height(Constants.FOOTER_BUTTON_HEIGHT)
|
||||
.onClick(async (event) => {
|
||||
GlobalContext.store('hiValidDate', false);
|
||||
|
Loading…
Reference in New Issue
Block a user