Skip to content

Commit

Permalink
feat: use configUrl.data as config
Browse files Browse the repository at this point in the history
  • Loading branch information
YunYouJun committed Jan 27, 2024
1 parent aa97926 commit bffa7d8
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 33 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "module",
"version": "0.1.2-beta.3",
"private": true,
"packageManager": "pnpm@8.14.3",
"packageManager": "pnpm@8.15.0",
"description": "Toolkit for YunLeFun developing.",
"author": {
"name": "YunLeFun",
Expand All @@ -26,7 +26,7 @@
},
"devDependencies": {
"@antfu/eslint-config": "^2.6.3",
"@types/node": "^20.11.7",
"@types/node": "^20.11.8",
"@yunlefun/vueuse": "workspace:*",
"@yunyoujun/utils": "^0.3.5",
"bumpp": "^9.3.0",
Expand Down
15 changes: 12 additions & 3 deletions packages/vueuse/src/wx/jsApi/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ export interface WxJsApiOptions extends WxInitOptions {
debug?: boolean
/**
* get config from server url
* return { appId, timestamp, nonceStr, signature }
* return {
* data: { appId, timestamp, nonceStr, signature }
* }
*/
configUrl?: string
}
Expand Down Expand Up @@ -39,11 +41,18 @@ export function useWxJsApi(
signature?: string
} = {}
if (options.configUrl) {
data = await fetch(options.configUrl).then(
const res = await fetch(options.configUrl).then(
res => res.json(),
)
if (res.data) {
data = res.data
}
else {
console.error('wx config data (fetch from configUrl) error', res)
return
}
if (options.debug)
console.log('wx config data (fetch from configUrl)', data)
console.log('wx config data (fetch from configUrl)', res)
}

wx.value = createWx({
Expand Down
48 changes: 20 additions & 28 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bffa7d8

Please sign in to comment.