Jelajahi Sumber

继续测试

liyangzheng 1 tahun lalu
induk
melakukan
9faa31caf7

+ 11 - 0
src/api/login.js

@@ -0,0 +1,11 @@
+import request from "@/utils/request"
+function LoginNow(data){
+    return request({
+        url:`/login`,
+        method:"post",
+        params:data,
+    })
+}
+export default{
+    LoginNow,
+}

+ 0 - 11
src/api/text.js

@@ -1,11 +0,0 @@
-import request from "@/utils/request"
-function test(data) {
-    return request({
-        url: "/area/tree",
-        method: "get",
-        params:data
-    })
-}
-export default {
-    test,
-}

+ 19 - 0
src/pages/home/HomePage.vue

@@ -0,0 +1,19 @@
+<template>
+    <div>
+        <h1>this is home</h1>
+    </div>
+</template>
+
+<script>
+export default {
+    setup () {
+        
+
+        return {}
+    }
+}
+</script>
+
+<style lang="scss" scoped>
+
+</style>

+ 39 - 7
src/pages/login/LoginNow.vue

@@ -1,17 +1,34 @@
 <template>
     <div>
-        <el-input v-model="less"></el-input>
-        <el-button @click="sss">555</el-button>
+        <div>
+            <el-form :model="loginForm" label-width="120px">
+                <el-form-item label="用户名">
+                    <el-input v-model="loginForm.username" />
+                </el-form-item>
+                <el-form-item label="密码">
+                    <el-input v-model="loginForm.userpass" />
+                </el-form-item>
+            </el-form>
+            <el-button type="primary" @click="sureLog">登录</el-button>
+        </div>
     </div>
 </template>
 
 <script>
 import { ref, onMounted } from "vue"
+import { useRouter } from 'vue-router'
+
+import { ElMessage } from "element-plus"
 import { jsPlumb } from 'jsplumb'
-import texts from "@/api/text"
+import login from "@/api/login"
 export default {
     setup() {
         let less = ref("")
+        let loginForm = ref({
+            username: "",
+            userpass: ""
+        })
+        let router = useRouter()
         function encryptPassword(password) {
             let val = SmCrypto.doSm3AndSm2Encrypt(password) + '0000'
             let ascCode = 0
@@ -29,16 +46,31 @@ export default {
             console.log(val, 'val');
             return val
         }
-        function sss() {
-            let kis = encryptPassword(less.value)
-            console.log(kis, 'kiss');
+        function sureLog() {
+            let kis = encryptPassword(loginForm.value.userpass)
+            login.LoginNow({
+                login_account: loginForm.value.username,
+                pwd: kis
+            }).then(res => {
+                if (res.returncode === 200) {
+                    router.push('/home')
+                } else {
+                    ElMessage({
+                        message: res.msg,
+                        type: "error"
+                    })
+                    // router.push('/home')
+                }
+                console.log(res, 'login');
+            })
         }
         onMounted(() => {
         })
         return {
             encryptPassword,
             less,
-            sss,
+            sureLog,
+            loginForm,
         }
     }
 }

+ 59 - 50
src/pages/mapLoad/FatherMap.vue

@@ -1,48 +1,50 @@
 <template>
-    <div style="width: 90vw;height: 90vh;">
-        <ul class="box">
-            <li class="leftMenu">
-                <h3>选择节点</h3>
-                <el-collapse>
-                    <el-collapse-item :title="item1.name" v-for="(item1, index) in leftMenuData" :key="index">
-                        <draggable @start="moveStart" @end="moveEnd" v-model="item1.children" :options="options">
-                            <div v-for="(item2, n) in item1.children" class="content" :divOption="JSON.stringify(item2)"
-                                @mousedown="mouseDownFun" :key="n">
-                                {{ item2.config[0].value }}
-                            </div>
-                        </draggable>
-                    </el-collapse-item>
-                </el-collapse>
-            </li>
-            <li class="plumbBox" id="plumbBox">
-                <div v-for="(item, index) in info" :key="index" :id="item.id" :style="getStyle(item)"
-                    :class="item.id === activeNode.id ? 'activeNode' : 'normalNode'" @click="sendActive(item)">
-                    <div class="plumbNode" :id="item.id + 'plumbNode'">
-                        <el-icon :size="20">
-                            <CirclePlusFilled />
+    <div>
+        <div style="width: 90vw;height: 90vh;" id="diagramContainer">
+            <ul class="box">
+                <li class="leftMenu">
+                    <h3>选择节点</h3>
+                    <el-collapse>
+                        <el-collapse-item :title="item1.name" v-for="(item1, index) in leftMenuData" :key="index">
+                            <draggable @start="moveStart" @end="moveEnd" v-model="item1.children" :options="options">
+                                <div v-for="(item2, n) in item1.children" class="content" :divOption="JSON.stringify(item2)"
+                                    @mousedown="mouseDownFun" :key="n">
+                                    {{ item2.config[0].value }}
+                                </div>
+                            </draggable>
+                        </el-collapse-item>
+                    </el-collapse>
+                </li>
+                <li class="plumbBox" id="plumbBox">
+                    <div v-for="(item, index) in info" :key="index" :id="item.id" :style="getStyle(item)"
+                        :class="item.id === activeNode.id ? 'activeNode' : 'normalNode'" @click="sendActive(item)">
+                        <div class="plumbNode" :id="item.id + 'plumbNode'">
+                            <el-icon :size="20">
+                                <CirclePlusFilled />
+                            </el-icon>
+                        </div>
+                        {{ item.config[0].value }}
+                        <el-icon class="is-loading" v-if="item.status === 'loading'" color="blue">
+                            <Loading />
+                        </el-icon>
+                        <el-icon v-else-if="item.status === 'success'" color="green">
+                            <CircleCheckFilled />
+                        </el-icon>
+                        <el-icon v-else-if="item.status === 'error'" color="red">
+                            <CircleCloseFilled />
                         </el-icon>
                     </div>
-                    {{ item.config[0].value }}
-                    <el-icon class="is-loading" v-if="item.status === 'loading'" color="blue">
-                        <Loading />
-                    </el-icon>
-                    <el-icon v-else-if="item.status === 'success'" color="green">
-                        <CircleCheckFilled />
-                    </el-icon>
-                    <el-icon v-else-if="item.status === 'error'" color="red">
-                        <CircleCloseFilled />
-                    </el-icon>
-                </div>
-            </li>
+                </li>
 
-            <li class="rightContent">
-                <h3>节点操作</h3>
-                <div style="padding-left: 10px">
-                    <RightForm ref="rightForm" @changeActiveNodeInfo="changeActiveNodeInfo" @deleteLine="deleteLine"
-                        @deleteNode="deleteNode"></RightForm>
-                </div>
-            </li>
-        </ul>
+                <li class="rightContent">
+                    <h3>节点操作</h3>
+                    <div style="padding-left: 10px">
+                        <RightForm ref="rightForm" @changeActiveNodeInfo="changeActiveNodeInfo" @deleteLine="deleteLine"
+                            @deleteNode="deleteNode"></RightForm>
+                    </div>
+                </li>
+            </ul>
+        </div>
     </div>
 </template>
 <script setup>
@@ -408,21 +410,28 @@ const makeFun = (item) => {
     var common = {
         isSource: true,
         isTarget: true,
-        connector: ['Straight'],
-        overlays: [['Arrow', { width: 12, length: 12, location: 0.5 }]]
+        connector: ['Flowchart'],
+        grid: [10, 10],
+        maxConnections: -1,
+        overlays: [
+            ['Arrow', { width: 12, length: 12, location: 0.5 }],
+            // ["Label", { location: 0.5, label: "标签", cssClass: "endpointTargetLabel", visible: true, id: "label" }]
+        ],
+        anchor: ['Bottom'],
+        // anchor: "Continuous"
     }
     plumbInit.addEndpoint(item.id + '', common)
-    // plumbInit.setSourceEnabled(item.id, { anchors: ['Right'] }, common);
-    // plumbInit.setTargetEnabled(item.id, { anchors: ['Right'] }, common);
-    // plumbInit.setDraggable(item.id, true);
+    plumbInit.setSourceEnabled(item.id, common);
+    plumbInit.setTargetEnabled(item.id, common);
+    plumbInit.setDraggable(item.id, true);
     plumbInit.makeSource(item.id, {
         filter: ".plumbNode",
         filterExclude: false,
         allowLoopback: true,
         maxConnections: -1,
         Container: "plumbBox",
-        anchor: item.anchor,
-        connector: item.connector,
+        anchor: "Continuous",
+        connector: ['Flowchart'],
         endpoint: item.endpoint,
         overlays: item.overlays,
         paintStyle: item.paintStyle,
@@ -435,8 +444,8 @@ const makeFun = (item) => {
         allowLoopback: true,
         maxConnections: 1,
         Container: "plumbBox",
-        anchor: item.anchor,
-        connector: item.connector,
+        anchor: "Continuous",
+        connector: ['Flowchart'],
         endpoint: item.endpoint,
         overlays: item.overlays,
         paintStyle: item.paintStyle,

+ 31 - 16
src/router/index.js

@@ -1,5 +1,6 @@
 // router/index.js
 import { createRouter, createWebHistory } from 'vue-router'
+import { ElMessage } from 'element-plus'
 const routes = [
     // 添加更多路由信息
     {
@@ -19,6 +20,16 @@ const routes = [
     {
         path:"/77",
         component:()=>import("@/pages/mapLoad/FatherMap.vue")
+    },
+    {
+        path:"/home",
+        component:()=>import("@/pages/home/HomePage.vue"),
+        meta:{
+            name:"home"
+        },
+        children:[
+
+        ]
     }
 ]
 
@@ -26,20 +37,24 @@ const router = createRouter({
     history: createWebHistory(),
     routes,
 })
-// router.beforeEach((to, from, next) => {
-//     // 假设您有一个名为 isAuthenticated 的全局变量来表示用户是否已登录
-//     const isAuthenticated = false; // 请替换为实际的登录状态判断逻辑
-//     // 如果用户已登录,正常导航到目标路由
-//     if (isAuthenticated) {
-//         next();
-//     } else {
-//         // 如果用户未登录,重定向到登录页
-//         if (to.path !== '/login') {
-//             next('/login');
-//         } else {
-//             // 如果用户已经在登录页,继续正常导航
-//             next();
-//         }
-//     }
-// })
+router.beforeEach((to, from, next) => {
+    // 假设您有一个名为 isAuthenticated 的全局变量来表示用户是否已登录
+    const isAuthenticated = true; // 请替换为实际的登录状态判断逻辑
+    // 如果用户已登录,正常导航到目标路由
+    if (isAuthenticated) {
+        next();
+    } else {
+        ElMessage({
+            type:"error",
+            message:"您还未登录"
+        })
+        // 如果用户未登录,重定向到登录页
+        if (to.path !== '/login') {
+            next('/login');
+        } else {
+            // 如果用户已经在登录页,继续正常导航
+            next();
+        }
+    }
+})
 export default router

+ 1 - 1
src/utils/request.js

@@ -6,7 +6,7 @@ import router from '@/router'
 // 请求url
 const service = axios.create({
     // baseURL: window.STATIC_CONFIG.proxyUrl, // url = base url + request url
-    baseURL: "http://localhost:18001/api",
+    baseURL: "http://8.142.173.95:10086/api",
     timeout: 15000 // request timeout
 })