index.uts 601 B

1234567891011121314151617181920
  1. import { bundleManager, common } from '@kit.AbilityKit';
  2. import OpenLinkOptions from '@ohos.app.ability.OpenLinkOptions'
  3. import { getAbilityContext } from '@dcloudio/uni-runtime'
  4. import { OpenSchema, CanOpenURL } from '../interface.uts'
  5. export const openSchema : OpenSchema = function (url : string) : void {
  6. (getAbilityContext() as common.UIAbilityContext)?.openLink(url, {
  7. appLinkingOnly: false
  8. } as OpenLinkOptions)
  9. }
  10. export const canOpenURL : CanOpenURL = function (url : string) : boolean {
  11. try {
  12. return bundleManager.canOpenLink(url)
  13. } catch (error) {
  14. return false
  15. }
  16. }