From ff532ec8c16e578bbbffbfce48216135cb92f80c Mon Sep 17 00:00:00 2001 From: zhoulisheng <635547767@qq.com> Date: Tue, 31 Oct 2023 11:30:30 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E6=94=B9library=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E7=9A=84=E4=BB=A3=E7=A0=81,=E8=8E=B7=E5=8F=96context=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhoulisheng <635547767@qq.com> --- library/src/main/ets/Index.ets | 2 +- library/src/main/ets/pages/Index.ets | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/library/src/main/ets/Index.ets b/library/src/main/ets/Index.ets index 1b34845..c526015 100644 --- a/library/src/main/ets/Index.ets +++ b/library/src/main/ets/Index.ets @@ -131,4 +131,4 @@ export { IDrawLifeCycle } from '@ohos/imageknife' export { LogUtil } from '@ohos/imageknife' // 额外开放初始化ImageKnife的方法 -export {InitImageKnife} from './src/main/ets/pages/InitImageKnife' \ No newline at end of file +export {InitImageKnife} from '../ets/pages/InitImageKnife' \ No newline at end of file diff --git a/library/src/main/ets/pages/Index.ets b/library/src/main/ets/pages/Index.ets index dc7606c..86f8d60 100644 --- a/library/src/main/ets/pages/Index.ets +++ b/library/src/main/ets/pages/Index.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { ImageKnifeComponent, ImageKnifeOption, FileUtils } from '@ohos/imageknife' +import {ImageKnifeGlobal, ImageKnifeComponent, ImageKnifeOption, FileUtils } from '@ohos/imageknife' import common from '@ohos.app.ability.common' @Entry @@ -54,7 +54,8 @@ struct Index { Button('点击加载本地文件').onClick(()=>{ getContext(this).createModuleContext('library').resourceManager.getMediaContent($r('app.media.setting').id).then((data:Uint8Array)=>{ - let path = globalThis.ImageKnife.getImageKnifeContext().filesDir+"/set.jpeg"; + let ctx = ImageKnifeGlobal.getInstance().getHapContext() as common.UIAbilityContext; + let path = ctx.filesDir+"/set.jpeg"; FileUtils.getInstance().writeFile(path,data.buffer) FileUtils.getInstance().readFilePicAsync(path).then(buffer=>{ this.imageOption3 = {