Commit 29b5a203 by luyt

add;gl-components组件库文档

1 parent b81f30a3
...@@ -23,7 +23,12 @@ module.exports = { ...@@ -23,7 +23,12 @@ module.exports = {
{ {
title: "开发指南", title: "开发指南",
collapsable: false, // 是否具有展开收起功能 collapsable: false, // 是否具有展开收起功能
children: ["/firstside/", "/firstside/update", "/firstside/child/"], // 这个是根据自己的需求来订,对应自己在docs下的文件夹名,默认首页是README.md children: ["/firstside/","/firstside/update"], // 这个是根据自己的需求来订,对应自己在docs下的文件夹名,默认首页是README.md
},
{
title: "组件文档",
collapsable: false, // 是否具有展开收起功能
children: ["/components/table","/components/button"],
}, },
// { // {
// title: "第一个侧边栏", // title: "第一个侧边栏",
......
# 广联数科-glsx-components介绍 # 广联数科-glsx-components介绍
## 网站快速成型工具
一套为广联数科-SRCM特制基于 [Vue 2.x](https://cn.vuejs.org/) 的桌面端组件库,底层基于[Element](https://element.eleme.cn/#/zh-CN) UI再次封装
更多详情移到组件介绍页 - [开发指南](/firstside/)
<!-- ```html <!-- ```html
<div>123456</div> <div>123456</div>
......
# GLButton 按钮
基于"[element-ui](https://element.eleme.cn/#/zh-CN)": "^2.15.6",将 [Button](https://element.eleme.cn/#/zh-CN/component/table) 组件进行了封装。根据业务需求,增加了权限校验,提高了工作效率。
#### 使用方式
在你想要使用的组件内,如下使用
(注:Button,渲染函数封装,如果你不了解渲染函数,请移步vue的[渲染函数](https://cn.vuejs.org/v2/guide/render-function.html)文档查阅相关资料)
```vue
<template>
<GLButton @click="click"
fn="1-1-1-11"
mode="el-button"
display="disabled">
232321321
</GLButton>
</template>
<script>
import { GLButton } from 'glsx-components';
import 'glsx-components/dist/glsx-components.css';
export default {
name:'demo',
data(){
return {
visible:false
}
},
components:{
GLButton
},
methods:{
click() {
console.log(111111111111)
this.visible = true
}
}
}
</script>
```
#### Props
|Name|Description|Type|Required|Default|
|---|---|---|---|---|
|fn|权限|String|否|null|
|mode|要渲染的元素|String|否|el-button|
|display|是否禁用|String|否|null|
更多详情参考 [Element Button](https://element.eleme.cn/#/zh-CN/component/button) Attributes
# GLTable 表格
基于"[element-ui](https://element.eleme.cn/#/zh-CN)": "^2.15.6",将 [table](https://element.eleme.cn/#/zh-CN/component/table) 和 [Pagination](https://element.eleme.cn/#/zh-CN/component/pagination) 组件进行了封装,通过配置参数的方式就能快速生成表格。
使用该组件,能够在提高了工作效率的同时,保证了代码的可靠性和健壮性。
#### 使用方式
在你想要使用的组件内,如下使用
(注:table column pagination 属性事件透传,table使用默认的$attr,$listener)
```vue
<template>
<GLTable ref="liveRoomRef"
:tableParams="tableParams"
:tableData="tableData"
:tableTotal="100"
header-row-class-name="header-row"
@row-click="handleRowClick"
:paginationattrs="paginationattrs"
:paginationlisteners="paginationlisteners">
</GLTable>
</template>
<script>
import { GLTable } from 'glsx-components';
import 'glsx-components/dist/glsx-components.css';
export default {
name: 'demo',
data() {
return {
demo1: true,
// el分页属性透传
paginationattrs: {
'prev-text':'上一页',
'next-text':'下一页'
},
// el分页事件透传
paginationlisteners: {
'prev-click':this.prevClickHandle,
'next-click':this.nextClickHandle
},
tableParams: {
listName: 'list',
tableOption: false,
tableColumns: [
{
label: '最近开播',
prop: 'time',
width: '180',
formatter: cellValue => {
return cellValue.startTime + '-' + cellValue.endTime
},
// column 属性透传
columnattrs:{
'class-name':'custom-class'
}
},
{
label: '直播间名称',
prop: 'name',
line: 1
},
{
label: '房间号',
prop: 'roomId'
},
{
label: '主播',
prop: 'anchorName',
line: 1
}
]
},
tableData: [
{
name: '王小虎王小虎王小虎王',
liveStatus3: '132',
liveStatus4: '789',
name1: '123',
name2: '123'
},
{
name: '王小虎王小虎王小虎王',
liveStatus3: '132',
liveStatus4: '789',
name1: '123',
name2: '123'
},
{
name: '王小虎',
liveStatus3: '132',
liveStatus4: '789',
name1: '123',
name2: '123'
},
{
name: '王小虎王小虎王小虎王',
liveStatus3: '132',
liveStatus4: '789',
name1: '123',
name2: '123'
}
]
}
},
methods:{
btnClick(){
alert('点击')
},
toggleShow(num){
// console.log(123)
this['demo' + num] = !this['demo' + num]
},
handleRowClick(){
alert('点击这行')
},
prevClickHandle(){
alert('我是上一页点击事件')
},
nextClickHandle(){
alert('我是下一页点击事件')
}
},
components:{
GLTable
}
}
</script>
```
#### Props
|Name|Description|Type|Required|Default|
|---|---|---|---|---|
|size|`medium` / `small` / `mini`|`String`|`false`|medium|
|height|-|`String`|`false`|-|
|noDataImg|maxHeight:{ type:String, default:'3000' },|`String`|`false`|-|
|noDataText|-|`String`|`false`|暂无数据|
|border|-|`Boolean`|`false`|false|
|headerStyle|-|`Object`|`false`|-|
|tableId|表格需要多传入一个id的情况|`String`|`false`|-|
|searchForm|搜索条件|`Object`|`false`|-|
|isCustomHead|是否定制表头|`Boolean`|`false`|false|
|customHeadShowList|表头展示|`Array`|`false`|[]|
|tableData|表格数据-外部传入|`Array`|`false`|[]|
|tableTotal|-|`Number`|`false`|0|
|getListApi|获取列表接口|`Function`|`false`|-|
|beforeSearchFn|搜索前操作|`Function`|`false`|() => { return new Promise((resolve, reject) => {resolve();}); } |
|pageSizes|-|`Array`|`false`|[10,20,30,40]|
|hasPage|分页,默认有|`Boolean`|`false`|true|
|pageConf|-|`Object`|`false`|{"pageSize":"pageSize","pageNum":"pageNum","totalCount":"totalCount"}|
|layout|分页组件配置|`String`|`false`|sizes,total,->,prev,pager,next,jumper|
|hasNum|序号,默认有|`Boolean`|`false`|true|
|tableParams|-|`Object`|`false`|{"checkSelectKey":{"default":""},"checkSelectVal":{},"listName":{"default":""},"tableColumns":{}}|
|paginationattrs|el分页组件属性透传|`Object`|`false`|{}|
|paginationlisteners|el分页组件事件透传|`Object`|`false`|{}|
#### Events
|Event Name|Description|Parameters|
|---|---|---|
|sortChange|排序|column \ prop \ order|
|selectionTable|多选|-|
|setTableFinishFun|表格请求到数据 console.log('表格请求到数据this.data',this.data)|-|
|refreshTable|刷新表格|-|
#### Slots
|Name |Description |Default Slot Content|
|---|---|---|
|addHtml|自定义插槽的名字| 名字为动态传入 |
|auth-button|按钮插槽的名字|-|
|additionalContent|-|-|
...@@ -53,3 +53,90 @@ new Vue({ ...@@ -53,3 +53,90 @@ new Vue({
render: h => h(App) render: h => h(App)
}); });
``` ```
## 项目结构
```
├─build // gulp的配置文件
├─documents // 自动生文档静态站点所依赖的库
├─node_modules
├─public // html入口
├─src // 源码目录
├─assets // 静态资源
├─components
├─directives // 自定义指令
├─filters // 自定义过滤器
├─localtest // 用本地打包后的组件 文件测试 umd
├─packages // 封装的组件源码
├─plugins // 使用的插件目录 目前只有element
├─theme // 主题样式
├─utils // 工具函数, 主题切换等
├─App.vue
├─index.js // 组件载入的入口 仅用于本地测试 npm run serve
└─main.js // 项目入口
├─website // 组件文档静态资源网站
├─.browserslistrc
├─.gitignore
├─gulpfile.js // 生成组件文档的gulp配置
├─...
├─babel.config
├─package.json
├─vue.config.js // 项目打包的一些配置
└─README.md
```
## 自定义主题
产品 SaaS 化,通常需要有换肤功能,所以我们也实现了一套,主题色及其衍生色(高亮、浅色)的更换功能。通过尝试我们采取的方案是 Scss变量+css变量的方式,这种方式也是目前社区采用的最普遍的一种方式,兼容性良好。
#### 实现的原理
通过接口获取主题色(或者设置主题色) --> js 计算衍生色值 --> 赋值到 css 变量 --> scss 全局变量用 var() 函数引入 css 变量 --> 页面样式引用 scss 全局颜色值
### 使用栗子
比如我们要在Saas使用(scrm项目采用微前端乾坤+Vue2.x的方式)
#### 主应用的使用
```js
import { convertTheme } from 'glsx-components/src/utils/convertTheme'
//路由守卫
router.beforeEach(async (to, from, next) => {
//设置主题色(flag的目的是为了防止多次设置 主题色)
if (!flag) {
//假设我们在原型上定义了一个颜色,反正就是传入一个颜色,如 #456743
console.log('Vue.prototype.$themeColor',Vue.prototype.$themeColor)
convertTheme(Vue.prototype.$themeColor)
flag = true
}
beforeEachFn(to, from, next)
})
```
#### 步骤1 根据配置获取主题色
![步骤1](./img/main/1.png)
#### 步骤2 下发主题色
![步骤2](./img/main/2.png)
#### 步骤3 设置主题色
![步骤3](./img/main/3.png)
#### 步骤4 设置基座的颜色变量
![步骤4](./img/main/4.png)
#### 步骤5 主应用配置公共scss文件
![步骤5](./img/main/5.png)
#### scss变量说明
![步骤6](./img/main/6.png)
# child 模块
\ No newline at end of file \ No newline at end of file
# 更新日志 # 更新日志
## v1.3.6
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!