zhengyiming
2025-02-24 03047a382e6f0f1945be32e28fd65e6b31817dfa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { BlLifeRecharge } from '@life-payment/core';
import { inject, shallowReactive } from 'vue';
import type { InjectionKey, UnwrapNestedRefs, Ref } from 'vue';
 
export type LifeRechargeContext = {
  blLifeRecharge: UnwrapNestedRefs<BlLifeRecharge>;
};
 
const clientKey: InjectionKey<LifeRechargeContext> = Symbol('blLifeRecharge');
 
export type VueLifeRechargePluginOptions = {
  blLifeRecharge: BlLifeRecharge;
};
 
export const VueLifeRechargePlugin = {
  install: (app: any, { blLifeRecharge }: VueLifeRechargePluginOptions) => {
    app.provide(clientKey, {
      blLifeRecharge: shallowReactive(blLifeRecharge),
    });
  },
};
 
export function useLifeRechargeContext() {
  return inject(clientKey);
}