press-next
Version:
Vue3 组件库,支持 Composition API
25 lines (20 loc) • 729 B
text/typescript
export function getGpScheme({
path = 'views/index/index',
appId = 'wx688122c86a023da7',
query = '',
version = 'release',
}) {
let res = `weixin://dl/business/?appid=${appId}&path=${path}&env_version=${version}`;
if (query) {
res += `&query=${query}`;
}
return res;
}
export const DEFAULT_OPEN_LINK = 'weixin://dl/business/?appid=wx688122c86a023da7&path=views/index/index&env_version=release';
export function encodeQuery(obj: Record<string, string>) {
const queryString = Object.keys(obj)
.map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`)
.join('&'); // 把对象转换成 a=1&b=2&c=3&d=4 的字符串格式
const res = encodeURIComponent(queryString);
return res;
}