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
陈剑华
2024-09-27 19:07:47 +0800
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
2e87101bf3f6eae3f958668ebac6dd3586eceaea
2e87101b
2 parents
bc235eca
ab44c1a0
Merge remote-tracking branch 'origin/main'
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
260 additions
and
44 deletions
sight_harmony/commons/wdConstant/src/main/ets/constants/SpConstants.ets
sight_harmony/commons/wdKit/src/main/ets/utils/FileUtils.ets
sight_harmony/commons/wdNetwork/src/main/ets/utils/HttpUtils.ets
sight_harmony/features/wdComponent/src/main/ets/components/H5NewsWebPageComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/ImageAndTextPageComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/view/OperRowListView.ets
sight_harmony/features/wdDetailPlayLive/src/main/ets/pages/DetailPlayVLivePage.ets
sight_harmony/features/wdDetailPlayLive/src/main/ets/viewModel/LiveDetailPageLogic.ets
sight_harmony/features/wdDetailPlayLive/src/main/ets/widgets/vertical/PlayerComponent.ets
sight_harmony/features/wdDetailPlayLive/src/main/ets/widgets/vertical/PlayerUIComponent.ets
sight_harmony/features/wdDetailPlayLive/src/main/ets/widgets/vertical/PlayerVideoControlComponent.ets
sight_harmony/features/wdDetailPlayShortVideo/src/main/ets/view/OperationListView.ets
sight_harmony/features/wdDetailPlayShortVideo/src/main/ets/view/PlayerRightView.ets
sight_harmony/products/phone/src/main/ets/pages/launchPage/LaunchPage.ets
sight_harmony/products/phone/src/main/ets/pages/viewModel/LaunchPageModel.ets
sight_harmony/products/phone/src/main/ets/pages/web/H5TipsPage.ets
sight_harmony/products/phone/src/main/ets/pages/web/WebPageJumpInterceptor.ets
sight_harmony/products/phone/src/main/ets/startupmanager/StartupManager.ets
sight_harmony/commons/wdConstant/src/main/ets/constants/SpConstants.ets
View file @
2e87101
...
...
@@ -66,4 +66,10 @@ export class SpConstants{
static GETUI_PUSH_DEVICE_TOKEN = "deviceToken"
//link
static HAS_LINK="has_link"
// 是否开启H5白名单
static H5_WHITE_LIST_ENABLE ="h5_whilte_list_enable"
static H5_WHITE_LIST_LAST_DATA_MD5 ="h5_whilte_list_last_data_md5"
}
\ No newline at end of file
...
...
sight_harmony/commons/wdKit/src/main/ets/utils/FileUtils.ets
View file @
2e87101
import fs from '@ohos.file.fs';
import { BusinessError } from '@kit.BasicServicesKit';
import { util } from '@kit.ArkTS';
export class FileUtils {
...
...
@@ -31,4 +32,26 @@ export class FileUtils {
})
})
}
static readFile(path: string): ArrayBuffer {
try {
let stat = fs.statSync(path)
let fd = fs.openSync(path, fs.OpenMode.READ_ONLY).fd;
let length = stat.size
let buf = new ArrayBuffer(length);
fs.readSync(fd, buf)
fs.closeSync(fd)
return buf
} catch (e) {
console.log("FileUtils - readFilePicSync " + e)
return new ArrayBuffer(0)
}
}
static readFileAsString(path: string): string {
const data = FileUtils.readFile(path)
let decoder = util.TextDecoder.create('utf-8');
let str = decoder.decodeToString(new Uint8Array(data));
return str
}
}
\ No newline at end of file
...
...
sight_harmony/commons/wdNetwork/src/main/ets/utils/HttpUtils.ets
View file @
2e87101
import { SpConstants } from 'wdConstant/Index';
import { DeviceUtil, SPHelper, StringUtils } from 'wdKit/Index';
import { DeviceUtil,
Logger,
SPHelper, StringUtils } from 'wdKit/Index';
import { HttpRequest } from '../http/HttpRequest';
import { http } from '@kit.NetworkKit';
import fs from '@ohos.file.fs';
import { BusinessError } from '@kit.BasicServicesKit';
import { JSON } from '@kit.ArkTS';
const TAG: string = '[HttpUtils]'
...
...
@@ -81,4 +85,37 @@ export class HttpUtils {
}
return true
}
static downloadUrlToPathWithout(url: string, toFilePath: string): Promise<boolean> {
Logger.debug(TAG, "will donwload url:" + url + " ======> " + toFilePath);
return new Promise((reslove, fail) => {
let httpRequest = http.createHttp()
httpRequest.request(url, (err, data) => {
if (!err && data.responseCode == http.ResponseCode.OK) {
let imgFile = fs.openSync(toFilePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
let wroteLength = 0
fs.write(imgFile.fd, data.result as ArrayBuffer).then((writeLen: number) => {
Logger.debug(TAG, "write data to file succeed and size is:" + writeLen);
wroteLength = writeLen
}).catch((err: BusinessError) => {
Logger.error(TAG, "write data to file failed with error message: " + err.message + ", error code: " + err.code);
}).finally(() => {
fs.closeSync(imgFile);
httpRequest.destroy()
reslove(wroteLength > 0)
});
return
}
Logger.error(TAG, "download failed " + JSON.stringify(err));
httpRequest.destroy()
fail("failed")
});
})
}
}
\ No newline at end of file
...
...
sight_harmony/features/wdComponent/src/main/ets/components/H5NewsWebPageComponent.ets
View file @
2e87101
...
...
@@ -258,7 +258,10 @@ export struct H5NewsWebPageComponent {
// 初次进入详情页偶现获取失败,重新获取newsStatusOfUser对象
this.getInteractDataStatus()
}
}).catch((error:Error) =>{
ToastUtils.showToast(error.message, 1000);
})
}
/**
...
...
sight_harmony/features/wdComponent/src/main/ets/components/ImageAndTextPageComponent.ets
View file @
2e87101
...
...
@@ -465,7 +465,10 @@ export struct ImageAndTextPageComponent {
// 初次进入详情页偶现获取失败,重新获取newsStatusOfUser对象
this.getInteractDataStatus()
}
}).catch((error:Error) =>{
ToastUtils.showToast(error.message, 1000);
})
}
/**
...
...
sight_harmony/features/wdComponent/src/main/ets/components/view/OperRowListView.ets
View file @
2e87101
...
...
@@ -537,6 +537,8 @@ export struct OperRowListView {
this.queryContentInteractCount()
}
console.log(TAG, '收藏点击 this.newsStatusOfUser', JSON.stringify(this.newsStatusOfUser))
}).catch((error:Error) =>{
ToastUtils.showToast(error.message, 1000);
})
}
...
...
sight_harmony/features/wdDetailPlayLive/src/main/ets/pages/DetailPlayVLivePage.ets
View file @
2e87101
...
...
@@ -51,6 +51,8 @@ export struct DetailPlayVLivePage {
@State toastText: ResourceStr = "这是一个非Wi-Fi环境。请注意流量消耗"
chatRoomController: LiveDetailChatRoomController = new LiveDetailChatRoomController()
@Provide banComment: boolean = true
/// null 直播流画面类型未知,0 横屏流,1 竖屏流,后台选择画面时,以选择的为准
@Provide isVerticalStream: boolean | null = this.liveDetailPageLogic.dealLiveStreamType()
dialogToast: CustomDialogController = new CustomDialogController({
builder: CustomToast({
...
...
sight_harmony/features/wdDetailPlayLive/src/main/ets/viewModel/LiveDetailPageLogic.ets
View file @
2e87101
...
...
@@ -109,4 +109,20 @@ export class LiveDetailPageLogic {
return false
}
dealLiveStreamType(): boolean | null {
if (this.contentDetailData.liveInfo.vlive && this.contentDetailData.liveInfo.vlive.count > 0) {
const liveStreamType: number | null = this.contentDetailData.liveInfo.vlive[0].liveStreamType
if (liveStreamType == null) { ///直播流画面类型位置
return null
}
if (liveStreamType == 1) { ///后台选择的竖屏流
return true
}
if (liveStreamType == 0) { ///后台选择的横屏流
return false
}
}
return true
}
}
\ No newline at end of file
...
...
sight_harmony/features/wdDetailPlayLive/src/main/ets/widgets/vertical/PlayerComponent.ets
View file @
2e87101
...
...
@@ -27,6 +27,7 @@ export struct PlayerComponent {
@Link isPlayerError: boolean
@Link isCanplay: boolean
@State isLarge:boolean = false
@Consume isVerticalStream: boolean
pageShowChange() {
this.playerController?.play()
}
...
...
@@ -54,13 +55,15 @@ export struct PlayerComponent {
}
this.playerController.onVideoSizePlayerComponentBack = (width: number, height: number) => {
if(width>height){
if (this.isVerticalStream != null) {
return
}
if (width > height) {
this.isLarge = false
if(width > 2){
this.liveStreamType = 0
}
}else{
}else {
this.isLarge = true
this.liveStreamType = 1
}
}
}
...
...
sight_harmony/features/wdDetailPlayLive/src/main/ets/widgets/vertical/PlayerUIComponent.ets
View file @
2e87101
...
...
@@ -17,6 +17,7 @@ export struct PlayerUIComponent {
@Consume isFullScreen: boolean
@Consume displayDirection: DisplayDirection
@State isPlayStatus: boolean = true;
@Consume isVerticalStream: boolean | null
onChangeMenuVisible() {
if (this.displayDirection == DisplayDirection.VERTICAL
|| !this.isShowControl
...
...
@@ -38,6 +39,10 @@ export struct PlayerUIComponent {
return
}
this.playerController.onVideoSizePlayerUIComponentMethod = (width: number, height: number) => {
if (this.isVerticalStream != null) {
this.isSmall = this.isVerticalStream == false
return
}
if (width > height){
this.isSmall = true
} else {
...
...
sight_harmony/features/wdDetailPlayLive/src/main/ets/widgets/vertical/PlayerVideoControlComponent.ets
View file @
2e87101
...
...
@@ -16,7 +16,6 @@ export struct PlayerVideoControlComponent {
@Link isPlayStatus?: boolean
@Consume displayDirection: DisplayDirection
@Consume contentDetailData: ContentDetailDTO
@Consume isSmall:boolean
@Consume isFullScreen: boolean
@State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0
aboutToAppear(): void {
...
...
@@ -61,37 +60,6 @@ export struct PlayerVideoControlComponent {
right: 16
})
}
//全屏按钮
// if(!this.isSmall) {
// Image($r('app.media.icon_live_player_full_screen'))
// .height(32)
// .width(32)
// .padding(5)
// .borderRadius($r('app.float.vp_16'))
// .border({width:0.5})
// .borderColor(0x4DFFFFFF)
// .backgroundColor(0x4D222222)
// .margin({right:10})
// .onClick(() => {
// WindowModel.shared.setSpecificSystemBarEnabled(false)
// this.displayDirection = DisplayDirection.VIDEO_HORIZONTAL
// WindowModel.shared.setPreferredOrientation(
// window.Orientation.LANDSCAPE)
// if(this.playerController){
// // if(this.playerController.onVideoSizePlayerUIComponentMethod){
// // this.playerController.onVideoSizePlayerUIComponentMethod(1,2)
// // }
// if(this.playerController.onVideoSizePlayerComponentBack){
// this.playerController.onVideoSizePlayerComponentBack(1,2)
// }
//
// if(this.playerController.onVideoSizePlayerTitleComponentBack){
// this.playerController.onVideoSizePlayerTitleComponentBack(1,2)
// }
// }
// this.isFullScreen = true
// })
// }
}
.alignItems(VerticalAlign.Center)
// .linearGradient({ angle: 0, colors: [['#99000000', 0], ['#00000000', 1]] })
...
...
sight_harmony/features/wdDetailPlayShortVideo/src/main/ets/view/OperationListView.ets
View file @
2e87101
...
...
@@ -90,7 +90,10 @@ export struct OperationListView {
// console.log('点赞、取消点赞==', this.newsStatusOfUser?.likeStatus, this.interactData?.likeNum)
// this.queryContentInteractCount()
}
}).catch((error:Error) =>{
ToastUtils.showToast(error.message, 1000);
})
}
/**
...
...
@@ -124,8 +127,11 @@ export struct OperationListView {
}
// console.log('收藏、取消收藏==', this.newsStatusOfUser?.collectStatus, this.interactData?.collectNum)
}
}).catch((error:Error) =>{
ToastUtils.showToast(error.message, 1000);
})
}
/**
...
...
sight_harmony/features/wdDetailPlayShortVideo/src/main/ets/view/PlayerRightView.ets
View file @
2e87101
...
...
@@ -114,7 +114,10 @@ export struct PlayerRightView {
// this.queryContentInteractCount()
}
}).catch((error:Error) =>{
ToastUtils.showToast(error.message, 1000);
})
}
/**
...
...
@@ -152,8 +155,11 @@ export struct PlayerRightView {
}
// console.log(TAG, '收藏、取消收藏==', this.newsStatusOfUser?.collectStatus, this.interactData?.collectNum)
}
}).catch((error:Error) =>{
ToastUtils.showToast(error.message, 1000);
})
}
/**
...
...
sight_harmony/products/phone/src/main/ets/pages/launchPage/LaunchPage.ets
View file @
2e87101
...
...
@@ -114,6 +114,9 @@ struct LaunchPage {
if (!dataModelStr) {
//直接跳转首页
WDRouterRule.jumpWithReplacePage(WDRouterPage.mainPage)
//同意隐私协议后每次启动app请求启动页相关数据,并更新数据
this.requestLaunchPageData();
return
}
...
...
sight_harmony/products/phone/src/main/ets/pages/viewModel/LaunchPageModel.ets
View file @
2e87101
...
...
@@ -2,22 +2,26 @@
import LaunchDataModel from '../viewModel/LaunchDataModel'
import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest';
import { HttpUrlUtils, ResponseDTO } from 'wdNetwork/Index';
import { DisplayUtils, Logger, SPHelper } from 'wdKit/Index';
import { HttpUrlUtils, HttpUtils, ResponseDTO } from 'wdNetwork/Index';
import { AppUtils, DisplayUtils, Logger, SPHelper } from 'wdKit/Index';
import { SpConstants } from 'wdConstant/Index';
import { FileUtils } from '@ohos/imageknife';
export class LaunchPageModel {
getLaunchPageData(): Promise<LaunchDataModel> {
return new Promise<LaunchDataModel>((success, fail) => {
HttpRequest.get<ResponseDTO<LaunchDataModel>>(HttpUrlUtils.getLaunchPageDataUrl()+ `?height=${DisplayUtils.getDeviceHeight()}&width=${DisplayUtils.getDeviceWidth()}`).then((data: ResponseDTO<LaunchDataModel>) => {
HttpRequest.get<ResponseDTO<LaunchDataModel>>(HttpUrlUtils.getLaunchPageDataUrl()+ `?height=${DisplayUtils.getDeviceHeight()}&width=${DisplayUtils.getDeviceWidth()}`)
.then(async (data: ResponseDTO<LaunchDataModel>) => {
if (!data || !data.data) {
fail("数据为空")
LaunchPageModel.dealWithLaunchDataModel()
return
}
if (data.code != 0) {
fail(data.message)
LaunchPageModel.dealWithLaunchDataModel()
return
}
// Logger.debug("LaunchPageModel获取启动相关数据获取成功:success ", JSON.stringify(data))
...
...
@@ -27,6 +31,8 @@ export class LaunchPageModel {
// console.log(obj)
SPHelper.default.saveSync(SpConstants.APP_LAUNCH_PAGE_DATA_MODEL,obj)
LaunchPageModel.dealWithLaunchDataModel(data.data)
}, (error: Error) => {
// Logger.debug("LaunchPageModel获取启动相关数据获取失败:error ", error.toString())
fail(error.message)
...
...
@@ -34,6 +40,47 @@ export class LaunchPageModel {
})
}
static async dealWithLaunchDataModel(model?: LaunchDataModel) {
if (!model) {
let dataModelStr = SPHelper.default.getSync(SpConstants.APP_LAUNCH_PAGE_DATA_MODEL, '') as string
model = JSON.parse(dataModelStr ?? "")
if (!model) { return }
}
LaunchPageModel.dealWithWhiteListWith(model)
// TODO: others
}
static async dealWithWhiteListWith(model: LaunchDataModel) {
SPHelper.default.saveSync(SpConstants.H5_WHITE_LIST_ENABLE, model.operationUrl.enabled)
const lastMD5 = SPHelper.default.getSync(SpConstants.H5_WHITE_LIST_LAST_DATA_MD5, "") as string
if (lastMD5 && lastMD5 == model.operationUrl.md5) {
// MD5未变更,保持已下载的白名单
if (AppUtils.gotApplicationContextFunc) {
let filePath = AppUtils.gotApplicationContextFunc().getApplicationContext().filesDir + "/h5_whitelist.txt"
if (FileUtils.getInstance().exist(filePath)) {
return
}
}
}
if (!AppUtils.gotApplicationContextFunc) {
return
}
let filePath = AppUtils.gotApplicationContextFunc().getApplicationContext().filesDir + "/h5_whitelist.txt"
const result = await HttpUtils.downloadUrlToPathWithout(model.operationUrl.linkUrl, filePath)
if (result) {
SPHelper.default.saveSync(SpConstants.H5_WHITE_LIST_LAST_DATA_MD5, model.operationUrl.md5 ?? "")
}
}
getMournsInfoData(): Promise<LaunchDataModel> {
return new Promise<LaunchDataModel>((success, fail) => {
HttpRequest.get<ResponseDTO<LaunchDataModel>>(HttpUrlUtils.getLaunchPageDataUrl()).then((data: ResponseDTO<LaunchDataModel>) => {
...
...
sight_harmony/products/phone/src/main/ets/pages/web/H5TipsPage.ets
View file @
2e87101
...
...
@@ -62,10 +62,8 @@ struct H5TipsPage {
// 获取系统剪贴板对象
let systemPasteboard = pasteboard.getSystemPasteboard();
// 创建一条纯文本类型的剪贴板内容对象createPlainTextData
let pasteData = pasteboard.createPlainTextData(this.webUrl);
pasteData.addTextRecord(this.webUrl);
// 将数据写入系统剪贴板
let pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, this.webUrl)
// // 将数据写入系统剪贴板
systemPasteboard.setData(pasteData).then(()=>{
// 存入成功,处理正常场景
ToastUtils.shortToast('复制成功')
...
...
sight_harmony/products/phone/src/main/ets/pages/web/WebPageJumpInterceptor.ets
0 → 100644
View file @
2e87101
import { FileUtils as imageFileUtils } from '@ohos/imageknife'
import { Action } from 'wdBean'
import { AppUtils, FileUtils, SPHelper } from 'wdKit'
import { JumpInterceptorAction, RouterJumpInterceptor, WDRouterPage } from 'wdRouter'
import { JSON, uri } from '@kit.ArkTS'
import { SpConstants } from 'wdConstant'
import { router } from '@kit.ArkUI'
interface WhiteListModel {
whiteurls: string[]
}
class DefaultWebJumpHandler implements JumpInterceptorAction {
/// 说明是调用了跳转 WDRouterPage.loginPage 页面的行为
on(params?: object | undefined, singleMode?: boolean | undefined): boolean {
let action = params as Action
if (action.params?.url) {
const whiteListEnable = SPHelper.default.getSync(SpConstants.H5_WHITE_LIST_ENABLE, false) as boolean
if (!whiteListEnable) {
return false
}
const jumpHost = new uri.URI(action.params?.url).host
const list = this.configWhiteLists()
list.push(...this.localWhiteLists())
const inWhilteList = list.filter((host) => {
return host == jumpHost
}).length > 0
if (false == inWhilteList) {
router.pushUrl({url: WDRouterPage.h5TipsPage.url(), params: action.params})
return true
}
}
return false
}
configWhiteLists() : string[] {
let list : string[] = []
if (!AppUtils.gotApplicationContextFunc) {
return list
}
let filePath = AppUtils.gotApplicationContextFunc().getApplicationContext().filesDir + "/h5_whitelist.txt"
const jsonStr = FileUtils.readFileAsString(filePath)
const listObj = JSON.parse(jsonStr) as WhiteListModel
if (listObj && listObj.whiteurls && listObj.whiteurls.length) {
const urls = listObj.whiteurls.map((obj) => {
if (obj.startsWith("http")) {
return new uri.URI(obj).host
}
return new uri.URI("https://" + obj).host
})
list.push(...urls)
}
return list
}
localWhiteLists() : string[] {
const list = [
"https://cdnpeoplefrontdev.aikan.pdnews.cn",
"https://cdnpeoplefrontsit.aikan.pdnews.cn",
"https://cdnpeoplefrontuat.aikan.pdnews.cn",
"https://cdnpeoplefront.aikan.pdnews.cn",
"https://pd-people-uat.pdnews.cn",
"https://pd-people-sit.pdnews.cn",
"https://pd-people-dev.pdnews.cn",
"https://www.peopleapp.com",
"https://h5.peopleapp.com"
]
return list.map((url) => {
return new uri.URI(url).host
})
}
}
export function registerDefaultWebJumpInterceptor() {
RouterJumpInterceptor.register(WDRouterPage.defaultWebPage, new DefaultWebJumpHandler())
RouterJumpInterceptor.register(WDRouterPage.h5NewsWebPage, new DefaultWebJumpHandler())
}
...
...
sight_harmony/products/phone/src/main/ets/startupmanager/StartupManager.ets
View file @
2e87101
...
...
@@ -27,6 +27,7 @@ import { initGlobalPlayerSettings } from 'wdPlayer/src/main/ets/utils/GlobalSett
import { BackgroundAudioController } from 'wdPlayer/Index'
import { SpConstants } from 'wdConstant'
import { WDShareBase } from 'wdShareBase/Index';
import { registerDefaultWebJumpInterceptor } from '../pages/web/WebPageJumpInterceptor'
const TAG = "[StartupManager]"
...
...
@@ -59,6 +60,7 @@ export class StartupManager {
KVStoreHelper.init(context)
// 路由注册
registerRouter();
registerDefaultWebJumpInterceptor()
// 设置全局context
AppUtils.gotApplicationContextFunc = () => {
...
...
Please
register
or
login
to post a comment