br-dionysus 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -0
- package/dist/br-dionysus.es.js +2087 -2079
- package/dist/br-dionysus.umd.js +8 -8
- package/dist/packages/Hook/usePackageConfig/usePackageConfig.d.ts +13 -0
- package/dist/packages/Hook/useTableConfig/useTableConfig.d.ts +0 -7
- package/dist/packages/MTableColumn/src/MTableColumn.vue.d.ts +1 -1
- package/package.json +2 -1
- package/packages/Hook/usePackageConfig/README.md +47 -0
- package/packages/Hook/usePackageConfig/demo.vue +136 -0
- package/packages/Hook/usePackageConfig/usePackageConfig.ts +35 -0
- package/packages/Hook/useTableConfig/useTableConfig.ts +15 -12
- package/packages/SkinConfig/src/useSkin.ts +11 -4
- package/packages/list.json +6 -0
- package/src/App.vue +13 -1
- package/src/components/Preview.vue +31 -47
- package/src/env.d.ts +11 -0
- package/src/global.d.ts +1 -0
- package/src/router.ts +5 -0
- package/tags.json +1 -1
- package/web-types.json +1 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface UsePackageConfig {
|
|
2
|
+
set: Function;
|
|
3
|
+
get: Function;
|
|
4
|
+
}
|
|
5
|
+
interface UsePackageConfigParameter {
|
|
6
|
+
setConfig?: Function;
|
|
7
|
+
getConfig?: Function;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* @description 配置保存与获取
|
|
11
|
+
* */
|
|
12
|
+
declare const usePackageConfig: ({ setConfig, getConfig }?: UsePackageConfigParameter) => UsePackageConfig;
|
|
13
|
+
export default usePackageConfig;
|
|
@@ -37,11 +37,11 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
37
37
|
"onUpdate:filtersValue"?: ((...args: any[]) => any) | undefined;
|
|
38
38
|
}, {
|
|
39
39
|
children: PropChildren[];
|
|
40
|
+
filtersValue: FilterValue;
|
|
40
41
|
filters: {
|
|
41
42
|
text: string | number;
|
|
42
43
|
value: string | number;
|
|
43
44
|
}[];
|
|
44
|
-
filtersValue: FilterValue;
|
|
45
45
|
filterMethod: Function;
|
|
46
46
|
}, {}>, {
|
|
47
47
|
default?(_: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "br-dionysus",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "vite --config ./build/base.config.ts",
|
|
6
6
|
"build:doc": "vue-tsc --noEmit && vite build --config ./build/doc.config.ts && node script/copyDir.js",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"@vue/eslint-config-prettier": "~8.0.0",
|
|
33
33
|
"@vue/eslint-config-standard": "~8.0.1",
|
|
34
34
|
"@vue/eslint-config-typescript": "~12.0.0",
|
|
35
|
+
"axios": "^1.7.0",
|
|
35
36
|
"connect-history-api-fallback": "^2.0.0",
|
|
36
37
|
"eslint": "~8.49.0",
|
|
37
38
|
"eslint-plugin-cypress": "~2.15.1",
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import demo from './demo.vue'
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
配置保存与获取 hook
|
|
6
|
+
=================
|
|
7
|
+
|
|
8
|
+
### 1) 基础用法
|
|
9
|
+
|
|
10
|
+
<Preview comp-name="usePackageConfig" demo-name="demo" is-hook>
|
|
11
|
+
<demo />
|
|
12
|
+
</Preview>
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### 1) 所需参数
|
|
16
|
+
|
|
17
|
+
| 名称 | 描述 | 类型 | 可选值 | 默认值 |
|
|
18
|
+
|------------|--------|--------------|:---:|:---:|
|
|
19
|
+
| name | 表格唯一标识 | string | - | - |
|
|
20
|
+
| tableTitle | 列配置 | tableTitle[] | - | - |
|
|
21
|
+
| tableData | 表格数据 | ref<any[]> | - | - |
|
|
22
|
+
|
|
23
|
+
### 2) 返回值
|
|
24
|
+
|
|
25
|
+
| 名称 | 描述 | 类型 |
|
|
26
|
+
|------------------|---------|-----------------------------------------|
|
|
27
|
+
| tableTitle | 处理之后的表头 | TableTitle[] |
|
|
28
|
+
| tableConfig | 表头的配置项 | { [propName: string]: TableConfigItem} |
|
|
29
|
+
| headerDragend | 表格拖拽事件 | function |
|
|
30
|
+
| initColumnFilter | 列的筛选 | function |
|
|
31
|
+
| filtersValue | 过滤条件 | { [key: string]: Array<string,number>} |
|
|
32
|
+
|
|
33
|
+
### 3) TableTitle
|
|
34
|
+
|
|
35
|
+
| 名称 | 描述 | 类型 |
|
|
36
|
+
|---------------|----------------------------------------------------------------------|---------------------------------------------|
|
|
37
|
+
| label | 显示的标题 | string |
|
|
38
|
+
| prop | 字段对应列的字段名字也可以使用 property属性 | string |
|
|
39
|
+
| minWidth? | 对应列的最小宽度与 width 的区别是 width 是固定的,min-width 会按比例分配剩余宽度 | number ,string, |
|
|
40
|
+
| className? | 列的className | string |
|
|
41
|
+
| sortable | 列是否能够排序 则代表用户希望远程排序,需要监听 Table 的 sort-change 事件 */ | Boolean |
|
|
42
|
+
| filters? | 据过滤的选项, 数组格式,数组中的元素需要有 text 和 value 属性。 数组中的每个元素都需要有 text 和 value 属性 | {text:string,number,value:string,number} [] |
|
|
43
|
+
| filterMethod? | 数据过滤使用的方法, 如果是多选的筛选项,对每一条数据会执行多次,任意一次返回 true 就会显示 | Function |
|
|
44
|
+
| headerAlign? | 表头对齐方式, 若不设置该项,则使用表格的对齐方式 | 'left' , 'center' , 'right' |
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<el-button @click="getConfig">获取config</el-button>
|
|
4
|
+
<el-button @click="setConfig">设置config</el-button>
|
|
5
|
+
</div>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script setup lang="ts">
|
|
9
|
+
import usePackageConfig from 'packages/Hook/usePackageConfig/usePackageConfig'
|
|
10
|
+
// import Axios from 'axios'
|
|
11
|
+
// import { ElMessage } from 'element-plus'
|
|
12
|
+
//
|
|
13
|
+
// enum Method {
|
|
14
|
+
// GET = 'get',
|
|
15
|
+
// POST = 'post',
|
|
16
|
+
// }
|
|
17
|
+
//
|
|
18
|
+
// type ajaxQuery = {
|
|
19
|
+
// base: {
|
|
20
|
+
// url: string,
|
|
21
|
+
// method: Method,
|
|
22
|
+
// baseUrl: string
|
|
23
|
+
// },
|
|
24
|
+
// data: {
|
|
25
|
+
// query?: any,
|
|
26
|
+
// body?: any,
|
|
27
|
+
// headers?: any,
|
|
28
|
+
// [key: string]: any
|
|
29
|
+
// }
|
|
30
|
+
// }
|
|
31
|
+
//
|
|
32
|
+
// const token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJjVXNlcklkIjoianlsIiwiY1Bzbl9OdW0iOiIiLCJzQWNjSWQiOiIxMDMiLCJzQWNjTmFtZSI6IlsxMDNd55WF5a6P55S15a2Q5LqL5Lia6YOoIiwiY0V4cGlyeSI6IjIwMjQtMDUtMjFUMDA6NTQ6MTYuNDgyNjQ4NiswODowMCIsImNVc2VyTmFtZSI6Imp5bCIsIkxvZ2luU3lzIjoxLCJMb2dpblRpbWUiOiIyMDI0LTA1LTIwVDE4OjU0OjE2LjQ4MjY0ODYrMDg6MDAiLCJDbGllbnRJZCI6InI4cXR5b0xFVzlvSkZfaHVQTmtrZCIsIktlZXBBbGl2ZVRpbWUiOiIwMDAxLTAxLTAxVDAwOjAwOjAwIiwiZXhwIjoxNzE2MjI0MDU2fQ.F7iyZJ2feGMpBC5rFUXngJvdAnp2hKj7Da0-iXRXL6I'
|
|
33
|
+
// const ajax = (base: ajaxQuery['base'], data: ajaxQuery['data']): Promise<any> => {
|
|
34
|
+
// return new Promise((resolve, reject) => {
|
|
35
|
+
// Axios({
|
|
36
|
+
// baseURL: base.baseUrl || '',
|
|
37
|
+
// url: base.url,
|
|
38
|
+
// method: base.method,
|
|
39
|
+
// params: data.query || (base.method === Method.GET ? data : {}),
|
|
40
|
+
// data: data.body || (base.method === Method.POST ? data : {}),
|
|
41
|
+
// timeout: 1000 * 50,
|
|
42
|
+
// headers: {
|
|
43
|
+
// access_token: token
|
|
44
|
+
// }
|
|
45
|
+
// })
|
|
46
|
+
// .then((res: any) => {
|
|
47
|
+
// resolve(res.data)
|
|
48
|
+
// })
|
|
49
|
+
// .catch((err: any) => {
|
|
50
|
+
// reject(err.data)
|
|
51
|
+
// ElMessage.error('网络异常,请稍后再试!')
|
|
52
|
+
// })
|
|
53
|
+
// })
|
|
54
|
+
// }
|
|
55
|
+
//
|
|
56
|
+
// interface PlatConfigSaveReqDto {
|
|
57
|
+
// /** @description ID修改时需传 */
|
|
58
|
+
// Id?: string;
|
|
59
|
+
// /** @description 配置的KEY */
|
|
60
|
+
// cKey: string;
|
|
61
|
+
// /** @description 配置名称 */
|
|
62
|
+
// cName?: string;
|
|
63
|
+
// /** @description 配置的JSON数据 */
|
|
64
|
+
// cData: string;
|
|
65
|
+
// /** @description 是否公共配置方案 */
|
|
66
|
+
// bPub?: boolean;
|
|
67
|
+
// /** @description 配置的账套号-不传默认当前登录所在账套,预留后期从一个账套复制到另一个账套 */
|
|
68
|
+
// AccId?: string;
|
|
69
|
+
// }
|
|
70
|
+
// /**
|
|
71
|
+
// * @description 保存
|
|
72
|
+
// * @param {PlatConfigSaveReqDto} data 请求参数
|
|
73
|
+
// * @returns {Promise<any>} ajax
|
|
74
|
+
// */
|
|
75
|
+
// const postPlatconfigSave = (data: PlatConfigSaveReqDto): Promise<any> => {
|
|
76
|
+
// return ajax({
|
|
77
|
+
// baseUrl: 'http://192.168.3.25:10205/',
|
|
78
|
+
// url: '/platconfig/save',
|
|
79
|
+
// method: Method.POST
|
|
80
|
+
// }, data)
|
|
81
|
+
// }
|
|
82
|
+
//
|
|
83
|
+
// interface QueryPlatConfigReqDto {
|
|
84
|
+
// /** @description 配置KEY */
|
|
85
|
+
// cKey: string;
|
|
86
|
+
// /** @description 是否公共方案 传 null 时先找个人 再找公共 */
|
|
87
|
+
// bPub?: boolean;
|
|
88
|
+
// }
|
|
89
|
+
// interface PlatconfigInfoResType {
|
|
90
|
+
// /** @description 操作结果类型 */
|
|
91
|
+
// code?: number | null;
|
|
92
|
+
// /** @description 获取 返回数据 */
|
|
93
|
+
// data: {
|
|
94
|
+
// /** @description ID修改时需传 */
|
|
95
|
+
// Id?: string;
|
|
96
|
+
// /** @description 配置的KEY */
|
|
97
|
+
// cKey?: string;
|
|
98
|
+
// /** @description 配置名称 */
|
|
99
|
+
// cName?: string;
|
|
100
|
+
// /** @description 配置的JSON数据 */
|
|
101
|
+
// cData?: string;
|
|
102
|
+
// /** @description 是否公共配置方案 */
|
|
103
|
+
// bPub?: boolean;
|
|
104
|
+
// };
|
|
105
|
+
// /** @description 获取 消息内容 */
|
|
106
|
+
// msg?: string;
|
|
107
|
+
// }
|
|
108
|
+
// /**
|
|
109
|
+
// * @description 明细
|
|
110
|
+
// * @param {QueryPlatConfigReqDto} data 请求参数
|
|
111
|
+
// * @returns {Promise<PlatconfigInfoResType>} ajax
|
|
112
|
+
// */
|
|
113
|
+
// const postPlatconfigInfo = (data: QueryPlatConfigReqDto): Promise<PlatconfigInfoResType> => {
|
|
114
|
+
// return ajax({
|
|
115
|
+
// baseUrl: 'http://192.168.3.25:10205/',
|
|
116
|
+
// url: '/platconfig/info',
|
|
117
|
+
// method: Method.POST
|
|
118
|
+
// }, data)
|
|
119
|
+
// }
|
|
120
|
+
//
|
|
121
|
+
// usePackageConfig({
|
|
122
|
+
// getConfig: (key: string = '', elName: string = '') => {
|
|
123
|
+
// console.log('sss')
|
|
124
|
+
// return 'test'
|
|
125
|
+
// },
|
|
126
|
+
// setConfig: (key: string = '', data: any) => {
|
|
127
|
+
// }
|
|
128
|
+
// })
|
|
129
|
+
const packageConfig = usePackageConfig()
|
|
130
|
+
const getConfig = () => {
|
|
131
|
+
console.log('packageConfig.get()', packageConfig.get())
|
|
132
|
+
}
|
|
133
|
+
const setConfig = () => {}
|
|
134
|
+
</script>
|
|
135
|
+
|
|
136
|
+
<style lang="scss"></style>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
let setApiAjax: any = (key: string, data: any) => localStorage.setItem(key, JSON.stringify(data))
|
|
2
|
+
let getApiAjax: any = (key: string) => JSON.parse(localStorage.getItem(key) || '{}')
|
|
3
|
+
|
|
4
|
+
interface UsePackageConfig {
|
|
5
|
+
set: Function,
|
|
6
|
+
get: Function
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface UsePackageConfigParameter {
|
|
10
|
+
setConfig?: Function,
|
|
11
|
+
getConfig?: Function
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @description 配置保存与获取
|
|
16
|
+
* */
|
|
17
|
+
const usePackageConfig = ({ setConfig, getConfig }: UsePackageConfigParameter = {}): UsePackageConfig => {
|
|
18
|
+
if (setConfig) setApiAjax = setConfig
|
|
19
|
+
if (getConfig) getApiAjax = getConfig
|
|
20
|
+
|
|
21
|
+
const setConfigEvent = (key: string, value: any, elName: string) => {
|
|
22
|
+
return setApiAjax(key, value, elName)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const getConfigEvent = (key: string, elName: string) => {
|
|
26
|
+
return getApiAjax(key, elName)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
set: setConfigEvent,
|
|
31
|
+
get: getConfigEvent
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default usePackageConfig
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import { ref, watch, computed } from 'vue'
|
|
1
|
+
import { ref, watch, computed, onMounted } from 'vue'
|
|
2
2
|
import type { Ref } from 'vue'
|
|
3
3
|
import { Page } from '../../typings/class'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
pageSize: number
|
|
8
|
-
/** 分页大小可选项 */
|
|
9
|
-
pageSizesOptions: number[]
|
|
10
|
-
}
|
|
4
|
+
import usePackageConfig from 'packages/Hook/usePackageConfig/usePackageConfig'
|
|
5
|
+
|
|
6
|
+
const packageConfig = usePackageConfig()
|
|
11
7
|
|
|
12
8
|
/** 表格列配置(单个) */
|
|
13
9
|
export interface TableConfigItem {
|
|
@@ -44,13 +40,18 @@ export interface FilterValue {
|
|
|
44
40
|
const useTableConfig = (name: string, tableTitle: TableTitle[], tableData: Ref <any[]>) => {
|
|
45
41
|
/** 表格列头 */
|
|
46
42
|
const _tableTitle: Ref<TableTitle[]> = ref<TableTitle[]>([])
|
|
47
|
-
const tableConfig: Ref<TableConfig> = ref<TableConfig>(JSON.parse(localStorage.getItem('tableConfig' + name) || '{}'))
|
|
48
|
-
const
|
|
43
|
+
// const tableConfig: Ref<TableConfig> = ref<TableConfig>(JSON.parse(localStorage.getItem('tableConfig' + name) || '{}'))
|
|
44
|
+
const tableConfig: Ref<TableConfig> = ref<TableConfig>(packageConfig.get('tableConfig' + name))
|
|
45
|
+
// const pageConfig = JSON.parse(localStorage.getItem('tablePage' + name) || '{}')
|
|
46
|
+
const pageConfig = packageConfig.get('tablePage' + name)
|
|
49
47
|
const page = ref<Page>(new Page(pageConfig))
|
|
50
48
|
/** 列筛选 */
|
|
51
49
|
const filterMethod = (value: string, row: any, column: Column) => {
|
|
52
50
|
return row[column.property] === value
|
|
53
51
|
}
|
|
52
|
+
onMounted(async () => {
|
|
53
|
+
|
|
54
|
+
})
|
|
54
55
|
|
|
55
56
|
/** 过滤条件 */
|
|
56
57
|
const filtersValue = ref<FilterValue>({})
|
|
@@ -90,7 +91,8 @@ const useTableConfig = (name: string, tableTitle: TableTitle[], tableData: Ref <
|
|
|
90
91
|
() => tableConfig.value,
|
|
91
92
|
() => {
|
|
92
93
|
syncTableTitle()
|
|
93
|
-
localStorage.setItem('tableConfig' + name, JSON.stringify(tableConfig.value))
|
|
94
|
+
// localStorage.setItem('tableConfig' + name, JSON.stringify(tableConfig.value))
|
|
95
|
+
packageConfig.set('tableConfig' + name, tableConfig.value)
|
|
94
96
|
},
|
|
95
97
|
{ deep: true }
|
|
96
98
|
)
|
|
@@ -98,7 +100,8 @@ const useTableConfig = (name: string, tableTitle: TableTitle[], tableData: Ref <
|
|
|
98
100
|
watch(
|
|
99
101
|
() => page.value,
|
|
100
102
|
(item) => {
|
|
101
|
-
localStorage.setItem('tablePage' + name, JSON.stringify({ pageSize: item.pageSize, pageSizesOptions: item.pageSizesOptions }))
|
|
103
|
+
// localStorage.setItem('tablePage' + name, JSON.stringify({ pageSize: item.pageSize, pageSizesOptions: item.pageSizesOptions }))
|
|
104
|
+
packageConfig.set('tablePage' + name, { pageSize: item.pageSize, pageSizesOptions: item.pageSizesOptions })
|
|
102
105
|
},
|
|
103
106
|
{ deep: true }
|
|
104
107
|
)
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { reactive } from 'vue'
|
|
2
2
|
import { Size } from 'packages/typings/enum'
|
|
3
3
|
import compareStructures from '../../../tool/compareStructures'
|
|
4
|
+
import usePackageConfig from 'packages/Hook/usePackageConfig/usePackageConfig'
|
|
5
|
+
|
|
6
|
+
const packageConfig = usePackageConfig()
|
|
4
7
|
|
|
5
8
|
/**
|
|
6
9
|
* @description 颜色计算
|
|
@@ -93,14 +96,17 @@ const useSkin = (): {
|
|
|
93
96
|
}
|
|
94
97
|
|
|
95
98
|
// 清洗数据
|
|
96
|
-
const skinConfigData = JSON.parse(localStorage.getItem('skinConfig') || '{}')
|
|
99
|
+
// const skinConfigData = JSON.parse(localStorage.getItem('skinConfig') || '{}')
|
|
100
|
+
const skinConfigData = packageConfig.get('skinConfig')
|
|
97
101
|
// 数据结构不一致,既认为为不同版本需要清洗
|
|
98
102
|
if (!compareStructures(skinConfigData, defaultSkinConfig)) {
|
|
99
|
-
localStorage.setItem('skinConfig', JSON.stringify(defaultSkinConfig))
|
|
103
|
+
// localStorage.setItem('skinConfig', JSON.stringify(defaultSkinConfig))
|
|
104
|
+
packageConfig.set('skinConfig', defaultSkinConfig)
|
|
100
105
|
}
|
|
101
106
|
|
|
102
107
|
/** 皮肤配置 */
|
|
103
|
-
const skinConfig: SkinConfig = reactive(JSON.parse(localStorage.getItem('skinConfig') as string))
|
|
108
|
+
// const skinConfig: SkinConfig = reactive(JSON.parse(localStorage.getItem('skinConfig') as string))
|
|
109
|
+
const skinConfig: SkinConfig = reactive(packageConfig.get('skinConfig'))
|
|
104
110
|
|
|
105
111
|
/**
|
|
106
112
|
* @description 设置皮肤色
|
|
@@ -211,7 +217,8 @@ const useSkin = (): {
|
|
|
211
217
|
* @description 保存皮肤配置到本地
|
|
212
218
|
*/
|
|
213
219
|
const save = () => {
|
|
214
|
-
localStorage.setItem('skinConfig', JSON.stringify(skinConfig))
|
|
220
|
+
// localStorage.setItem('skinConfig', JSON.stringify(skinConfig))
|
|
221
|
+
packageConfig.set('skinConfig', skinConfig)
|
|
215
222
|
}
|
|
216
223
|
|
|
217
224
|
return {
|
package/packages/list.json
CHANGED
package/src/App.vue
CHANGED
|
@@ -16,10 +16,22 @@
|
|
|
16
16
|
</div>
|
|
17
17
|
</template>
|
|
18
18
|
|
|
19
|
-
<script setup>
|
|
19
|
+
<script setup lang="ts">
|
|
20
20
|
import ComponentList from 'packages/list.json'
|
|
21
21
|
import { reactive } from 'vue'
|
|
22
22
|
|
|
23
|
+
import usePackageConfig from 'packages/Hook/usePackageConfig/usePackageConfig'
|
|
24
|
+
usePackageConfig({
|
|
25
|
+
getConfig: (key: string = '', elName: string = '') => {
|
|
26
|
+
return JSON.parse(localStorage.getItem(key) || '{}')
|
|
27
|
+
},
|
|
28
|
+
setConfig: (key: string = '', data: any, elName: string = '') => {
|
|
29
|
+
setTimeout(() => {
|
|
30
|
+
localStorage.setItem(key, JSON.stringify(data))
|
|
31
|
+
}, 1000)
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
|
|
23
35
|
const data = reactive({
|
|
24
36
|
links: ComponentList.map(item => ({
|
|
25
37
|
path: `/components/${item.compName}`,
|
|
@@ -22,60 +22,45 @@
|
|
|
22
22
|
</div>
|
|
23
23
|
</template>
|
|
24
24
|
|
|
25
|
-
<script>
|
|
25
|
+
<script setup lang="ts">
|
|
26
|
+
import { ref, computed, onMounted } from 'vue'
|
|
26
27
|
import Prism from 'prismjs'
|
|
27
28
|
import '../assets/prism.css'
|
|
28
29
|
|
|
29
30
|
const isDev = import.meta.env.MODE === 'development'
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
computed: {
|
|
53
|
-
previewSourceCode () {
|
|
54
|
-
return this.sourceCode.replace(/'\.\.\/\.\.\/index'/g, '\'@tencent/my-kit\'')
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
async mounted () {
|
|
58
|
-
if (this.compName && this.demoName) {
|
|
59
|
-
if (isDev) {
|
|
60
|
-
this.sourceCode = (
|
|
61
|
-
await import(/* @vite-ignore */ `../../packages/${this.compName}/docs/${this.demoName}.vue?raw`)
|
|
62
|
-
).default
|
|
63
|
-
} else {
|
|
64
|
-
this.sourceCode = await fetch(`${isDev ? '' : '/MY-Kit'}/packages/${this.compName}/docs/${this.demoName}.vue`).then((res) => res.text())
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
await this.$nextTick()
|
|
68
|
-
Prism.highlightAll()
|
|
69
|
-
},
|
|
70
|
-
methods: {
|
|
71
|
-
async copyCode () {
|
|
72
|
-
// this.$copyText(this.sourceCode);
|
|
73
|
-
},
|
|
74
|
-
showSourceCode () {
|
|
75
|
-
this.codeVisible = !this.codeVisible
|
|
32
|
+
const props = withDefaults(defineProps<{
|
|
33
|
+
/** 是否为hook */
|
|
34
|
+
isHook?: boolean,
|
|
35
|
+
compName?: string,
|
|
36
|
+
demoName: string
|
|
37
|
+
}>(), {
|
|
38
|
+
isHook: false,
|
|
39
|
+
compName: '',
|
|
40
|
+
demoName: ''
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
const sourceCode = ref<string>('')
|
|
44
|
+
const codeVisible = ref<boolean>(false)
|
|
45
|
+
onMounted(async () => {
|
|
46
|
+
if (props.compName && props.demoName) {
|
|
47
|
+
const path = props.isHook ? `/packages/Hook/${props.compName}/${props.demoName}.vue` : `/packages/${props.compName}/docs/${props.demoName}.vue`
|
|
48
|
+
console.log('path', path)
|
|
49
|
+
if (isDev) {
|
|
50
|
+
sourceCode.value = (await import(path + '?raw')).default
|
|
51
|
+
} else {
|
|
52
|
+
sourceCode.value = await fetch(path).then((res) => res.text())
|
|
76
53
|
}
|
|
77
54
|
}
|
|
55
|
+
// await this.$nextTick()
|
|
56
|
+
Prism.highlightAll()
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
const showSourceCode = () => {
|
|
60
|
+
codeVisible.value = !codeVisible.value
|
|
78
61
|
}
|
|
62
|
+
|
|
63
|
+
const previewSourceCode = computed(() => sourceCode.value.replace(/'\.\.\/\.\.\/index'/g, '\'@tencent/\''))
|
|
79
64
|
</script>
|
|
80
65
|
|
|
81
66
|
<style lang="scss">
|
|
@@ -85,7 +70,6 @@ pre {
|
|
|
85
70
|
.g-preview {
|
|
86
71
|
border: 1px dashed #e7e7e7;
|
|
87
72
|
padding: 10px;
|
|
88
|
-
border-bottom: 1px dashed #e7e7e7;
|
|
89
73
|
section {
|
|
90
74
|
margin: 15px;
|
|
91
75
|
}
|
package/src/env.d.ts
CHANGED
|
@@ -9,3 +9,14 @@ declare module '*.md' {
|
|
|
9
9
|
const Component: ComponentOptions
|
|
10
10
|
export default Component
|
|
11
11
|
}
|
|
12
|
+
|
|
13
|
+
interface ImportMetaEnv {
|
|
14
|
+
readonly VITE_APP_TITLE: string,
|
|
15
|
+
readonly VITE_APP_LOGOTYPE: string,
|
|
16
|
+
readonly MODE: string,
|
|
17
|
+
// 更多环境变量...
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface ImportMeta {
|
|
21
|
+
readonly env: ImportMetaEnv
|
|
22
|
+
}
|
package/src/global.d.ts
CHANGED
package/src/router.ts
CHANGED
|
@@ -60,6 +60,11 @@ const routes = [{
|
|
|
60
60
|
name: 'MDialog',
|
|
61
61
|
path: '/components/MDialog',
|
|
62
62
|
component: () => import('packages/MDialog/docs/README.md')
|
|
63
|
+
}, {
|
|
64
|
+
title: '配置保存与获取',
|
|
65
|
+
name: 'usePackageConfig',
|
|
66
|
+
path: '/components/usePackageConfig',
|
|
67
|
+
component: () => import('packages/Hook/usePackageConfig/README.md')
|
|
63
68
|
}]
|
|
64
69
|
|
|
65
70
|
const routerConfig = {
|
package/tags.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"m-dialog":{"attributes":["modelValue","width","resize","draggable","resized"],"description":"这是一个MDialog"},"m-inline":{"attributes":["minWidth","maxWidth","size","switch"],"description":"这是一个MInline"},"m-input-number":{"attributes":["modelValue","placeholder","disabled","size","min","max","step","stepStrictly","thousandthPlace","noBorder","noSpacing","update:modelValue","change","focus","blur"],"description":"这是一个MInputNumber"},"m-option":{"attributes":[],"description":"这是一个MOption"},"m-select":{"attributes":["checkboxMode","multiple"],"description":"这是一个MSelect"},"m-select-table":{"attributes":["modelValue","placeholder","disabled","options","tableTitle","remoteMethod","allowCreate","focusShow","isSelect","clearable","size","labelKey","scrollbarAlwaysOn","total","update:modelValue","selectMultiple","change","selected","clear"],"description":"这是一个MSelectTable"},"m-select-v2":{"attributes":["checkboxMode","multiple","showAll","options","update:modelValue"],"description":"这是一个MSelectV2"},"m-table":{"attributes":["sole","data","filtersValue","pasteData"],"description":"这是一个MTable"},"m-table-column":{"attributes":["filtersValue","filters","filterMethod","children","update:filtersValue"],"description":"这是一个MTableColumn"},"m-table-column-set":{"attributes":["modelValue","foldMode","link","update:modelValue"],"description":"这是一个MTableColumnSet"},"skin-config":{"attributes":["change"],"description":"这是一个SkinConfig"},"tab-page":{"attributes":["modelValue","activeKey","showRightClickMenu","primaryColor","primaryBackgroundColor","close","click"],"description":"这是一个TabPage"}}
|
|
1
|
+
{"demo":{"attributes":[],"description":"这是一个demo"},"m-dialog":{"attributes":["modelValue","width","resize","draggable","resized"],"description":"这是一个MDialog"},"m-inline":{"attributes":["minWidth","maxWidth","size","switch"],"description":"这是一个MInline"},"m-input-number":{"attributes":["modelValue","placeholder","disabled","size","min","max","step","stepStrictly","thousandthPlace","noBorder","noSpacing","update:modelValue","change","focus","blur"],"description":"这是一个MInputNumber"},"m-option":{"attributes":[],"description":"这是一个MOption"},"m-select":{"attributes":["checkboxMode","multiple"],"description":"这是一个MSelect"},"m-select-table":{"attributes":["modelValue","placeholder","disabled","options","tableTitle","remoteMethod","allowCreate","focusShow","isSelect","clearable","size","labelKey","scrollbarAlwaysOn","total","update:modelValue","selectMultiple","change","selected","clear"],"description":"这是一个MSelectTable"},"m-select-v2":{"attributes":["checkboxMode","multiple","showAll","options","update:modelValue"],"description":"这是一个MSelectV2"},"m-table":{"attributes":["sole","data","filtersValue","pasteData"],"description":"这是一个MTable"},"m-table-column":{"attributes":["filtersValue","filters","filterMethod","children","update:filtersValue"],"description":"这是一个MTableColumn"},"m-table-column-set":{"attributes":["modelValue","foldMode","link","update:modelValue"],"description":"这是一个MTableColumnSet"},"skin-config":{"attributes":["change"],"description":"这是一个SkinConfig"},"tab-page":{"attributes":["modelValue","activeKey","showRightClickMenu","primaryColor","primaryBackgroundColor","close","click"],"description":"这是一个TabPage"}}
|