@deppon/deppon-router 2.1.1

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.
@@ -0,0 +1,36 @@
1
+ import type { RouteLocationNormalizedLoaded } from 'vue-router';
2
+ import type { DepponRouter } from './index';
3
+
4
+ /**
5
+ * Composition API: useRouter
6
+ * 在 Vue 3 Composition API 中使用 router
7
+ */
8
+ export function useRouter(): DepponRouter | null;
9
+
10
+ /**
11
+ * 扩展的 Route 类型,包含 getQueryByRoute 方法
12
+ * 继承 RouteLocationNormalizedLoaded 的所有属性(path、params、query、meta 等)
13
+ */
14
+ export interface ExtendedRouteLocation extends RouteLocationNormalizedLoaded {
15
+ /**
16
+ * 智能获取路由参数:在 iframe 环境中从父级获取,否则从当前路由 query 获取
17
+ * @param key - 参数键名,如果不提供则返回所有参数对象
18
+ * @returns 参数值(如果提供了 key)或参数对象(如果未提供 key)
19
+ */
20
+ getQueryByRoute(): Record<string, any>;
21
+ getQueryByRoute(key: string): any;
22
+ }
23
+
24
+ /**
25
+ * Composition API: useRoute
26
+ * 在 Vue 3 Composition API 中使用当前路由
27
+ * 基于 vue-router 的 useRoute,如果需要则扩展 getQueryByRoute 方法
28
+ *
29
+ * 返回类型与 vue-router 的 useRoute 保持一致,支持所有 RouteLocationNormalizedLoaded 属性
30
+ * 包括 path、params、query、meta 等
31
+ *
32
+ * 注意:虽然运行时返回的是 ref,但类型定义与 vue-router 保持一致,在模板中会自动解包
33
+ *
34
+ * @returns ExtendedRouteLocation | RouteLocationNormalizedLoaded - 当前路由对象
35
+ */
36
+ export function useRoute(): ExtendedRouteLocation | null;
@@ -0,0 +1,138 @@
1
+ import './_virtual/_rollup-plugin-inject-process-env.js';
2
+ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
3
+ import { inject, getCurrentInstance } from 'vue';
4
+ import { useRouter as useRouter$1, useRoute as useRoute$1 } from 'vue-router';
5
+
6
+ function createRouteProxy(routeRef, router) {
7
+ var target = {};
8
+ return new Proxy(target, {
9
+ get: function get(_t, key) {
10
+ if (key === '__v_isRef') return false;
11
+ if (key === 'value') return undefined;
12
+ if (key === 'getQueryByRoute') {
13
+ return function getQueryByRoute(k) {
14
+ return router && typeof router.getQueryByRoute === 'function' ? router.getQueryByRoute(k) : undefined;
15
+ };
16
+ }
17
+ var value = routeRef && 'value' in routeRef ? routeRef.value : routeRef;
18
+ return value ? value[key] : undefined;
19
+ },
20
+ has: function has(_t, key) {
21
+ var value = routeRef && 'value' in routeRef ? routeRef.value : routeRef;
22
+ if (!value) return false;
23
+ return key in value || key === 'getQueryByRoute';
24
+ },
25
+ ownKeys: function ownKeys() {
26
+ var value = routeRef && 'value' in routeRef ? routeRef.value : routeRef;
27
+ var keys = value ? Reflect.ownKeys(value) : [];
28
+ return [].concat(_toConsumableArray(keys), ['getQueryByRoute']);
29
+ },
30
+ getOwnPropertyDescriptor: function getOwnPropertyDescriptor(_t, key) {
31
+ return {
32
+ enumerable: true,
33
+ configurable: true
34
+ };
35
+ }
36
+ });
37
+ }
38
+
39
+ /**
40
+ * Composition API: useRouter
41
+ * 在 Vue 3 Composition API 中使用 router
42
+ *
43
+ * @example
44
+ * import { useRouter } from '@deppon/deppon-router'
45
+ *
46
+ * export default {
47
+ * setup() {
48
+ * const router = useRouter()
49
+ *
50
+ * const handleClick = () => {
51
+ * router.push('/home')
52
+ * }
53
+ *
54
+ * return { handleClick }
55
+ * }
56
+ * }
57
+ */
58
+ function useRouter() {
59
+ // 优先从 provide 获取增强的 router
60
+ var routerFromProvide = inject('depponRouter', null);
61
+
62
+ // 如果 provide 中没有,尝试从 Vue Router 获取
63
+ if (!routerFromProvide) {
64
+ try {
65
+ return useRouter$1();
66
+ } catch (error) {
67
+ // 如果 Vue Router 的 useRouter 也失败,尝试从实例获取
68
+ var instance = getCurrentInstance();
69
+ if (instance) {
70
+ var router = instance.appContext.config.globalProperties.$router;
71
+ if (router) {
72
+ return router;
73
+ }
74
+ }
75
+ return null;
76
+ }
77
+ }
78
+ return routerFromProvide;
79
+ }
80
+
81
+ /**
82
+ * Composition API: useRoute
83
+ * 在 Vue 3 Composition API 中使用当前路由
84
+ *
85
+ * @example
86
+ * import { useRoute } from '@deppon/deppon-router'
87
+ *
88
+ * export default {
89
+ * setup() {
90
+ * const route = useRoute()
91
+ *
92
+ * console.log(route.path)
93
+ * console.log(route.params)
94
+ * console.log(route.query)
95
+ *
96
+ * // 使用 getQueryByRoute 获取参数(自动适配 iframe 环境)
97
+ * const allParams = route.getQueryByRoute();
98
+ * const sourceType = route.getQueryByRoute('sourceType');
99
+ *
100
+ * return {}
101
+ * }
102
+ * }
103
+ */
104
+ function useRoute() {
105
+ try {
106
+ // Vue Router 4 的 useRoute 返回一个 ref
107
+ var route = useRoute$1();
108
+
109
+ // 尝试获取 router 实例以访问 getQueryByRoute 方法
110
+ var router = null;
111
+ try {
112
+ router = useRouter();
113
+ } catch (e) {
114
+ // 如果 useRouter 失败,尝试从实例获取
115
+ var instance = getCurrentInstance();
116
+ if (instance) {
117
+ router = instance.appContext.config.globalProperties.$router;
118
+ }
119
+ }
120
+
121
+ // 返回可直接访问属性的代理对象(无需 .value)
122
+ return createRouteProxy(route, router);
123
+ } catch (error) {
124
+ // 如果失败,尝试从实例获取
125
+ var _instance = getCurrentInstance();
126
+ if (_instance) {
127
+ var _router = _instance.appContext.config.globalProperties.$router;
128
+ if (_router) {
129
+ // Vue Router 4 的 currentRoute 是一个 ref
130
+ var _route = _router.currentRoute;
131
+ return createRouteProxy(_route, _router);
132
+ }
133
+ }
134
+ return null;
135
+ }
136
+ }
137
+
138
+ export { useRoute, useRouter };
package/es/guards.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 设置路由守卫
3
+ * @param {Object} router - Vue Router 实例
4
+ * @param {Object} guards - 守卫配置
5
+ * @param {Object} log - 日志实例
6
+ * @param {Function} onRouteChange - 路由变化回调
7
+ */
8
+ export function setupGuards(router: Object, guards: Object | undefined, log: Object, onRouteChange: Function): void;
package/es/guards.js ADDED
@@ -0,0 +1,122 @@
1
+ import './_virtual/_rollup-plugin-inject-process-env.js';
2
+
3
+ /**
4
+ * 设置路由守卫
5
+ * @param {Object} router - Vue Router 实例
6
+ * @param {Object} guards - 守卫配置
7
+ * @param {Object} log - 日志实例
8
+ * @param {Function} onRouteChange - 路由变化回调
9
+ */
10
+ function setupGuards(router) {
11
+ var guards = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
12
+ var log = arguments.length > 2 ? arguments[2] : undefined;
13
+ var onRouteChange = arguments.length > 3 ? arguments[3] : undefined;
14
+ var beforeEach = guards.beforeEach,
15
+ afterEach = guards.afterEach,
16
+ beforeResolve = guards.beforeResolve;
17
+
18
+ // 全局前置守卫
19
+ router.beforeEach(function (to, from, next) {
20
+ var autoTrack = function autoTrack() {
21
+ if (log && typeof log.eventTrack === 'function') {
22
+ var _to$meta;
23
+ log.eventTrack('$route_before', {
24
+ $url: to.fullPath,
25
+ $url_path: to.path,
26
+ $title: ((_to$meta = to.meta) === null || _to$meta === void 0 ? void 0 : _to$meta.title) || document.title,
27
+ $referrer: from.fullPath
28
+ });
29
+ }
30
+ };
31
+
32
+ // 执行默认的日志记录
33
+ autoTrack();
34
+
35
+ // 执行用户自定义的 beforeEach
36
+ if (beforeEach) {
37
+ try {
38
+ // 如果用户守卫显式接收 next(长度>=3),交由用户自行调用 next,避免重复调用
39
+ if (beforeEach.length >= 3) {
40
+ return beforeEach(to, from, next);
41
+ }
42
+ // 简写守卫:允许返回 boolean/Promise,我们在合适时机自动调用 next
43
+ var result = beforeEach(to, from);
44
+ if (result === false) {
45
+ // 阻止导航
46
+ return;
47
+ }
48
+ if (result && typeof result.then === 'function') {
49
+ return result.then(function () {
50
+ return next();
51
+ })["catch"](function (err) {
52
+ return next(err);
53
+ });
54
+ }
55
+ // 未返回或返回 true/undefined:继续导航
56
+ return next();
57
+ } catch (e) {
58
+ return next(e);
59
+ }
60
+ } else {
61
+ // 没有自定义守卫,直接继续导航
62
+ next();
63
+ }
64
+ });
65
+
66
+ // 全局后置守卫
67
+ router.afterEach(function (to, from) {
68
+ var _to$meta3;
69
+ // 执行用户自定义的 afterEach
70
+ if (afterEach) {
71
+ afterEach(to, from);
72
+ }
73
+
74
+ // 执行默认的日志记录
75
+ if (log && typeof log.eventTrack === 'function') {
76
+ var _to$meta2;
77
+ log.eventTrack('$pageview', {
78
+ $url: to.fullPath,
79
+ $url_path: to.path,
80
+ $title: ((_to$meta2 = to.meta) === null || _to$meta2 === void 0 ? void 0 : _to$meta2.title) || document.title,
81
+ $referrer: from.fullPath
82
+ });
83
+ }
84
+
85
+ // 执行路由变化回调
86
+ if (onRouteChange && typeof onRouteChange === 'function') {
87
+ onRouteChange(to, from);
88
+ }
89
+
90
+ // 设置页面标题
91
+ if ((_to$meta3 = to.meta) !== null && _to$meta3 !== void 0 && _to$meta3.title) {
92
+ document.title = to.meta.title;
93
+ }
94
+ });
95
+
96
+ // 全局解析守卫
97
+ if (beforeResolve) {
98
+ router.beforeResolve(function (to, from, next) {
99
+ try {
100
+ if (beforeResolve.length >= 3) {
101
+ return beforeResolve(to, from, next);
102
+ }
103
+ var result = beforeResolve(to, from);
104
+ if (result === false) {
105
+ return;
106
+ }
107
+ if (result && typeof result.then === 'function') {
108
+ return result.then(function () {
109
+ return next();
110
+ })["catch"](function (err) {
111
+ return next(err);
112
+ });
113
+ }
114
+ return next();
115
+ } catch (e) {
116
+ return next(e);
117
+ }
118
+ });
119
+ }
120
+ }
121
+
122
+ export { setupGuards };
package/es/index.d.ts ADDED
@@ -0,0 +1,87 @@
1
+ import type {
2
+ RouteLocationNormalized,
3
+ RouteLocationRaw,
4
+ RouteRecordRaw,
5
+ Router,
6
+ RouterOptions,
7
+ NavigationFailure,
8
+ } from 'vue-router';
9
+
10
+ export interface ViewTabOptions {
11
+ title?: string;
12
+ uumsFunction?: {
13
+ functionCode?: string;
14
+ sourceSystem?: string;
15
+ [key: string]: any;
16
+ };
17
+ closeCurrentTab?: boolean;
18
+ [key: string]: any;
19
+ }
20
+
21
+ export interface RouterGuards {
22
+ beforeEach?: Parameters<Router['beforeEach']>[0];
23
+ afterEach?: Parameters<Router['afterEach']>[0];
24
+ beforeResolve?: Parameters<Router['beforeResolve']>[0];
25
+ }
26
+
27
+ export interface CreateDepponRouterOptions {
28
+ routes?: RouteRecordRaw[];
29
+ routerOptions?: Omit<RouterOptions, 'routes' | 'history'> & {
30
+ history?: 'web' | 'hash' | 'memory';
31
+ };
32
+ guards?: RouterGuards;
33
+ log?: Record<string, any>;
34
+ onRouteChange?: (to: RouteLocationNormalized, from: RouteLocationNormalized) => void;
35
+ defaultViewTab?: ViewTabOptions;
36
+ }
37
+
38
+ type DepponPushLocation =
39
+ | RouteLocationRaw
40
+ | (Exclude<RouteLocationRaw, string | number> & { _viewTab?: ViewTabOptions | null | undefined });
41
+
42
+ export interface DepponRouterUtils {
43
+ safePush(
44
+ location: RouteLocationRaw,
45
+ onComplete?: () => void,
46
+ onAbort?: (error: NavigationFailure) => void,
47
+ ): Promise<void | NavigationFailure | undefined>;
48
+ safeReplace(
49
+ location: RouteLocationRaw,
50
+ onComplete?: () => void,
51
+ onAbort?: (error: NavigationFailure) => void,
52
+ ): Promise<void | NavigationFailure | undefined>;
53
+ pushByName(
54
+ name: string,
55
+ params?: Record<string, any>,
56
+ query?: Record<string, any>,
57
+ ): Promise<void | NavigationFailure | undefined>;
58
+ pushByPath(path: string, query?: Record<string, any>): Promise<void | NavigationFailure | undefined>;
59
+ goBack(delta?: number): void;
60
+ hasRoute(name: string): boolean;
61
+ getRouteConfig(name: string): RouteRecordRaw | null;
62
+ getQueryByRoute(): Record<string, any>;
63
+ getQueryByRoute(key: string): any;
64
+ depponPush(
65
+ location: DepponPushLocation,
66
+ onComplete?: () => void,
67
+ onAbort?: (error: NavigationFailure) => void,
68
+ ): Promise<void | NavigationFailure | undefined>;
69
+ closeCurrentTab(url?: string, type?: string): void;
70
+ }
71
+
72
+ export type DepponRouter = Router & DepponRouterUtils;
73
+
74
+ // 显式导出 Router 类型,确保 addRoute 等方法可用
75
+ export type { Router } from 'vue-router';
76
+
77
+ export declare function createDepponRouter(options?: CreateDepponRouterOptions): DepponRouter;
78
+
79
+ export default createDepponRouter;
80
+
81
+ export { default as VuePlugin } from './vue';
82
+ export { useRouter, useRoute } from './composable';
83
+
84
+ // 重新导出 vue-router 的组件
85
+ export { RouterView, RouterLink } from 'vue-router';
86
+
87
+ export * from './types';
package/es/index.js ADDED
@@ -0,0 +1,99 @@
1
+ import './_virtual/_rollup-plugin-inject-process-env.js';
2
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
3
+ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
4
+ import { createWebHistory, createMemoryHistory, createWebHashHistory, createRouter } from 'vue-router';
5
+ export { RouterLink, RouterView } from 'vue-router';
6
+ import { setupGuards } from './guards.js';
7
+ import { createRouterUtils } from './utils.js';
8
+ export { default as VuePlugin } from './vue.js';
9
+ export { useRoute, useRouter } from './composable.js';
10
+
11
+ var _excluded = ["history", "base", "scrollBehavior"],
12
+ _excluded2 = ["push"];
13
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
14
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
15
+
16
+ /**
17
+ * 创建增强的 Vue Router 实例
18
+ * @param {Object} [options={}] - 路由配置选项
19
+ * @param {Array} [options.routes=[]] - 路由配置数组
20
+ * @param {Object} [options.routerOptions={}] - Vue Router 原始配置选项
21
+ * @param {String} [options.routerOptions.history='web'] - 历史模式('web' | 'hash' | 'memory'),默认为 'web'
22
+ * @param {String} [options.routerOptions.base] - 应用的基础路径
23
+ * @param {Function} [options.routerOptions.scrollBehavior] - 滚动行为函数
24
+ * @param {Object} [options.guards={}] - 路由守卫配置(可选)
25
+ * @param {Function} [options.guards.beforeEach] - 全局前置守卫(可选)
26
+ * @param {Function} [options.guards.afterEach] - 全局后置守卫(可选)
27
+ * @param {Function} [options.guards.beforeResolve] - 全局解析守卫(可选)
28
+ * @param {Object} [options.log] - 日志实例(可选,用于路由追踪)
29
+ * @param {Function} [options.onRouteChange] - 路由变化回调(可选)
30
+ * @param {Object} [options.defaultViewTab] - 默认的 viewTab 配置(可选),会在调用 router.push 时自动应用
31
+ * @param {String} [options.defaultViewTab.title] - 默认标签页标题
32
+ * @param {Object} [options.defaultViewTab.uumsFunction] - 默认 UUMS 功能配置
33
+ * @param {String} [options.defaultViewTab.uumsFunction.functionCode] - 功能代码
34
+ * @param {String} [options.defaultViewTab.uumsFunction.sourceSystem] - 来源系统
35
+ * @param {Boolean} [options.defaultViewTab.closeCurrentTab] - 是否关闭当前标签页(默认 false)
36
+ * @returns {Object} Vue Router 实例(包含以下扩展方法:safePush, safeReplace, pushByName, pushByPath, goBack, hasRoute, getRouteConfig, depponPush, getQueryByRoute)
37
+ */
38
+ function createDepponRouter() {
39
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
40
+ var _options$routes = options.routes,
41
+ routes = _options$routes === void 0 ? [] : _options$routes,
42
+ _options$routerOption = options.routerOptions,
43
+ routerOptions = _options$routerOption === void 0 ? {} : _options$routerOption,
44
+ _options$guards = options.guards,
45
+ guards = _options$guards === void 0 ? {} : _options$guards,
46
+ log = options.log,
47
+ onRouteChange = options.onRouteChange,
48
+ defaultViewTab = options.defaultViewTab;
49
+ var _routerOptions$histor = routerOptions.history,
50
+ history = _routerOptions$histor === void 0 ? 'web' : _routerOptions$histor,
51
+ base = routerOptions.base,
52
+ scrollBehavior = routerOptions.scrollBehavior,
53
+ restOptions = _objectWithoutProperties(routerOptions, _excluded);
54
+
55
+ // 根据 history 选项创建对应的历史模式
56
+ var historyInstance;
57
+ switch (history) {
58
+ case 'hash':
59
+ historyInstance = createWebHashHistory(base);
60
+ break;
61
+ case 'memory':
62
+ historyInstance = createMemoryHistory(base);
63
+ break;
64
+ case 'web':
65
+ default:
66
+ historyInstance = createWebHistory(base);
67
+ break;
68
+ }
69
+
70
+ // 创建 Vue Router 实例
71
+ var router = createRouter(_objectSpread({
72
+ history: historyInstance,
73
+ routes: routes,
74
+ scrollBehavior: scrollBehavior
75
+ }, restOptions));
76
+
77
+ // 设置路由守卫
78
+ setupGuards(router, guards, log, onRouteChange);
79
+
80
+ // 扩展 router 实例,添加工具方法
81
+ var utils = createRouterUtils(router, defaultViewTab);
82
+
83
+ // 先添加所有其他方法(包括 depponPush),这样 push 方法中的 this.depponPush 才能找到
84
+ var push = utils.push,
85
+ otherUtils = _objectWithoutProperties(utils, _excluded2);
86
+ Object.assign(router, otherUtils);
87
+
88
+ // 最后单独覆盖 push 方法,确保 this 绑定正确,此时 this.depponPush 已经存在
89
+ if (push) {
90
+ router.push = push.bind(router);
91
+ }
92
+
93
+ // utils 中的 push 方法已经处理了默认配置
94
+ // 这样旧代码使用 router.push 时也能自动应用默认的 viewTab 配置
95
+
96
+ return router;
97
+ }
98
+
99
+ export { createDepponRouter, createDepponRouter as default };
package/es/types.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 重新导出 vue-router 的类型(供其他包使用)
3
+ */
4
+ export type { RouterView, Router, RouteRecordRaw, NavigationGuardNext, RouteLocationNormalized } from 'vue-router';
package/es/utils.d.ts ADDED
@@ -0,0 +1,142 @@
1
+ export function createRouterUtils(router: any, defaultViewTab?: null): {
2
+ /**
3
+ * 包装后的 push 方法,自动应用默认的 _viewTab 配置
4
+ * @param {Object|String} location - 路由位置
5
+ * @param {Function} onComplete - 成功回调
6
+ * @param {Function} onAbort - 失败回调
7
+ */
8
+ push(location: Object | string, onComplete: Function, onAbort: Function): Promise<any>;
9
+ /**
10
+ * 安全的路由跳转(带错误处理)
11
+ * @param {Object|String} location - 路由位置
12
+ * @param {Function} onComplete - 成功回调
13
+ * @param {Function} onAbort - 失败回调
14
+ */
15
+ safePush(location: Object | string, onComplete: Function, onAbort: Function): any;
16
+ /**
17
+ * 安全的路由替换(带错误处理)
18
+ * @param {Object|String} location - 路由位置
19
+ * @param {Function} onComplete - 成功回调
20
+ * @param {Function} onAbort - 失败回调
21
+ */
22
+ safeReplace(location: Object | string, onComplete: Function, onAbort: Function): any;
23
+ /**
24
+ * 根据路由名称跳转
25
+ * @param {String} name - 路由名称
26
+ * @param {Object} params - 路由参数
27
+ * @param {Object} query - 查询参数
28
+ */
29
+ pushByName(name: string, params?: Object, query?: Object): any;
30
+ /**
31
+ * 根据路由路径跳转
32
+ * @param {String} path - 路由路径
33
+ * @param {Object} query - 查询参数
34
+ */
35
+ pushByPath(path: string, query?: Object): any;
36
+ /**
37
+ * 返回上一页
38
+ * @param {Number} delta - 返回的步数,默认为 1
39
+ */
40
+ goBack(delta?: number): void;
41
+ /**
42
+ * 关闭当前标签页
43
+ * @param {string} [url] - 标签页 URL(默认使用当前页面的 location.href)
44
+ * @param {string} [type='IFRAME'] - 标签页类型(默认:'IFRAME')
45
+ */
46
+ closeCurrentTab(url?: string | undefined, type?: string | undefined): void;
47
+ /**
48
+ * 检查路由是否存在(包括动态添加的路由)
49
+ * @param {String} name - 路由名称
50
+ * @returns {Boolean}
51
+ */
52
+ hasRoute(name: string): boolean;
53
+ /**
54
+ * 获取路由配置(包括动态添加的路由)
55
+ * @param {String} name - 路由名称
56
+ * @returns {Object|null}
57
+ */
58
+ getRouteConfig(name: string): Object | null;
59
+ /**
60
+ * 智能获取路由参数:在 iframe 环境中优先从父级获取,否则从当前路由 query 获取
61
+ * 与 depponPush 的参数获取逻辑保持一致
62
+ * @param {String} [key] - 参数键名,如果不提供则返回所有参数对象
63
+ * @returns {any} 参数值(如果提供了 key)或参数对象(如果未提供 key)
64
+ *
65
+ * @example
66
+ * // 获取所有参数
67
+ * const params = router.getQueryByRoute();
68
+ *
69
+ * // 获取指定参数
70
+ * const sourceType = router.getQueryByRoute('sourceType');
71
+ */
72
+ getQueryByRoute(key?: string | undefined): any;
73
+ /**
74
+ * 智能路由跳转:在 iframe 环境中自动使用 viewTab,否则使用 router.push
75
+ * 参数传递方式与 router.push 完全一致,在 iframe 环境中会自动适配 viewTab
76
+ * @param {Object|String} location - 路由位置(与 router.push 一致)
77
+ * - 如果是字符串:路径字符串,如 '/home' 或 '/home?id=1'
78
+ * - 如果是对象,可以包含以下属性:
79
+ * - path: 路径
80
+ * - name: 路由名称
81
+ * - params: 路由参数(在 iframe 环境中会传递给 viewTab 的 params)
82
+ * - query: 查询参数(会转换为 URL 的 query string)
83
+ * - _viewTab: viewTab 选项对象(可选,仅在 iframe 环境中生效)
84
+ * - title: 标签页标题(默认使用路由 meta.title 或 '新页面')
85
+ * - uumsFunction: UUMS 功能配置
86
+ * - functionCode: 功能代码
87
+ * - sourceSystem: 来源系统
88
+ * - closeCurrentTab: 是否关闭当前标签页(默认 false)
89
+ * @param {Function} [onComplete] - 成功回调(与 router.push 一致)
90
+ * @param {Function} [onAbort] - 失败回调(与 router.push 一致)
91
+ * @returns {Promise} 跳转 Promise
92
+ *
93
+ * @example
94
+ * // 基本用法(与 router.push 完全一致,在 iframe 环境中自动使用 viewTab)
95
+ * router.depponPush('/home');
96
+ * router.depponPush({ path: '/home', query: { id: 1 } });
97
+ * router.depponPush({ name: 'Home', params: { id: 1 } });
98
+ *
99
+ * // 在 iframe 环境中自定义 viewTab 选项
100
+ * router.depponPush({
101
+ * path: '/preferInfo',
102
+ * query: { sourceType: 'insert' },
103
+ * params: { custNumber: '701265308', preferId: '1312' },
104
+ * _viewTab: {
105
+ * title: 'CMC-产品折扣新增',
106
+ * uumsFunction: {
107
+ * functionCode: 'CMC_FUNCTION_00002',
108
+ * sourceSystem: 'CMC',
109
+ * },
110
+ * closeCurrentTab: true,
111
+ * },
112
+ * });
113
+ *
114
+ * // 替换原有代码示例:
115
+ * // 原代码:
116
+ * // if (top.viewTab) {
117
+ * // let params = { sourceType: 'insert' };
118
+ * // let url = location.origin + '/#/preferInfo?sourceType=insert';
119
+ * // let tabUrl = top.Ext.urlAppend(url, 'isUap=true');
120
+ * // top.closeTab(tabUrl, 'IFRAME');
121
+ * // top.viewTab('CMC-产品折扣新增', url, 'iframe', params, { ... });
122
+ * // } else {
123
+ * // this.$router.push({ path: '/preferInfo', query: { sourceType: 'insert' } });
124
+ * // }
125
+ * //
126
+ * // 新代码(自动适配):
127
+ * router.depponPush({
128
+ * path: '/preferInfo',
129
+ * query: { sourceType: 'insert' },
130
+ * params: { sourceType: 'insert' },
131
+ * _viewTab: {
132
+ * title: 'CMC-产品折扣新增',
133
+ * uumsFunction: {
134
+ * functionCode: 'CMC_FUNCTION_00002',
135
+ * sourceSystem: 'CMC',
136
+ * },
137
+ * closeCurrentTab: true,
138
+ * },
139
+ * });
140
+ */
141
+ depponPush(location: Object | string, onComplete?: Function | undefined, onAbort?: Function | undefined): Promise<any>;
142
+ };