refactor: 重命名文件扩展名为.ets,优化类型定义和导入逻辑
This commit is contained in:
parent
1c5d5c78c3
commit
da34d5dbb5
@ -1,10 +0,0 @@
|
|||||||
/*
|
|
||||||
* @Author: wangzhongjie
|
|
||||||
* @Date: 2024-03-07 10:54:19
|
|
||||||
* @LastEditors: wangzhongjie
|
|
||||||
* @LastEditTime: 2024-03-07 11:15:11
|
|
||||||
* @Description:
|
|
||||||
* @Email: shutdown0630@163.com
|
|
||||||
*/
|
|
||||||
export * from "./global"
|
|
||||||
export * from "./judge"
|
|
||||||
@ -7,6 +7,4 @@
|
|||||||
* @Email: shutdown0630@163.com
|
* @Email: shutdown0630@163.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export const JudgeConfig={
|
|
||||||
|
|
||||||
}
|
|
||||||
4
entry/src/main/ets/model/Other.ets
Normal file
4
entry/src/main/ets/model/Other.ets
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
export interface TakePhotoCallbackData {
|
||||||
|
fileSize: number;
|
||||||
|
errorCode: number
|
||||||
|
}
|
||||||
@ -17,3 +17,5 @@ export * from "./CarCheck"
|
|||||||
export * from "./api"
|
export * from "./api"
|
||||||
|
|
||||||
export * from "./TableColumn"
|
export * from "./TableColumn"
|
||||||
|
|
||||||
|
export * from "./Other"
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import router from '@ohos.router'
|
import router from '@ohos.router'
|
||||||
import { CarCheckDataType } from '../model/CarCheck'
|
import { CarCheckDataType } from '../model/CarCheck'
|
||||||
import { BaseInfoType } from '../model/Common'
|
import { BaseInfoType, CarInfoType } from '../model/Common'
|
||||||
import TopLogo from './compontents/TopLogo'
|
import TopLogo from './compontents/TopLogo'
|
||||||
|
|
||||||
@Entry
|
@Entry
|
||||||
@ -9,7 +9,7 @@ struct Index {
|
|||||||
@State ratio: number = 1280 / 960
|
@State ratio: number = 1280 / 960
|
||||||
@State url: string = ''
|
@State url: string = ''
|
||||||
@State baseInfo: BaseInfoType = {}
|
@State baseInfo: BaseInfoType = {}
|
||||||
@State carInfo: CarCheckDataType = {}
|
@State carInfo: CarInfoType = {}
|
||||||
@State @Watch('outClick') outFlag: boolean = false;
|
@State @Watch('outClick') outFlag: boolean = false;
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
@ -88,8 +88,8 @@ struct Index {
|
|||||||
aboutToAppear() {
|
aboutToAppear() {
|
||||||
// this.vocObj = new voiceService(async (status, val, next) => {
|
// this.vocObj = new voiceService(async (status, val, next) => {
|
||||||
// });
|
// });
|
||||||
this.carInfo = AppStorage.get('carInfo')
|
this.carInfo = AppStorage.get<CarInfoType>('carInfo')
|
||||||
this.baseInfo = AppStorage.get('baseinfo') as BaseInfoType
|
this.baseInfo = AppStorage.get<BaseInfoType>('baseInfo')
|
||||||
}
|
}
|
||||||
|
|
||||||
outClick() {
|
outClick() {
|
||||||
|
|||||||
@ -1404,15 +1404,3 @@ struct LabelBlock {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface systemParam {
|
|
||||||
'Param341': boolean, //是否按顺序考试
|
|
||||||
'Param803Str': string, //开始考试前必须解开安全带或关车门
|
|
||||||
'Param612Str': string, //开始考试触发方式
|
|
||||||
'Param305Str': string, //视频保存天数
|
|
||||||
'Param352Str': string, //车上考试过一次就不能缺考
|
|
||||||
'Param828Str': string, //828考生待考界面,安全员显示考试员
|
|
||||||
'Param770Str': string, //车上没有缺考功能
|
|
||||||
'Param830Str': string, //同一学员连续第二次考试时不再验证身份
|
|
||||||
'Param364': string, //考前上车准备
|
|
||||||
'Param398': string, //考前上车准备
|
|
||||||
}
|
|
||||||
@ -53,6 +53,7 @@ import {
|
|||||||
} from './api/index';
|
} from './api/index';
|
||||||
import { writeObjectOut } from '../../api/judge';
|
import { writeObjectOut } from '../../api/judge';
|
||||||
import { saveStartRecordVideo } from '../../utils/Video';
|
import { saveStartRecordVideo } from '../../utils/Video';
|
||||||
|
import common from '@ohos.app.ability.common';
|
||||||
|
|
||||||
const judgeTag = 'SURENJUN_JUDGE'
|
const judgeTag = 'SURENJUN_JUDGE'
|
||||||
|
|
||||||
|
|||||||
@ -1,16 +1,15 @@
|
|||||||
import mediaLibrary from '@ohos.multimedia.mediaLibrary'
|
|
||||||
import photoAccessHelper from '@ohos.file.photoAccessHelper'
|
import photoAccessHelper from '@ohos.file.photoAccessHelper'
|
||||||
import dataSharePredicates from '@ohos.data.dataSharePredicates'
|
import dataSharePredicates from '@ohos.data.dataSharePredicates'
|
||||||
import { dateFormat, getCurrentTime, isSevenDaysAgo } from '../utils/tools'
|
|
||||||
// import rtsp_server from '@ohos.rtsprecord';
|
|
||||||
import record from '@ohos.rtsprecord';
|
import record from '@ohos.rtsprecord';
|
||||||
import { FileHelper } from './FileHelper';
|
|
||||||
import FileUtil from '../utils/File';
|
|
||||||
import { GlobalConfig } from '../../config';
|
|
||||||
import promptAction from '@ohos.promptAction';
|
import promptAction from '@ohos.promptAction';
|
||||||
import { GetCurrentTime, IsDaysAgo } from './Common';
|
import { GetCurrentTime, IsDaysAgo } from './Common';
|
||||||
import { RecordHandleType, VideoConfig } from '../model';
|
import { RecordHandleType, TakePhotoCallbackData, VideoConfig } from '../model';
|
||||||
import common from '@ohos.app.ability.common';
|
import common from '@ohos.app.ability.common';
|
||||||
|
import { FileHelper } from '../common/service/FileHelper';
|
||||||
|
import FileUtil from '../common/utils/File';
|
||||||
|
import dayTs from './Date';
|
||||||
|
import { GlobalConfig } from '../config';
|
||||||
|
import { BusinessError } from '@ohos.base';
|
||||||
|
|
||||||
const rtsp_server = record.createServer();
|
const rtsp_server = record.createServer();
|
||||||
//开始录屏
|
//开始录屏
|
||||||
@ -84,29 +83,37 @@ export async function endRecordVideo(record_handleObj: RecordHandleType) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export async function saveStartRecordVideo(path) {
|
export async function saveStartRecordVideo(path: string, context?: common.UIAbilityContext): Promise<RecordHandleType> {
|
||||||
return new Promise(async (reslove, reject) => {
|
context = context || globalThis.context
|
||||||
const fileUtil = new FileUtil(globalThis.context)
|
return new Promise(async (resolve, reject) => {
|
||||||
|
const fileUtil = new FileUtil(context)
|
||||||
const fileHelper = new FileHelper();
|
const fileHelper = new FileHelper();
|
||||||
const date = dateFormat(new Date).split(' ')[0]
|
// const date = dateFormat(new Date).split(' ')[0]
|
||||||
|
const date = dayTs().format('YYYY-MM-DD HH:mm:ss').split(' ')[0]
|
||||||
fileHelper.createAlbum(date);
|
fileHelper.createAlbum(date);
|
||||||
// const folderPath = await fileUtil.initFolder(`/${path}/${date}`);
|
// const folderPath = await fileUtil.initFolder(`/${path}/${date}`);
|
||||||
const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/config3.txt');
|
// TODO:待修改
|
||||||
const param = JSON.parse(data)
|
const data: string = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/config3.txt');
|
||||||
const record_handle = {
|
const param: VideoConfig = JSON.parse(data)
|
||||||
1: 0,
|
const record_handle: RecordHandleType = {
|
||||||
2: 1,
|
rocord_handle1: 0,
|
||||||
3: 2,
|
rocord_handle2: 1,
|
||||||
4: 3
|
rocord_handle3: 2,
|
||||||
|
rocord_handle4: 3
|
||||||
}
|
}
|
||||||
for (let i = 1; i <= 4; i++) {
|
for (let i = 1; i <= 4; i++) {
|
||||||
if (param['videoRecord'+i]) {
|
// if (param['videoRecord'+i]) {
|
||||||
console.log('pathpath0', path)
|
//
|
||||||
|
// record_handle[i] = await getFilehandleCode(i, param, date, path, i)
|
||||||
|
// }
|
||||||
|
if (Reflect.get(param, 'videoRecord' + i)) {
|
||||||
|
// Reflect.set(record_handle, i, await getFileHandleCode(i, param, date, path, i));
|
||||||
|
const data = await startRecordVideo(param, i, context, date, path, i);
|
||||||
|
Reflect.set(record_handle, i, data);
|
||||||
|
|
||||||
record_handle[i] = await getfilehandleCode(i, param, date, path, i)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
reslove(record_handle)
|
resolve(record_handle)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +142,7 @@ interface takePhotoParam {
|
|||||||
*/
|
*/
|
||||||
const fileHelper = new FileHelper();
|
const fileHelper = new FileHelper();
|
||||||
|
|
||||||
export async function delPic(day, type) {
|
export async function delPic(day: number, type: number) {
|
||||||
let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(globalThis.context);
|
let phAccessHelper = photoAccessHelper.getPhotoAccessHelper(globalThis.context);
|
||||||
console.info('albumGetAssetsDemoCallback');
|
console.info('albumGetAssetsDemoCallback');
|
||||||
let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
|
let predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates();
|
||||||
@ -162,82 +169,79 @@ export async function delPic(day, type) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function takePhoto(param, context, dir, flag = 1, callback?) {
|
export async function takePhoto(param: VideoConfig, context: common.UIAbilityContext, dir: string, flag = 1,
|
||||||
|
callback?: (data: TakePhotoCallbackData) => void) {
|
||||||
let video_uri = `rtsp://${param.userName}:${param.pwd}@${param.ip}:${param.port}/h264/ch${param.pztd}/main/av_stream`;
|
let video_uri = `rtsp://${param.userName}:${param.pwd}@${param.ip}:${param.port}/h264/ch${param.pztd}/main/av_stream`;
|
||||||
|
|
||||||
const num = Math.floor(Math.random() * 10000)
|
const num = Math.floor(Math.random() * 10000)
|
||||||
const fileName = `picture_record${num}.jpg`
|
const fileName = `picture_record${num}.jpg`
|
||||||
|
|
||||||
if (flag == 0) {
|
if (flag == 0) {
|
||||||
rtsp_server.detectVideoSnapshotSize(video_uri, fileName, (err, snapResult) => {
|
rtsp_server.detectVideoSnapshotSize(video_uri, fileName, (err: BusinessError, snapResult: record.RtspResult) => {
|
||||||
callback({ fileSize: snapResult.fileSize, errorCode: snapResult.errorCode })
|
callback({ fileSize: snapResult.fileSize, errorCode: snapResult.errorCode })
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
return new Promise<takePhotoParam>(async (resolve, reject) => {
|
return new Promise<takePhotoParam>(async (resolve, reject) => {
|
||||||
const time = await getCurrentTime()
|
const time = await GetCurrentTime()
|
||||||
const date = time.split(' ')[0]
|
const date = time.split(' ')[0]
|
||||||
let dirName = dir ? dir : date
|
let dirName = dir ? dir : date
|
||||||
rtsp_server.getVideoSnapshot(context, video_uri, fileName, dirName, true, async (err, snapResult) => {
|
rtsp_server.getVideoSnapshot(context, video_uri, fileName, dirName, true,
|
||||||
if (snapResult.result && snapResult.errorCode == 0) {
|
async (err: BusinessError, snapResult: record.RtspResult) => {
|
||||||
resolve({
|
if (snapResult.result && snapResult.errorCode == 0) {
|
||||||
base64: snapResult.dataString,
|
resolve({
|
||||||
name: snapResult.fileName,
|
base64: snapResult.dataString,
|
||||||
fileSize: snapResult.fileSize,
|
name: snapResult.fileName,
|
||||||
errorCode: snapResult.errorCode
|
fileSize: snapResult.fileSize,
|
||||||
})
|
errorCode: snapResult.errorCode
|
||||||
} else {
|
})
|
||||||
promptAction.showToast({
|
} else {
|
||||||
message: `拍照失败`,
|
promptAction.showToast({
|
||||||
duration: 3000
|
message: `拍照失败`,
|
||||||
});
|
duration: 3000
|
||||||
reject(false)
|
});
|
||||||
// reject()
|
reject(false)
|
||||||
}
|
// reject()
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//type:1 是图片 2是视频
|
//type:1 是图片 2是视频
|
||||||
export async function deleteAllFileByPiC(dirName, type = 1) {
|
export async function deleteAllFileByPiC(dirName: string, type = 1) {
|
||||||
// const fileHelper = new FileHelper();
|
// const fileHelper = new FileHelper();
|
||||||
fileHelper.deleteFileOfAlbum(dirName, type);
|
fileHelper.deleteFileOfAlbum(dirName, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function deleteAllVideos(context, type: photoAccessHelper.AlbumType,
|
export async function deleteAllVideos(context: common.UIAbilityContext, type: photoAccessHelper.AlbumType,
|
||||||
subType: photoAccessHelper.AlbumSubtype): Promise<void> {
|
subType: photoAccessHelper.AlbumSubtype): Promise<void> {
|
||||||
let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = null;
|
let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = null;
|
||||||
try {
|
try {
|
||||||
const userFileMgr = photoAccessHelper.getPhotoAccessHelper(context);
|
const userFileMgr = photoAccessHelper.getPhotoAccessHelper(context);
|
||||||
fetchResult = await userFileMgr.getAlbums(type, subType);
|
fetchResult = await userFileMgr.getAlbums(type, subType);
|
||||||
console.log('baoyihu get Album fetchResult, count: ' + fetchResult.getCount());
|
|
||||||
for (let i = 0; i < fetchResult.getCount(); i++) {
|
for (let i = 0; i < fetchResult.getCount(); i++) {
|
||||||
let albumAsset: photoAccessHelper.Album = await fetchResult.getObjectByPosition(i);
|
let albumAsset: photoAccessHelper.Album = await fetchResult.getObjectByPosition(i);
|
||||||
let photoFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = null;
|
let photoFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = null;
|
||||||
let count = 0;
|
let count = 0;
|
||||||
try {
|
try {
|
||||||
let predicates = new dataSharePredicates.DataSharePredicates();
|
let predicates = new dataSharePredicates.DataSharePredicates();
|
||||||
let fetchOptions = {
|
let fetchOptions: photoAccessHelper.FetchOptions = {
|
||||||
fetchColumns: FILE_ASSET_FETCH_COLUMNS,
|
fetchColumns: FILE_ASSET_FETCH_COLUMNS,
|
||||||
predicates: predicates
|
predicates: predicates
|
||||||
};
|
};
|
||||||
photoFetchResult = await albumAsset.getAssets(fetchOptions);
|
photoFetchResult = await albumAsset.getAssets(fetchOptions);
|
||||||
count = photoFetchResult.getCount();
|
count = photoFetchResult.getCount();
|
||||||
console.log('baoyihu photoFetchResult count: ' + count);
|
let all_fileAsset = await photoFetchResult.getAllObjects();
|
||||||
var all_fileAsset = await photoFetchResult.getAllObjects();
|
let uri_array: string[] = []
|
||||||
var uri_array = []
|
|
||||||
console.log('baoyihu batch delete begin');
|
|
||||||
for (let onfile of all_fileAsset) {
|
for (let onfile of all_fileAsset) {
|
||||||
console.log('baoyihu push one uri : ' + onfile.uri);
|
console.log('baoyihu push one uri : ' + onfile.uri);
|
||||||
uri_array.push(onfile.uri);
|
uri_array.push(onfile.uri);
|
||||||
}
|
}
|
||||||
await userFileMgr.deleteAssets(uri_array);
|
await userFileMgr.deleteAssets(uri_array);
|
||||||
|
|
||||||
console.log('baoyihu batch delete end');
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log('baoyihu get Album getPhotoAssets failed with err: ' + err);
|
|
||||||
} finally {
|
} finally {
|
||||||
if (photoFetchResult != null) {
|
if (photoFetchResult != null) {
|
||||||
photoFetchResult.close();
|
photoFetchResult.close();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user