@tarojs/router 4.0.0-beta.82 → 4.0.0-beta.83
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -8
- package/dist/api.d.ts +6 -7
- package/dist/api.js +4 -16
- package/dist/events/resize.d.ts +2 -3
- package/dist/events/scroll.d.ts +2 -3
- package/dist/history.d.ts +10 -8
- package/dist/index.cjs.js +84 -68
- package/dist/index.d.ts +9 -10
- package/dist/index.esm.js +82 -66
- package/dist/navigationBar.d.ts +2 -3
- package/dist/router/index.d.ts +3 -4
- package/dist/router/index.js +3 -2
- package/dist/router/mpa.d.ts +4 -5
- package/dist/router/mpa.js +2 -2
- package/dist/router/multi-page.d.ts +7 -8
- package/dist/router/navigation-bar.d.ts +3 -3
- package/dist/router/navigation-bar.js +6 -6
- package/dist/router/page.d.ts +11 -10
- package/dist/router/page.js +26 -14
- package/dist/router/spa.d.ts +4 -5
- package/dist/router/spa.js +36 -23
- package/dist/router/stack.d.ts +2 -2
- package/dist/style.d.ts +4 -5
- package/dist/style.js +6 -4
- package/dist/tabbar.d.ts +2 -3
- package/dist/utils/index.d.ts +2 -3
- package/dist/utils/navigate.d.ts +6 -7
- package/package.json +18 -29
- package/dist/index.cjs.d.ts +0 -66
- package/dist/index.esm.d.ts +0 -66
package/dist/router/spa.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { AppInstance } from '@tarojs/runtime';
|
|
2
|
-
import { History } from
|
|
3
|
-
import { SpaRouterConfig } from '../../types/router';
|
|
4
|
-
declare function createRouter(history: History, app: AppInstance, config: SpaRouterConfig, framework?: string): () => void;
|
|
5
|
-
export { createRouter };
|
|
1
|
+
import type { AppInstance } from '@tarojs/runtime';
|
|
2
|
+
import type { History } from 'history';
|
|
3
|
+
import type { SpaRouterConfig } from '../../types/router';
|
|
4
|
+
export declare function createRouter(history: History, app: AppInstance, config: SpaRouterConfig, framework?: string): () => void;
|
package/dist/router/spa.js
CHANGED
|
@@ -17,6 +17,10 @@ function createRouter(history, app, config, framework) {
|
|
|
17
17
|
}
|
|
18
18
|
RouterConfig.config = config;
|
|
19
19
|
const handler = new PageHandler(config, history);
|
|
20
|
+
// Note: 弱网情况下,快速切换 tab,会造成同个页面实例被多次挂在到页面上,原因是资源请求是异步的,短时间内发起多个请求,
|
|
21
|
+
// 会在资源加载完成后,同时走到挂载的逻辑,造成 pageStampId 更新不及时,两个 page 的Id 相同,后面很多操作是通过 getElementById 来进行的
|
|
22
|
+
// 所以需要加一个锁来应对这个情况
|
|
23
|
+
const pageLock = {};
|
|
20
24
|
routesAlias.set(handler.router.customRoutes);
|
|
21
25
|
const basename = handler.router.basename;
|
|
22
26
|
const routes = handler.routes.map(route => {
|
|
@@ -38,29 +42,35 @@ function createRouter(history, app, config, framework) {
|
|
|
38
42
|
eventCenter.trigger('__taroRouterLaunch', launchParam);
|
|
39
43
|
(_a = app.onLaunch) === null || _a === void 0 ? void 0 : _a.call(app, launchParam);
|
|
40
44
|
app.onError && window.addEventListener('error', e => { var _a; return (_a = app.onError) === null || _a === void 0 ? void 0 : _a.call(app, e.message); });
|
|
41
|
-
const render = (
|
|
42
|
-
var
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
const render = (_c) => __awaiter(this, [_c], void 0, function* ({ location, action }) {
|
|
46
|
+
var _d, _e, _f, _g, _h, _j, _k, _l;
|
|
47
|
+
// Note: 由于下面有异步加载操作 先不要在这里去设置 handler.pathname
|
|
48
|
+
const currentPathname = decodeURI(location.pathname);
|
|
49
|
+
if ((_d = window.__taroAppConfig) === null || _d === void 0 ? void 0 : _d.usingWindowScroll)
|
|
45
50
|
window.scrollTo(0, 0);
|
|
46
51
|
eventCenter.trigger('__taroRouterChange', {
|
|
47
52
|
toLocation: {
|
|
48
|
-
path:
|
|
53
|
+
path: currentPathname
|
|
49
54
|
}
|
|
50
55
|
});
|
|
51
|
-
let element, params;
|
|
56
|
+
let element, context, params;
|
|
57
|
+
const routerPath = handler.router.forcePath || currentPathname;
|
|
58
|
+
pageLock[routerPath] = typeof pageLock[routerPath] === 'number' ? pageLock[routerPath] + 1 : 1;
|
|
59
|
+
const currentLock = pageLock[routerPath];
|
|
60
|
+
let postLock;
|
|
52
61
|
try {
|
|
53
|
-
const result = yield router.resolve(
|
|
54
|
-
[element, , params] = yield Promise.all(result);
|
|
62
|
+
const result = yield router.resolve(routerPath);
|
|
63
|
+
[element, context, params] = yield Promise.all(result);
|
|
64
|
+
postLock = pageLock[routerPath];
|
|
55
65
|
}
|
|
56
66
|
catch (error) {
|
|
57
67
|
if (error.status === 404) {
|
|
58
68
|
const notFoundEvent = {
|
|
59
69
|
isEntryPage: stacks.length === 0,
|
|
60
|
-
path:
|
|
70
|
+
path: currentPathname,
|
|
61
71
|
query: handler.getQuery(createStampId()),
|
|
62
72
|
};
|
|
63
|
-
(
|
|
73
|
+
(_e = app.onPageNotFound) === null || _e === void 0 ? void 0 : _e.call(app, notFoundEvent);
|
|
64
74
|
eventCenter.trigger('__taroRouterNotFound', notFoundEvent);
|
|
65
75
|
}
|
|
66
76
|
else if (/Loading hot update .* failed./.test(error.message)) {
|
|
@@ -71,13 +81,16 @@ function createRouter(history, app, config, framework) {
|
|
|
71
81
|
throw error;
|
|
72
82
|
}
|
|
73
83
|
}
|
|
74
|
-
if (!element)
|
|
84
|
+
if (!element || currentLock !== postLock)
|
|
75
85
|
return;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
let
|
|
86
|
+
// Note: 异步结束后,在设置 handler.pathname
|
|
87
|
+
// context.pathname 在 universal-router 被处理过了,是发起资源请求的时候传入的 pathname,即 await router.resolve(routerPath) 这个 routerPath
|
|
88
|
+
handler.pathname = context.pathname;
|
|
89
|
+
const { pathname, pageConfig } = handler;
|
|
90
|
+
let enablePullDownRefresh = ((_f = config === null || config === void 0 ? void 0 : config.window) === null || _f === void 0 ? void 0 : _f.enablePullDownRefresh) || false;
|
|
91
|
+
let navigationStyle = ((_g = config === null || config === void 0 ? void 0 : config.window) === null || _g === void 0 ? void 0 : _g.navigationStyle) || 'default';
|
|
92
|
+
let navigationBarTextStyle = ((_h = config === null || config === void 0 ? void 0 : config.window) === null || _h === void 0 ? void 0 : _h.navigationBarTextStyle) || 'white';
|
|
93
|
+
let navigationBarBackgroundColor = ((_j = config === null || config === void 0 ? void 0 : config.window) === null || _j === void 0 ? void 0 : _j.navigationBarBackgroundColor) || '#000000';
|
|
81
94
|
if (pageConfig) {
|
|
82
95
|
if (typeof pageConfig.enablePullDownRefresh === 'boolean') {
|
|
83
96
|
enablePullDownRefresh = pageConfig.enablePullDownRefresh;
|
|
@@ -94,8 +107,7 @@ function createRouter(history, app, config, framework) {
|
|
|
94
107
|
}
|
|
95
108
|
eventCenter.trigger('__taroSetNavigationStyle', navigationStyle, navigationBarTextStyle, navigationBarBackgroundColor);
|
|
96
109
|
const currentPage = Current.page;
|
|
97
|
-
const
|
|
98
|
-
const methodName = (_j = stacks.method) !== null && _j !== void 0 ? _j : '';
|
|
110
|
+
const methodName = (_k = stacks.method) !== null && _k !== void 0 ? _k : '';
|
|
99
111
|
const cacheTabs = stacks.getTabs();
|
|
100
112
|
let shouldLoad = false;
|
|
101
113
|
stacks.method = '';
|
|
@@ -110,10 +122,11 @@ function createRouter(history, app, config, framework) {
|
|
|
110
122
|
}
|
|
111
123
|
shouldLoad = true;
|
|
112
124
|
}
|
|
113
|
-
else if (currentPage && handler.isTabBar(
|
|
125
|
+
else if (currentPage && handler.isTabBar(pathname)) {
|
|
114
126
|
if (handler.isSamePage(currentPage))
|
|
115
127
|
return;
|
|
116
128
|
if (handler.isTabBar(currentPage.path)) {
|
|
129
|
+
// NOTE: 从 tabBar 页面切换到 tabBar 页面
|
|
117
130
|
handler.hide(currentPage);
|
|
118
131
|
stacks.pushTab(currentPage.path.split('?')[0]);
|
|
119
132
|
}
|
|
@@ -127,8 +140,8 @@ function createRouter(history, app, config, framework) {
|
|
|
127
140
|
handler.unload(currentPage, stacks.length, true);
|
|
128
141
|
}
|
|
129
142
|
}
|
|
130
|
-
if (cacheTabs[
|
|
131
|
-
stacks.popTab(
|
|
143
|
+
if (cacheTabs[pathname]) {
|
|
144
|
+
stacks.popTab(pathname);
|
|
132
145
|
return handler.show(stacks.getItem(0), pageConfig, 0);
|
|
133
146
|
}
|
|
134
147
|
shouldLoad = true;
|
|
@@ -157,11 +170,11 @@ function createRouter(history, app, config, framework) {
|
|
|
157
170
|
shouldLoad = true;
|
|
158
171
|
}
|
|
159
172
|
else if (action === 'PUSH') {
|
|
160
|
-
handler.hide(currentPage);
|
|
173
|
+
handler.hide(currentPage, true);
|
|
161
174
|
shouldLoad = true;
|
|
162
175
|
}
|
|
163
176
|
if (shouldLoad || stacks.length < 1) {
|
|
164
|
-
const el = (
|
|
177
|
+
const el = (_l = element.default) !== null && _l !== void 0 ? _l : element;
|
|
165
178
|
const loadConfig = Object.assign({}, pageConfig);
|
|
166
179
|
const stacksIndex = stacks.length;
|
|
167
180
|
delete loadConfig['path'];
|
package/dist/router/stack.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PageInstance } from '@tarojs/runtime';
|
|
1
|
+
import type { PageInstance } from '@tarojs/runtime';
|
|
2
2
|
declare class Stacks {
|
|
3
3
|
stacks: PageInstance[];
|
|
4
4
|
backDelta: number;
|
|
@@ -23,4 +23,4 @@ declare class Stacks {
|
|
|
23
23
|
removeTab(path: string): void;
|
|
24
24
|
}
|
|
25
25
|
declare const stacks: Stacks;
|
|
26
|
-
export
|
|
26
|
+
export default stacks;
|
package/dist/style.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 插入页面动画需要的样式
|
|
3
3
|
*/
|
|
4
|
-
declare function loadAnimateStyle(ms?: number): void;
|
|
4
|
+
export declare function loadAnimateStyle(ms?: number): void;
|
|
5
5
|
/**
|
|
6
6
|
* 插入路由相关样式
|
|
7
7
|
*/
|
|
8
|
-
declare function loadRouterStyle(enableTabBar: boolean, enableWindowScroll: boolean): void;
|
|
8
|
+
export declare function loadRouterStyle(enableTabBar: boolean, enableWindowScroll: boolean): void;
|
|
9
9
|
/**
|
|
10
10
|
* 插入导航栏相关的样式
|
|
11
11
|
*/
|
|
12
|
-
declare function loadNavigationBarStyle(): void;
|
|
13
|
-
declare function addStyle(css: any): void;
|
|
14
|
-
export { loadAnimateStyle, loadRouterStyle, loadNavigationBarStyle, addStyle };
|
|
12
|
+
export declare function loadNavigationBarStyle(): void;
|
|
13
|
+
export declare function addStyle(css: any): void;
|
package/dist/style.js
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
function loadAnimateStyle(ms = 300) {
|
|
5
5
|
const css = `
|
|
6
6
|
body {
|
|
7
|
-
|
|
7
|
+
/* 防止 iOS 页面滚动 */
|
|
8
|
+
overflow: hidden;
|
|
8
9
|
}
|
|
9
10
|
.taro_router > .taro_page {
|
|
10
11
|
position: absolute;
|
|
@@ -61,8 +62,9 @@ ${enableTabBar ? `
|
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
` : ''}
|
|
64
|
-
.taro_page_shade,
|
|
65
|
-
.
|
|
65
|
+
.taro_page_shade:has(+.taro_page_stationed),
|
|
66
|
+
.taro_page_shade.taro_tabbar_page,
|
|
67
|
+
.taro_router > .taro_page.taro_page_show.taro_page_stationed:not(.taro_page_shade):not(.taro_tabbar_page):not(:last-child):has(+.taro_page_stationed) {
|
|
66
68
|
display: none;
|
|
67
69
|
}
|
|
68
70
|
`;
|
|
@@ -130,7 +132,7 @@ function loadNavigationBarStyle() {
|
|
|
130
132
|
to {
|
|
131
133
|
transform: rotate(360deg);
|
|
132
134
|
}
|
|
133
|
-
}
|
|
135
|
+
}
|
|
134
136
|
|
|
135
137
|
.taro-navigation-bar-no-icon > .taro-navigation-bar-home {
|
|
136
138
|
display: none;
|
package/dist/tabbar.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { AppConfig } from '@tarojs/taro';
|
|
2
|
-
import { History } from
|
|
3
|
-
declare function initTabbar(config: AppConfig, history: History): void;
|
|
4
|
-
export { initTabbar };
|
|
2
|
+
import type { History } from 'history';
|
|
3
|
+
export declare function initTabbar(config: AppConfig, history: History): void;
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -6,6 +6,5 @@ declare class RoutesAlias {
|
|
|
6
6
|
getAlias: (url?: string) => string;
|
|
7
7
|
getAll: (url?: string) => string[];
|
|
8
8
|
}
|
|
9
|
-
declare const routesAlias: RoutesAlias;
|
|
10
|
-
export
|
|
11
|
-
export * from "./navigate.js";
|
|
9
|
+
export declare const routesAlias: RoutesAlias;
|
|
10
|
+
export * from './navigate';
|
package/dist/utils/navigate.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
declare const isWeixin: () => boolean;
|
|
2
|
-
declare const isDingTalk: () => boolean;
|
|
3
|
-
declare function setMpaTitle(title: string): void;
|
|
4
|
-
declare function setTitle(title: string): void;
|
|
5
|
-
declare function setNavigationBarStyle(option: {
|
|
1
|
+
export declare const isWeixin: () => boolean;
|
|
2
|
+
export declare const isDingTalk: () => boolean;
|
|
3
|
+
export declare function setMpaTitle(title: string): void;
|
|
4
|
+
export declare function setTitle(title: string): void;
|
|
5
|
+
export declare function setNavigationBarStyle(option: {
|
|
6
6
|
backgroundColor: string;
|
|
7
7
|
frontColor: string;
|
|
8
8
|
}): void;
|
|
9
|
-
declare function setNavigationBarLoading(loading: boolean): void;
|
|
10
|
-
export { isWeixin, isDingTalk, setMpaTitle, setTitle, setNavigationBarStyle, setNavigationBarLoading };
|
|
9
|
+
export declare function setNavigationBarLoading(loading: boolean): void;
|
package/package.json
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tarojs/router",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.83",
|
|
4
4
|
"description": "Taro-router",
|
|
5
|
+
"author": "O2Team",
|
|
6
|
+
"license": "MIT",
|
|
5
7
|
"browser": "dist/index.js",
|
|
6
8
|
"main:h5": "dist/index.esm.js",
|
|
7
9
|
"main": "dist/index.js",
|
|
@@ -20,47 +22,34 @@
|
|
|
20
22
|
"keywords": [
|
|
21
23
|
"router"
|
|
22
24
|
],
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">= 18"
|
|
27
|
+
},
|
|
25
28
|
"dependencies": {
|
|
26
29
|
"dingtalk-jsapi": "~2.15.2",
|
|
27
|
-
"history": "^5.
|
|
30
|
+
"history": "^5.3.0",
|
|
28
31
|
"mobile-detect": "^1.4.2",
|
|
29
|
-
"query-string": "^
|
|
32
|
+
"query-string": "^9.0.0",
|
|
30
33
|
"tslib": "^2.6.2",
|
|
31
|
-
"universal-router": "^
|
|
34
|
+
"universal-router": "^9.2.0"
|
|
32
35
|
},
|
|
33
36
|
"devDependencies": {
|
|
34
|
-
"@
|
|
35
|
-
"@
|
|
36
|
-
"@
|
|
37
|
-
"@
|
|
38
|
-
"jest": "^29.3.1",
|
|
39
|
-
"jest-cli": "^29.3.1",
|
|
40
|
-
"jest-environment-jsdom": "^29.6.4",
|
|
41
|
-
"jsdom": "^21.1.0",
|
|
42
|
-
"rollup": "^3.8.1",
|
|
43
|
-
"rollup-plugin-node-externals": "^5.0.0",
|
|
44
|
-
"rollup-plugin-ts": "^3.0.2",
|
|
45
|
-
"ts-jest": "^29.0.5",
|
|
46
|
-
"typescript": "^4.7.4",
|
|
47
|
-
"@tarojs/taro": "4.0.0-beta.82",
|
|
48
|
-
"@tarojs/shared": "4.0.0-beta.82",
|
|
49
|
-
"@tarojs/runtime": "4.0.0-beta.82"
|
|
37
|
+
"@tarojs/components": "4.0.0-beta.83",
|
|
38
|
+
"@tarojs/runtime": "4.0.0-beta.83",
|
|
39
|
+
"@tarojs/taro": "4.0.0-beta.83",
|
|
40
|
+
"@tarojs/shared": "4.0.0-beta.83"
|
|
50
41
|
},
|
|
51
42
|
"peerDependencies": {
|
|
52
|
-
"@tarojs/runtime": "4.0.0-beta.
|
|
53
|
-
"@tarojs/
|
|
54
|
-
"@tarojs/
|
|
43
|
+
"@tarojs/runtime": "4.0.0-beta.83",
|
|
44
|
+
"@tarojs/shared": "4.0.0-beta.83",
|
|
45
|
+
"@tarojs/taro": "4.0.0-beta.83"
|
|
55
46
|
},
|
|
56
47
|
"scripts": {
|
|
48
|
+
"prod": "pnpm run build",
|
|
57
49
|
"prebuild": "pnpm run clean",
|
|
58
50
|
"build": "pnpm run rollup --environment NODE_ENV:production",
|
|
59
51
|
"clean": "rimraf --impl=move-remove ./dist",
|
|
60
52
|
"dev": "pnpm run rollup --environment NODE_ENV:development -w",
|
|
61
|
-
"rollup": "rollup --config rollup.config.
|
|
62
|
-
"test": "cross-env NODE_ENV=jest jest",
|
|
63
|
-
"test:ci": "cross-env NODE_ENV=jest jest --ci -i --coverage --silent",
|
|
64
|
-
"test:dev": "cross-env NODE_ENV=jest jest --watch"
|
|
53
|
+
"rollup": "rollup --config rollup.config.mts --configPlugin typescript"
|
|
65
54
|
}
|
|
66
55
|
}
|
package/dist/index.cjs.d.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { Action, createBrowserHistory, createHashHistory, Blocker, BrowserHistoryOptions, HashHistoryOptions, History, Listener, Location, Path, To } from "history";
|
|
2
|
-
import { IH5RouterConfig } from "@tarojs/taro/types/compile";
|
|
3
|
-
import { StateEvent } from "../types/history";
|
|
4
|
-
import { MpaRouterConfig, SpaRouterConfig } from '../types/router';
|
|
5
|
-
import Taro from "@tarojs/taro";
|
|
6
|
-
import { AppInstance } from "@tarojs/runtime";
|
|
7
|
-
import { MpaRouterConfig as MpaRouterConfig$0 } from "../../types/router";
|
|
8
|
-
import { SpaRouterConfig as SpaRouterConfig$0 } from "../../types/router";
|
|
9
|
-
declare let history: History;
|
|
10
|
-
declare class MpaHistory implements History {
|
|
11
|
-
action: Action;
|
|
12
|
-
get location(): Location;
|
|
13
|
-
createHref(_to: To): string;
|
|
14
|
-
parseUrl(to: Partial<Path>): string;
|
|
15
|
-
push(to: Partial<Path>, _state?: Record<string, unknown>): void;
|
|
16
|
-
replace(to: Partial<Path>, _state?: Record<string, unknown>): void;
|
|
17
|
-
go(delta: number): void;
|
|
18
|
-
back: () => void;
|
|
19
|
-
forward: () => void;
|
|
20
|
-
listen(listener: Listener): () => void;
|
|
21
|
-
block(_blocker: Blocker): () => void;
|
|
22
|
-
pushState: globalThis.History["pushState"];
|
|
23
|
-
replaceState: globalThis.History["replaceState"];
|
|
24
|
-
eventState(action: Required<StateEvent>["action"]): (data: any, unused: string, url?: string | URL | null) => any;
|
|
25
|
-
}
|
|
26
|
-
declare function setHistory(h: History, base?: string): void;
|
|
27
|
-
declare function createMpaHistory(_?: HashHistoryOptions | BrowserHistoryOptions): MpaHistory;
|
|
28
|
-
declare function setHistoryMode(mode?: IH5RouterConfig["mode"], base?: string): void;
|
|
29
|
-
declare function prependBasename(url?: string): string;
|
|
30
|
-
declare function navigateTo(option: Taro.navigateTo.Option): ReturnType<typeof Taro.navigateTo>;
|
|
31
|
-
declare function redirectTo(option: Taro.redirectTo.Option): ReturnType<typeof Taro.redirectTo>;
|
|
32
|
-
declare function navigateBack(option?: Taro.navigateBack.Option): ReturnType<typeof Taro.navigateBack>;
|
|
33
|
-
declare function switchTab(option: Taro.switchTab.Option): ReturnType<typeof Taro.switchTab>;
|
|
34
|
-
declare function reLaunch(option: Taro.reLaunch.Option): ReturnType<typeof Taro.reLaunch>;
|
|
35
|
-
declare function getCurrentPages(): Taro.Page[];
|
|
36
|
-
// TODO 支持多路由 (APP 生命周期仅触发一次)
|
|
37
|
-
/** Note: 关于多页面应用
|
|
38
|
-
* - 需要配置路由映射(根目录跳转、404 页面……)
|
|
39
|
-
* - app.onPageNotFound 事件不支持
|
|
40
|
-
* - 应用生命周期可能多次触发
|
|
41
|
-
* - TabBar 会多次加载
|
|
42
|
-
* - 不支持路由动画
|
|
43
|
-
*/
|
|
44
|
-
declare function createMultiRouter(history: History, app: AppInstance, config: MpaRouterConfig$0, framework?: string): Promise<void>;
|
|
45
|
-
declare function createRouter(history: History, app: AppInstance, config: SpaRouterConfig$0, framework?: string): () => void;
|
|
46
|
-
declare class RoutesAlias {
|
|
47
|
-
conf: Array<string[]>;
|
|
48
|
-
set(customRoutes?: Record<string, string | string[]>): void;
|
|
49
|
-
getConfig: (url?: string) => string[];
|
|
50
|
-
getOrigin: (url?: string) => string;
|
|
51
|
-
getAlias: (url?: string) => string;
|
|
52
|
-
getAll: (url?: string) => string[];
|
|
53
|
-
}
|
|
54
|
-
declare const routesAlias: RoutesAlias;
|
|
55
|
-
declare const isWeixin: () => boolean;
|
|
56
|
-
declare const isDingTalk: () => boolean;
|
|
57
|
-
declare function setMpaTitle(title: string): void;
|
|
58
|
-
declare function setTitle(title: string): void;
|
|
59
|
-
declare function setNavigationBarStyle(option: {
|
|
60
|
-
backgroundColor: string;
|
|
61
|
-
frontColor: string;
|
|
62
|
-
}): void;
|
|
63
|
-
declare function setNavigationBarLoading(loading: boolean): void;
|
|
64
|
-
declare function handleAppMount(config: SpaRouterConfig | MpaRouterConfig, _: History, appId?: string): void;
|
|
65
|
-
declare function handleAppMountWithTabbar(config: SpaRouterConfig | MpaRouterConfig, history: History, appId?: string): void;
|
|
66
|
-
export { navigateTo, redirectTo, navigateBack, switchTab, reLaunch, getCurrentPages, history, setHistory, createMpaHistory, createBrowserHistory, createHashHistory, setHistoryMode, prependBasename, createMultiRouter, createRouter, routesAlias, isWeixin, isDingTalk, setMpaTitle, setTitle, setNavigationBarStyle, setNavigationBarLoading, handleAppMount, handleAppMountWithTabbar };
|
package/dist/index.esm.d.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { Action, createBrowserHistory, createHashHistory, Blocker, BrowserHistoryOptions, HashHistoryOptions, History, Listener, Location, Path, To } from "history";
|
|
2
|
-
import { IH5RouterConfig } from "@tarojs/taro/types/compile";
|
|
3
|
-
import { StateEvent } from "../types/history";
|
|
4
|
-
import { MpaRouterConfig, SpaRouterConfig } from '../types/router';
|
|
5
|
-
import Taro from "@tarojs/taro";
|
|
6
|
-
import { AppInstance } from "@tarojs/runtime";
|
|
7
|
-
import { MpaRouterConfig as MpaRouterConfig$0 } from "../../types/router";
|
|
8
|
-
import { SpaRouterConfig as SpaRouterConfig$0 } from "../../types/router";
|
|
9
|
-
declare let history: History;
|
|
10
|
-
declare class MpaHistory implements History {
|
|
11
|
-
action: Action;
|
|
12
|
-
get location(): Location;
|
|
13
|
-
createHref(_to: To): string;
|
|
14
|
-
parseUrl(to: Partial<Path>): string;
|
|
15
|
-
push(to: Partial<Path>, _state?: Record<string, unknown>): void;
|
|
16
|
-
replace(to: Partial<Path>, _state?: Record<string, unknown>): void;
|
|
17
|
-
go(delta: number): void;
|
|
18
|
-
back: () => void;
|
|
19
|
-
forward: () => void;
|
|
20
|
-
listen(listener: Listener): () => void;
|
|
21
|
-
block(_blocker: Blocker): () => void;
|
|
22
|
-
pushState: globalThis.History["pushState"];
|
|
23
|
-
replaceState: globalThis.History["replaceState"];
|
|
24
|
-
eventState(action: Required<StateEvent>["action"]): (data: any, unused: string, url?: string | URL | null) => any;
|
|
25
|
-
}
|
|
26
|
-
declare function setHistory(h: History, base?: string): void;
|
|
27
|
-
declare function createMpaHistory(_?: HashHistoryOptions | BrowserHistoryOptions): MpaHistory;
|
|
28
|
-
declare function setHistoryMode(mode?: IH5RouterConfig["mode"], base?: string): void;
|
|
29
|
-
declare function prependBasename(url?: string): string;
|
|
30
|
-
declare function navigateTo(option: Taro.navigateTo.Option): ReturnType<typeof Taro.navigateTo>;
|
|
31
|
-
declare function redirectTo(option: Taro.redirectTo.Option): ReturnType<typeof Taro.redirectTo>;
|
|
32
|
-
declare function navigateBack(option?: Taro.navigateBack.Option): ReturnType<typeof Taro.navigateBack>;
|
|
33
|
-
declare function switchTab(option: Taro.switchTab.Option): ReturnType<typeof Taro.switchTab>;
|
|
34
|
-
declare function reLaunch(option: Taro.reLaunch.Option): ReturnType<typeof Taro.reLaunch>;
|
|
35
|
-
declare function getCurrentPages(): Taro.Page[];
|
|
36
|
-
// TODO 支持多路由 (APP 生命周期仅触发一次)
|
|
37
|
-
/** Note: 关于多页面应用
|
|
38
|
-
* - 需要配置路由映射(根目录跳转、404 页面……)
|
|
39
|
-
* - app.onPageNotFound 事件不支持
|
|
40
|
-
* - 应用生命周期可能多次触发
|
|
41
|
-
* - TabBar 会多次加载
|
|
42
|
-
* - 不支持路由动画
|
|
43
|
-
*/
|
|
44
|
-
declare function createMultiRouter(history: History, app: AppInstance, config: MpaRouterConfig$0, framework?: string): Promise<void>;
|
|
45
|
-
declare function createRouter(history: History, app: AppInstance, config: SpaRouterConfig$0, framework?: string): () => void;
|
|
46
|
-
declare class RoutesAlias {
|
|
47
|
-
conf: Array<string[]>;
|
|
48
|
-
set(customRoutes?: Record<string, string | string[]>): void;
|
|
49
|
-
getConfig: (url?: string) => string[];
|
|
50
|
-
getOrigin: (url?: string) => string;
|
|
51
|
-
getAlias: (url?: string) => string;
|
|
52
|
-
getAll: (url?: string) => string[];
|
|
53
|
-
}
|
|
54
|
-
declare const routesAlias: RoutesAlias;
|
|
55
|
-
declare const isWeixin: () => boolean;
|
|
56
|
-
declare const isDingTalk: () => boolean;
|
|
57
|
-
declare function setMpaTitle(title: string): void;
|
|
58
|
-
declare function setTitle(title: string): void;
|
|
59
|
-
declare function setNavigationBarStyle(option: {
|
|
60
|
-
backgroundColor: string;
|
|
61
|
-
frontColor: string;
|
|
62
|
-
}): void;
|
|
63
|
-
declare function setNavigationBarLoading(loading: boolean): void;
|
|
64
|
-
declare function handleAppMount(config: SpaRouterConfig | MpaRouterConfig, _: History, appId?: string): void;
|
|
65
|
-
declare function handleAppMountWithTabbar(config: SpaRouterConfig | MpaRouterConfig, history: History, appId?: string): void;
|
|
66
|
-
export { navigateTo, redirectTo, navigateBack, switchTab, reLaunch, getCurrentPages, history, setHistory, createMpaHistory, createBrowserHistory, createHashHistory, setHistoryMode, prependBasename, createMultiRouter, createRouter, routesAlias, isWeixin, isDingTalk, setMpaTitle, setTitle, setNavigationBarStyle, setNavigationBarLoading, handleAppMount, handleAppMountWithTabbar };
|