Skip to content

Commit 51d4e10

Browse files
committed
feat: add uview-plus 3
1 parent 1d23fd1 commit 51d4e10

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+9341
-7
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Install the supported ui component library in your project and install the plug-
2828
- arco-design/react 2
2929
- arco-design/vue 2
3030
- uview-ui 1、2
31+
- uview-plus 3
3132
- taro 3
3233

3334
### [antdv demo](assets/antdv.gif)

README_zh.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
- arco-design/react 2
2929
- arco-design/vue 2
3030
- uview-ui 1、2
31+
- uview-plus 3
3132
- taro 3
3233

3334
### [antdv demo](assets/antdv.gif)

scripts/generateIndex.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,21 @@ const fsp = require('node:fs/promises')
44
const fg = require('fast-glob')
55

66
export async function run() {
7-
const folder = 'src/ui/nuxtUiPro'
8-
const lib = 'nuxtUiPro1'
9-
const name = 'nuxtUiPro1'
10-
const isHyphen = false /** 生成的模板中的使用是 true ? a-affix : AAfix */
7+
const folder = 'src/ui/uviewPlus'
8+
const lib = 'uviewPlus3'
9+
const name = 'uviewPlus3'
10+
const isHyphen = true /** 生成的模板中的使用是 true ? a-affix : AAfix */
1111
const url = path.resolve(root, `${folder}/${name}`)
1212
const entry = await fg(['**/*.json'], { dot: true, cwd: url })
1313
const imports = entry.map((_url: string) => `import ${_url.split('.')[0]} from './${_url}'`)
14-
let prefix = ''
14+
let prefix = 'up'
1515
const map = entry.map((_url: string) => {
1616
let tagName = `${_url.split('.')[0]}`
1717
if (isHyphen) {
1818
tagName = hyphenate(tagName)
19-
prefix = `'${tagName.split('-')[0]}'`
19+
// prefix = `'${tagName.split('-')[0]}'`
20+
return `[${_url.split('.')[0]}, ${_url.split('.')[0]}.name, \`<${tagName}><${tagName}>\`],`
21+
2022
}
2123
return `[${_url.split('.')[0]}, ${_url.split('.')[0]}.name, \`<\${${tagName}.name}></\${${tagName}.name}\`],`
2224
})

scripts/transformPropsType.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const root = process.cwd()
44
const fsp = require('node:fs/promises')
55

66
export async function run() {
7-
const folder = 'src/ui/nuxtUi'
7+
const folder = 'src/ui/uviewPlus'
88
const isHyphen = false /** 生成的模板中的使用是 true ? a-affix : AAfix */
99
const url = path.resolve(root, folder)
1010
const entry = await fg(['**/*.json'], { dot: true, cwd: url })

scripts/uview.browser.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,17 @@ function getProps() {
9797
})
9898
return props
9999
}
100+
101+
function getEvents() {
102+
const events = []
103+
const eventBody = $0.closest('tbody').querySelectorAll('tr')
104+
if (eventBody) {
105+
Array.from(eventBody).forEach((item) => {
106+
const name = item.children[0].textContent
107+
const description = item.children[1].textContent
108+
const params = item.children[2].textContent
109+
events.push({ name, description, description_zh: description, params })
110+
})
111+
}
112+
return events
113+
}

scripts/uviewPlus.browser.js

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
function run() {
2+
const props = {}
3+
const events = []
4+
const methods = []
5+
const slots = []
6+
const link = location.href
7+
const prefix = 'Up'
8+
const basename = link.split('/').slice(-1)[0].split('.')[0].split('-').map((i) => {
9+
return i[0].toUpperCase() + i.slice(1)
10+
}).join('')
11+
const name = `${prefix}${basename}`
12+
const tbody = document.querySelector('#props + table')
13+
? document.querySelector('#props + table')
14+
: document.querySelector('#props + * + table')
15+
? document.querySelector('#props + * + table')
16+
: document.querySelector(`#${basename.toLocaleLowerCase()}-props + table`)
17+
|| document.querySelector(`#${basename.toLocaleLowerCase()}-props + * + table`)
18+
if (tbody) {
19+
Array.from(tbody.querySelectorAll('tbody tr')).forEach((item) => {
20+
const name = item.children[0].firstChild.textContent
21+
const description = item.children[1].textContent
22+
const type = !/(-|true|false)/.test(item.children[4].textContent)
23+
? item.children[4].textContent
24+
: item.children[2].textContent
25+
const value = item.children[3].textContent
26+
props[name] = {
27+
description,
28+
description_zh: description,
29+
default: value,
30+
value: '',
31+
type,
32+
}
33+
})
34+
}
35+
const eventBody = (document.querySelector('#event + table')
36+
? document.querySelector('#event + table')
37+
: document.querySelector('#event + * + table'))
38+
|| (document.querySelector('#events + table')
39+
? document.querySelector('#events + table')
40+
: document.querySelector('#events + * + table'))
41+
|| (document.querySelector(`#${basename.toLocaleLowerCase()}-event + table`))
42+
|| (document.querySelector(`#${basename.toLocaleLowerCase()}-event + * + table`))
43+
|| (document.querySelector(`#${basename.toLocaleLowerCase()}-events + table`))
44+
|| (document.querySelector(`#${basename.toLocaleLowerCase()}-events + * + table`))
45+
46+
if (eventBody) {
47+
Array.from(eventBody.querySelectorAll('tbody tr')).forEach((item) => {
48+
const name = item.children[0].textContent.split(' ')[0]
49+
const description = item.children[1].textContent
50+
const params = item.children[2].textContent
51+
events.push({ name, description, description_zh: description, params })
52+
})
53+
}
54+
const slotBody = document.querySelectorAll('#slots + table tbody tr')?.length ? document.querySelectorAll('#slots + table tbody tr') : document.querySelectorAll('#slot + table tbody tr')
55+
if (slotBody) {
56+
Array.from(slotBody).forEach((item) => {
57+
let name = item.children[0].textContent.split(' ')[0]
58+
const description = item.children[1].textContent
59+
if (name === '-' || !name)
60+
name = 'default'
61+
slots.push({
62+
name,
63+
description,
64+
description_zh: description,
65+
})
66+
})
67+
}
68+
const methodsBody = (document.querySelector('#methods + table')
69+
? document.querySelector('#methods + table')
70+
: document.querySelector('#methods + * + table'))
71+
|| (document.querySelector('#method + table')
72+
? document.querySelector('#method + table')
73+
: document.querySelector('#method + * + table'))
74+
|| (document.querySelector(`#${basename.toLocaleLowerCase()}-methods + table`))
75+
|| (document.querySelector(`#${basename.toLocaleLowerCase()}-methods + * + table`))
76+
|| (document.querySelector(`#${basename.toLocaleLowerCase()}-method + table`))
77+
|| (document.querySelector(`#${basename.toLocaleLowerCase()}-method + * + table`))
78+
79+
if (methodsBody) {
80+
Array.from(methodsBody.querySelectorAll('tbody tr')).forEach((item) => {
81+
const name = item.children[0].textContent.split('(')[0]
82+
const description = item.children[1].textContent
83+
const params = item.children[0].textContent.split('(')[1]
84+
? `(${item.children[0].textContent.split('(')[1]}`
85+
: ''
86+
methods.push({ name, description, description_zh: description, params })
87+
})
88+
}
89+
90+
const result = { name, props, link, link_zh: link, typeDetail: {}, events, methods, slots, suggestions: [] }
91+
copyToClipboard(JSON.stringify(result, null, 2))
92+
93+
return result
94+
}
95+
96+
function getProps() {
97+
const props = {}
98+
$0.closest('tbody').querySelectorAll('tr').forEach((item) => {
99+
const name = item.children[0].firstChild.textContent
100+
const description = item.children[1].textContent
101+
const type = !/(-|true|false)/.test(item.children[4].textContent)
102+
? item.children[4].textContent
103+
: item.children[2].textContent
104+
const value = item.children[3].textContent
105+
props[name] = {
106+
description,
107+
description_zh: description,
108+
default: value,
109+
value: '',
110+
type,
111+
}
112+
})
113+
copyToClipboard(JSON.stringify(props, null, 2))
114+
return props
115+
}
116+
117+
function getEvents() {
118+
const events = []
119+
const eventBody = $0.closest('tbody').querySelectorAll('tr')
120+
if (eventBody) {
121+
Array.from(eventBody).forEach((item) => {
122+
const name = item.children[0].textContent
123+
const description = item.children[1].textContent
124+
const params = item.children[2].textContent
125+
events.push({ name, description, description_zh: description, params })
126+
})
127+
}
128+
copyToClipboard(JSON.stringify(events, null, 2))
129+
130+
return events
131+
}
132+
133+
function getSlots() {
134+
const slots = []
135+
Array.from($0.closest('tbody').children).forEach(child => {
136+
const name = child.children[0].textContent
137+
const description = child.children[1].textContent
138+
slots.push({
139+
name,
140+
description,
141+
description_zh: description,
142+
})
143+
})
144+
copyToClipboard(JSON.stringify(slots, null, 2))
145+
146+
return slots
147+
}
148+
149+
function getMethods() {
150+
const methods = []
151+
const methodsBody = $0.closest('tbody').querySelectorAll('tr')
152+
if (methodsBody) {
153+
Array.from(methodsBody).forEach((item) => {
154+
const name = item.children[0].textContent.split('(')[0]
155+
const description = item.children[1].textContent
156+
const params = item.children[2]
157+
? item.children[2].textContent
158+
: item.children[0].textContent.split('(')[1]
159+
? `(${item.children[0].textContent.split('(')[1]}`
160+
: ''
161+
methods.push({ name, description, description_zh: description, params })
162+
})
163+
}
164+
copyToClipboard(JSON.stringify(methods, null, 2))
165+
166+
return methods
167+
}
168+
169+
function copyToClipboard(text) {
170+
const textArea = document.createElement('textarea');
171+
textArea.value = text;
172+
document.body.appendChild(textArea);
173+
textArea.select();
174+
textArea.setSelectionRange(0, 99999); // 选中全部内容
175+
document.execCommand('copy');
176+
document.body.removeChild(textArea);
177+
}
178+

src/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const UINames = [
2222
'@tarojs/components',
2323
'@nuxt/ui-pro',
2424
'antd-mobile',
25+
'uview-plus',
2526
]
2627

2728
export const nameMap: any = {

src/ui/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { arcoDesignVue2, arcoDesignVue2Components } from './arcoDesignVue'
2020
import { taro3, taro3Components } from './taro'
2121
import { nuxtUiPro1, nuxtUiPro1Components } from './nuxtUiPro'
2222
import { antdMobile5, antdMobile5Components } from './antdMobile'
23+
import { uviewPlus3, uviewPlus3Components } from './uviewPlus'
2324

2425
export default {
2526
elementUi2,
@@ -50,6 +51,7 @@ export default {
5051
arcoDesignVue2,
5152
nuxtUiPro1,
5253
antdMobile5,
54+
uviewPlus3,
5355
elementUi2Components,
5456
antd4Components,
5557
antd5Components,
@@ -78,4 +80,5 @@ export default {
7880
taro3Components,
7981
nuxtUiPro1Components,
8082
antdMobile5Components,
83+
uviewPlus3Components,
8184
}

src/ui/uviewPlus/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './uviewPlus3'

0 commit comments

Comments
 (0)