This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.

Cyber Narrator(CN)

安装

npm install

开发环境

npm run serve

生产环境

npm run build

Lints

npm run lint

技术选型

1.VUE3

2.基础UI库

项目UI设计与NEZHA相似度较高考虑到工作量、学习成本结合NEZHA的体验选用element-plus

3.图表组件库

图表echarts5.0
地图amCharts
拖拽 & ResizeVue-grid-layout  https://jbaysolutions.github.io/vue-grid-layout/guide/

4.响应式方案

lib-flexible + postcss-px2rem-exclude + 媒体查询
lib-flexible 将px自动转为rempostcss-px2rem-exclude 避免将ui库的css转换媒体查询根据不同屏幕大小使用不同的root font size

5.工具

lodash库该库包含大部分常用工具方法包括数组操作、函数功能扩展、对象操作等且高性能、一致。开发中应该优先使用该库的方法
https://www.lodashjs.com/

开发规范 & 要求

1.语义化

  • 所有命名要求使用语义化英文,意思表达清晰、准确
  • 除如IP、SNMP这类特殊名词外避免将单词缩略简写
  • 禁用汉语拼音

2.命名

多个单词时,应该以高阶的 (通常是一般化描述的) 单词开头,以描述性的修饰词结尾
egSearchButtonClear.vue 反例:ClearSearchButton.vue

  • 文件夹
    使用小写,单词间使用连字符-连接,或使用驼峰格式 egright-boxrightBox

  • VUE组件文件
    使用大写开头的驼峰格式
    egAssetBox.vue

  • JS/CSS/SCSS/png等
    使用小写,单词间使用连字符-连接
    egtable-common.scss

  • JS标识符 使用小写开头的驼峰格式
    egconst tableTitle = 'Role'

  • CLASS
    使用BEM规范命名 B__E--M其中B名称必须是唯一的
    BEM具体内容见 http://getbem.com/introduction/

推荐阅读
VUE官方风格指南 https://v3.cn.vuejs.org/style-guide/

3.开发

  • 功能开发之初应考虑未来复用的可能性,将可能复用的功能代码提取为组件或使用混入,合理暴露参数、插槽,降低耦合;时间紧迫时优先级放后

  • 性能
    1.组件销毁前注意解绑挂载在window对象和其他组件实例上的事件
    2.减少能够触发浏览器回流、重绘的代码,必须使用时将使用次数尽量减少
    触发回流、重绘的js函数
    offsetTop、offsetLeft、offsetWidth、offsetHeight scrollTop、scrollLeft、scrollWidth、scrollHeight clientTop、clientLeft、clientWidth、clientHeight getComputedStyle() getBoundingClientRect()
    需要使用js修改style时一次性赋值而不是分为多次
    eg
    const el = document.getElementById('el')
    el.style.cssText += 'border-left: 1px; border-right: 2px; padding: 5px;';
    反例:
    const el = document.getElementById('el')
    el.style.padding = 'xxx'
    el.style.margin = 'xxx'
    el.style.border = 'xxx'

  • 布局
    避免使用float视情况使用position建议使用flex和grid

Description
No description provided
Readme 316 MiB
Languages
Vue 54.2%
JavaScript 34.1%
SCSS 11.3%
CSS 0.3%