|
@@ -1,5 +1,6 @@
|
|
import { pages, subPackages } from '@/pages.json'
|
|
import { pages, subPackages } from '@/pages.json'
|
|
import { isMpWeixin } from './platform'
|
|
import { isMpWeixin } from './platform'
|
|
|
|
+import { stringifyQuery } from './queryString'
|
|
|
|
|
|
export function getLastPage() {
|
|
export function getLastPage() {
|
|
// getCurrentPages() 至少有1个元素,所以不再额外判断
|
|
// getCurrentPages() 至少有1个元素,所以不再额外判断
|
|
@@ -9,6 +10,18 @@ export function getLastPage() {
|
|
return pages[pages.length - 1]
|
|
return pages[pages.length - 1]
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+export function getLastPageUrl() {
|
|
|
|
+ const { route, options }: any = getLastPage()
|
|
|
|
+ // 拼接完整的页面路径和参数
|
|
|
|
+ let fullPath = `/${route}`
|
|
|
|
+ if (options && Object.keys(options).length > 0) {
|
|
|
|
+ const strParams = stringifyQuery(options)
|
|
|
|
+ fullPath = `${fullPath}?${strParams}`
|
|
|
|
+ }
|
|
|
|
+ console.log(fullPath)
|
|
|
|
+ return fullPath
|
|
|
|
+}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 获取当前页面路由的 path 路径和 redirectPath 路径
|
|
* 获取当前页面路由的 path 路径和 redirectPath 路径
|
|
* path 如 '/pages/login/index'
|
|
* path 如 '/pages/login/index'
|
|
@@ -196,39 +209,6 @@ export function qs(params) {
|
|
.join('&')
|
|
.join('&')
|
|
}
|
|
}
|
|
|
|
|
|
-/**
|
|
|
|
- * 解析 URL 查询字符串为对象
|
|
|
|
- * @param {string} queryString - 需要解析的查询字符串(如 "a=1&b=2")
|
|
|
|
- * @returns {object} 解析后的参数对象
|
|
|
|
- */
|
|
|
|
-export function parseQs(queryString) {
|
|
|
|
- if (!queryString)
|
|
|
|
- return {}
|
|
|
|
-
|
|
|
|
- // 移除开头的问号(如果有)
|
|
|
|
- const cleanQuery = queryString.startsWith('?')
|
|
|
|
- ? queryString.slice(1)
|
|
|
|
- : queryString
|
|
|
|
-
|
|
|
|
- return cleanQuery.split('&')
|
|
|
|
- .reduce((acc, pair) => {
|
|
|
|
- const [encodedKey, encodedValue] = pair.split('=')
|
|
|
|
-
|
|
|
|
- if (encodedKey === undefined)
|
|
|
|
- return acc
|
|
|
|
-
|
|
|
|
- const key = decodeURIComponent(encodedKey)
|
|
|
|
- const value = encodedValue === undefined
|
|
|
|
- ? undefined
|
|
|
|
- : decodeURIComponent(encodedValue)
|
|
|
|
-
|
|
|
|
- // 处理空字符串值
|
|
|
|
- acc[key] = value === '' ? null : value
|
|
|
|
-
|
|
|
|
- return acc
|
|
|
|
- }, {})
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 数字格式化,加逗号分隔符,支持自定义小数位数
|
|
* 数字格式化,加逗号分隔符,支持自定义小数位数
|
|
* @param num 要格式化的数字,支持 number 或 string 类型
|
|
* @param num 要格式化的数字,支持 number 或 string 类型
|