Compare commits

...

2 Commits

Author SHA1 Message Date
aa878365fe Merge remote-tracking branch 'origin/api10' into api10 2025-04-09 14:37:11 +08:00
8fb91e4cf4 错误修改 2025-04-09 14:37:02 +08:00
2 changed files with 26 additions and 33 deletions

View File

@ -5,24 +5,20 @@ import { GetSyncData } from '../utils/table/Operation';
const cBg = $rawfile('judge/km3/road/luxian_pre.png');
const lBg = $rawfile('judge/km3/road/luxian_nor.png');
const ctBg = $rawfile('judge/km3/road/luxian_pre.png');
const ltBg = $rawfile('judge/km3/road/luxian_nor.png');
//单机模式才选线路
@Entry
@Component
struct Index {
@State outFlag: boolean = false;
@State roadObj: ESObject = {};
@State roadObj: number[] = [];
async aboutToAppear() {
//读取systemparam表的no1等于4的
const systemParms: Array<MASYSTEMPARMType> = await GetSyncData('MA_SYSTEMPARM') as MASYSTEMPARMType[];
systemParms.forEach((systemParm: MASYSTEMPARMType) => {
//TODO 字段名称待修改
// const { no1, no2, no3, txt1, txt2 } = systemParm;
if (systemParm.no1 == 4) {
this.roadObj[systemParm.no2] = systemParm.no2
this.roadObj.push(systemParm.no2)
}
})
}
@ -51,14 +47,11 @@ struct Index {
.height(220)
.margin({ left: 5, bottom: 10 })
.onClick(async () => {
const roadArr = Reflect.ownKeys(this.roadObj).map((roadKey) => {
return this.roadObj[roadKey]
});
const wayno = roadArr[Math.floor(Math.random() * roadArr.length)];
const wayno = this.roadObj[Math.floor(Math.random() * this.roadObj.length)];
this.goJudge(wayno)
})
ForEach(Reflect.ownKeys(this.roadObj), (roadIndex) => {
ForEach(this.roadObj, (item: number) => {
ListItem() {
Column() {
Row() {
@ -68,7 +61,7 @@ struct Index {
.width(90)
.height(80)
Text(`线路${this.roadObj[roadIndex] + ''}`) {
Text(`线路${item}`) {
}.fontColor('#FFF2D9').fontSize(24).padding({ top: 10 })
}
}
@ -78,7 +71,7 @@ struct Index {
.height(220)
.margin({ left: 5, bottom: 10 })
.onClick(async () => {
this.goJudge(this.roadObj[roadIndex])
this.goJudge(item)
})
})
}.lanes(8).margin({ top: 50, left: 15 })
@ -89,7 +82,7 @@ struct Index {
}
goJudge(wayno: string) {
goJudge(wayno: number) {
let currentParams: RouteParamsType = router.getParams() as RouteParamsType;
router.replaceUrl({
url: 'pages/Judge',

View File

@ -54,9 +54,9 @@ export class FileHelper {
}
}
async getUserAlbumItemByDisplayName(displayName: string): Promise<photoAccessHelper.Album> {
let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = null
let album: photoAccessHelper.Album = null
async getUserAlbumItemByDisplayName(displayName: string): Promise<photoAccessHelper.Album | undefined> {
let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> | undefined = undefined
let album: photoAccessHelper.Album | undefined = undefined
try {
console.log(FileHelpTag, 'getUserAlbumItemByDisplayName');
let predicates = new dataSharePredicates.DataSharePredicates();
@ -75,7 +75,7 @@ export class FileHelper {
} catch (err) {
console.error(FileHelpTag, 'get Album fetchResult failed with err: ' + err);
} finally {
if (fetchResult != null) {
if (fetchResult !== undefined) {
fetchResult.close();
}
}
@ -98,7 +98,7 @@ export class FileHelper {
let asset = await assetsResult.getFirstObject();
console.log(FileHelpTag, ' addAssetToAlbum one asset uri : ' + asset.uri + ', photoType : ' + asset.photoType +
', displayName : ' + asset.displayName);
await album.addAssets([asset]);
await album?.addAssets([asset]);
console.log(FileHelpTag, ' addAssetToAlbum success ');
}
} catch (err) {
@ -109,7 +109,7 @@ export class FileHelper {
public async deleteFileOfAlbum(album_Name: string, file_type: number | string | boolean): Promise<void> {
console.log(FileHelpTag, ' deletePictureOfAlbum album_Name' + album_Name);
let photoFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = null;
let photoFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> | undefined = undefined;
try {
let album = await this.getUserAlbumItemByName(album_Name);
let predicates = new dataSharePredicates.DataSharePredicates();
@ -118,12 +118,12 @@ export class FileHelper {
fetchColumns: this.FILE_ASSET_FETCH_COLUMNS,
predicates: predicates
};
photoFetchResult = await album.getAssets(fetchOptions)
let all_fileAsset = await photoFetchResult.getAllObjects();
photoFetchResult = await album?.getAssets(fetchOptions)
let all_fileAsset = await photoFetchResult?.getAllObjects();
let uri_array: string[] = []
console.log(FileHelpTag, ' deletePictureOfAlbum iterator begin', album_Name);
for (let onfile of all_fileAsset) {
for (let onfile of all_fileAsset!) {
console.log(FileHelpTag, album_Name,
' deletePictureOfAlbum uri : ' + onfile.uri + ', photoType : ' + onfile.photoType +
', displayName : ' + onfile.displayName);
@ -131,7 +131,7 @@ export class FileHelper {
}
await this.userFileMgr.deleteAssets(uri_array);
let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = null;
let albumFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> | undefined = undefined;
try {
albumFetchResult =
await this.userFileMgr.getAlbums(photoAccessHelper.AlbumType.SYSTEM, photoAccessHelper.AlbumSubtype.TRASH);
@ -162,7 +162,7 @@ export class FileHelper {
public async deleteAllPictures(): Promise<void> {
console.log(FileHelpTag, ' deleteAllPictures');
let photoFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = null;
let photoFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> | undefined = undefined;
try {
let predicates = new dataSharePredicates.DataSharePredicates();
let fetchOptions: photoAccessHelper.FetchOptions = {
@ -216,9 +216,9 @@ export class FileHelper {
// return album;
// }
async getUserAlbumItemByName(albumName: string): Promise<photoAccessHelper.Album> {
let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = null
let album: photoAccessHelper.Album = null
async getUserAlbumItemByName(albumName: string): Promise<photoAccessHelper.Album | undefined> {
let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> | undefined = undefined
let album: photoAccessHelper.Album | undefined = undefined
try {
console.log(FileHelpTag, 'getUserAlbumItemByName');
let predicates = new dataSharePredicates.DataSharePredicates();
@ -246,7 +246,7 @@ export class FileHelper {
}
public async createAlbum(albumName: string): Promise<string> {
public async createAlbum(albumName: string): Promise<string | undefined> {
try {
console.log(FileHelpTag, " createAlbum beging");
let albumAsset = await this.userFileMgr.createAlbum(albumName);
@ -257,7 +257,7 @@ export class FileHelper {
return albumAsset.albumUri;
} catch (err) {
console.error(FileHelpTag, ' createAlbum failed with err: ' + err);
} finally {
return undefined
}
}
@ -280,7 +280,7 @@ export class FileHelper {
public async queryAlbum(type: photoAccessHelper.AlbumType, subType: photoAccessHelper.AlbumSubtype): Promise<string> {
let firstUri = "";
let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = null;
let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> | undefined = undefined;
try {
fetchResult = await this.userFileMgr.getAlbums(type, subType);
console.log(FileHelpTag, ' queryAlbum success count: ' + fetchResult.getCount());
@ -327,13 +327,13 @@ export class FileHelper {
public async deleteAllVideos(type: photoAccessHelper.AlbumType,
subType: photoAccessHelper.AlbumSubtype): Promise<void> {
let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = null;
let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> | undefined = undefined;
try {
fetchResult = await this.userFileMgr.getAlbums(type, subType);
console.log(FileHelpTag, ' get Album fetchResult, count: ' + fetchResult.getCount());
for (let i = 0; i < fetchResult.getCount(); i++) {
let albumAsset: photoAccessHelper.Album = await fetchResult.getObjectByPosition(i);
let photoFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> = null;
let photoFetchResult: photoAccessHelper.FetchResult<photoAccessHelper.PhotoAsset> | undefined = undefined;
let count = 0;
console.log(FileHelpTag, ' get one Album name : ' + albumAsset.albumName);
try {