AuthCallback-dev.4480f579.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. import { v as defineComponent, r as ref, l as onMounted, B as createElementBlock, C as createVNode, D as withCtx, aA as useRouter, aB as useRoute, ak as resolveComponent, y as openBlock, E as createBaseVNode, O as toDisplayString, M as createTextVNode } from "./vue-dev.7a51ac2d.js";
  2. import { u as useAuthStore } from "./index-dev.bb5c7162.js";
  3. import { a as ElMessage } from "./element-dev.26a170ea.js";
  4. import { _ as _export_sfc } from "./_plugin-vue_export-helper-dev.cc2b3d55.js";
  5. import "./utils-dev.be08a1a2.js";
  6. const _hoisted_1 = { class: "callback-container" };
  7. const _hoisted_2 = {
  8. key: 0,
  9. class: "loading-content"
  10. };
  11. const _hoisted_3 = {
  12. key: 1,
  13. class: "error-content"
  14. };
  15. const _hoisted_4 = {
  16. key: 2,
  17. class: "success-content"
  18. };
  19. const _sfc_main = /* @__PURE__ */ defineComponent({
  20. __name: "AuthCallback",
  21. setup(__props) {
  22. const router = useRouter();
  23. const route = useRoute();
  24. const authStore = useAuthStore();
  25. const loading = ref(true);
  26. const error = ref("");
  27. onMounted(async () => {
  28. try {
  29. const token = route.query.token;
  30. const errorParam = route.query.error;
  31. if (errorParam) {
  32. error.value = "授权失败: " + errorParam;
  33. loading.value = false;
  34. return;
  35. }
  36. if (!token) {
  37. error.value = "未收到访问令牌";
  38. loading.value = false;
  39. return;
  40. }
  41. authStore.setToken(token);
  42. await authStore.fetchUserInfo();
  43. loading.value = false;
  44. ElMessage.success("登录成功");
  45. setTimeout(() => {
  46. router.push("/dashboard");
  47. }, 1e3);
  48. } catch (err) {
  49. console.error("处理登录回调失败:", err);
  50. error.value = err.message || "登录处理失败";
  51. loading.value = false;
  52. }
  53. });
  54. return (_ctx, _cache) => {
  55. const _component_Loading = resolveComponent("Loading");
  56. const _component_el_icon = resolveComponent("el-icon");
  57. const _component_Warning = resolveComponent("Warning");
  58. const _component_el_button = resolveComponent("el-button");
  59. const _component_SuccessFilled = resolveComponent("SuccessFilled");
  60. const _component_el_card = resolveComponent("el-card");
  61. return openBlock(), createElementBlock("div", _hoisted_1, [
  62. createVNode(_component_el_card, { class: "callback-box" }, {
  63. default: withCtx(() => [
  64. loading.value ? (openBlock(), createElementBlock("div", _hoisted_2, [
  65. createVNode(_component_el_icon, {
  66. class: "is-loading",
  67. size: "48"
  68. }, {
  69. default: withCtx(() => [
  70. createVNode(_component_Loading)
  71. ]),
  72. _: 1
  73. }),
  74. _cache[1] || (_cache[1] = createBaseVNode("h2", null, "正在处理登录...", -1)),
  75. _cache[2] || (_cache[2] = createBaseVNode("p", null, "请稍候,系统正在验证您的身份", -1))
  76. ])) : error.value ? (openBlock(), createElementBlock("div", _hoisted_3, [
  77. createVNode(_component_el_icon, {
  78. size: "48",
  79. color: "#F56C6C"
  80. }, {
  81. default: withCtx(() => [
  82. createVNode(_component_Warning)
  83. ]),
  84. _: 1
  85. }),
  86. _cache[4] || (_cache[4] = createBaseVNode("h2", null, "登录失败", -1)),
  87. createBaseVNode("p", null, toDisplayString(error.value), 1),
  88. createVNode(_component_el_button, {
  89. type: "primary",
  90. onClick: _cache[0] || (_cache[0] = ($event) => _ctx.$router.push("/login"))
  91. }, {
  92. default: withCtx(() => [..._cache[3] || (_cache[3] = [
  93. createTextVNode(" 重新登录 ", -1)
  94. ])]),
  95. _: 1
  96. })
  97. ])) : (openBlock(), createElementBlock("div", _hoisted_4, [
  98. createVNode(_component_el_icon, {
  99. size: "48",
  100. color: "#67C23A"
  101. }, {
  102. default: withCtx(() => [
  103. createVNode(_component_SuccessFilled)
  104. ]),
  105. _: 1
  106. }),
  107. _cache[5] || (_cache[5] = createBaseVNode("h2", null, "登录成功", -1)),
  108. _cache[6] || (_cache[6] = createBaseVNode("p", null, "正在跳转到系统首页...", -1))
  109. ]))
  110. ]),
  111. _: 1
  112. })
  113. ]);
  114. };
  115. }
  116. });
  117. const AuthCallback_vue_vue_type_style_index_0_scoped_b75e7ee2_lang = "";
  118. const AuthCallback = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-b75e7ee2"]]);
  119. export {
  120. AuthCallback as default
  121. };
  122. //# sourceMappingURL=AuthCallback-dev.4480f579.js.map