-
Notifications
You must be signed in to change notification settings - Fork 269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(popup): RN #2614
feat(popup): RN #2614
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -4,6 +4,7 @@ var glob = require('glob') | |||||
const path = require('path') | ||||||
const fs = require('fs-extra') | ||||||
let importStr = `` | ||||||
let importRNStr = `` | ||||||
let importMarkdownStr = `` | ||||||
let importScssStr = `\n` | ||||||
const packages = [] | ||||||
|
@@ -12,14 +13,17 @@ const raws = [] | |||||
|
||||||
config.nav.map((item) => { | ||||||
item.packages.forEach((element) => { | ||||||
let { name, show, type, taro, exportEmpty, exclude, version } = element | ||||||
let { name, show, type, taro, exportEmpty, exclude, version, rn } = element | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 建议为解构赋值添加默认值 在对 可以应用以下修改: - let { name, show, type, taro, exportEmpty, exclude, version, rn } = element
+ let { name, show, type, taro, exportEmpty, exclude, version, rn = false } = element 📝 Committable suggestion
Suggested change
|
||||||
if (exclude) return | ||||||
if (version !== '3.0.0') return // 不显示的不导出 | ||||||
if (version !== '3.0.0') return | ||||||
|
||||||
importStr += `import ${name} from '@/packages/${name.toLowerCase()}/index.taro'\n` | ||||||
importStr += `export * from '@/packages/${name.toLowerCase()}/index.taro'\n` | ||||||
importRNStr += `import ${name} from '@/packages/${name.toLowerCase()}/index.${rn?'rn':'taro'}'\n` | ||||||
importRNStr += `export * from '@/packages/${name.toLowerCase()}/index.${rn?'rn':'taro'}'\n` | ||||||
Comment on lines
+22
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 提取重复代码,增强可维护性
可以重构为: function generateImportStrings(name, type) {
return `import ${name} from '@/packages/${name.toLowerCase()}/index.${type}'\nexport * from '@/packages/${name.toLowerCase()}/index.${type}'\n`;
}
importStr += generateImportStrings(name, 'taro');
importRNStr += generateImportStrings(name, rn ? 'rn' : 'taro'); |
||||||
importScssStr += `import '@/packages/${name.toLowerCase()}/${name.toLowerCase()}.harmony.css'\n` | ||||||
packages.push(name) | ||||||
|
||||||
glob | ||||||
.sync( | ||||||
path.join(__dirname, `../../nutui-react/packages/${name.toLowerCase()}/`) + | ||||||
|
@@ -41,18 +45,6 @@ config.nav.map((item) => { | |||||
}) | ||||||
}) | ||||||
|
||||||
// let fileStrBuild = `${importStr} | ||||||
// export { ${packages.join(',')} };` | ||||||
|
||||||
// fs.outputFile( | ||||||
// path.resolve(__dirname, '../../nutui-react/packages/nutui.react.build.taro.ts'), | ||||||
// fileStrBuild, | ||||||
// 'utf8', | ||||||
// (error) => { | ||||||
// if (error) throw error | ||||||
// } | ||||||
// ) | ||||||
|
||||||
let fileStr = `${importStr} | ||||||
${importScssStr} | ||||||
export { ${packages.join(',')} };` | ||||||
|
@@ -65,6 +57,18 @@ fs.outputFile( | |||||
} | ||||||
) | ||||||
|
||||||
let fileRNStr = `${importRNStr} | ||||||
${importScssStr} | ||||||
export { ${packages.join(',')} };` | ||||||
fs.outputFile( | ||||||
path.resolve(__dirname, '../../nutui-react/packages/nutui.react.rn.ts'), | ||||||
fileRNStr, | ||||||
'utf8', | ||||||
(error) => { | ||||||
if (error) throw error | ||||||
} | ||||||
) | ||||||
|
||||||
Comment on lines
+60
to
+71
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 封装文件输出逻辑,减少代码重复 多个文件的输出逻辑相似,建议封装成通用函数,避免代码重复,提高代码可维护性。 可以考虑如下重构: function writeOutputFile(filePath, content) {
fs.outputFile(
path.resolve(__dirname, filePath),
content,
'utf8',
(error) => {
if (error) throw error;
}
);
}
writeOutputFile('../../nutui-react/packages/nutui.react.taro.ts', fileStr);
writeOutputFile('../../nutui-react/packages/nutui.react.rn.ts', fileRNStr); |
||||||
let taroScssfileStr = ` | ||||||
${importScssStr} | ||||||
export default { "NutUI":"NutUI-Taro" };` | ||||||
|
@@ -76,28 +80,3 @@ fs.outputFile( | |||||
if (error) throw error | ||||||
} | ||||||
) | ||||||
|
||||||
// fs.outputFile( | ||||||
// path.resolve(__dirname, '../../nutui-react/packages/nutui.react.scss.ts'), | ||||||
// importScssStr, | ||||||
// 'utf8', | ||||||
// (error) => { | ||||||
// if (error) throw error | ||||||
// } | ||||||
// ) | ||||||
|
||||||
// let mdFileStr = `${importMarkdownStr} | ||||||
// export const routers = [${mds.map((m) => `'${m}'`)}] | ||||||
// export const raws = {${raws.join(',')}} | ||||||
// ` | ||||||
|
||||||
// fs.outputFile( | ||||||
// path.resolve(__dirname, '../../src/sites/doc/docs.taro.ts'), | ||||||
// mdFileStr, | ||||||
// 'utf8', | ||||||
// (error) => { | ||||||
// if (error) throw error | ||||||
// } | ||||||
// ) | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
发现仍在使用旧的 Taro 实现 @nutui/nutui-react-taro
以下文件仍在引入
@nutui/nutui-react-taro
,请确保这些引用已更新为新的 React Native 实现,以保持项目的一致性和正确性:🔗 Analysis chain
更新了 @nutui/nutui-react-taro 的别名路径
这个更改将 @nutui/nutui-react-taro 的路径从 Taro 特定实现更改为 React Native 实现。
请确保以下几点:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 204
Script:
Length of output: 125
Script:
Length of output: 58615
Script:
Length of output: 58615