forked from natuka/web.puabadge.com
修改:新增抖音下单页面
This commit is contained in:
1 parent
024c8a5155
commit
73971e4a08
38 files changed
+14447
-35505
No files matched your search
@@ -0,0 +1,39 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
|
||||
const root = path.resolve('src/views/douyin/components/image-point-cloud')
|
||||
|
||||
function walk(d) {
|
||||
for (const f of fs.readdirSync(d)) {
|
||||
const p = path.join(d, f)
|
||||
if (fs.statSync(p).isDirectory()) walk(p)
|
||||
else if (f.endsWith('.js')) convert(p)
|
||||
}
|
||||
}
|
||||
|
||||
function convert(file) {
|
||||
let s = fs.readFileSync(file, 'utf8')
|
||||
|
||||
s = s.replace(
|
||||
/const\s+\{([^}]+)\}\s*=\s*require\((['"])(.*?)\2\)/g,
|
||||
(_m, names, _q, mod) => `import {${names}} from '${mod}'`
|
||||
)
|
||||
s = s.replace(
|
||||
/const\s+(\w+)\s*=\s*require\((['"])(.*?)\2\)/g,
|
||||
(_m, name, _q, mod) => `import * as ${name} from '${mod}'`
|
||||
)
|
||||
|
||||
// remove config perf require block
|
||||
s = s.replace(
|
||||
/try\s*\{[\s\S]*?POINT_CLOUD_PERF_LOG[\s\S]*?\}\s*catch[\s\S]*?\{[\s\S]*?\}/,
|
||||
'let _perfLog = false'
|
||||
)
|
||||
|
||||
s = s.replace(/module\.exports\s*=\s*\{([\s\S]*?)\}\s*$/m, (_m, body) => `export {${body}}`)
|
||||
s = s.replace(/module\.exports\s*=\s*(\w+)\s*$/m, 'export default $1')
|
||||
|
||||
fs.writeFileSync(file, s)
|
||||
console.log('converted', file)
|
||||
}
|
||||
|
||||
walk(root)
|
||||
Reference in new issue
Block a user