| | |
| | | import { BlLifeRecharge } from '@life-payment/core'; |
| | | import { inject, shallowReactive } from 'vue'; |
| | | import { BlLifeRecharge, BlLifeRechargeOptions } from '@life-payment/core'; |
| | | import { inject, reactive, provide, ref } from 'vue'; |
| | | import type { InjectionKey, UnwrapNestedRefs, Ref } from 'vue'; |
| | | |
| | | export type LifeRechargeContext = { |
| | |
| | | blLifeRecharge: BlLifeRecharge; |
| | | }; |
| | | |
| | | function updateState(state: Record<string, unknown>, update: Record<string, any>): void { |
| | | Object.keys(state).forEach((key) => { |
| | | state[key] = update[key]; |
| | | }); |
| | | } |
| | | |
| | | export const VueLifeRechargePlugin = { |
| | | install: (app: any, { blLifeRecharge }: VueLifeRechargePluginOptions) => { |
| | | const _blLifeRecharge = reactive(blLifeRecharge); |
| | | _blLifeRecharge.init(); |
| | | |
| | | // blLifeRecharge.listener.addListener({ |
| | | // update: (state) => { |
| | | // updateState(_blLifeRecharge, state); |
| | | // }, |
| | | // }); |
| | | |
| | | app.provide(clientKey, { |
| | | blLifeRecharge: shallowReactive(blLifeRecharge), |
| | | blLifeRecharge: _blLifeRecharge, |
| | | }); |
| | | }, |
| | | }; |