Newer
Older
dxCard-admin / src / store / index.ts
YFJ on 23 Sep 478 bytes 项目推送
import type { App } from 'vue';
import type { Pinia } from 'pinia';
import { createPinia } from 'pinia';

let app: Nullable<App<Element>> = null;
let store: Nullable<Pinia> = null;

export function setupStore($app: App<Element>) {
  if (store == null) {
    store = createPinia();
  }
  app = $app;
  app.use(store);
}

// 销毁store
export function destroyStore() {
  store = null;
}

// 获取app实例
export const getAppContext = () => app?._context;

export {app, store};