소스 검색

1.qingban分支2.docker部署3.修改各种变量4.单点登录适配。

jiaxiaoqiang 11 달 전
부모
커밋
c9a26af0bb
10개의 변경된 파일403개의 추가작업 그리고 101개의 파일을 삭제
  1. 2 4
      .env.development
  2. 1 1
      .env.production
  3. 1 1
      .gitignore
  4. 1 1
      docker/Dockerfile
  5. 1 3
      package.json
  6. 3 1
      src/api/auth/types.ts
  7. 3 54
      src/router/index.ts
  8. 56 35
      src/views/login/index.vue
  9. 2 1
      tsconfig.json
  10. 333 0
      vite.config.ts.timestamp-1718780321854-379d34a92f5ac.mjs

+ 2 - 4
.env.development

@@ -10,10 +10,8 @@ VITE_APP_BASE_API = '/dev-api'
 # 上传文件接口地址
 VITE_APP_UPLOAD_URL = 'http://192.168.101.4:9000'
 # 开发接口地址
-# VITE_APP_API_URL = 'http://192.168.101.4:8078'
-VITE_APP_API_URL = 'http://121.41.179.41:8079'
-#  VITE_APP_API_URL = 'http://121.41.179.41:8078'  #lup
-#VITE_APP_API_URL = 'http://192.168.101.64:8078'  #hetao
+ VITE_APP_API_URL = 'http://192.168.101.4:7104'
+
 
 # 是否启用 Mock 服务
 VITE_MOCK_DEV_SERVER = false

+ 1 - 1
.env.production

@@ -2,7 +2,7 @@
 NODE_ENV='production'
 
 # 上传文件接口地址
-VITE_APP_UPLOAD_URL = 'http://192.168.101.189:9000'
+VITE_APP_UPLOAD_URL = 'http://192.168.101.4:9000'
 # 代理前缀
 VITE_APP_BASE_API = '/mes-server'
 

+ 1 - 1
.gitignore

@@ -1,6 +1,6 @@
 node_modules
 .DS_Store
-dist
+docker/dist
 dist-ssr
 *.local
 .history

+ 1 - 1
docker/Dockerfile

@@ -7,7 +7,7 @@ RUN echo "server {  \
                       listen       80; \
                       client_max_body_size 100m;\
                       location   /mes-server/ { \
-                      proxy_pass              http://192.168.101.4:8078/; \
+                      proxy_pass              http://192.168.101.4:7104/; \
                       proxy_redirect          off; \
                       proxy_set_header        Host mes-server; \
                       proxy_set_header        X-Real-IP \$remote_addr; \

+ 1 - 3
package.json

@@ -6,8 +6,7 @@
   "scripts": {
     "preinstall": "npx only-allow pnpm",
     "dev": "vite serve --mode development",
-    "build:prod": "vite build --mode production && vue-tsc --noEmit",
-    "prepare": "husky",
+    "build": "vite build --mode production",
     "lint:eslint": "eslint  --fix --ext .ts,.js,.vue ./src ",
     "lint:prettier": "prettier --write \"**/*.{js,cjs,ts,json,tsx,css,less,scss,vue,html,md}\"",
     "lint:stylelint": "stylelint  \"**/*.{css,scss,vue}\" --fix",
@@ -99,7 +98,6 @@
     "eslint-plugin-prettier": "^5.1.3",
     "eslint-plugin-vue": "^9.22.0",
     "fast-glob": "^3.3.2",
-    "husky": "^9.0.11",
     "lint-staged": "^15.2.2",
     "postcss": "^8.4.35",
     "postcss-html": "^1.6.0",

+ 3 - 1
src/api/auth/types.ts

@@ -21,7 +21,9 @@ export interface LoginData {
    */
   captchaCode?: string;
 
-  orgId: number;
+  orgId?: number;
+
+  token?: string;
 }
 
 /**

+ 3 - 54
src/router/index.ts

@@ -1,4 +1,4 @@
-import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";
+import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router";
 
 export const Layout = () => import("@/layout/index.vue");
 
@@ -27,7 +27,7 @@ export const constantRoutes: RouteRecordRaw[] = [
     name: "/",
     meta: { hidden: true },
     component: Layout,
-    // redirect: "/welcome",
+    redirect: "/welcome",
     children: [
       {
         path: "welcome",
@@ -43,64 +43,13 @@ export const constantRoutes: RouteRecordRaw[] = [
     meta: { hidden: true },
     component: () => import("@/views/error-page/404.vue"),
   },
-  // 外部链接
-  // {
-  //   path: "/external-link",
-  //   component: Layout,
-  //   children: [ {
-  //       component: () => import("@/views/external-link/index.vue"),
-  //       path: "https://www.cnblogs.com/haoxianrui/",
-  //       meta: { title: "外部链接", icon: "link" },
-  //     },
-  //   ],
-  // },
-  // 多级嵌套路由
-  /* {
-         path: '/nested',
-         component: Layout,
-         redirect: '/nested/level1/level2',
-         name: 'Nested',
-         meta: {title: '多级菜单', icon: 'nested'},
-         children: [
-             {
-                 path: 'level1',
-                 component: () => import('@/views/nested/level1/index.vue'),
-                 name: 'Level1',
-                 meta: {title: '菜单一级'},
-                 redirect: '/nested/level1/level2',
-                 children: [
-                     {
-                         path: 'level2',
-                         component: () => import('@/views/nested/level1/level2/index.vue'),
-                         name: 'Level2',
-                         meta: {title: '菜单二级'},
-                         redirect: '/nested/level1/level2/level3',
-                         children: [
-                             {
-                                 path: 'level3-1',
-                                 component: () => import('@/views/nested/level1/level2/level3/index1.vue'),
-                                 name: 'Level3-1',
-                                 meta: {title: '菜单三级-1'}
-                             },
-                             {
-                                 path: 'level3-2',
-                                 component: () => import('@/views/nested/level1/level2/level3/index2.vue'),
-                                 name: 'Level3-2',
-                                 meta: {title: '菜单三级-2'}
-                             }
-                         ]
-                     }
-                 ]
-             },
-         ]
-     }*/
 ];
 
 /**
  * 创建路由
  */
 const router = createRouter({
-  history: createWebHashHistory(),
+  history: createWebHistory(),
   routes: constantRoutes,
   // 刷新时,滚动条位置还原
   scrollBehavior: () => ({ left: 0, top: 0 }),

+ 56 - 35
src/views/login/index.vue

@@ -138,9 +138,9 @@ const captchaBase64 = ref(); // 验证码图片Base64字符串
 const loginFormRef = ref(ElForm); // 登录表单ref
 const { height } = useWindowSize();
 
-const loginData = ref<any>({
-  userName: "admin",
-  password: "admin@123",
+const loginData = ref<LoginData>({
+  userName: "",
+  password: "",
 });
 
 const loginRules = computed?.(() => {
@@ -199,42 +199,46 @@ const route = useRoute();
 function handleLogin() {
   loginFormRef.value.validate((valid: boolean) => {
     if (valid) {
-      loading.value = true;
-      userStore
-        .login(loginData.value)
-        .then(async () => {
-          const query: LocationQuery = route.query;
-          const redirect = (query.redirect as LocationQueryValue) ?? "/";
-          const otherQueryParams = Object.keys(query).reduce(
-            (acc: any, cur: string) => {
-              if (cur !== "redirect") {
-                acc[cur] = query[cur];
-              }
-              return acc;
-            },
-            {}
-          );
-          // 获取字典
-          getUserDicts(dictStore.types).then((res) => {
-            if (res.data) {
-              dictStore.dicts = res?.data ?? [];
-            }
-          });
-
-          // router.push({ path: redirect, query: otherQueryParams });
-          router.push("/welcome");
-        })
-        .catch(() => {
-          // getCaptcha();
-          console.log("catch");
-        })
-        .finally(() => {
-          loading.value = false;
-        });
+      toLogin();
     }
   });
 }
 
+const toLogin = () => {
+  loading.value = true;
+  userStore
+    .login(loginData.value)
+    .then(async () => {
+      const query: LocationQuery = route.query;
+      const redirect = (query.redirect as LocationQueryValue) ?? "/";
+      const otherQueryParams = Object.keys(query).reduce(
+        (acc: any, cur: string) => {
+          if (cur !== "redirect") {
+            acc[cur] = query[cur];
+          }
+          return acc;
+        },
+        {}
+      );
+      // 获取字典
+      getUserDicts(dictStore.types).then((res) => {
+        if (res.data) {
+          dictStore.dicts = res?.data ?? [];
+        }
+      });
+
+      router.push({ path: redirect, query: otherQueryParams });
+      // router.push("/welcome");
+    })
+    .catch(() => {
+      // getCaptcha();
+      console.log("catch");
+    })
+    .finally(() => {
+      loading.value = false;
+    });
+};
+
 /**
  * 主题切换
  */
@@ -263,6 +267,23 @@ function checkCapslock(e: any) {
 }
 
 onMounted?.(() => {
+  // 处理SSO
+  const query: LocationQuery = route.query;
+  if (query.token) {
+    loginData.value.token = query.token + "";
+    toLogin();
+    // localStorage.setItem("token", query.token + "");
+    // const redirect = (query.redirect as LocationQueryValue) ?? "/";
+    // // 获取字典
+    // getUserDicts(dictStore.types).then((res) => {
+    //   if (res.data) {
+    //     dictStore.dicts = res?.data ?? [];
+    //   }
+    // });
+    //
+    // router.push({ path: redirect });
+  }
+
   getOrgList();
   toggleTheme();
 });

+ 2 - 1
tsconfig.json

@@ -32,5 +32,6 @@
     "mock/**/*.ts",
     "vite.config.ts"
   ],
-  "exclude": ["node_modules", "dist", "**/*.js"]
+  "exclude": ["node_modules",
+    "docker/dist", "**/*.js"]
 }

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 333 - 0
vite.config.ts.timestamp-1718780321854-379d34a92f5ac.mjs