Skip to content

Commit

Permalink
chore: fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
YunYouJun committed Jan 26, 2024
1 parent f3fde53 commit 1de972e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 31 deletions.
8 changes: 4 additions & 4 deletions bump.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { defineConfig } from "bumpp";
import { defineConfig } from 'bumpp'

export default defineConfig({
all: true,

files: [
"package.json",
"packages/*/package.json",
'package.json',
'packages/*/package.json',
],
});
})
6 changes: 3 additions & 3 deletions packages/utils/src/wx/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { registerWxShare } from './jsApi'
import type { WxConfig } from './types'

export interface WxInitOptions {
config?: Partial<WxConfig>;
onReady?: () => void;
onError?: (res: any) => void;
config?: Partial<WxConfig>
onReady?: () => void
onError?: (res: any) => void
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/vueuse/src/wx/demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if (isInWxBrowser()) {
link: 'https://github.com/YunLeFun/toolkit/blob/main/packages/vueuse/?source=wx',
imgUrl: 'https://cn.vuejs.org/logo.svg',
})
}
},
})
isReady.value = isWxReady.value
}
Expand Down
38 changes: 15 additions & 23 deletions packages/vueuse/src/wx/jsApi/init.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable no-alert */
/* eslint-disable no-console */
import { ref } from 'vue'
import { isClient, useScriptTag } from '@vueuse/core'
import type { WxInitOptions } from '@yunlefun/utils'
Expand All @@ -19,8 +21,6 @@ export interface WxJsApiOptions extends WxInitOptions {
export function useWxJsApi(
options: WxJsApiOptions,
) {


const isReady = ref(false)
const error = ref()
const wx = ref<ReturnType<typeof createWx>>()
Expand All @@ -29,15 +29,9 @@ export function useWxJsApi(
if (!isClient)
return

if (options.configUrl) {}

if (!window.wx)
return

if (options.debug) {
console.log('wxOptions', options)
}

let data: {
appId?: string
timestamp?: string
Expand All @@ -46,13 +40,11 @@ export function useWxJsApi(
} = {}
if (options.configUrl) {
data = await fetch(options.configUrl).then(
(res) => res.json()
);
if (options.debug) {
res => res.json(),
)
if (options.debug)
console.log('wx config data (fetch from configUrl)', data)
}
}


wx.value = createWx({
...options,
Expand All @@ -62,25 +54,25 @@ export function useWxJsApi(
timestamp: data.timestamp,
nonceStr: data.nonceStr,
signature: data.signature,
jsApiList: ["updateAppMessageShareData", "updateTimelineShareData"],
jsApiList: ['updateAppMessageShareData', 'updateTimelineShareData'],
...(options.config || {}),
},

onReady: () => {
if (options.debug) {
if (options.debug)
alert('wx ready')
}
isReady.value = true;
options.onReady?.();

isReady.value = true
options.onReady?.()
},
onError: (res) => {
if (options.debug) {
if (options.debug)
alert('wx error')
}
error.value = res;
options.onError?.(res);

error.value = res
options.onError?.(res)
},
});
})
})

return {
Expand Down

0 comments on commit 1de972e

Please sign in to comment.