flat: 演示版
This commit is contained in:
@@ -51,6 +51,23 @@ const prePage = () => {
|
||||
}
|
||||
|
||||
|
||||
export function safeReLaunch(url) {
|
||||
const pages = getCurrentPages();
|
||||
const currentPage = pages[pages.length - 1];
|
||||
|
||||
// 移除传入url开头的斜杠用于对比
|
||||
const cleanUrl = url.startsWith('/') ? url.slice(1) : url;
|
||||
|
||||
if (currentPage && currentPage.route === cleanUrl) {
|
||||
console.log('已在当前页');
|
||||
return;
|
||||
}
|
||||
|
||||
uni.reLaunch({
|
||||
url
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@@ -627,7 +644,8 @@ export const $api = {
|
||||
sendingMiniProgramMessage,
|
||||
copyText,
|
||||
aes_Decrypt,
|
||||
createRequestWithCache
|
||||
createRequestWithCache,
|
||||
safeReLaunch
|
||||
}
|
||||
|
||||
|
||||
@@ -660,5 +678,6 @@ export default {
|
||||
sm4Decrypt,
|
||||
aes_Decrypt,
|
||||
sm2_Decrypt,
|
||||
sm2_Encrypt
|
||||
sm2_Encrypt,
|
||||
safeReLaunch
|
||||
}
|
||||
Reference in New Issue
Block a user