Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
yuzhilin
2024-05-17 14:19:27 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
dedcb70a37536822edbd16a1ebe239560f6fbcda
dedcb70a
1 parent
5eba3a8f
feat:意图框架事件推荐
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
153 additions
and
23 deletions
sight_harmony/features/wdComponent/src/main/ets/components/CardParser.ets
sight_harmony/features/wdComponent/src/main/ets/components/DynamicDetailComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/ImageAndTextPageComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/MultiPictureDetailPageComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/SpacialTopicPageComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/cardview/Card5Component.ets
sight_harmony/features/wdComponent/src/main/ets/utils/InsightIntentShare.ets
sight_harmony/products/phone/src/main/ets/utils/InsightIntentExecutorImpl.ets
sight_harmony/products/phone/src/main/resources/base/profile/insight_intent.json
sight_harmony/features/wdComponent/src/main/ets/components/CardParser.ets
View file @
dedcb70
...
...
@@ -44,7 +44,7 @@ export struct CardParser {
} else if (contentDTO.appStyle === CompStyle.Card_04) {
Card4Component({ compDTO: this.compDTO, contentDTO })
} else if (contentDTO.appStyle === CompStyle.Card_05) {
Card5Component({ contentDTO, titleShowPolicy: this.compDTO.titleShowPolicy
, compDTO: this.compDTO
})
Card5Component({ contentDTO, titleShowPolicy: this.compDTO.titleShowPolicy})
} else if (contentDTO.appStyle === CompStyle.Card_06 || contentDTO.appStyle === CompStyle
.Card_13) {
Card6Component({ compDTO: this.compDTO, contentDTO: this.contentDTO })
...
...
sight_harmony/features/wdComponent/src/main/ets/components/DynamicDetailComponent.ets
View file @
dedcb70
...
...
@@ -41,6 +41,8 @@ import { publishCommentModel } from './comment/model/PublishCommentModel';
import { CommentComponent } from './comment/view/CommentComponent';
import { EmptyComponent } from './view/EmptyComponent';
import { detailedSkeleton } from './skeleton/detailSkeleton';
import { viewBlogItemInsightIntentShare } from '../utils/InsightIntentShare'
import { common } from '@kit.AbilityKit';
const TAG = 'DynamicDetailComponent'
const PATTERN_DATE_CN_RN: string = 'yyyy年MM月dd日 HH:mm';
...
...
@@ -602,6 +604,7 @@ export struct DynamicDetailComponent {
this.getInteractDataStatus()
this.makeJumpInfo()
this.interactDataV2()
this.viewBlogInsightIntentShare()
}
private async interactDataV2() {
...
...
@@ -761,6 +764,14 @@ export struct DynamicDetailComponent {
console.log('点赞、取消点赞==', this.newsStatusOfUser?.likeStatus, this.interactDataDTO?.likeNum)
})
}
/**
* 意图上报
*/
private viewBlogInsightIntentShare(){
let context = getContext(this) as common.UIAbilityContext;
viewBlogItemInsightIntentShare(context,this.contentDetailData, this.interactDataDTO)
}
}
interface radiusType {
...
...
sight_harmony/features/wdComponent/src/main/ets/components/ImageAndTextPageComponent.ets
View file @
dedcb70
...
...
@@ -31,6 +31,8 @@ import { publishCommentModel } from '../components/comment/model/PublishCommentM
import { EmptyComponent } from '../components/view/EmptyComponent';
import { CommentComponent } from '../components/comment/view/CommentComponent'
import { HttpUtils } from 'wdNetwork/Index';
import { viewBlogItemInsightIntentShare } from '../utils/InsightIntentShare'
import { common } from '@kit.AbilityKit';
const PATTERN_DATE_CN_RN: string = 'yyyy年MM月dd日 HH:mm';
...
...
@@ -56,7 +58,6 @@ export struct ImageAndTextPageComponent {
@State likeNum: number = 0
@State reachEndIncreament: number = 0
@State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0
build() {
Stack({ alignContent: Alignment.Top }) {
Stack({ alignContent: Alignment.Bottom }) {
...
...
@@ -261,10 +262,20 @@ export struct ImageAndTextPageComponent {
} else {
this.operationButtonList = ['comment', 'collect', 'share']
}
//意图上报
this.viewBlogInsightIntentShare()
}
}
}
//意图上报
private viewBlogInsightIntentShare(){
let context = getContext(this) as common.UIAbilityContext;
viewBlogItemInsightIntentShare(context,this.contentDetailData, this.interactData)
}
private async getRecommend() {
let params: postRecommendListParams = {
imei: HttpUtils.getImei(),
...
...
@@ -341,6 +352,7 @@ export struct ImageAndTextPageComponent {
}
PageRepository.getContentInteract(params).then(res => {
if (res.data) {
this.interactData = res.data[0]
this.likeNum = Number(res.data[0]?.likeNum) || 0
}
})
...
...
sight_harmony/features/wdComponent/src/main/ets/components/MultiPictureDetailPageComponent.ets
View file @
dedcb70
...
...
@@ -22,6 +22,8 @@ import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
import { PageRepository } from '../repository/PageRepository';
import { SpConstants } from 'wdConstant/Index';
import { router } from '@kit.ArkUI';
import { viewBlogItemInsightIntentShare } from '../utils/InsightIntentShare'
import { common } from '@kit.AbilityKit';
const TAG = 'MultiPictureDetailPageComponent';
...
...
@@ -467,6 +469,7 @@ export struct MultiPictureDetailPageComponent {
this.getInteractBrowsOperate()
this.getBatchAttentionStatus()
}
this.viewBlogInsightIntentShare()
})
.catch((err: Error) => {
Logger.info(TAG, `fetchDetailData then,err: ${JSON.stringify(err)}`);
...
...
@@ -544,4 +547,12 @@ export struct MultiPictureDetailPageComponent {
}
})
}
/**
* 意图上报
*/
private viewBlogInsightIntentShare(){
let context = getContext(this) as common.UIAbilityContext;
viewBlogItemInsightIntentShare(context,this.contentDetailData)
}
}
\ No newline at end of file
...
...
sight_harmony/features/wdComponent/src/main/ets/components/SpacialTopicPageComponent.ets
View file @
dedcb70
...
...
@@ -10,6 +10,8 @@ import DetailViewModel from '../viewmodel/DetailViewModel';
import { publishCommentModel } from '../components/comment/model/PublishCommentModel';
import { EmptyComponent } from '../components/view/EmptyComponent';
import { NetworkUtil, WindowModel } from 'wdKit';
import { viewBlogItemInsightIntentShare } from '../utils/InsightIntentShare'
import { common } from '@kit.AbilityKit';
const TAG: string = 'SpacialTopicPageComponent'
...
...
@@ -49,6 +51,12 @@ export struct SpacialTopicPageComponent {
})
}
//意图上报
private viewBlogInsightIntentShare(){
let context = getContext(this) as common.UIAbilityContext;
viewBlogItemInsightIntentShare(context,this.contentDetailData)
}
private async getDetail() {
this.isNetConnected = NetworkUtil.isNetConnected()
...
...
@@ -71,6 +79,7 @@ export struct SpacialTopicPageComponent {
let detailBeans = await DetailViewModel.getDetailPageData(relId, contentId, relType)
if (detailBeans && detailBeans.length > 0) {
this.contentDetailData = detailBeans[0];
this.viewBlogInsightIntentShare()
// if (this.contentDetailData[0]?.openComment) {
this.publishCommentModel.targetId = String(this.contentDetailData?.newsId || '')
this.publishCommentModel.targetRelId = String(this.contentDetailData?.reLInfo?.relId || '')
...
...
sight_harmony/features/wdComponent/src/main/ets/components/cardview/Card5Component.ets
View file @
dedcb70
...
...
@@ -3,8 +3,6 @@ import { CommonConstants } from 'wdConstant';
import { ProcessUtils } from 'wdRouter';
import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
import { Notes } from './notes';
import { viewBlogInsightIntentShare, ActionMode } from '../../utils/InsightIntentShare'
import { common } from '@kit.AbilityKit';
const TAG: string = 'Card5Component';
...
...
@@ -15,7 +13,6 @@ const TAG: string = 'Card5Component';
export struct Card5Component {
@State contentDTO: ContentDTO = new ContentDTO();
@Prop titleShowPolicy: number | string
@Prop compDTO: CompDTO = {} as CompDTO
@State loadImg: boolean = false;
@State clicked: boolean = false;
@State titleMarked: boolean = false;
...
...
@@ -100,8 +97,6 @@ export struct Card5Component {
.onClick((event: ClickEvent) => {
this.clicked = true;
ProcessUtils.processPage(this.contentDTO)
let context = getContext(this) as common.UIAbilityContext;
viewBlogInsightIntentShare(context, this.contentDTO?.channelId, [this.compDTO], ActionMode.EXECUTED)
})
}
...
...
sight_harmony/features/wdComponent/src/main/ets/utils/InsightIntentShare.ets
View file @
dedcb70
import { common } from '@kit.AbilityKit';
import { insightIntent } from '@kit.IntentsKit';
import { BusinessError } from '@kit.BasicServicesKit';
import { CompDTO, CompList, ContentDTO, PageInfoBean } from 'wdBean';
import { CompDTO, CompList, ContentDTO, PageInfoBean
, ContentDetailDTO, InteractDataDTO
} from 'wdBean';
function generateUUID() {
let dt = new Date().getTime(); // 获取当前时间的时间戳(毫秒)
...
...
@@ -82,12 +82,58 @@ export function viewBlogInsightIntentShare(context: common.UIAbilityContext, ent
}
}
//ViewBlog意图共享-节目详情 目前单独在详情页上报
export function viewBlogItemInsightIntentShare(context: common.UIAbilityContext, item: ContentDetailDTO,
interactData?: InteractDataDTO) {
let identifier = generateUUID()
let viewBlogInsightIntentItem: insightIntent.InsightIntent = {
intentName: 'ViewBlog',
intentVersion: '1.0.1',
identifier,
intentActionInfo: {
actionMode: ActionMode.EXECUTED,
currentPercentage: 50,
},
intentEntityInfo: {
entityName: 'Blog',
entityId: String(item?.newsId),
displayName: item?.newsTitle,
entityGroupId: String(item?.reLInfo?.channelId), //channelId
logoURL: item.fullColumnImgUrls.length > 0 ? item.fullColumnImgUrls[0]?.url : item.firstFrameImageUri,
metadataModificationTime: item?.publishTime,
blogTitle: item?.newsTitle,
blogType: 'Normal',
blogCategory: item,
categoryDisplayName: '', //TODO 分类名称
blogSubTitle: item?.newsSummary.length > 20 ?
item?.newsSummary.substring(0, 20) : item?.newsSummary,
blogAuthor: item?.newsSourceName,
blogPublishTime: item?.publishTime,
tag: item?.newsTags.split(','),
viewCount: item?.viewCount || 0,
likeCount: interactData?.likeNum || 0,
forwardCount: interactData?.shareNum || 0,
commentCount: interactData?.commentNum || 0,
favorites: interactData?.collectNum || 0,
rankingHint: 99,
isPublicData: true
}
}
//ViewBlog意图共享-早晚报
console.log('yzl', JSON.stringify(viewBlogInsightIntentItem))
// 共享数据
insightIntent.shareIntent(context, [viewBlogInsightIntentItem]).then(() => {
console.log('yzl shareIntent success');
}).catch((err: BusinessError) => {
console.error(`yzl failed because ${err?.message}`);
});
}
//ViewColumn意图共享-早晚报
export function viewColumInsightIntentShare(context: common.UIAbilityContext, entityId: string,
pageInfoBean: PageInfoBean) {
console.log('viewColumInsightIntentShare')
let view
Blog
InsightIntentItem: insightIntent.InsightIntent = {
let view
Colum
InsightIntentItem: insightIntent.InsightIntent = {
intentName: 'ViewColumn',
intentVersion: '1.0.1',
identifier: generateUUID(),
...
...
@@ -108,10 +154,10 @@ export function viewColumInsightIntentShare(context: common.UIAbilityContext, en
isPublicData: true
}
}
console.log('yzl viewColumInsightIntentShare', JSON.stringify(view
Blog
InsightIntentItem))
console.log('yzl viewColumInsightIntentShare', JSON.stringify(view
Colum
InsightIntentItem))
// 共享数据
insightIntent.shareIntent(context, [view
Blog
InsightIntentItem]).then(() => {
insightIntent.shareIntent(context, [view
Colum
InsightIntentItem]).then(() => {
console.log('yzl shareIntent success');
}).catch((err: BusinessError) => {
console.error(`yzl failed because ${err?.message}`);
...
...
sight_harmony/products/phone/src/main/ets/utils/InsightIntentExecutorImpl.ets
View file @
dedcb70
import { insightIntent, InsightIntentExecutor } from '@kit.AbilityKit';
import { window } from '@kit.ArkUI';
import { BusinessError } from '@kit.BasicServicesKit';
import { ProcessUtils } from 'wdRouter';
/**
* 意图调用
*/
export default class InsightIntentExecutorImpl extends InsightIntentExecutor {
private static readonly ViewColumn = 'ViewColumn';
private static readonly ViewBlog = 'ViewBlog';
private static readonly ViewColumnUpdate = 'ViewColumnUpdate';
/**
* override 执行前台UIAbility意图
*
...
...
@@ -17,10 +19,13 @@ export default class InsightIntentExecutorImpl extends InsightIntentExecutor {
*/
onExecuteInUIAbilityForegroundMode(name: string, param: Record<string, Object>, pageLoader: window.WindowStage):
Promise<insightIntent.ExecuteResult> {
console.log('yzl onExecuteInUIAbilityForegroundMode',name,JSON.stringify(param))
// 根据意图名称分发处理逻辑
switch (name) {
case InsightIntentExecutorImpl.ViewColumn:
return this.jumpToView(param, pageLoader);
case InsightIntentExecutorImpl.ViewBlog:
return this.jumpToViewBlog(param, pageLoader);
case InsightIntentExecutorImpl.ViewColumnUpdate:
return this.jumpToViewColumnUpdate(param, pageLoader);
default:
break;
}
...
...
@@ -32,18 +37,47 @@ export default class InsightIntentExecutorImpl extends InsightIntentExecutor {
} as insightIntent.ExecuteResult)
}
/**
* 实现跳转新闻页面功能
*
* 实现习惯推荐功能
* @param param 意图参数
* @param pageLoader 窗口
*/
private jumpToView(param: Record<string, Object>, pageLoader: window.WindowStage): Promise<insightIntent.ExecuteResult> {
private jumpToViewBlog(param: Record<string, Object>, pageLoader: window.WindowStage): Promise<insightIntent.ExecuteResult> {
console.log('yzl jumpToView',JSON.stringify(param))
return new Promise((resolve, reject) => {
// TODO 实现意图调用,loadContent的入参为歌曲落地页路径,例如:pages/SongPage
pageLoader.loadContent('pages/MainPage')
.then(() => {
let entityId: string = (param.items as Array<object>)?.[0]?.['entityId'];
// TODO 调用成功的情况,此处可以打印日志
let entityGroupId: string = (param.items as Array<object>)?.[0]?.['entityGroupId'];
ProcessUtils.jumpChannelTab(entityGroupId,'')
resolve({
code: 0,
result: {
message: 'Intent execute success'
}
});
})
.catch((err: BusinessError) => {
resolve({
code: -1,
result: {
message: 'Intent execute failed'
}
})
});
})
}
/**
* 实现事件推荐功能
* @param param 意图参数
* @param pageLoader 窗口
*/
private jumpToViewColumnUpdate(param: Record<string, Object>, pageLoader: window.WindowStage): Promise<insightIntent.ExecuteResult> {
console.log('yzl jumpToViewColum',JSON.stringify(param))
return new Promise((resolve, reject) => {
pageLoader.loadContent('pages/MainPage')
.then(() => {
// TODO 事件推荐调用
resolve({
code: 0,
result: {
...
...
@@ -52,7 +86,6 @@ export default class InsightIntentExecutorImpl extends InsightIntentExecutor {
});
})
.catch((err: BusinessError) => {
// TODO 调用失败的情况
resolve({
code: -1,
result: {
...
...
sight_harmony/products/phone/src/main/resources/base/profile/insight_intent.json
View file @
dedcb70
{
"insightIntents"
:
[
{
"intentName"
:
"ViewColumn"
,
"intentName"
:
"ViewBlog"
,
"domain"
:
""
,
"intentVersion"
:
"1.0.1"
,
"srcEntry"
:
"./ets/utils/InsightIntentExecutorImpl.ets"
,
"uiAbility"
:
{
"ability"
:
"EntryAbility"
,
"executeMode"
:
[
"background"
,
"foreground"
]
}
},
{
"intentName"
:
"ViewColumnUpdate"
,
"domain"
:
""
,
"intentVersion"
:
"1.0.1"
,
"srcEntry"
:
"./ets/utils/InsightIntentExecutorImpl.ets"
,
...
...
Please
register
or
login
to post a comment