lvkun996 2 лет назад
Родитель
Сommit
61fdc16fac
8 измененных файлов с 135 добавлено и 128 удалено
  1. 0 84
      Artwork.cpp
  2. 32 23
      README.md
  3. 25 0
      src/components/TableProV2/README.md
  4. 31 17
      src/components/TableProV2/index.tsx
  5. 14 0
      src/global.d.ts
  6. 29 2
      src/main.ts
  7. 1 1
      src/pages/Iot/rule/linkRules.vue
  8. 3 1
      tsconfig.json

+ 0 - 84
Artwork.cpp

@@ -1,84 +0,0 @@
-#include <iostream>
-#include <vector>
-#include <string>
-
-class Artwork {
-public:
-    Artwork(const std::string& author, const std::string& title, int birthYear, const std::string& category)
-        : author(author), title(title), birthYear(birthYear), category(category) {}
-
-    virtual void displayInfo() const {
-        std::cout << "Author: " << author << ", Title: " << title << ", Birth Year: " << birthYear << ", Category: " << category;
-    }
-
-    virtual ~Artwork() = default;
-
-private:
-    std::string author;
-    std::string title;
-    int birthYear;
-    std::string category;
-};
-
-class Painting : public Artwork {
-public:
-    Painting(const std::string& author, const std::string& title, int birthYear, const std::string& category, const std::string& size)
-        : Artwork(author, title, birthYear, category), size(size) {}
-
-    void displayInfo() const override {
-        Artwork::displayInfo();
-        std::cout << ", Size: " << size;
-    }
-
-private:
-    std::string size;
-};
-
-class Music : public Artwork {
-public:
-    Music(const std::string& author, const std::string& title, int birthYear, const std::string& category, const std::string& content)
-        : Artwork(author, title, birthYear, category), content(content) {}
-
-    void displayInfo() const override {
-        Artwork::displayInfo();
-        std::cout << ", Content: " << content;
-    }
-
-private:
-    std::string content;
-};
-
-class Chamber : public Music {
-public:
-    Chamber(const std::string& author, const std::string& title, int birthYear, const std::string& content, int numPerformers)
-        : Music(author, title, birthYear, "Chamber", content), numPerformers(numPerformers) {}
-
-    void displayInfo() const override {
-        Music::displayInfo();
-        std::cout << ", Number of Performers: " << numPerformers;
-    }
-
-private:
-    int numPerformers;
-};
-
-int main() {
-    std::vector<Artwork*> artworks;
-
-    artworks.push_back(new Painting("Artist", "Painting", 2020, "Painting", "30x40"));
-    artworks.push_back(new Music("Composer", "Music", 2021, "Music", "Symphony"));
-    artworks.push_back(new Chamber("Composer", "Chamber", 2022, "Quartet", 4));
-
-
-    for (const auto& artwork : artworks) {
-        artwork->displayInfo();
-        std::cout << std::endl;
-    }
-
-  
-    for (const auto& artwork : artworks) {
-        delete artwork;
-    }
-
-    return 0;
-}

+ 32 - 23
README.md

@@ -21,37 +21,33 @@ request:
 | value | select的value |
 | key   | select的key   |
 
-## 打包
+## 项目脚本
 
-###  build
+### build
 
 npm run build 该指令全是将目前已有的模块全部打包
 
-### package
+### build:cli
 
-npm run build:package  该指令全是将目前已有的模块分别打包
+可视化选择打包
 
-目前已有的模块
+1. 打包是否去除logo与用户模块
+2. 选择打包的模块
+3. 选择打包的平台
 
-| key      | 名称     | 链接                                     |
-| -------- | -------- | ---------------------------------------- |
-| iot      | 物联网   | /iot                                     |
-| rts      | 视联网   | /rts                                     |
-| schedule | 数据中台 | /schedule |
-| view     | 可视化   | http://cloudview.jiaolongcloud.com/      |
-| lowcode  | 低代码   | http://49.232.161.110:5556               |
-| user  | 用户群组   | /user             |
-| login | 登陆页 | /login |
-| login | 登陆页 | /login |
-#### 使用说明
+| key      | 名称     | 链接                                |
+| -------- | -------- | ----------------------------------- |
+| iot      | 物联网   | /iot                                |
+| cvs      | 视联网   | /cvs                                |
+| schedule | 数据中台 | /schedule                           |
+| view     | 可视化   | http://cloudview.jiaolongcloud.com/ |
+| lowcode  | 低代码   | http://49.232.161.110:5556          |
+| user     | 用户群组 | /user                               |
+| login    | 登陆页   | /login                              |
 
-当运行 npm run build:package iot rts 时 , 将会打包`物联网`与`视联网`两个模块
+ps: 当模块的链接是外部链接时,如果打包的模块在参数的首位,则打包后会自动跳转到外部链接
 
-当运行 npm run build:package rts 时 , 将会打包`视联网`模块
 
-当运行 npm run build:package schedule view 时 ,将会打包`数据中台`与`可视化`两个模块
-
-当模块的链接是外部链接时,如果打包的模块在参数的首位,则打包后会自动跳转到外部链接
 
 ## 登陆
 
@@ -66,9 +62,7 @@ npm run build:package  该指令全是将目前已有的模块分别打包
 ## 待做
 
 1. 支持对浏览器标签的信息设置
-5. 区域纯净模式
 6. 登录逻辑封装npm包
-7. 当前项目对状态码的错误处理
 7. 打包的mac app,顶部的状态栏高度有问题
 
 ## 代理
@@ -93,3 +87,18 @@ npm run build:package  该指令全是将目前已有的模块分别打包
 
 
 
+# 组件
+
+本项目封装了大量的组件
+
+## table-pro
+
+# ui
+
+遵从简洁易操作原则
+
+1. 新增表单改为页面嵌入式,表单分开
+2. 选择数据之类的操作从右侧推入
+3. 页面布局分为navar + sideler 或者 单独siderler布局
+4. 新增新手交互引导(布局切换)
+5. 项目主色调 + 字体大小调整

+ 25 - 0
src/components/TableProV2/README.md

@@ -0,0 +1,25 @@
+# table-pro
+
+基于antd-vue的table组件,无侵入式封装原组件,继承排序、筛选、列表显示、数据图表、刷新、分页、放大图表,集成新增行为
+
+
+
+props
+
+| name  | select的label |
+| ----- | ------------- |
+| value | select的value |
+| key   | select的key   |
+
+
+
+
+
+
+
+
+
+
+
+
+

+ 31 - 17
src/components/TableProV2/index.tsx

@@ -7,8 +7,19 @@ import {
   PropType, computed, defineComponent, ref, onMounted, toRefs, Teleport, cloneVNode
 } from 'vue'
 
+//
+// ['export', { key: 'export', label: '新增' }]
+const opraMap = new Map([
+  ['add', { key: 'add', label: '新增' }],
+  ['reload', { key: 'reload', label: '刷新' }],
+  ['pure', { key: 'pure', label: '新增' }]
+])
+
+Array.from(opraMap, ([key, value]) => ({ ...value }))
+
 /**
  * @description Table Pro 超级table 将各种业务与操作融合起来
+ *
  */
 const TablePro = defineComponent({
   props: {
@@ -73,7 +84,6 @@ const TablePro = defineComponent({
       loading.value = false
       paginationRef.value.total = sum
       dataSource.value = data
-      console.log('data:', data)
     }
 
     const onChangePage = (page: number, pageSize: number) => {
@@ -88,6 +98,7 @@ const TablePro = defineComponent({
       service && dispatchRequest()
     })
 
+    // 放大图表
     const pure = () => {
       pureVisible.value = false
 
@@ -103,7 +114,10 @@ const TablePro = defineComponent({
 
     const opraMeun = (
       <Menu>
-           { hiddenMeunKeys.value.includes('add') ? null : <Menu.Item key={0} onClick={() => ctx.emit('add')} > 新增 </Menu.Item> }
+        {/* {
+          Array.from(opraMap, ([key, value]) => ({...value})).map( item => Menu.Item key={1} onClick={() => pure()} > 放大 </Menu.Item> )
+        } */}
+        { hiddenMeunKeys.value.includes('add') ? null : <Menu.Item key={0} onClick={() => ctx.emit('add')} > 新增 </Menu.Item> }
         <Menu.Item key={1} onClick={() => pure()} > 放大 </Menu.Item>
       </Menu>
     )
@@ -153,21 +167,21 @@ const TablePro = defineComponent({
           </Col>
           <Col span={24} >
 
-          <Teleport disabled={pureVisible.value} to="#teleport-full-container" >
-            <Table
-              style={{ marginTop: '20px', width: pureVisible.value ? '100%' : '100vw', cursor: pureVisible.value ? 'normal' : 'not-allowed' }}
-              columns={columnsPro.value.filter(item => item._active)}
-              loading={loading.value}
-              pagination={ typeof pagination === 'boolean' ? pagination : { ...paginationRef.value, onChange: onChangePage }}
-              dataSource={columnsPro.value.filter(item => item._active).length ? dataSource.value : []}
-              v-slots={{
-                bodyCell (scope) {
-                  return ctx.slots.render?.({ column: scope.column, record: scope.record })
-                }
-              }}
-            >
-            </Table>
-            </Teleport>
+            <Teleport disabled={pureVisible.value} to="#teleport-full-container" >
+              <Table
+                style={{ marginTop: '20px', width: pureVisible.value ? '100%' : '100vw', cursor: pureVisible.value ? 'normal' : 'not-allowed' }}
+                columns={columnsPro.value.filter(item => item._active)}
+                loading={loading.value}
+                pagination={ typeof pagination === 'boolean' ? pagination : { ...paginationRef.value, onChange: onChangePage }}
+                dataSource={columnsPro.value.filter(item => item._active).length ? dataSource.value : []}
+                v-slots={{
+                  bodyCell (scope) {
+                    return ctx.slots.render?.({ column: scope.column, record: scope.record })
+                  }
+                }}
+              >
+              </Table>
+             </Teleport>
           </Col>
         </Row>
 

+ 14 - 0
src/global.d.ts

@@ -1,3 +1,17 @@
 declare const window: Window & typeof globalThis & {flv: any}
 declare module '@vue-js-cron/ant'
 declare module 'flicker-vue-hooks'
+
+interface Object {
+ /**
+  * @description  Map数据格式转为数组
+ */
+  mapToArray(map: Map<any, any>): any[];
+
+/**
+  * @description  对象数组转为MAP结构,需要指定转换的key,
+  * 指定value时,MAP的value为指定的key,不指定value的key,
+  * 则整个对象变为MAP结构的value
+ */
+  arrayToMap(array: Record<string, any>[], key: string, valueKey?: string): Map<string, any>
+}

+ 29 - 2
src/main.ts

@@ -26,7 +26,34 @@ app.use(router)
   .provide('useStaticImg', assets)
   .mount('#app')
 
+// `trace` 是组件层级结构的追踪
 app.config.warnHandler = (msg, instance, trace) => {
-  // `trace` 是组件层级结构的追踪
-  console.log('trace 是组件层级结构的追踪')
+
+}
+
+// 全局注册一些辅助性的函数 desc在 global.d.ts下
+window.Object.prototype.mapToArray = function (map: Map<any, any>) {
+  return Array.from(map, ([key, value]) => {
+    if (typeof value === 'object') {
+      return { key, ...value }
+    } else {
+      return { key, value }
+    }
+  })
+}
+
+window.Object.prototype.arrayToMap = function (array: Record<string, any>[], key: string, valueKey?: string): Map<string, any> {
+  if (typeof array[0] !== 'object') {
+    throw new Error('仅支持Record<string, any>[]格式的数组')
+  }
+  const _map = new Map()
+  array.forEach(item => {
+    _map.set(item[key], valueKey ? item[valueKey] : item)
+  })
+
+  return _map
 }
+
+const a = new Map([['a', 1]])
+
+Object.mapToArray(a)

+ 1 - 1
src/pages/Iot/rule/linkRules.vue

@@ -1,5 +1,5 @@
 <template>
-   <StatisticsTemplate
+  <StatisticsTemplate
     title="规则统计"
     :list="state.linkCount"
   />

+ 3 - 1
tsconfig.json

@@ -32,11 +32,13 @@
     ]
   },
   "include": [
+    "global.d.ts",
     "src/**/*.ts",
     "src/**/*.tsx",
     "src/**/*.vue",
     "tests/**/*.ts",
-    "tests/**/*.tsx"
+    "tests/**/*.tsx",
+    
   ],
   "exclude": [
     "node_modules"