提交 e41bbeaa 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

refactor: 移除平台兼容代码

上级 47a614e4
<template>
<page-head title="getLaunchOptionsSync"></page-head>
<view class="uni-padding-wrap">
<button @click="getLaunchOptionsSync">getLaunchOptionsSync</button>
<view v-if="launchOptionsPath.length > 0" class="uni-common-mt">
<text>应用启动路径:</text>
<text style="margin-top: 5px">{{ launchOptionsPath }}</text>
</view>
</view>
</template>
<script lang="uts">
type OnShowReturn = {
appOnShow : OnShowOptions,
onShowOption : OnShowOptions
}
type IOnLaunchOptions = {
appOnLaunch : OnLaunchOptions,
launchOptions : OnLaunchOptions
}
export default {
data() {
return {
checked: false,
homePagePath: 'pages/tabBar/component',
globalPropertiesPath: 'pages/component/global-properties/global-properties',
launchOptionsPath: '',
}
},
methods: {
// 自动化测试
compareOnLaunchRes() : IOnLaunchOptions {
const launchOptions = uni.getLaunchOptionsSync();
const app = getApp()
const appOnLaunch = app.globalData.launchOptions as OnLaunchOptions
const res : IOnLaunchOptions = {
appOnLaunch,
launchOptions
}
return res
},
compareOnShowRes() : OnShowReturn {
// #ifdef APP-ANDROID
const res : OnShowReturn = {
appOnShow: {
path: ''
} as OnShowOptions,
onShowOption: {
path: ''
} as OnShowOptions
}
return res
// #endif
// #ifndef APP-ANDROID
const onShowOption = uni.getEnterOptionsSync();
const app = getApp()
const appOnShow = app.globalData.onShowOption as OnShowOptions
return {
appOnShow,
onShowOption
}
// #endif
},
getLaunchOptionsSync() {
const launchOptions = uni.getLaunchOptionsSync()
this.launchOptionsPath = launchOptions.path
let targetLaunchPath = ''
// #ifdef APP
targetLaunchPath = this.homePagePath
// #endif
// #ifdef WEB
targetLaunchPath = this.globalPropertiesPath
// #endif
if (launchOptions.path == targetLaunchPath) {
this.checked = true
}
},
},
}
<template>
<page-head title="getLaunchOptionsSync"></page-head>
<view class="uni-padding-wrap">
<button @click="getLaunchOptionsSync">getLaunchOptionsSync</button>
<view v-if="launchOptionsPath.length > 0" class="uni-common-mt">
<text>应用启动路径:</text>
<text style="margin-top: 5px">{{ launchOptionsPath }}</text>
</view>
</view>
</template>
<script lang="uts">
type OnShowReturn = {
appOnShow : OnShowOptions,
onShowOption : OnShowOptions
}
type IOnLaunchOptions = {
appOnLaunch : OnLaunchOptions,
launchOptions : OnLaunchOptions
}
export default {
data() {
return {
checked: false,
homePagePath: 'pages/tabBar/component',
launchOptionsPath: '',
}
},
methods: {
// 自动化测试
compareOnLaunchRes() : IOnLaunchOptions {
const launchOptions = uni.getLaunchOptionsSync();
const app = getApp()
const appOnLaunch = app.globalData.launchOptions as OnLaunchOptions
const res : IOnLaunchOptions = {
appOnLaunch,
launchOptions
}
return res
},
compareOnShowRes() : OnShowReturn {
// #ifdef APP-ANDROID
const res : OnShowReturn = {
appOnShow: {
path: ''
} as OnShowOptions,
onShowOption: {
path: ''
} as OnShowOptions
}
return res
// #endif
// #ifndef APP-ANDROID
const onShowOption = uni.getEnterOptionsSync();
const app = getApp()
const appOnShow = app.globalData.onShowOption as OnShowOptions
return {
appOnShow,
onShowOption
}
// #endif
},
getLaunchOptionsSync() {
const launchOptions = uni.getLaunchOptionsSync()
this.launchOptionsPath = launchOptions.path
if (launchOptions.path == this.homePagePath) {
this.checked = true
}
},
},
}
</script>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册