zhangbo1_wd

新增外链跳转方法

... ... @@ -26,7 +26,7 @@ export class ResourcesUtils {
try {
let text = buffer.from(content).toString("utf8");
if (text) {
Logger.info(TAG, "getResourcesText then text:" + text);
// Logger.info(TAG, "getResourcesText then text:" + text);
success(text);
} else {
Logger.warn(TAG, "getResourcesText then text is empty");
... ...
... ... @@ -4,6 +4,8 @@ import { Logger } from 'wdKit';
import { StringUtils } from 'wdKit/src/main/ets/utils/StringUtils';
import { WDRouterRule } from '../router/WDRouterRule';
import { ContentConstants } from 'wdConstant';
import { common, Want } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';
// import { LiveModel } from '../viewmodel/LiveModel';
... ... @@ -214,3 +216,21 @@ export class ProcessUtils {
Logger.debug(TAG, `gotoAtlasDetailPage, ${content.objectId}`);
}
}
/**
* 打开外链
* @param url 外链地址
*/
public static jumpExternalWebPage(url: string) {
let context = getContext() as common.UIAbilityContext;
let wantInfo: Want = {
action: 'ohos.want.action.viewData',
entities: ['entity.system.browsable'],
uri: url
}
context.startAbility(wantInfo).then(() => {
Logger.debug(TAG, 'jumpExternalWebPage success')
}).catch((err: BusinessError) => {
Logger.error(TAG, 'jumpExternalWebPage success, error: ' + JSON.stringify(err))
})
}
}
... ...