Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Contact.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

欢迎小伙伴们加入micro-app微信群交流^ ^
![d41ddc5fce71b2d9127b1d908091f9b0](https://github.com/user-attachments/assets/07511474-187b-4faf-a6de-0ab4e1073d33)
![52934c047e043329136e0edfc26ee85a](https://github.com/user-attachments/assets/47046f55-3f0a-4564-8e1e-361188992f52)





Expand All @@ -11,7 +13,9 @@


欢迎小伙伴们加入micro-app-DevTools开发交流群^ ^
![682a80d5b3d6e250dfc269383c5ab9c7](https://github.com/user-attachments/assets/e16b4efa-ef2d-47e5-bb4b-a23d02e4d33e)
![bbae0360b1bdd1244404681fb9f2b49d](https://github.com/user-attachments/assets/ebbe8c8f-91e7-40ca-a0bf-58e5f27e6812)





Expand Down
4 changes: 2 additions & 2 deletions docs/zh-cn/router.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ microApp.start({
**常见问题:**主应用为Vue时,路由跳转后子应用频繁卸载和渲染,解决方式参考[Vue常见问题-2](/zh-cn/framework/vue?id=question-2)

#### ** pure模式 **
pure模式是指子应用独立于浏览器路由系统进行渲染,即不修改浏览器地址,也不增加路由堆栈,pure模式下的子应用更像是一个组件。
pure模式是指子应用独立于浏览器路由系统进行渲染,即不修改浏览器地址,也不增加路由堆栈,pure模式下的子应用更像是一个组件。(还在测试中,子应用复杂情况不推荐使用)

**切换方式:**

Expand All @@ -98,7 +98,7 @@ microApp.start({
```

#### ** state模式 **
state模式是指基于浏览器history.state进行渲染的路由模式,在不修改浏览器地址的情况下模拟路由行为,相比其它路由模式更加简洁优雅。
state模式是指基于浏览器history.state进行渲染的路由模式,在不修改浏览器地址的情况下模拟路由行为,相比其它路由模式更加简洁优雅。(还在测试中,子应用复杂情况不推荐使用)

state模式的表现和iframe路由系统类似,但却没有iframe路由存在的问题。

Expand Down
23 changes: 12 additions & 11 deletions src/libs/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ export const version = '__MICRO_APP_VERSION__'
export const isBrowser = typeof window !== 'undefined'

// do not use isUndefined
export const globalThis = (typeof global !== 'undefined')
? global
: (
(typeof window !== 'undefined')
? window
: (
(typeof self !== 'undefined') ? self : Function('return this')()
)
)
export const globalObj =
typeof globalThis !== 'undefined'
? globalThis
: typeof global !== 'undefined'
? global
: typeof window !== 'undefined'
? window
: typeof self !== 'undefined'
? self
: Function('return this')()

export const noop = () => { }
export const noopFalse = () => false
Expand Down Expand Up @@ -300,7 +301,7 @@ export const createURL = (function (): (path: string | URL, base?: string) => Mi
* @param url address
*/
export function addProtocol(url: string): string {
return url.startsWith('//') ? `${globalThis.location.protocol}${url}` : url
return url.startsWith('//') ? `${globalObj.location.protocol}${url}` : url
}

/**
Expand Down Expand Up @@ -438,7 +439,7 @@ export function unique(array: any[]): any[] {
}

// requestIdleCallback polyfill
export const requestIdleCallback = globalThis.requestIdleCallback ||
export const requestIdleCallback = globalObj.requestIdleCallback ||
function (fn: CallableFunction) {
const lastTime = Date.now()
return setTimeout(function () {
Expand Down