You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

76 lines
2.8 KiB

import sys, os, re
from pathlib import Path
from dotenv import load_dotenv
load_dotenv(Path("D:/code/crm-需求梳理/lanhu-mcp/.env"), override=True)
sys.path.insert(0, "D:/code/crm-需求梳理/lanhu-mcp")
os.chdir("D:/code/crm-需求梳理/lanhu-mcp")
from lanhu_mcp_server import DATA_DIR
resource_dir = Path(DATA_DIR) / "axure_extract_bade4454"
files_dir = resource_dir / "files"
BACKSLASH = chr(92)
def read_data_js(subdir_name):
data_js = files_dir / subdir_name / "data.js"
if not data_js.exists():
return f"[data.js not found: {data_js}]"
with open(data_js, encoding='utf-8', errors='ignore') as f:
js = f.read()
texts = []
for m in re.finditer(r'"([^"\\]{2,})"', js):
t = m.group(1).strip()
if (t and len(t) >= 2
and not re.match(r'^[0-9a-f\-]{8,}$', t)
and not t.startswith('http')
and not t.startswith('#')
and not t.startswith('rgb')
and BACKSLASH not in t
and not re.match(r'^[A-Za-z][A-Za-z0-9_.]*$', t)
):
texts.append(t)
seen = set()
uniq = []
for t in texts:
if t not in seen:
seen.add(t)
uniq.append(t)
return '\n'.join(uniq[:300])
targets = {
"A7-3-1 线索规则": "a7-3-1_线索规则",
"A2-1-1 线索看板": "a2-1-1线索管理(看板视图)",
"A2-1-1 线索列表": "a2-1-1线索管理(列表视图)",
"A2-1-1-1 新建线索": "a2-1-1-1新建线索",
"A2-1-2 我的线索": "a2-1-2我的线索",
"A2-1-2-1 线索详情": "a2-1-2-1线索详情",
"A2-1-2-2 领取线索": "a2-1-2-2领取线索",
"A2-1-2-3 编辑线索": "a2-1-2-3编辑线索",
"A2-1-4 公共池": "a2-1-4公共池",
"A2-1-4-1 公共池领取线索": "a2-1-4-1领取线索",
"A2-1-5 全部线索": "a2-1-5全部线索",
}
all_dirs = {d.name: d for d in files_dir.iterdir() if d.is_dir()}
out_path = Path("D:/code/crm-backend-matt/tmp/prototype_text.txt")
with open(out_path, 'w', encoding='utf-8') as out:
for label, key in targets.items():
matched_dir = all_dirs.get(key)
if not matched_dir:
key_nsp = key.replace(' ', '')
candidates = [name for name in all_dirs if key_nsp in name.replace(' ', '')]
if candidates:
matched_dir = all_dirs[candidates[0]]
out.write(f"\n{'='*60}\n## {label} [{matched_dir.name if matched_dir else 'NOT FOUND'}]\n{'='*60}\n")
if matched_dir:
text = read_data_js(matched_dir.name)
out.write(text[:5000])
print(f" OK {label}: {len(text)} chars")
else:
out.write("[NOT FOUND]\n")
print(f" MISS {label}")
print(f"\nWritten: {out_path}")