Add apps/miniprogram/tt as a standalone Douyin app with official usePrivacyCheck + tt.showModal/setClipboardData flow, single-chapter offline reader, and document console privacy setup for clipboard. Co-authored-by: Cursor <cursoragent@cursor.com>
62 lines
1.6 KiB
JavaScript
62 lines
1.6 KiB
JavaScript
/**
|
||
* 抖音官方分包限制(developer.open-douyin.com 分包简介):
|
||
* - 主包 ≤ 4MB
|
||
* - 单个分包 ≤ 2MB
|
||
* - 全部包合计 ≤ 16MB
|
||
* 校验 dist(已 strip .map);上传前请先 copy-static。
|
||
*/
|
||
import fs from 'fs'
|
||
import path from 'path'
|
||
import { fileURLToPath } from 'url'
|
||
|
||
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
|
||
const dist = path.join(root, 'dist')
|
||
const MAIN_LIMIT = 4 * 1024 * 1024
|
||
const SUB_LIMIT = 2 * 1024 * 1024
|
||
const TOTAL_LIMIT = 16 * 1024 * 1024
|
||
|
||
function dirSize(dir) {
|
||
if (!fs.existsSync(dir)) return 0
|
||
let n = 0
|
||
for (const name of fs.readdirSync(dir)) {
|
||
const p = path.join(dir, name)
|
||
const st = fs.statSync(p)
|
||
if (st.isDirectory()) n += dirSize(p)
|
||
else if (!name.endsWith('.map')) n += st.size
|
||
}
|
||
return n
|
||
}
|
||
|
||
function mb(n) {
|
||
return (n / 1024 / 1024).toFixed(2)
|
||
}
|
||
|
||
if (!fs.existsSync(dist)) {
|
||
console.error('missing dist/')
|
||
process.exit(1)
|
||
}
|
||
|
||
const packageBook = path.join(dist, 'packageBook')
|
||
const sub = dirSize(packageBook)
|
||
const total = dirSize(dist)
|
||
const main = total - sub
|
||
|
||
console.log(`tt size check (official: main≤4 / sub≤2 / total≤16 MB)`)
|
||
console.log(` main≈${mb(main)} MB packageBook=${mb(sub)} MB total=${mb(total)} MB`)
|
||
|
||
let fail = 0
|
||
if (main > MAIN_LIMIT) {
|
||
console.error(`FAIL main ${mb(main)} > 4 MB`)
|
||
fail = 1
|
||
}
|
||
if (sub > SUB_LIMIT) {
|
||
console.error(`FAIL packageBook ${mb(sub)} > 2 MB`)
|
||
fail = 1
|
||
}
|
||
if (total > TOTAL_LIMIT) {
|
||
console.error(`FAIL total ${mb(total)} > 16 MB`)
|
||
fail = 1
|
||
}
|
||
if (!fail) console.log('OK')
|
||
process.exit(fail)
|