diff --git a/imageknife/index.ets b/imageknife/index.ets index 5f0dd67..6668275 100644 --- a/imageknife/index.ets +++ b/imageknife/index.ets @@ -19,7 +19,6 @@ */ export * from './src/main/ets/components/cache/FileUtils' -export * from './src/main/ets/components/cache/Md5' export * from './src/main/ets/components/cache/Base64' export * from './src/main/ets/components/cache/LruCache' export * from './src/main/ets/components/cache/diskstrategy/enum/ALL' @@ -125,4 +124,5 @@ export {gifHandler} from './GifWorker' export type {IDrawLifeCycle} from './src/main/ets/components/imageknife/interface/IDrawLifeCycle' // 日志管理 -export * from './src/main/ets/components/imageknife/utils/LogUtil' \ No newline at end of file +export * from './src/main/ets/components/imageknife/utils/LogUtil' +export * from './src/main/ets/components/imageknife/utils/spark-md5' \ No newline at end of file diff --git a/imageknife/src/main/ets/components/imageknife/networkmanage/DownloadClient.ets b/imageknife/src/main/ets/components/imageknife/networkmanage/DownloadClient.ets index 22ac8be..9d2e7ae 100644 --- a/imageknife/src/main/ets/components/imageknife/networkmanage/DownloadClient.ets +++ b/imageknife/src/main/ets/components/imageknife/networkmanage/DownloadClient.ets @@ -15,8 +15,6 @@ import type { IDataFetch } from '../networkmanage/IDataFetch' import { RequestOption } from '../RequestOption' -import { Md5 } from '../../cache/Md5' -import { FileUtils } from '../../cache/FileUtils' import { NetworkDownloadClient } from './NetworkDownloadClient' import { LoadLocalFileClient } from './LoadLocalFileClient' import { LoadDataShareFileClient } from './LoadDataShareFileClient' diff --git a/imageknife/src/main/ets/components/imageknife/networkmanage/LoadLocalFileClient.ets b/imageknife/src/main/ets/components/imageknife/networkmanage/LoadLocalFileClient.ets index b48937c..cf59a9c 100644 --- a/imageknife/src/main/ets/components/imageknife/networkmanage/LoadLocalFileClient.ets +++ b/imageknife/src/main/ets/components/imageknife/networkmanage/LoadLocalFileClient.ets @@ -15,9 +15,7 @@ import type { IDataFetch } from '../networkmanage/IDataFetch' import { RequestOption } from '../RequestOption' -import { Md5 } from '../../cache/Md5' import { FileUtils } from '../../cache/FileUtils' -import loadRequest from '@ohos.request'; export class LoadLocalFileClient implements IDataFetch { loadData(request: RequestOption, onComplete: (img: ArrayBuffer) => void, onError: (err: string) => void) { diff --git a/imageknife/src/main/ets/components/imageknife/networkmanage/NetworkDownloadClient.ets b/imageknife/src/main/ets/components/imageknife/networkmanage/NetworkDownloadClient.ets index 156e152..bae9bea 100644 --- a/imageknife/src/main/ets/components/imageknife/networkmanage/NetworkDownloadClient.ets +++ b/imageknife/src/main/ets/components/imageknife/networkmanage/NetworkDownloadClient.ets @@ -15,14 +15,14 @@ import type { IDataFetch } from '../networkmanage/IDataFetch' import { RequestOption } from '../RequestOption' -import { Md5 } from '../../cache/Md5' +import { SparkMD5 } from '../utils/spark-md5' import { FileUtils } from '../../cache/FileUtils' import loadRequest from '@ohos.request'; // 数据加载器 export class NetworkDownloadClient implements IDataFetch { loadData(request: RequestOption, onComplete: (img: ArrayBuffer) => void, onError: (err: string) => void) { - let filename = Md5.hashStr(request.generateDataKey); + let filename = SparkMD5.hash(request.generateDataKey); let downloadFolder = request.getFilesPath() + "/" + request.networkCacheFolder; let allpath = request.getFilesPath() + "/" + request.networkCacheFolder + "/" + filename + ".img"; if (!FileUtils.getInstance().existFolder(downloadFolder)) { diff --git a/imageknife/src/main/ets/components/imageknife/requestmanage/RequestManager.ets b/imageknife/src/main/ets/components/imageknife/requestmanage/RequestManager.ets index bf4d341..1f7a86f 100644 --- a/imageknife/src/main/ets/components/imageknife/requestmanage/RequestManager.ets +++ b/imageknife/src/main/ets/components/imageknife/requestmanage/RequestManager.ets @@ -13,25 +13,24 @@ * limitations under the License. */ -import { RequestOption } from "../../imageknife/RequestOption" -import { DiskLruCache } from "@ohos/disklrucache" -import { LruCache } from "../../cache/LruCache" -import {FileUtils} from "../../cache/FileUtils" -import {Md5} from "../../cache/Md5" -import{MemoryCacheProxy} from "../requestmanage/MemoryCacheProxy" -import{DiskCacheProxy} from "../requestmanage/DiskCacheProxy" -import{FileTypeUtil} from "../utils/FileTypeUtil" -import type {IDataFetch} from "../../imageknife/networkmanage/IDataFetch" -import type {IResourceFetch} from "../../imageknife/resourcemanage/IResourceFetch" -import{ImageKnifeData,ImageKnifeType} from "../ImageKnifeData" -import {AllCacheInfo} from "../../imageknife/interface/IAllCacheInfoCallback" -import{ParseImageUtil} from '../utils/ParseImageUtil' -import type {IParseImage} from '../interface/IParseImage' -import image from "@ohos.multimedia.image" +import { RequestOption } from '../../imageknife/RequestOption' +import { DiskLruCache } from '@ohos/disklrucache' +import { LruCache } from '../../cache/LruCache' +import { SparkMD5 } from '../utils/spark-md5' +import { MemoryCacheProxy } from '../requestmanage/MemoryCacheProxy' +import { DiskCacheProxy } from '../requestmanage/DiskCacheProxy' +import { FileTypeUtil } from '../utils/FileTypeUtil' +import type { IDataFetch } from '../../imageknife/networkmanage/IDataFetch' +import type { IResourceFetch } from '../../imageknife/resourcemanage/IResourceFetch' +import { ImageKnifeData, ImageKnifeType } from '../ImageKnifeData' +import { AllCacheInfo } from '../../imageknife/interface/IAllCacheInfoCallback' +import { ParseImageUtil } from '../utils/ParseImageUtil' +import type { IParseImage } from '../interface/IParseImage' +import image from '@ohos.multimedia.image' import { SVGParseImpl } from '../utils/svg/SVGParseImpl' import { GIFParseImpl } from '../utils/gif/GIFParseImpl' import { GIFFrame } from '../utils/gif/GIFFrame' -import {LogUtil} from '../../imageknife/utils/LogUtil' +import { LogUtil } from '../../imageknife/utils/LogUtil' export interface AsyncString { (data: string): void; @@ -113,14 +112,14 @@ export class RequestManager { // 变换后缓存 allCacheInfo.resourceCacheInfo = { - key: Md5.hashStr(this.options.generateResourceKey), - path: (this.mDiskCacheProxy.getCachePath() + Md5.hashStr(this.options.generateResourceKey)) + key: SparkMD5.hash(this.options.generateResourceKey), + path: (this.mDiskCacheProxy.getCachePath() + SparkMD5.hash(this.options.generateResourceKey)) }; // 原图缓存 allCacheInfo.dataCacheInfo = { - key: Md5.hashStr(this.options.generateDataKey), - path: this.mDiskCacheProxy.getCachePath() + Md5.hashStr(this.options.generateDataKey) + key: SparkMD5.hash(this.options.generateDataKey), + path: this.mDiskCacheProxy.getCachePath() + SparkMD5.hash(this.options.generateDataKey) } this.options.allCacheInfoCallback(allCacheInfo) }