27 lines
845 B
Python
27 lines
845 B
Python
import json
|
|
from pathlib import Path
|
|
|
|
root = Path(__file__).resolve().parents[1]
|
|
paras = json.loads((root / 'tmp_user_agreement.json').read_text(encoding='utf-8'))
|
|
existing = (root / 'src/views/homePage/agreement/agreementDocs.js').read_text(encoding='utf-8')
|
|
privacy_start = existing.index(" 'privacy': {")
|
|
privacy_block = existing[privacy_start:]
|
|
|
|
lines = [
|
|
'export default {',
|
|
" 'user': {",
|
|
" 'title': '用户协议',",
|
|
" 'paragraphs': ["
|
|
]
|
|
for p in paras:
|
|
esc = p.replace('\\', '\\\\').replace("'", "\\'")
|
|
lines.append(f" '{esc}',")
|
|
lines[-1] = lines[-1].rstrip(',')
|
|
lines.append(' ]')
|
|
lines.append(' },')
|
|
lines.append(privacy_block)
|
|
|
|
out = root / 'src/views/homePage/agreement/agreementDocs.js'
|
|
out.write_text('\n'.join(lines), encoding='utf-8')
|
|
print(f'Updated {out} with {len(paras)} paragraphs')
|