Browse Source

add login

Michael Wang 3 years ago
parent
commit
7c2c816a2f

+ 15 - 7
.vscode/settings.json

@@ -1,8 +1,16 @@
 {
-	"workbench.colorCustomizations": {
-		"activityBar.background": "#2B1D74",
-		"titleBar.activeBackground": "#3D28A3",
-		"titleBar.activeForeground": "#FAF9FE"
-	},
-	"editor.formatOnSave": true
-}
+  "workbench.colorCustomizations": {
+    "activityBar.background": "#2B1D74",
+    "titleBar.activeBackground": "#3D28A3",
+    "titleBar.activeForeground": "#FAF9FE"
+  },
+  "editor.formatOnSave": true,
+  "files.exclude": {
+    "**/.git": true,
+    "**/.svn": true,
+    "**/.hg": true,
+    "**/CVS": true,
+    "**/.DS_Store": true,
+    "**/Thumbs.db": true
+  }
+}

+ 5 - 0
components.d.ts

@@ -5,6 +5,11 @@
 declare module 'vue' {
   export interface GlobalComponents {
     404: typeof import('./src/components/404.vue')['default']
+    AButton: typeof import('ant-design-vue/es')['Button']
+    AForm: typeof import('ant-design-vue/es')['Form']
+    AFormItem: typeof import('ant-design-vue/es')['FormItem']
+    AInput: typeof import('ant-design-vue/es')['Input']
+    AInputNumber: typeof import('ant-design-vue/es')['InputNumber']
     ASpin: typeof import('ant-design-vue/es')['Spin']
   }
 }

+ 13 - 0
src/api/samplePage.ts → src/api/loginPage.ts

@@ -19,3 +19,16 @@ import { httpApp } from "@/plugins/axiosApp";
 //   return httpApp.post("/admin/exam/arbitrate/clear", form);
 // }
 
+export function loginByUsername(loginInfo: {
+  accountValue: string;
+  password: string;
+  rootOrgId: string;
+}) {
+  return httpApp.post("/api/ess/auth/login", loginInfo, {
+    noErrorMessage: true,
+  });
+}
+
+export function logout() {
+  return httpApp.post("/api/ess/auth/logout");
+}

+ 54 - 1
src/features/Login/Login.vue

@@ -1,3 +1,56 @@
 <template>
-  <div>login</div>
+  <div class="tw-h-screen tw-flex tw-justify-center tw-items-center">
+    <div class="tw-flex" style="width: 860px; height: 558px">
+      <div style="width: 400px" class="left-panel">
+        <div class="tw-text-2xl">欢迎登录,<br />考试成绩综合分析系统</div>
+        <div style="font-size: 12px">武汉启明泰和软件服务有限公司技术支持</div>
+      </div>
+
+      <div class="tw-bg-white" style="padding: 0 70px 0 90px">
+        <div style="padding: 80px 0">icon</div>
+
+        <div style="width: 300px">
+          <a-form-item>
+            <a-input v-model:value="accountValue" placeholder="请输入用户名" />
+          </a-form-item>
+          <a-form-item>
+            <a-input v-model:value="password" placeholder="请输入密码" />
+          </a-form-item>
+
+          <a-button type="primary" @click="login">立即登录</a-button>
+        </div>
+      </div>
+    </div>
+  </div>
 </template>
+
+<script setup lang="ts">
+import { loginByUsername } from "@/api/loginPage";
+import { ref } from "vue";
+
+let accountValue = ref("");
+let password = ref("");
+const rootOrgId = "1";
+
+async function login() {
+  const res = await loginByUsername({
+    accountValue: accountValue.value,
+    password: password.value,
+    rootOrgId: rootOrgId,
+  });
+  console.log(res);
+}
+</script>
+
+<style scoped>
+.left-panel {
+  width: 400px;
+  padding: 58px 100px 30px 60px;
+  color: white;
+  background-image: url(./left.png);
+
+  display: flex;
+  flex-direction: column;
+  justify-content: space-between;
+}
+</style>

BIN
src/features/Login/left.png


+ 4 - 2
src/main.ts

@@ -5,6 +5,9 @@ if (!validUA) {
   );
   location.href = "about:blank";
 }
+// vite-plugin-components 不能引入message的style
+import "ant-design-vue/es/message/style/css.js";
+
 import "virtual:windi.css";
 import "./styles/global.css";
 import { createApp } from "vue";
@@ -13,8 +16,7 @@ import router from "@/router";
 import filters from "@/filters";
 // import Antd from "ant-design-vue";
 // import "ant-design-vue/dist/antd.css";
-// vite-plugin-components 不能引入message的style
-import "ant-design-vue/es/message/style/css.js";
+
 import { createPinia } from "pinia";
 
 // if(process.env.NODE_ENV)

+ 6 - 2
src/plugins/axiosApp.ts

@@ -1,5 +1,4 @@
 import Vue from "vue";
-// import Store from "@/store";
 import axios from "axios";
 // @ts-ignore
 import { loadProgressBar } from "axios-progress-bar";
@@ -7,7 +6,9 @@ import cachingGet from "./axiosCache";
 import { notifyInvalidTokenThrottled } from "./axiosNotice";
 import axiosRetry from "axios-retry";
 import { message } from "ant-design-vue";
-import { store } from "@/features/mark/store";
+import { useMainStore } from "@/store";
+
+let store = null as unknown as ReturnType<typeof useMainStore>;
 
 const config = {
   // baseURL: process.env.baseURL || process.env.apiUrl || ""
@@ -21,6 +22,9 @@ axiosRetry(_axiosApp);
 
 _axiosApp.interceptors.request.use(
   function (config) {
+    if (!store) {
+      store = useMainStore();
+    }
     if (config.setGlobalMask) {
       store.globalMask = true;
     }

+ 2 - 2
src/plugins/axiosNotice.ts

@@ -1,7 +1,7 @@
 import Vue from "vue";
 import { throttle } from "lodash-es";
 import { message } from "ant-design-vue";
-import { doLogout } from "@/api/markPage";
+import { logout } from "@/api/loginPage";
 
 export const notifyInvalidTokenThrottled = throttle(() => {
   message.error({
@@ -9,7 +9,7 @@ export const notifyInvalidTokenThrottled = throttle(() => {
     duration: 10,
   });
   setTimeout(() => {
-    doLogout();
+    logout();
   }, 3000);
   console.log("登录失效");
 }, 1000);

+ 2 - 1
src/styles/global.css

@@ -3,7 +3,7 @@
 :root {
   --header-bg-color: #191b37;
   --app-container-bg-color: white;
-  --app-main-bg-color: #edf2fa;
+  --app-main-bg-color: #dee4f3;
   --app-main-text-color: #283e76;
   --app-min-width: 1280px;
   --app-bold-text-color: #435488;
@@ -22,6 +22,7 @@ body {
   margin: 0;
   font-size: var(--app-main-font-size);
   min-width: var(--app-min-width);
+  background-color: var(--app-main-bg-color);
   min-height: 600px;
   user-select: none;
 }

+ 1 - 13
vite.config.ts

@@ -5,7 +5,7 @@ import { AntDesignVueResolver } from "unplugin-vue-components/resolvers";
 import AutoImport from "unplugin-auto-import/vite";
 import WindiCSS from "vite-plugin-windicss";
 
-const SERVER_URL = "http://192.168.10.224:80";
+const SERVER_URL = "http://192.168.10.39:8081";
 const path = require("path");
 
 // https://vitejs.dev/config/
@@ -39,18 +39,6 @@ export default defineConfig({
       allow: ["./"],
     },
     proxy: {
-      "/login": {
-        target: SERVER_URL,
-        changeOrigin: true,
-      },
-      "/mark": {
-        target: SERVER_URL,
-        changeOrigin: true,
-      },
-      "/admin": {
-        target: SERVER_URL,
-        changeOrigin: true,
-      },
       "/api": {
         target: SERVER_URL,
         changeOrigin: true,

+ 1 - 1
windi.config.ts

@@ -2,5 +2,5 @@ import { defineConfig } from "windicss/helpers";
 
 export default defineConfig({
   /* configurations... */
-  prefix: "tw",
+  prefix: "tw-",
 });