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

refactor: 调整示例,兼容 UniPage

上级 78555572
......@@ -43,10 +43,10 @@
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
const currentPages = getCurrentPages()
const parentPage = this.getParentPage()!
const parentPage = this.$page.getParentPage()!
const grandParentPage = parentPage.getParentPage()
const dialogPages = parentPage.getDialogPages()
const dialogPage = this.$dialogPage!
const dialogPage = this.$page as UniDialogPage
if (
currentPages.length == 1 &&
grandParentPage == null &&
......@@ -126,7 +126,7 @@
},
closeThisDialog() {
uni.closeDialogPage({
dialogPage: this.$dialogPage,
dialogPage: this.$page as UniDialogPage,
success(res) {
console.log('closeThisDialog success', res)
// 自动化测试
......
......@@ -93,7 +93,7 @@
},
closeThisDialog() {
uni.closeDialogPage({
dialogPage: this.$dialogPage,
dialogPage: this.$page as UniDialogPage,
success(res) {
console.log('closeThisDialog success', res)
// 自动化测试
......@@ -138,4 +138,4 @@
.mt-10 {
margin-top: 10px;
}
</style>
</style>
......@@ -112,14 +112,14 @@
getPageStyle() : UTSJSONObject {
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
this.currentPageStyle = currentPage.$getPageStyle()
this.currentPageStyle = currentPage.getPageStyle()
return this.currentPageStyle;
},
setPageStyle(style : UTSJSONObject) {
console.log('setPageStyle:', style);
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
currentPage.$setPageStyle(style);
currentPage.setPageStyle(style);
},
goSetDisablePullDownRefresh() {
uni.navigateTo({
......@@ -175,4 +175,4 @@
.radio-value {
margin-left: 10px;
}
</style>
</style>
......@@ -44,13 +44,13 @@
getPageStyle() {
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
this.currentPageStyle = currentPage.$getPageStyle();
this.currentPageStyle = currentPage.getPageStyle();
},
setPageStyle(enable : boolean) {
// 目前仅支持 enablePullDownRefresh
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
currentPage.$setPageStyle({
currentPage.setPageStyle({
enablePullDownRefresh: enable
});
this.enablePullDownRefreshStatus = enable
......@@ -95,4 +95,4 @@
margin-top: 15px;
opacity: .8;
}
</style>
</style>
......@@ -16,10 +16,10 @@
changeColor() {
let pages = getCurrentPages()
let page = pages[pages.length - 1]
page.$setPageStyle({ "backgroundColorContent": this.isChange ? "" : "red" })
page.setPageStyle({ "backgroundColorContent": this.isChange ? "" : "red" })
this.isChange = !this.isChange
let pageJson = page.$getPageStyle()
let pageJson = page.getPageStyle()
this.currentBackgroundColorContent = pageJson["backgroundColorContent"]
}
}
......@@ -32,4 +32,4 @@
align-items: center;
justify-content: center;
}
</style>
</style>
......@@ -224,19 +224,16 @@ export const get_page_name = (routepath : string) : string => {
if (page.route != routepath) {
const pages = getCurrentPages()
// 如果传入路由与当前页面不同,则从页面栈找一个,如果找不到返回空
let page_now = pages.find((v) : boolean => {
if (v.route == routepath) {
return true;
}
return false
})
let page_now = pages.find((p): boolean => p.route == routepath)
if (page_now == null) {
return ''
}
page = page_now
}
// @ts-ignore
page = page_now.vm!
}
const pageStyle = page.$getPageStyle()
// @ts-ignore
const pageStyle = page.$page.getPageStyle()
const titleText = pageStyle['navigationBarTitleText'] ?? ''
return titleText as string
}
......@@ -250,8 +247,9 @@ export const get_page_vm = () : Page | null => {
return null
}
let page = pages[pages.length - 1]
// TODO 正常来说,调用当前方法的地方只在 生命周期内,数组内最少会有一个页面,所以理论上是不存在获取不到的情况的
return page
// TODO 正常来说,调用当前方法的地方只在 生命周期内,数组内最少会有一个页面,所以理论上是不存在获取不到的情况的
// @ts-ignore
return page.vm
}
......@@ -416,17 +414,17 @@ export const uni_cloud_config = () : UniCloudInitOptions | null => {
export const get_space = (config : UniCloudInitOptions) : UniCloudInitOptions | null => {
const uniCloudConfig = uni_cloud_config()
if (uniCloudConfig == null) {
console.log(config);
// #ifdef APP-ANDROID
if (config.spaceId != '') {
return config
}
// #endif
// #ifndef APP-ANDROID
if (config?.spaceId != '') {
return config
}
// #endif
console.log(config);
// #ifdef APP-ANDROID
if (config.spaceId != '') {
return config
}
// #endif
// #ifndef APP-ANDROID
if (config?.spaceId != '') {
return config
}
// #endif
return null
}
......@@ -510,4 +508,4 @@ export const calibration = (eventName : string, options : any | null) : boolean
return true
}
return false
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册