wupengfei
2025-02-21 83f821e00802979e64840901bf2a1d18b4b61601
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 './lifeRecharge';
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);
}