diff --git a/IntentsKitNewsUpdate/Application/build-profile.json5 b/IntentsKitNewsUpdate/Application/build-profile.json5 index 59bb60f29216721afbddbbb925bba0fb4356309a..e7ad1daa252110cb69dbd01d17d482fb004da49f 100644 --- a/IntentsKitNewsUpdate/Application/build-profile.json5 +++ b/IntentsKitNewsUpdate/Application/build-profile.json5 @@ -5,7 +5,6 @@ { "name": "default", "signingConfig": "default", - "targetSdkVersion": "5.0.5(17)", "compatibleSdkVersion": "5.0.5(17)", "runtimeOS": "HarmonyOS", "buildOption": { diff --git a/IntentsKitNewsUpdate/Application/cloud_objects/BuildProfile.ets b/IntentsKitNewsUpdate/Application/cloud_objects/BuildProfile.ets deleted file mode 100644 index 6033e79a01b85a7b72e746eb3c8eba704e312bd5..0000000000000000000000000000000000000000 --- a/IntentsKitNewsUpdate/Application/cloud_objects/BuildProfile.ets +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Use these variables when you tailor your ArkTS code. They must be of the const type. - */ -export const HAR_VERSION = '1.0.0'; -export const BUILD_MODE_NAME = 'release'; -export const DEBUG = false; -export const TARGET_NAME = 'default'; - -/** - * BuildProfile Class is used only for compatibility purposes. - */ -export default class BuildProfile { - static readonly HAR_VERSION = HAR_VERSION; - static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; - static readonly DEBUG = DEBUG; - static readonly TARGET_NAME = TARGET_NAME; -} \ No newline at end of file diff --git a/IntentsKitNewsUpdate/Application/entry/obfuscation-rules.txt b/IntentsKitNewsUpdate/Application/entry/obfuscation-rules.txt index 62b2522b2882ad3a00a9268511c0a305a53efe49..272efb6ca3f240859091bbbfc7c5802d52793b0b 100644 --- a/IntentsKitNewsUpdate/Application/entry/obfuscation-rules.txt +++ b/IntentsKitNewsUpdate/Application/entry/obfuscation-rules.txt @@ -20,7 +20,4 @@ -enable-property-obfuscation -enable-toplevel-obfuscation -enable-filename-obfuscation --enable-export-obfuscation - --keep -XXX/oh_modules/@hw-agconnect/auth \ No newline at end of file +-enable-export-obfuscation \ No newline at end of file diff --git a/IntentsKitNewsUpdate/Application/entry/oh-package-lock.json5 b/IntentsKitNewsUpdate/Application/entry/oh-package-lock.json5 deleted file mode 100644 index f74e8c3ee3ddd587e9c6a562a795d63f6bbc5b45..0000000000000000000000000000000000000000 --- a/IntentsKitNewsUpdate/Application/entry/oh-package-lock.json5 +++ /dev/null @@ -1,18 +0,0 @@ -{ - "meta": { - "stableOrder": true - }, - "lockfileVersion": 3, - "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", - "specifiers": { - "cloud_objects@../cloud_objects": "cloud_objects@../cloud_objects" - }, - "packages": { - "cloud_objects@../cloud_objects": { - "name": "cloud_objects", - "version": "1.0.0", - "resolved": "../cloud_objects", - "registryType": "local" - } - } -} \ No newline at end of file diff --git a/IntentsKitNewsUpdate/Application/entry/src/main/ets/clouddb/news/News.ts b/IntentsKitNewsUpdate/Application/entry/src/main/ets/clouddb/news/News.ets similarity index 79% rename from IntentsKitNewsUpdate/Application/entry/src/main/ets/clouddb/news/News.ts rename to IntentsKitNewsUpdate/Application/entry/src/main/ets/clouddb/news/News.ets index 7e3b43193a232fe0cd7314175267ef55708ea23f..391ec28615d39d422e4923b01204060bca6b44be 100644 --- a/IntentsKitNewsUpdate/Application/entry/src/main/ets/clouddb/news/News.ts +++ b/IntentsKitNewsUpdate/Application/entry/src/main/ets/clouddb/news/News.ets @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2025 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 @@ -16,14 +16,14 @@ import { cloudDatabase } from '@kit.CloudFoundationKit'; class News extends cloudDatabase.DatabaseObject { - public newsId: number; + public newsId: number = 0; public title = ''; public content = ''; public newsType = '图文'; - public pubUserName: string; - public pubUserAvatar: string; - public pubDate: Date; - public viewCount: number; + public pubUserName: string = ''; + public pubUserAvatar: string = ''; + public pubDate: Date = new Date(); + public viewCount: number = 0; public naturalbase_ClassName(): string { return 'News'; diff --git a/IntentsKitNewsUpdate/Application/entry/src/main/ets/clouddb/news/NewsDb.ets b/IntentsKitNewsUpdate/Application/entry/src/main/ets/clouddb/news/NewsDb.ets index 75065a770ae78ab19d9989cd47f12b6f9cce9f11..d0dfb4440bef27ee187a68620bf7e53d1370fb9a 100644 --- a/IntentsKitNewsUpdate/Application/entry/src/main/ets/clouddb/news/NewsDb.ets +++ b/IntentsKitNewsUpdate/Application/entry/src/main/ets/clouddb/news/NewsDb.ets @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2025 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 diff --git a/IntentsKitNewsUpdate/Application/entry/src/main/ets/common/utils/Logger.ets b/IntentsKitNewsUpdate/Application/entry/src/main/ets/common/utils/Logger.ets index 3aa2c7130adc1d78dae113ed1154c4360451a220..0a51a7444815b8842d4d1aa4abc3c364a3442621 100644 --- a/IntentsKitNewsUpdate/Application/entry/src/main/ets/common/utils/Logger.ets +++ b/IntentsKitNewsUpdate/Application/entry/src/main/ets/common/utils/Logger.ets @@ -12,8 +12,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { hilog } from "@kit.PerformanceAnalysisKit"; -import hilog from '@ohos.hilog'; const TAG = 'IntentsKitNews'; diff --git a/IntentsKitNewsUpdate/Application/entry/src/main/ets/insightintents/IntentExecutorImpl.ets b/IntentsKitNewsUpdate/Application/entry/src/main/ets/insightintents/IntentExecutorImpl.ets index a627e2cd8cba56c8f1a60e042d3cdd6e72834e8c..5ab8e9ad9a75b3816492d2e7447246256798d106 100644 --- a/IntentsKitNewsUpdate/Application/entry/src/main/ets/insightintents/IntentExecutorImpl.ets +++ b/IntentsKitNewsUpdate/Application/entry/src/main/ets/insightintents/IntentExecutorImpl.ets @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2025 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 diff --git a/IntentsKitNewsUpdate/Application/entry/src/main/ets/pages/Index.ets b/IntentsKitNewsUpdate/Application/entry/src/main/ets/pages/Index.ets index c8c80c2eb8d35d46791034c5198624f983fe73ff..158a14a63ff570fdbc6e6aefbf560ce135266899 100644 --- a/IntentsKitNewsUpdate/Application/entry/src/main/ets/pages/Index.ets +++ b/IntentsKitNewsUpdate/Application/entry/src/main/ets/pages/Index.ets @@ -38,7 +38,6 @@ struct Home { private tabsController: TabsController = new TabsController(); @State newsList: News[] = []; @State recommendList: News[] = []; - handleIntentParam = async (data: IIntentParam) => { if (!data) { return; @@ -56,19 +55,16 @@ struct Home { } if (data.items && data.items?.length > 0) { - this.recommendList = data.items?.map((item) => ({ - newsId: Number(item.entityId), - title: item.blogTitle, - content: '', - newsType: item.blogCategory, - pubUserName: item.blogAuthor, - pubUserAvatar: item.blogAuthorImage, - pubDate: new Date(item.blogPublishTime), - viewCount: 0, - naturalbase_ClassName(): string { - return 'News'; - } - } as News)) + this.recommendList = data.items?.map((item) => { + const news = new News(); + news.newsId = Number(item.entityId); + news.title = item.blogTitle; + news.newsType = item.blogCategory; + news.pubUserName = item.blogAuthor; + news.pubUserAvatar = item.blogAuthorImage; + news.pubDate = new Date(item.blogPublishTime); + return news; + }) } } diff --git a/IntentsKitNewsUpdate/Application/oh-package-lock.json5 b/IntentsKitNewsUpdate/Application/oh-package-lock.json5 deleted file mode 100644 index c6f99f5c73b06c5fdef7ec6f491b74b7befebe2e..0000000000000000000000000000000000000000 --- a/IntentsKitNewsUpdate/Application/oh-package-lock.json5 +++ /dev/null @@ -1,27 +0,0 @@ -{ - "meta": { - "stableOrder": true - }, - "lockfileVersion": 3, - "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", - "specifiers": { - "@ohos/hamock@1.0.0": "@ohos/hamock@1.0.0", - "@ohos/hypium@1.0.21": "@ohos/hypium@1.0.21" - }, - "packages": { - "@ohos/hamock@1.0.0": { - "name": "@ohos/hamock", - "version": "1.0.0", - "integrity": "sha512-K6lDPYc6VkKe6ZBNQa9aoG+ZZMiwqfcR/7yAVFSUGIuOAhPvCJAo9+t1fZnpe0dBRBPxj2bxPPbKh69VuyAtDg==", - "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hamock/-/hamock-1.0.0.har", - "registryType": "ohpm" - }, - "@ohos/hypium@1.0.21": { - "name": "@ohos/hypium", - "version": "1.0.21", - "integrity": "sha512-iyKGMXxE+9PpCkqEwu0VykN/7hNpb+QOeIuHwkmZnxOpI+dFZt6yhPB7k89EgV1MiSK/ieV/hMjr5Z2mWwRfMQ==", - "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hypium/-/hypium-1.0.21.har", - "registryType": "ohpm" - } - } -} \ No newline at end of file diff --git a/IntentsKitNewsUpdate/Application/oh-package.json5 b/IntentsKitNewsUpdate/Application/oh-package.json5 index 9c374d1e67122fe1fc7a0e6632ad1c5c2903088c..24414466b406296cdef9f123b993cf14d5bc7537 100644 --- a/IntentsKitNewsUpdate/Application/oh-package.json5 +++ b/IntentsKitNewsUpdate/Application/oh-package.json5 @@ -2,9 +2,6 @@ "modelVersion": "5.0.5", "description": "Please describe the basic information.", "dependencies": {}, - "devDependencies": { - "@ohos/hypium": "1.0.21", - "@ohos/hamock": "1.0.0" - }, + "devDependencies": {}, "dynamicDependencies": {} } \ No newline at end of file diff --git a/IntentsKitNewsUpdate/CloudProgram/cloudfunctions/cloud-intent-search-news/CloudDBZoneWrapper.ts b/IntentsKitNewsUpdate/CloudProgram/cloudfunctions/cloud-intent-search-news/CloudDBZoneWrapper.ts index d9c2bf886e43f9ae3a66f932ddd1a06527df4a3b..fb505d664155c9fd74dbd2f3549a0aaed4c7d030 100644 --- a/IntentsKitNewsUpdate/CloudProgram/cloudfunctions/cloud-intent-search-news/CloudDBZoneWrapper.ts +++ b/IntentsKitNewsUpdate/CloudProgram/cloudfunctions/cloud-intent-search-news/CloudDBZoneWrapper.ts @@ -18,7 +18,7 @@ import { cloud, CloudDBCollection } from '@hw-agconnect/cloud-server'; import { News } from './News'; // database zone -const ZONE_NAME = "News"; +const ZONE_NAME = 'News'; export class CloudDbZoneWrapper { collection: CloudDBCollection; @@ -39,67 +39,67 @@ export class CloudDbZoneWrapper { // Case 2: Only category if (hasCategory && !hasAuthor && !hasKeywords) { - return this.baseQuery().equalTo("newsType", blogCategory).get(); + return this.baseQuery().equalTo('newsType', blogCategory).get(); } // Case 3: Only author if (!hasCategory && hasAuthor && !hasKeywords) { - return this.baseQuery().equalTo("pubUserName", blogAuthor).get(); + return this.baseQuery().equalTo('pubUserName', blogAuthor).get(); } // Case 4: Only keywords if (!hasCategory && !hasAuthor && hasKeywords) { const keywordArray = keywords.split(','); return keywordArray.length > 1 - ? this.baseQuery().in("title", keywordArray).get() - : this.baseQuery().contains("title", keywords).get(); + ? this.baseQuery().in('title', keywordArray).get() + : this.baseQuery().contains('title', keywords).get(); } // Case 5: Category + author if (hasCategory && hasAuthor && !hasKeywords) { return this.baseQuery() - .equalTo("newsType", blogCategory) - .equalTo("pubUserName", blogAuthor) + .equalTo('newsType', blogCategory) + .equalTo('pubUserName', blogAuthor) .get(); } // Case 6: Category + keywords if (hasCategory && !hasAuthor && hasKeywords) { const keywordArray = keywords.split(','); - const query = this.baseQuery().equalTo("newsType", blogCategory); + const query = this.baseQuery().equalTo('newsType', blogCategory); return keywordArray.length > 1 - ? query.in("title", keywordArray).get() - : query.contains("title", keywords).get(); + ? query.in('title', keywordArray).get() + : query.contains('title', keywords).get(); } // Case 7: Author + keywords if (!hasCategory && hasAuthor && hasKeywords) { const keywordArray = keywords.split(','); - const query = this.baseQuery().equalTo("pubUserName", blogAuthor); + const query = this.baseQuery().equalTo('pubUserName', blogAuthor); return keywordArray.length > 1 - ? query.in("title", keywordArray).get() - : query.contains("title", keywords).get(); + ? query.in('title', keywordArray).get() + : query.contains('title', keywords).get(); } // Case 8: Category + author + keywords const keywordArray = keywords.split(','); const query = this.baseQuery() - .equalTo("newsType", blogCategory) - .equalTo("pubUserName", blogAuthor); + .equalTo('newsType', blogCategory) + .equalTo('pubUserName', blogAuthor); return keywordArray.length > 1 - ? query.in("title", keywordArray).get() - : query.contains("title", keywords).get(); + ? query.in('title', keywordArray).get() + : query.contains('title', keywords).get(); } // query data async queryNews() { - let query = this.baseQuery().orderByDesc("pubDate"); + let query = this.baseQuery().orderByDesc('pubDate'); return await query.get(); } async queryLatestNews() { - let query = this.baseQuery().orderByDesc("pubDate").limit(1, 0); + let query = this.baseQuery().orderByDesc('pubDate').limit(1, 0); return await query.get(); } diff --git a/IntentsKitNewsUpdate/CloudProgram/cloudfunctions/cloud-intent-search-news/cloudIntentSearchNews.ts b/IntentsKitNewsUpdate/CloudProgram/cloudfunctions/cloud-intent-search-news/cloudIntentSearchNews.ts index fdddcdb30fbce9c7b369ec8384ad054af3d35a82..35217e25c522fb8a9d26c6b23262df2412243124 100644 --- a/IntentsKitNewsUpdate/CloudProgram/cloudfunctions/cloud-intent-search-news/cloudIntentSearchNews.ts +++ b/IntentsKitNewsUpdate/CloudProgram/cloudfunctions/cloud-intent-search-news/cloudIntentSearchNews.ts @@ -18,7 +18,7 @@ import { CloudDbZoneWrapper } from './CloudDBZoneWrapper'; import { Device, PaginationReq, QueryBlogInfoReq } from './types'; interface ISearchParam { - version: string; // Request version, default "1.0", max 16 chars + version: string; // Request version, default '1.0', max 16 chars deviceInfo: Device; // Device information pagination?: PaginationReq; // Optional pagination parameters content: QueryBlogInfoReq; // Search parameters @@ -28,7 +28,7 @@ interface ISearchParam { interface ISearchResult { entityId: string; blogTitle: string; - blogType: "Normal" | "Video"; + blogType: 'Normal' | 'Video'; blogCategory: string; logoURL: { small: { @@ -84,20 +84,20 @@ let myHandler = async function (event, context, callback, logger) { const result: ISearchResult[] = data.map((item) => ({ entityId: item.getNewsId().toString(), blogTitle: item.getTitle(), - blogType: "Normal", + blogType: 'Normal', blogCategory: item.getNewsType(), logoURL: { small: { - url: "https://gitee.com/gorit/screenshots/raw/main/sm_img.png", + url: 'https://gitee.com/gorit/screenshots/raw/main/sm_img.png', widthPixels: 320, // Default value heightPixels: 180 // Default value } }, - description: item.getContent().split(",")[0], + description: item.getContent().split(',')[0], blogAuthor: item.getPubUserName(), blogAuthorImage: { small: { - url: item.getPubUserAvatar() || "https://gitee.com/gorit/screenshots/raw/main/avatar.png", + url: item.getPubUserAvatar() || 'https://gitee.com/gorit/screenshots/raw/main/avatar.png', widthPixels: 32, // Default value heightPixels: 32 // Default value } @@ -112,7 +112,7 @@ let myHandler = async function (event, context, callback, logger) { viewCount: 0, detailUrl: [{ webURL: `https://your-domain.com/news/${item.getNewsId()}`, - displayText: "查看详情" + displayText: '查看详情' }] })); @@ -121,15 +121,15 @@ let myHandler = async function (event, context, callback, logger) { items: result, pagination: { total: result.length, - next: result.length >= 20 ? "2" : undefined // Assuming 20 items per page + next: result.length >= 20 ? '2' : undefined // Assuming 20 items per page }, moreLink: { - webURL: "https://your-domain.com/news/list", - displayText: "查看更多资讯" + webURL: 'https://your-domain.com/news/list', + displayText: '查看更多资讯' } }, - errorCode: "0", - errorMessage: "SUCCESS" + errorCode: '0', + errorMessage: 'SUCCESS' }; callback(resp); diff --git a/IntentsKitNewsUpdate/CloudProgram/cloudfunctions/cloud-intent-search-news/types.ts b/IntentsKitNewsUpdate/CloudProgram/cloudfunctions/cloud-intent-search-news/types.ts index 1c3446481e07a11b0f6ac13d39ed34b8279487ca..766e240951aed7669813ba61f38e828932a8a657 100644 --- a/IntentsKitNewsUpdate/CloudProgram/cloudfunctions/cloud-intent-search-news/types.ts +++ b/IntentsKitNewsUpdate/CloudProgram/cloudfunctions/cloud-intent-search-news/types.ts @@ -13,26 +13,6 @@ * limitations under the License. */ - -// Request types -export interface SearchBlogRequest { - // Required header parameters - headers: { - Authorization: string; // OAuth2.0 bearer token, max 512 chars - accessKey: string; // Access key from Huawei Developer Alliance, max 64 chars - sign: string; // Base64(HMAC-SHA256(secretKey, ts)), max 256 chars - ts: string; // Timestamp in milliseconds since 1970, max 16 chars - }; - - // Request body - body: { - version: string; // Request version, default "1.0", max 16 chars - deviceInfo: Device; // Device information - pagination?: PaginationReq; // Optional pagination parameters - content: QueryBlogInfoReq; // Search parameters - }; -} - export interface Device { deviceId?: string; // Unique device identifier, max 512 chars location?: Location; // Geographic location @@ -43,7 +23,7 @@ export interface Device { } export interface Location { - locationSystem: "BD09LL" | "GCJ02" | "WGS84"; + locationSystem: 'BD09LL' | 'GCJ02' | 'WGS84'; latitude: string; // Format: ddd.dddddd longitude: string; // Format: ddd.dddddd } @@ -77,7 +57,7 @@ export interface BlogInfoItem { entityId: string; // Unique blog ID, max 32 chars blogTitle: string; // Blog title, max 32 chars blogSubTitle?: string; // Blog subtitle, max 32 chars - blogType: "Normal" | "Video"; + blogType: 'Normal' | 'Video'; blogCategory: string; // Max 32 chars logoURL: ImageInfo; // Thumbnail image description: string; // Max 128 chars diff --git a/README.md b/README.md index afa9f3a9782454ed0ff57b6ec59f550c163e8ad4..69737726a558dfaa74e35aad5ec4404af3f34796 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -# 基于意图框架推荐能力实现新闻推新 +# 基于意图框架习惯推荐能力实现新闻推新 ## 介绍 -本示例基于意图框架,使用@kit.IntentsKit实现意图共享,使用@kit.AbilityKit的InsightIntentExecutor实现意图调用。配合端云一体化提供的云函数,云数据库实现云端数据访问。意图框架根据端侧意图共享的参数实现云测意图调用,完成端云结合的习惯推荐实现新闻推新功能。 +本示例基于意图框架,使用@kit.IntentsKit实现意图共享,使用@kit.AbilityKit提供的InsightIntentExecutor实现意图调用。配合端云一体化提供的云函数,云数据库实现云端数据访问。意图框架根据端侧意图共享的参数实现云测意图调用,完成端云结合的习惯推荐实现新闻推新功能。 ## 效果预览 | 新闻首页 | 新闻详情页 | 小艺卡片展示共享意图 | 点击意图卡片实现推新 | diff --git a/SETUP.md b/SETUP.md index c05bd26c9566b5a4527a0fa2b3a4ddace3d427b6..212e2ce56c2166af9f59786be5227db104321493 100644 --- a/SETUP.md +++ b/SETUP.md @@ -1,14 +1,14 @@ -# 基于意图框架推荐能力实现新闻推新端云一体化搭建 +# 基于意图框架习惯推荐能力实现新闻推新端云一体化环境搭建 ### 1. 简介 -基于意图推荐新闻推新涉及端云一体化开发,[开源代码](https://gitee.com/harmonyos_samples/IntentsKitNewsUpdate)包含客户端工程(Application文件)和服务端工程(CloudProgram文件)两部分,需要进行端云一体化配置从而体验完整的基于意图推荐新闻推新的功能,本文章将讲述基于意图推荐新闻推新端云一体化配置过程。 +基于意图框架习惯推荐能力实现新闻推新涉及端云一体化开发,[开源代码](https://gitee.com/harmonyos_samples/IntentsKitNewsUpdate)包含客户端工程(Application)和服务端工程(CloudProgram)两部分,需要进行端云一体化配置从而体验完整的基于意图框架习惯推荐能力实现新闻推新的功能,本文章将讲述基于意图框架习惯推荐能力实现新闻推新新端云一体化配置过程。 ### 2. 项目准备 1. 注册华为账号 - 基于意图推荐新闻推新端云一体化搭建依托于[AppGallery Connect(AGC)](https://developer.huawei.com/consumer/cn/service/josp/agc/index.html#/)平台,使用AGC平台需要前往[华为开发者联盟官网](https://developer.huawei.com/consumer/cn/)进行华为账号注册,并完成实名认证,具体请参见[注册账号](https://developer.huawei.com/consumer/cn/doc/start/registration-and-verification-0000001053628148)。如果您已经拥有华为账号,并已完成实名认证,可跳过本步骤。 + 基于意图框架习惯推荐能力实现新闻推新端云一体化搭建依托于[AppGallery Connect(AGC)](https://developer.huawei.com/consumer/cn/service/josp/agc/index.html#/)平台,使用AGC平台需要前往[华为开发者联盟官网](https://developer.huawei.com/consumer/cn/)进行华为账号注册,并完成实名认证,具体请参见[注册账号](https://developer.huawei.com/consumer/cn/doc/start/registration-and-verification-0000001053628148)。如果您已经拥有华为账号,并已完成实名认证,可跳过本步骤。 2. 项目打开 @@ -18,12 +18,12 @@ ### 3. AGC基本环境搭建 -基于意图推荐新闻推新端云一体化配置,首先需要在[AGC](https://developer.huawei.com/consumer/cn/service/josp/agc/index.html#/)中创建本应用,完成AGC配置,为服务端工程在云端实现提供基础。操作步骤如下: +基于意图框架习惯推荐能力实现新闻推新端云一体化配置,首先需要在[AGC](https://developer.huawei.com/consumer/cn/service/josp/agc/index.html#/)中创建本应用,完成AGC配置,为服务端工程在云端实现提供基础。操作步骤如下: 1. 登录[AGC](https://developer.huawei.com/consumer/cn/service/josp/agc/index.html#/)平台,点击“我的项目”,在项目页面中点击“添加项目”。 ![image](screenshots/cloud/add_project.PNG) -2. 在“创建项目”页面中输入项目名称后,本文章项目名称以“意图框架为例”为例,点击“创建并继续”。 +2. 在“创建项目”页面中输入项目名称后,本文章项目名称以“意图推荐”为例,点击“完成”。 ![image](screenshots/cloud/create_project.PNG) @@ -49,7 +49,7 @@ ![image](screenshots/cloud/add_apply3.PNG) -6. 选择“应用所属项目”为当前项目“基于意图推荐新闻推新”。并点击“确认”。 +6. 选择“应用所属项目”为当前项目“意图推荐”。并点击“确认”。 ![image](screenshots/cloud/add_apply4.PNG) @@ -57,7 +57,7 @@ ![image](screenshots/cloud/add_apply5.PNG) -8. 如果未开启以上开放能力,并已点击“确认”完成应用创建,可前往“我的项目”,在左侧导航栏选择“项目设置”,进入“项目设置”页面,点击“开放能力管理”打开对应开放能力。如果您已在第8步完成“定位服务”、“位置服务”、“地图服务”和“推送服务”开放能力打开,请跳过第8步,进行第10步及以后配置。 +8. 如果未开启以上开放能力,并已点击“确认”完成应用创建,可前往“我的项目”,在左侧导航栏选择“项目设置”,进入“项目设置”页面,点击“开放能力管理”打开对应开放能力。如果您已在第7步完成“定位服务”、“位置服务”、“地图服务”和“推送服务”等开放能力打开,请跳过第8步,进行第9步及以后配置。 ![image](screenshots/cloud/open_capabilities.PNG) @@ -70,11 +70,11 @@ ![image](screenshots/cloud/data_position.PNG) -至此,已完成基于意图推荐新闻推新AGC基本环境搭建。 +至此,已完成基于意图框架习惯推荐能力实现新闻推新AGC基本环境搭建。 ### 4. 客户端适配 -基于意图推荐新闻推新端云一体化配置,需要修改客户端项目中的部分配置,为端云一体化搭建提供基础。操作步骤如下: +基于意图框架习惯推荐能力实现新闻推新端云一体化配置,需要修改客户端项目中的部分配置,为端云一体化搭建提供基础。操作步骤如下: 1. 修改客户端Bundle name,打开客户端代码AppScope > app.json5,修改Bundle name为包名,与第3章第5步的包名保持一致,以“com.example.intentnewsrecommend”为例。 @@ -84,15 +84,15 @@ ![image](screenshots/client/auto_signature.jpg) -至此,已完成基于意图推荐新闻推新客户端适配。 +至此,已完成基于意图框架习惯推荐能力实现新闻推新客户端适配。 ### 5.服务端项目配置 -基于意图推荐新闻推新端云一体化配置,服务端需要配置信息与[AGC平台](https://developer.huawei.com/consumer/cn/service/josp/agc/index.html#/)链接。操作步骤如下: +基于意图框架习惯推荐能力实现新闻推新端云一体化配置,服务端需要配置信息与[AGC平台](https://developer.huawei.com/consumer/cn/service/josp/agc/index.html#/)链接。操作步骤如下: 1. 修改配置文件CloudProgram > cloud-config.json。 - 修改cloud-config.json中的appId、projectId和teamId为[AGC平台](https://developer.huawei.com/consumer/cn/service/josp/agc/index.html#/)创建基于意图推荐新闻推新“项目设置”中的对应信息。 + 修改cloud-config.json中的appId、projectName、projectId和teamId为[AGC平台](https://developer.huawei.com/consumer/cn/service/josp/agc/index.html#/)创建基于意图推荐新闻推新“项目设置”中的对应信息。 ![image](screenshots/cloud/cloud_config.PNG) @@ -178,7 +178,7 @@ e #### 6.2 API网关配置 -申请 API 网关用于后续开发云函数可以使用公网地址提供http(s)接口用于和意图框架云测意图对接 +申请 API 网关用于后续开发云函数可以使用公网地址提供http(s)接口用于和意图框架云测意图对接。 1. 申请 [API 网关](https://developer.huawei.com/consumer/cn/doc/AppGallery-connect-Guides/agc-apigateway-getstarted-0000001142214987) 白名单权限。 @@ -186,7 +186,7 @@ e 3. 选中API网关列,点击创建按钮,我们以IntentKitNewsUpdate为名创建一个API分组 ![](./screenshots/cloud/add_api_gateway1.png) -4. 当我们的云函数云测接口开发完成后,我们需要给云函数接口新增一个API网关触发器,我们可以回到云函数,选择我们开发好的云函数 `cloud-intent-search-news`,新建一个触发器,选择前面已经创建好的API网关触发器分组IntentKitNewsUpdate,配置API名称为searchBlog,路径配置为`/SearchBlog`,这个是固定的接口请求路径。请求方法为 POST,为例方便调试,我们这边选择免鉴权,发布环境改为生产环境,只有这样这个接口才可以被公网访问![](./screenshots/cloud/add_api_gateway2.png) +4. 当我们的云函数云测接口开发完成后,我们需要给云函数接口新增一个API网关触发器,我们可以回到云函数,选择我们开发好的云函数 `cloud-intent-search-news`,新建一个触发器,选择前面已经创建好的API网关触发器分组IntentKitNewsUpdate,配置API名称为searchBlog,路径配置为`/SearchBlog`,这个是固定的接口请求路径。请求方法为 POST,为了方便调试,我们这边选择免鉴权,发布环境改为生产环境,只有这样这个接口才可以被公网访问![](./screenshots/cloud/add_api_gateway2.png) 5. 然后我们就可以看到创建好的API网关触发器,我们把这个公网接口路径拷贝下来,参考[端云结合的习惯推荐接入流程](https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/intents-habit-rec-dp-self-validation#section85691847152810),并提供给对应的意图接口负责人帮我们完成云测接口配置即可。 ![](./screenshots/cloud/add_api_gateway3.png) @@ -199,6 +199,6 @@ e ![image](screenshots/cloud/log_service1.JPG) -2. 如需查看特定云函数的日志,请点击“增加过滤条件”,依次选择“function_name” > “等于”,并输入目标云函数的名称。例如,若需查看云函数“push-message”的日志,请在输入框中填写“push-message”,如下图所示。 +2. 如需查看特定云函数的日志,请点击“增加过滤条件”,依次选择“function_name” > “等于”,并输入目标云函数的名称。例如,若需查看云函数“id-generator”的日志,请在输入框中填写“id-generator”,如下图所示。 ![image](screenshots/cloud/log_service2.JPG) diff --git a/screenshots/cloud/cloud_config.PNG b/screenshots/cloud/cloud_config.PNG index 344eb1261b1ced48f8073cd93e6e052802ee287d..ed47505d37b64363d9de8ed5c4387921398677b0 100644 Binary files a/screenshots/cloud/cloud_config.PNG and b/screenshots/cloud/cloud_config.PNG differ