import { login } from "./lib/logic";
import { appUpdate } from "./lib/wx/update";
import { useRouteQuery } from "./utils/route-query";
import i18n from "./i18n/install";

// app.ts
App<IAppOption>({
  globalData: {
    doctorId: "",
    patientId: "",
    dictionaries: [],
  },
  i18n: null,
  onLaunch(options: WechatMiniprogram.App.LaunchShowOption) {
    i18n().then((value) => this.i18n = value);
    appUpdate(true);
    const scene = options.query.scene;
    const query = useRouteQuery(scene);
    wx.setStorageSync("scene", scene);
    const doctorId = query.ys;
    this.globalData.doctorId = doctorId;
    wx.setStorageSync("doctorId", doctorId);
    login();
  },
});
