import { defineComponent as y, inject as C, ref as m, reactive as k, resolveComponent as n, openBlock as f, createElementBlock as v, createVNode as e, withCtx as t, createElementVNode as g, createTextVNode as I, createCommentVNode as N, pushScopeId as R, popScopeId as S } from "vue";
import { u as q, b as E, _ as L } from "./index-a857af7d.mjs";
const z = (r) => (R("data-v-4f8982f3"), r = r(), S(), r), B = { class: "login-container" }, F = { class: "login-form" }, U = /* @__PURE__ */ z(() => /* @__PURE__ */ g("h2", { class: "outline-none" }, "欢迎使用低代码平台", -1)), j = {
  key: 0,
  style: { color: "var(--el-color-error)" }
}, A = /* @__PURE__ */ y({
  __name: "index",
  setup(r) {
    const d = C("globalContext"), i = m(), l = k({
      username: "",
      password: ""
    }), s = m(!1), h = q();
    function x() {
      i.value.validate((_) => {
        s.value = !1, _ && E.login(d, l).then(() => {
          var o;
          h.push(((o = d.router.currentRoute.value.query) == null ? void 0 : o.redirect) || "/");
        }).catch((o) => {
          console.log(o), s.value = !0;
        });
      });
    }
    return (_, o) => {
      const u = n("lc-icon"), p = n("el-input"), a = n("el-form-item"), b = n("el-button"), w = n("el-form"), V = n("dvi");
      return f(), v("div", B, [
        e(V, { class: "login-area" }, {
          default: t(() => [
            g("div", F, [
              U,
              e(w, {
                ref_key: "loginFormRef",
                ref: i,
                model: l,
                size: "large",
                "label-position": "top"
              }, {
                default: t(() => [
                  e(a, {
                    prop: "username",
                    label: "用户名",
                    required: ""
                  }, {
                    default: t(() => [
                      e(p, {
                        clearable: "",
                        modelValue: l.username,
                        "onUpdate:modelValue": o[0] || (o[0] = (c) => l.username = c),
                        placeholder: "请输入用户名"
                      }, {
                        prefix: t(() => [
                          e(u, { icon: "mdiAccount" })
                        ]),
                        _: 1
                      }, 8, ["modelValue"])
                    ]),
                    _: 1
                  }),
                  e(a, {
                    prop: "password",
                    label: "密码",
                    required: ""
                  }, {
                    default: t(() => [
                      e(p, {
                        clearable: "",
                        "show-password": "",
                        modelValue: l.password,
                        "onUpdate:modelValue": o[1] || (o[1] = (c) => l.password = c),
                        placeholder: "请输入密码"
                      }, {
                        prefix: t(() => [
                          e(u, { icon: "mdiLock" })
                        ]),
                        _: 1
                      }, 8, ["modelValue"])
                    ]),
                    _: 1
                  }),
                  e(a, null, {
                    default: t(() => [
                      e(b, {
                        size: "large",
                        type: "primary",
                        style: { width: "100%" },
                        onClick: x
                      }, {
                        default: t(() => [
                          I("登录 ")
                        ]),
                        _: 1
                      })
                    ]),
                    _: 1
                  }),
                  e(a, null, {
                    default: t(() => [
                      s.value ? (f(), v("span", j, "登录失败,用户名或密码错误")) : N("", !0)
                    ]),
                    _: 1
                  })
                ]),
                _: 1
              }, 8, ["model"])
            ])
          ]),
          _: 1
        })
      ]);
    };
  }
});
const G = /* @__PURE__ */ L(A, [["__scopeId", "data-v-4f8982f3"]]);
export {
  G as default
};
