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