Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
京东前端
nutui-react
提交
68bd11cc
N
nutui-react
项目概览
京东前端
/
nutui-react
通知
0
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
nutui-react
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
68bd11cc
编写于
7月 27, 2022
作者:
O
oasis-cloud
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: 在线调试增加scss支持
上级
6eeb2495
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
31 addition
and
8 deletion
+31
-8
scripts/generate-nutui.js
scripts/generate-nutui.js
+26
-6
src/sites/doc/App.tsx
src/sites/doc/App.tsx
+2
-1
src/sites/doc/components/demoblock/demoblock.tsx
src/sites/doc/components/demoblock/demoblock.tsx
+3
-1
未找到文件。
scripts/generate-nutui.js
浏览文件 @
68bd11cc
...
...
@@ -5,8 +5,10 @@ const path = require('path')
const
fs
=
require
(
'
fs-extra
'
)
let
importStr
=
``
let
importMarkdownStr
=
``
let
importOnlineEditScssStr
=
``
let
importScssStr
=
`\n`
const
packages
=
[]
const
onlineEditScss
=
[]
const
mds
=
[]
const
raws
=
[]
...
...
@@ -16,11 +18,15 @@ config.nav.map((item) => {
if
(
show
||
exportEmpty
)
{
importStr
+=
`import
${
name
}
from '@/packages/
${
name
.
toLowerCase
()}
';\n`
importScssStr
+=
`import '@/packages/
${
name
.
toLowerCase
()}
/
${
name
.
toLowerCase
()}
.scss';\n`
packages
.
push
(
name
)
}
if
(
show
)
{
glob
.
sync
(
path
.
join
(
__dirname
,
`../src/packages/
${
name
.
toLowerCase
()}
/`
)
+
'
*.md
'
)
.
sync
(
path
.
join
(
__dirname
,
`../src/packages/
${
name
.
toLowerCase
()}
/`
)
+
'
*.md
'
)
.
map
((
f
)
=>
{
let
lang
=
'
zh-CN
'
let
matched
=
f
.
match
(
/doc
\.([
a-z-
]
+
)\.
md/i
)
...
...
@@ -31,8 +37,15 @@ config.nav.map((item) => {
raws
.
push
(
langComponentName
)
}
})
// fs.existsSync(path.join(__dirname, `../src/packages/${name.toLowerCase()}/doc.md`))
// console.log(__dirname)
glob
.
sync
(
path
.
join
(
__dirname
,
`../src/packages/
${
name
.
toLowerCase
()}
/`
)
+
'
demo.scss
'
)
.
map
((
f
)
=>
{
onlineEditScss
.
push
(
name
)
importOnlineEditScssStr
+=
`import
${
name
}
Scss from '@/packages/
${
name
.
toLowerCase
()}
/demo.scss?raw';\n`
})
importMarkdownStr
+=
`import
${
name
}
from '@/packages/
${
name
.
toLowerCase
()}
/doc.md?raw';\n`
mds
.
push
(
name
)
raws
.
push
(
name
)
...
...
@@ -74,10 +87,17 @@ fs.outputFile(
)
let
mdFileStr
=
`
${
importMarkdownStr
}
${
importOnlineEditScssStr
}
export const scssRaws = {
${
onlineEditScss
.
map
((
r
)
=>
r
+
'
Scss
'
).
join
(
'
,
'
)}
}
export const routers = [
${
mds
.
map
((
m
)
=>
`'
${
m
}
'`
)}
]
export const raws = {
${
raws
.
join
(
'
,
'
)}
}
`
fs
.
outputFile
(
path
.
resolve
(
__dirname
,
'
../src/sites/doc/docs.ts
'
),
mdFileStr
,
'
utf8
'
,
(
error
)
=>
{
if
(
error
)
throw
error
})
fs
.
outputFile
(
path
.
resolve
(
__dirname
,
'
../src/sites/doc/docs.ts
'
),
mdFileStr
,
'
utf8
'
,
(
error
)
=>
{
if
(
error
)
throw
error
}
)
src/sites/doc/App.tsx
浏览文件 @
68bd11cc
...
...
@@ -10,7 +10,7 @@ import './App.scss'
import
{
nav
}
from
'
@/config.json
'
import
useLocale
from
'
../assets/locale/uselocale
'
import
remarkGfm
from
'
remark-gfm
'
import
{
routers
,
raws
}
from
'
./docs
'
import
{
routers
,
raws
,
scssRaws
}
from
'
./docs
'
import
{
visit
}
from
'
unist-util-visit
'
import
ReactMarkdown
from
'
react-markdown
'
import
Nav
from
'
@/sites/doc/components/nav
'
...
...
@@ -142,6 +142,7 @@ const App = () => {
return
!
inline
&&
match
?
(
<
Demoblock
text
=
{
String
(
children
).
replace
(
/
\n
$/
,
''
)
}
scss
=
{
(
scssRaws
as
any
)[
ru
+
'
Scss
'
]
}
>
<
SyntaxHighlighter
children
=
{
String
(
children
).
replace
(
/
\n
$/
,
''
)
}
...
...
src/sites/doc/components/demoblock/demoblock.tsx
浏览文件 @
68bd11cc
...
...
@@ -2,6 +2,7 @@ import React, { useEffect, useState } from 'react'
import
{
compressText
,
copyCodeHtml
,
decompressText
}
from
'
./basedUtil
'
interface
A
{
text
:
string
scss
:
string
}
const
DemoBlock
:
React
.
FunctionComponent
<
A
>
=
(
props
)
=>
{
const
[
onlineUrl
,
setOnlineUrl
]
=
useState
(
''
)
...
...
@@ -20,7 +21,8 @@ ReactDOM.render(
const
sourceMainReactJs
=
compressText
(
sourceMainReactJsStr
)
const
sourceReactJs
=
compressText
(
props
.
text
)
const
onlineUrl
=
`https://codehouse.jd.com/?source=share&type=react&mainJs=
${
sourceMainReactJs
}
&appValue=
${
sourceReactJs
}
&scssValue=`
const
sourceScss
=
compressText
(
props
.
scss
)
const
onlineUrl
=
`https://codehouse.jd.com/?source=share&type=react&mainJs=
${
sourceMainReactJs
}
&appValue=
${
sourceReactJs
}
&scssValue=
${
sourceScss
}
`
setOnlineUrl
(
onlineUrl
)
},
[])
const
copyCode
=
()
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录