WXL
6 天以前 b76de9a566e4435146a970aa22333a58f87b485b
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const common_vendor = require("./common/vendor.js");
const utils_auth = require("./utils/auth.js");
const stores_user = require("./stores/user.js");
const i18n = require("./i18n.js");
const uni_modules_uviewPlus_index = require("./uni_modules/uview-plus/index.js");
require("./utils/request.js");
if (!Math) {
  "./pages/index/index.js";
  "./pages/login/Login.js";
  "./pages/login/Register.js";
  "./pages/my/index.js";
  "./pagesSub/case/index.js";
  "./pagesSub/case/CaseDetails.js";
  "./pagesSub/case/CaseInfo.js";
  "./pagesSub/case/transfer.js";
  "./pagesSub/case/transferinfo.js";
  "./pagesSub/ethicalReview/ethicalInfo.js";
  "./pagesSub/ethicalReview/index.js";
  "./pagesSub/my/notification.js";
  "./pagesSub/my/profile.js";
  "./pagesSub/my/health-records.js";
  "./pagesSub/common/search/index.js";
  "./pagesSub/common/news/list.js";
  "./pagesSub/common/news/detail.js";
}
const _sfc_main = {
  __name: "App",
  setup(__props) {
    const pageWhiteList = ["pages/login/Login", "pages/login/DingTalkLogin"];
    const isPageInWhiteList = (currentPage) => pageWhiteList.some((path) => currentPage.includes(path));
    let isProcessingSSO = false;
    common_vendor.onLaunch(() => {
      common_vendor.index.__f__("log", "at App.vue:13", "App Launch");
      const launchOptions = common_vendor.index.getLaunchOptionsSync();
      const currentPage = launchOptions.path || "";
      const query = launchOptions.query || {};
      common_vendor.index.__f__("log", "at App.vue:17", "启动参数:", { currentPage, query });
      if (query.code) {
        common_vendor.index.__f__("log", "at App.vue:21", "检测到免登码(code),准备跳转登录页");
        if (currentPage.includes("login/Login")) {
          common_vendor.index.__f__("log", "at App.vue:23", "当前已在登录页,等待login.vue处理");
          return;
        }
        if (isProcessingSSO)
          return;
        isProcessingSSO = true;
        common_vendor.index.__isSSOHandling = true;
        const queryParams = [];
        if (currentPage) {
          queryParams.push(`redirect=${encodeURIComponent("/" + currentPage)}`);
        }
        queryParams.push(`code=${encodeURIComponent(query.code)}`);
        common_vendor.index.__f__("log", "at App.vue:38", "跳转到登录页,参数:", queryParams);
        setTimeout(() => {
          common_vendor.index.redirectTo({
            url: `/pages/login/Login?${queryParams.join("&")}`,
            success: () => {
              setTimeout(() => {
                common_vendor.index.__isSSOHandling = false;
                isProcessingSSO = false;
              }, 500);
            },
            fail: () => {
              common_vendor.index.__isSSOHandling = false;
              isProcessingSSO = false;
            }
          });
        }, 200);
        return;
      }
      handleTokenCheck();
    });
    const handleTokenCheck = async () => {
      const userStore = stores_user.useUserStore();
      const token = utils_auth.getToken();
      const launchOptions = common_vendor.index.getLaunchOptionsSync();
      const currentPage = launchOptions.path || "";
      const query = launchOptions.query || {};
      common_vendor.index.__f__("log", "at App.vue:68", "token检查:", { hasToken: !!token, currentPage });
      if (!token) {
        if (!isPageInWhiteList(currentPage)) {
          common_vendor.index.__f__("log", "at App.vue:73", "无token且不在白名单,跳转登录页");
          let loginUrl = "/pages/login/Login";
          if (currentPage) {
            const queryParams = [];
            queryParams.push(`redirect=${encodeURIComponent("/" + currentPage)}`);
            for (const key in query) {
              if (query[key]) {
                queryParams.push(`${key}=${encodeURIComponent(query[key])}`);
              }
            }
            if (queryParams.length > 0) {
              loginUrl += `?${queryParams.join("&")}`;
            }
          }
          setTimeout(() => {
            common_vendor.index.redirectTo({ url: loginUrl });
          }, 100);
        }
        return;
      }
      try {
        const current = await common_vendor.index.$uapi.get("/getInfo");
        if (current && current.user) {
          userStore.setUserInfo(current.user);
          if (current.roles)
            userStore.setroleKey(current.roles);
          if (isPageInWhiteList(currentPage)) {
            common_vendor.index.switchTab({ url: "/pages/index/index" });
          }
        } else {
          common_vendor.index.__f__("error", "at App.vue:103", "token无效");
          userStore.clearUser();
          if (!isPageInWhiteList(currentPage)) {
            common_vendor.index.redirectTo({ url: "/pages/login/Login" });
          }
        }
      } catch (error) {
        common_vendor.index.__f__("error", "at App.vue:110", "初始化失败:", error);
        userStore.clearUser();
        if (!isPageInWhiteList(currentPage)) {
          common_vendor.index.redirectTo({ url: "/pages/login/Login" });
        }
      }
    };
    return () => {
    };
  }
};
function createApp() {
  const app = common_vendor.createSSRApp(_sfc_main);
  const pinia = common_vendor.createPinia();
  app.use(i18n.i18n);
  app.use(pinia);
  app.use(uni_modules_uviewPlus_index.uviewPlus);
  app.config.globalProperties.$t = i18n.i18n.global.t;
  return {
    app,
    i18n: i18n.i18n,
    pinia
  };
}
createApp().app.mount("#app");
exports.createApp = createApp;
//# sourceMappingURL=../.sourcemap/mp-weixin/app.js.map