Browse Source

Merge branch 'master' of https://git.caner.top/Caner/busRoute

bls-dan 2 years ago
parent
commit
54c70be546

+ 0 - 62
README.md

@@ -13,68 +13,6 @@
 |   - `services`                  全局服务
 |   - `services`                  全局服务
 |   - `assets`                    全局静态文件
 |   - `assets`                    全局静态文件
 ```
 ```
-## 编写规范
-```
-import { onMounted, ref, computed} from 'vue'
-<script setup>
-    <!-- 函数new区  -->
-    const test = new DataServer()
-
-    <!-- data 声明区 -->
-    const test=ref(1)
-    const test1:computed(()=>test)
-
-    <!-- fn 声明区 -->
-    function name(){
-      console.log(123)
-    }
-    test().then(res=>{})
-
-    <!-- vue 方法区 -->
-    onMounted(() => {test()})
-
-</script>
-<template></template>
-<style></style>
-```
-### TS
-* 不允许的操作
-  * `any` 类型
-  * `JSON.parse` 等危险操作时不嵌套异常处理
-  * 单个文件中的脚本代码总行数不允许超过`1024`行
-* 命名
-  * 文件 小写字母命名,多个词之间以 `-`连接,不允许大写字母及驼峰式
-  * 变量
-    * 小写字母开头的驼峰式,如 `userName`
-    * 必须使用英文单词或有意义的拼音
-    * 单字符变量名只允许在循环、循环回调中使用,可使用 `i,j,k,m,n,t,v`等
-  * 函数
-    * 小写字母开头的驼峰式,如 `shouUserName`
-    * `.service.ts` 文件中方法命名建议:
-      * 集合类数据获取采用 `loadUsers` 之类的命名,即以 `load`开头并以获取数据名结尾
-      * 单个数据获取采用 `fetchTemplate` 之类的命名,以`fetch`开头并以数据名结尾
-      * 保存数据采用 `saveFlow` 之类的命名
-      * 删除数据采用 `removeTemplate` 之类的命名
-  * 类及类型
-    * 大写字母开头的驼峰式,如 `UserService`
-    * 私有变量以下划线接小写字母开头的驼峰式,如 `_innerType`
-  * 全局常量,下划线连接大写字母,如 `GROUP_TYPES`
-* 类型及注释
-  * 注释写法分以下几类
-  /** 这种用于简单描述函数作用 或 类成员变量用处 */
-  // 这种用于描述函数内变量或代码段作用
-  /**
-   * 这种用于描述类、复杂函数用途及参数等
-   */
-* 函数调用
-  * async 在没有其它函数调用的情况下,写成.then
-
-### CSS
-* 不允许使用无封装或不唯一的全局类样式,必须使用时需备注说明并慎重选择类名
-* 颜色赋值使用 `var(--color-a)` 写法,无特殊说明不允许直接赋值
-* `class, id` 命名必须使用短线连接单词方式,如 `form-label`, `list-item-title` 等
-* 多层级类名嵌套时,必须使用`scss`嵌套写法,以免污染其他样式
-
 ### Notice
 ### Notice
 * 框架使用解构,注入方式
 * 框架使用解构,注入方式
 * 自行增加.env.development 测试环境变量
 * 自行增加.env.development 测试环境变量

+ 18 - 21
src/components/map/map.service.ts

@@ -157,33 +157,30 @@ export default class MapService extends Service {
 
 
   // 初始化marks集合
   // 初始化marks集合
   public _initMarks(key: string, checked: string[], item?: any) {
   public _initMarks(key: string, checked: string[], item?: any) {
-    this.key = key
     this.marks[key] = {}
     this.marks[key] = {}
     for (let k = 0; k < checked.length; k++) {
     for (let k = 0; k < checked.length; k++) {
       const el = checked[k]
       const el = checked[k]
       const icon = item.option.find((er: { value: string }) => er.value === el)?.icon
       const icon = item.option.find((er: { value: string }) => er.value === el)?.icon
-      const newIcon = this.getIcon(icon)
+      const newIcon = this.getIcon(icon) || carIcon
       if (!this.marks[key][el]) this.marks[key][el] = {}
       if (!this.marks[key][el]) this.marks[key][el] = {}
-      if (key === 'homePage' && el !== 'bus') {
-        // homePageMark
-        this.getMarkData(el).then((res) => {
-          // line 需要单独处理
-          if (!res.length) return
-          if (el === 'line') {
-            for (let j = 0; j < res.length; j++) {
-              const es = res[j]
-              const paths = es.child?.sort((a: { stationNo: number }, b: { stationNo: number }) => a.stationNo - b.stationNo).map((ec: { lon: string; lat: string }) => ([ +ec.lon, +ec.lat ]))
-              const color = this.colorRandom()
-              this.marks[this.key][el][es.paramId] = { markMap: this.addLine(paths, color) }
-            }
-          } else {
-            for (let z = 0; z < res.length; z++) {
-              const ez = res[z]
-              this.marks[this.key][el][ez.paramId] = { ...ez, markMap: this.addMark([ +ez.lon, +ez.lat ], newIcon) }
-            }
+      if (el === 'bus') continue
+      this.getMarkData(el).then((res) => {
+        // line 需要单独处理
+        if (!res.length) return
+        if (el === 'line') {
+          for (let j = 0; j < res.length; j++) {
+            const es = res[j]
+            const paths = es.child?.sort((a: { stationNo: number }, b: { stationNo: number }) => a.stationNo - b.stationNo).map((ec: { lon: string; lat: string }) => ([ +ec.lon, +ec.lat ]))
+            const color = this.colorRandom()
+            this.marks[key][el][es.paramId] = { markMap: this.addLine(paths, color) }
           }
           }
-        })
-      }
+        } else {
+          for (let z = 0; z < res.length; z++) {
+            const ez = res[z]
+            this.marks[key][el][ez.paramId] = { ...ez, markMap: this.addMark([ +ez.lon, +ez.lat ], newIcon) }
+          }
+        }
+      })
     }
     }
   }
   }
 
 

+ 10 - 4
src/components/map/map.vue

@@ -46,7 +46,7 @@ const store = useStore()
 const mapService = new MapService()
 const mapService = new MapService()
 const props = withDefaults(defineProps<{
 const props = withDefaults(defineProps<{
   zoom?: number,
   zoom?: number,
-  Item?: { contrlSelect: { title: string, option: Any[], icon: string, checked:string[] }, key:string }
+  Item?: { contrlSelect: { title: string, option: Any[], icon: string, checked: string[] }, key: string }
 }>(), {
 }>(), {
   zoom: 13,
   zoom: 13,
   Item: () => ({
   Item: () => ({
@@ -61,7 +61,7 @@ const emit = defineEmits<{(evt: 'update:contrlSelect', value: Any): void
 const checkBoxs = ref(props.Item.contrlSelect.checked)
 const checkBoxs = ref(props.Item.contrlSelect.checked)
 
 
 // checkBox勾选
 // checkBox勾选
-function checkBoxsChange(params:string[], mate:{actionType:string, value:string}) {
+function checkBoxsChange(params: string[], mate: { actionType: string, value: string }) {
   const { marks } = mapService
   const { marks } = mapService
   console.log('勾选', marks[props.Item.key][mate.value])
   console.log('勾选', marks[props.Item.key][mate.value])
   if (!Object.keys(marks[props.Item.key][mate.value]).length) return
   if (!Object.keys(marks[props.Item.key][mate.value]).length) return
@@ -106,13 +106,19 @@ watch(() => store.socektData, (v) => {
 
 
 // 菜单切换显示隐藏
 // 菜单切换显示隐藏
 watch(() => props.Item.key, (v) => {
 watch(() => props.Item.key, (v) => {
-  console.log('菜单切换需要重新初始化mark', v)
+  checkBoxs.value = props.Item.contrlSelect.checked
   const { marks } = mapService
   const { marks } = mapService
+  // 添加marks
+  console.log('菜单切换需要重新初始化mark', v, marks, props)
+  if (!Object.keys(marks).includes(v)) {
+    mapService._initMarks(v, props.Item.contrlSelect.checked, props.Item.contrlSelect)
+  }
+  // 切换显示或者隐藏
   for (const k in marks) {
   for (const k in marks) {
     for (const j in marks[k]) {
     for (const j in marks[k]) {
       if (Object.keys(marks[k][j]).length) {
       if (Object.keys(marks[k][j]).length) {
         for (const z in marks[k][j]) {
         for (const z in marks[k][j]) {
-          if (k === props.Item.key) {
+          if (k === v) {
             marks[k][j][z].markMap.show()
             marks[k][j][z].markMap.show()
           } else {
           } else {
             marks[k][j][z].markMap.hide()
             marks[k][j][z].markMap.hide()

+ 1 - 4
src/pages/main.ts

@@ -10,10 +10,7 @@ const store = createPinia()
 
 
 // 动态路由
 // 动态路由
 const routes = Object.values(import.meta.glob('./views/*/route.ts', { eager: true, import: 'default' })) as unknown as RouteRecordRaw[]
 const routes = Object.values(import.meta.glob('./views/*/route.ts', { eager: true, import: 'default' })) as unknown as RouteRecordRaw[]
-routes.push(
-  { path: '/login', component: () => import('./login/index.vue') },
-  { path: '/:path(.*)', redirect: '/login' }
-)
+routes.push({ path: '/:path(.*)', redirect: '/login' })
 
 
 const app = createApp(App)
 const app = createApp(App)
 const router = createRouter({
 const router = createRouter({

+ 25 - 25
src/pages/views/home/index.vue

@@ -186,16 +186,16 @@ const menus = [
       option: [
       option: [
         {
         {
           label: '维保场',
           label: '维保场',
-          value: 1,
-          icon: ''
+          value: 'maintenanceStation',
+          icon: '43'
         },
         },
         {
         {
           label: '运维驿站',
           label: '运维驿站',
-          value: 2,
-          icon: ''
+          value: 'operationStation',
+          icon: '43'
         }
         }
       ],
       ],
-      checked: [ 1, 2 ]
+      checked: [ 'maintenanceStation', 'operationStation' ]
     }
     }
   },
   },
   {
   {
@@ -215,31 +215,31 @@ const menus = [
       option: [
       option: [
         {
         {
           label: '车辆',
           label: '车辆',
-          value: 1,
-          icon: ''
+          value: 'carInfo',
+          icon: '39'
         },
         },
         {
         {
           label: '电子站牌',
           label: '电子站牌',
-          value: 2,
-          icon: ''
+          value: 'electronicStationSign',
+          icon: '43'
         },
         },
         {
         {
           label: '洗衣机',
           label: '洗衣机',
-          value: 3,
-          icon: ''
+          value: 'carWasher',
+          icon: '43'
         },
         },
         {
         {
           label: '充电桩',
           label: '充电桩',
-          value: 4,
-          icon: ''
+          value: 'powerCharge',
+          icon: '42'
         },
         },
         {
         {
           label: '车载部件',
           label: '车载部件',
-          value: 5,
-          icon: ''
+          value: 'vehicleMountedComponents',
+          icon: '43'
         }
         }
       ],
       ],
-      checked: [ 1, 2, 3, 4, 5 ]
+      checked: [ 'carInfo', 'electronicStationSign', 'carWasher', 'powerCharge', 'vehicleMountedComponents' ]
     }
     }
   },
   },
   {
   {
@@ -264,26 +264,26 @@ const menus = [
       option: [
       option: [
         {
         {
           label: '枢纽站',
           label: '枢纽站',
-          value: 1,
-          icon: ''
+          value: 'hubStation',
+          icon: '43'
         },
         },
         {
         {
           label: '首末站',
           label: '首末站',
-          value: 2,
-          icon: ''
+          value: 'startEndStation',
+          icon: '43'
         },
         },
         {
         {
           label: '停保场',
           label: '停保场',
-          value: 3,
-          icon: ''
+          value: 'parkingLot',
+          icon: '43'
         },
         },
         {
         {
           label: '维保站',
           label: '维保站',
-          value: 4,
-          icon: ''
+          value: 'maintenanceStation',
+          icon: '43'
         }
         }
       ],
       ],
-      checked: [ 1, 2, 3, 4 ]
+      checked: [ 'hubStation', 'startEndStation', 'parkingLot', 'maintenanceStation' ]
     }
     }
   },
   },
   {
   {

+ 2 - 2
src/pages/login/index.vue → src/pages/views/login/index.vue

@@ -1,7 +1,7 @@
 <script lang='ts' setup>
 <script lang='ts' setup>
 import { nextTick, ref } from 'vue'
 import { nextTick, ref } from 'vue'
-import NetService from '@/services/net.service'
-import useStore from '../store'
+import NetService from '../../../services/net.service'
+import useStore from '../../store'
 const netService = new NetService()
 const netService = new NetService()
 
 
 const store = useStore()
 const store = useStore()

+ 0 - 0
src/pages/login/route.ts → src/pages/views/login/route.ts


+ 0 - 3
src/pages/views/test/index.vue

@@ -1,3 +0,0 @@
-<template>
-  <div>3D测试</div>
-</template>

+ 0 - 10
src/pages/views/test/route.ts

@@ -1,10 +0,0 @@
-import { RouteRecordRaw } from 'vue-router'
-
-export default {
-  path: '/test',
-  meta: {
-    authorize: true
-  },
-  component: () => import('./index.vue'),
-  children: []
-} as RouteRecordRaw