#!/usr/bin/env python3 """Shared templates for dense desktop screenshots: a whole Mac-style screen with many windows open. Every content function takes the things a question is about (the "key" content) plus a `random.Random`, fills the rest from the made-up Chinese material below, and returns a dict {app, title, html, css}. Place it on screen with `at(content, x, y, w, h)` and hand a list of them to `desktop()`, front window first: import random import re, desktop as D rng = random.Random(7) page = D.portal_page(rng, site="东方快讯", news=[("09:41", "地铁 14 号线今晚延长运营")]) html = D.desktop([D.at(D.browser(page, rng=rng, url="news.dongfang.example"), 120, 60, 1240, 840), D.at(D.chat_app(rng, chat_name="周末爬山群"), 700, 200, 900, 640)], notifications=[D.notification("知了", "妈妈", "晚上回来吃饭吗")], rng=rng) The page is 1680 x 1050 at 1x (``, first screen only) for screen/render.py. All names, companies, apps and domains are made up (.example); place names may be real. "Today" is 2026-11-24 (Tue). Standard library only. """ import html as _html import random import re # ---------------------------------------------------------------- helpers FONT = '"PingFang SC", "Hiragino Sans GB", sans-serif' MONO = 'Menlo, "PingFang SC", monospace' WEEK = "一二三四五六日" def esc(s): return _html.escape(str(s), quote=True) def para(s): """Plain text -> paragraphs (blank line) and line breaks; text starting with '<' is taken as HTML.""" s = str(s) if s.lstrip().startswith("<"): return s return "".join("

" + "
".join(esc(l) for l in p.split("\n")) + "

" for p in s.split("\n\n")) def hue(s): return sum(ord(c) * (i + 7) for i, c in enumerate(str(s))) % 360 def avatar(name, size=32, radius="50%", font=None): ch = str(name).strip()[-2:] if len(str(name).strip()) <= 3 else str(name).strip()[:1] if len(str(name).strip()) == 3: ch = str(name).strip()[1:] ch = ch[:2] fs = font or max(10, int(size * (0.36 if len(ch) > 1 else 0.46))) return (f'{esc(ch)}') def pick(rng, pool, k): pool = list(pool) k = min(k, len(pool)) return rng.sample(pool, k) def mix(rng, fill, keys, positions=None, limit=None): """Insert key items into a filler list at random (or given) positions, keeping their order. limit: random positions only within the first `limit` places (so key items stay on screen).""" out = list(fill) keys = list(keys) if positions is None: top = len(out) if limit is None else min(len(out), limit) positions = sorted(rng.randint(0, max(0, top)) for _ in keys) for i, (p, k) in enumerate(zip(positions, keys)): out.insert(min(p + i, len(out)), k) return out def at(content, x, y, w, h): d = dict(content) d.update(x=x, y=y, w=w, h=h) return d # ---------------------------------------------------------------- material pools (all made up) SURNAMES = "王李张刘陈杨黄赵吴周徐孙马朱胡郭何林罗高郑梁谢宋唐许韩冯邓曹彭曾萧田董潘袁蔡蒋余于杜叶程魏苏吕丁任沈姚卢姜崔钟谭陆汪范金石廖贾夏韦付方白邹孟熊秦邱江尹薛闫段雷侯龙史陶黎贺顾毛郝龚邵万钱严覃武戴莫孔向汤" GIVEN = "伟芳娜秀英敏静丽强磊军洋勇艳杰娟涛明超秀兰霞平刚桂英华建国志强晓梅玉兰海燕思远子涵宇轩一诺欣怡梓萱浩然雨桐俊杰嘉怡文博佳琪若曦晨阳瑞欣婉清亦辰书瑶安然知夏予安沐阳景行乐瑶" NICK_A = ["爱吃", "不吃", "早睡的", "摸鱼的", "认真的", "路过的", "失眠的", "快乐的", "会飞的", "隔壁的", "迷路的", "努力的", "佛系", "暴躁", "安静的", "南方的", "北漂的", "社恐", "退休", "小镇"] NICK_B = ["橘子", "猫", "土豆", "小熊", "汽水", "咸鱼", "柠檬", "老张", "阿杰", "芋圆", "茶叶蛋", "西瓜", "程序员", "设计狮", "奶茶", "企鹅", "仓鼠", "柴犬", "海带", "包子", "番茄", "饭团", "铁匠", "骑手"] CITIES = ["北京", "上海", "广州", "深圳", "杭州", "成都", "重庆", "武汉", "南京", "西安", "苏州", "天津", "长沙", "郑州", "青岛", "厦门", "昆明", "合肥", "宁波", "福州", "大连", "沈阳", "济南", "哈尔滨"] DISTRICTS = ["朝阳区", "海淀区", "浦东新区", "徐汇区", "天河区", "南山区", "西湖区", "武侯区", "江汉区", "鼓楼区", "雁塔区", "工业园区", "滨江区", "福田区", "黄浦区", "越秀区"] CO_A = ["青禾", "远山", "星澜", "北辰", "云栖", "启明", "瀚海", "知行", "松果", "橙光", "蓝鲸", "木棉", "石榴", "九州", "长风", "拾光", "白鹭", "鹿鸣", "南风", "格物"] CO_B = ["科技", "数据", "物流", "文化", "教育", "传媒", "电子", "供应链", "网络", "设计", "健康", "餐饮管理", "咨询", "智能", "信息技术"] DEPTS = ["市场部", "产品部", "研发中心", "财务部", "人力资源部", "行政部", "设计组", "销售二部", "客服中心", "运营部", "法务部", "采购部"] def person(rng): return rng.choice(SURNAMES) + "".join(rng.choice(GIVEN) for _ in range(rng.choice([1, 2, 2]))) def nick(rng): s = rng.choice(NICK_A) + rng.choice(NICK_B) r = rng.random() if r < .25: s += str(rng.randint(1, 999)) elif r < .35: s = s + "_" + rng.choice(["v", "z", "x", "lin", "ok"]) return s def company(rng): return rng.choice(CO_A) + rng.choice(CO_B) PINYIN = ["qinghe", "yuanshan", "xinglan", "beichen", "yunqi", "qiming", "hanhai", "zhixing", "songguo", "chengguang", "lanjing", "mumian", "jiuzhou", "changfeng", "shiguang", "bailu", "luming", "nanfeng", "gewu", "xiaohe"] EN_NAMES = ["lin", "chen", "wang", "zhou", "liu", "xu", "sun", "he", "zhao", "yang", "huang", "wu", "tang", "song", "han"] def email_of(rng, domain=None): return f"{rng.choice(EN_NAMES)}.{rng.choice(EN_NAMES)}{rng.choice(['', str(rng.randint(1, 99))])}@{domain or rng.choice(PINYIN) + '.example'}" NEWS = { "要闻": [ "{city}今冬首场寒潮来袭 气象部门发布寒潮蓝色预警", "国务院常务会议部署进一步做好冬季能源保供工作", "多地出台措施促进消费 汽车家电以旧换新补贴延续至明年", "{city}地铁{n}号线西延段今日开通初期运营", "全国铁路今日起实行新运行图 新增旅客列车{n}对", "今年“双十一”快递业务量同比增长{p}%", "教育部:严格控制中小学生书面作业总量", "{city}发布住房公积金新政 首套房贷款额度上调", "国家统计局:10月份规模以上工业增加值同比增长{p}%", "冬季流感进入高发期 专家提醒老人儿童尽早接种疫苗", "{city}启动老旧小区加装电梯第三批申报", "交通运输部:元旦假期预计跨区域人员流动量超{n}亿人次", "全国冬小麦播种基本结束 苗情总体好于常年", "{city}推出新一批便民措施 社区医院可预约夜间门诊", "多部门联合开展冬季安全生产大检查", "个人所得税年度汇算明年3月1日开始", "新版医保药品目录明年1月1日起执行", ], "国内": [ "{city}一小区出现“共享菜园” 居民自发认领种菜", "长江中游航道冬季维护疏浚工程启动", "{city}机场新航站楼启用 首日保障航班{n}架次", "云南多地迎来观鸟季 红嘴鸥如期飞抵昆明", "东北多地降雪 哈尔滨冰雪大世界开始采冰", "{city}街头“口袋公园”新增{n}处", "黄河兰州段出现今冬首次流凌", "{city}推出社区食堂助餐服务 老年人可享折扣", "西安城墙景区夜游延长至22点", "{city}一处百年老街完成修缮 重新对外开放", "南水北调中线今年调水量创新高", "{city}地铁站内新增母婴室{n}处", "海南离岛免税购物额同比增长{p}%", ], "财经": [ "A股三大指数午盘涨跌不一 半导体板块走强", "人民币对美元中间价调升{n}个基点", "前十月全国网上零售额同比增长{p}%", "多家银行下调大额存单利率 三年期跌破2%", "新能源车11月前三周零售同比增长{p}%", "{city}发布楼市新政 二手房成交量环比回升", "黄金价格震荡回落 金饰报价每克下调{n}元", "央行开展{n}亿元逆回购操作", "冬季取暖用煤价格总体平稳", ], "科技": [ "国产大飞机今年交付量创新高", "我国在轨卫星互联网试验星完成组网测试", "端侧大模型走进家电 冰箱也能“看懂”食材", "多款折叠屏手机降价 入门价跌破五千元", "嫦娥探测器传回最新月背影像", "研究团队研制出新型钠离子电池 低温性能提升{p}%", "智能眼镜销量同比翻番 年轻人成主力", "家用储能设备进入社区试点", "高校开设人工智能通识课 选课人数爆满", "手机厂商推送系统更新 修复耗电问题", "国产操作系统装机量突破{n}亿台", "无人配送车在{city}{n}个小区试运行", ], "体育": [ "中超收官战落幕 {city}队主场逆转获胜", "CBA常规赛:{city}队加时险胜 外援砍下{n}分", "全国冬季两项锦标赛在吉林开赛", "{city}马拉松鸣枪 {n}万名跑者参赛", "女排联赛第{n}轮:天津女排3比1取胜", "乒乓球世界杯男单决赛今晚打响", "全国游泳冠军赛{city}站收官", "冰壶公开赛中国队晋级四强", "{city}青少年足球联赛开幕 {n}支队伍参赛", "羽毛球世界巡回赛总决赛名单出炉", ], "本地": [ "{district}一路段今晚起封闭施工 公交{n}路绕行", "{district}新开一处24小时自习室 免费预约", "周末{district}将举办冬季市集 共设摊位{n}个", "{district}菜市场完成改造 今天重新开业", "{district}图书馆延长开放时间至晚上9点", "{district}停车场收费标准调整 首小时{n}元", "暴雪预警解除 {district}中小学恢复正常上课", "{district}新增{n}个充电桩 覆盖12个小区", "{district}社区卫生服务中心开设周末门诊", "{district}一小学周边新增{n}个临时停车位", "{district}冬季供暖热线开通 24小时受理报修", "{district}口袋公园改造完工 新增儿童游乐区", ], "娱乐": [ "年度十大流行语发布 “情绪价值”入选", "电影《北方的雪》定档元旦 预售票房破{n}万", "综艺《一起去种地》第二季开录", "话剧《茶馆》新一轮巡演首站开票", "跨年晚会节目单曝光 多位歌手将合唱", "冬季音乐节阵容公布 {city}站门票秒空", "年度好书榜发布 历史类图书受欢迎", "动画电影《小橘子》票房破{n}亿", "{city}博物馆冬季特展开幕 免费预约参观", ], } HOT = ["寒潮来袭全国大范围降温", "地铁新线今日开通", "流感疫苗哪里打", "11月工资条晒出来了", "冬至吃饺子还是汤圆", "年终奖发放时间表", "居民供暖费标准调整", "跨年演唱会门票秒空", "首场雪什么时候下", "外卖平台新规", "医保个账可以家庭共济了", "考研倒计时30天", "演唱会退票手续费", "老人防诈骗提醒", "车险续保新规", "年货节提前开始", "高铁选座新功能", "羽绒服怎么洗"] ADS = [("冬季焕新季", "羽绒服低至3折 · 满299减50", "立即抢购"), ("青禾学堂", "成人本科 · 名师直播 · 免费试听3节", "预约试听"), ("远山家装", "全屋定制 每平米698元起 · 免费量房", "免费设计"), ("星澜旅行", "三亚5天4晚 自由行 ¥2,399起", "查看行程"), ("长风汽车", "新款SUV 限时金融0首付 · 置换补贴8000", "预约试驾"), ("拾光相册", "照片书 第二本半价 · 包邮到家", "马上制作")] PRODUCT = { "羽绒服": (["加厚", "短款", "长款过膝", "连帽", "轻薄", "白鸭绒", "90绒"], ["男女同款冬季外套", "面包服", "保暖防风", "宽松百搭"], (199, 899)), "电暖器": (["家用", "速热", "节能", "取暖器", "油汀"], ["13片 卧室静音", "小太阳 办公室", "暖风机 浴室防水"], (89, 459)), "保温杯": (["316不锈钢", "大容量", "便携", "带茶隔"], ["500ml 男女学生", "1L 户外运动", "车载 24小时保温"], (39, 169)), "四件套": (["纯棉", "珊瑚绒", "加厚牛奶绒", "水洗棉"], ["冬季保暖 1.8m床", "被套床单 1.5m", "简约条纹 宿舍"], (99, 399)), "雪地靴": (["加绒", "防滑", "一脚蹬", "厚底"], ["女冬季短靴", "男款棉鞋", "防水户外"], (79, 329)), "空气炸锅": (["5L大容量", "可视", "无油", "多功能"], ["家用 电炸锅", "烤箱一体机", "智能触屏"], (159, 599)), "电热毯": (["双人", "单人", "智能控温", "除螨"], ["1.8x2米 安全", "宿舍学生 1.2米", "水暖毯 无辐射"], (59, 299)), "围巾": (["羊毛", "格子", "针织", "纯色"], ["女冬季 百搭", "男士 商务", "加厚 披肩两用"], (39, 259)), } SHOPS = ["禾木家居旗舰店", "北辰户外专营店", "暖冬生活馆", "松果数码官方店", "鹿鸣服饰", "蓝鲸电器旗舰店", "石榴家纺", "橙光小家电", "九州运动专营店", "白鹭优选", "拾光杂货铺", "南风女装"] TAGS = ["包邮", "满300减40", "7天无理由", "退货包运费", "新品", "百亿补贴", "24小时发货", "以旧换新", "赠运费险", "店铺券满99减10"] MAIL_SUBJ = [ ("{co}", "【发票】您的电子发票已开具", "尊敬的客户,您于11月20日购买的服务已开具电子发票,请点击下载。"), ("人力资源部", "关于2026年度年假使用的提醒", "各位同事:今年剩余年假请于12月31日前休完,未休部分不予顺延。"), ("{p}", "Re: 第三季度预算调整", "收到,我这边再核对一下差旅部分,周四前给你回复。"), ("{p}", "方案初稿,请帮忙看看", "附件是第一版方案,主要改了第二部分的流程图,有问题随时说。"), ("{co}", "您的订单已发货", "您购买的商品已由快递发出,运单号 SF00000{n},预计2天内送达。"), ("行政部", "办公区本周五下午消防演练通知", "本周五下午3点进行全员消防演练,请听到警报后从最近的安全出口有序撤离。"), ("{p}", "周末聚餐地点定了吗", "我看了几家,{city}那边的火锅店评价不错,人均一百出头。"), ("IT 支持", "【工单 #{n}】打印机故障已处理", "您提交的工单已处理完成,如仍有问题请回复本邮件。"), ("{co}", "11月账单已出", "您的11月账单金额为 ¥{m},最后还款日为12月10日。"), ("{p}", "合同盖章版扫描件", "附件为双方盖章后的合同扫描件,原件已寄出,请注意查收。"), ("财务部", "10月报销已打款", "您提交的2笔报销已打款,合计 ¥{m},请注意查收。"), ("{co}", "会员到期提醒", "您的年度会员将于12月1日到期,续费可享8折优惠。"), ("{p}", "周报 11.17-11.21", "本周完成:1. 用户访谈整理 2. 原型第二版 3. 数据看板上线。"), ("{co}", "安全提醒:新设备登录", "您的账号于11月23日 21:14 在一台新设备上登录,如非本人操作请立即修改密码。"), ("{p}", "照片发你了", "上次出去玩的照片都在网盘里,链接见下面,提取码我单独发你。"), ("{co}", "年终大促 · 全场满减", "年终盛典开启,爆款低至5折,更有满500减80优惠券限时领取。"), ("{p}", "关于下周出差的安排", "高铁票已经订好了,周三早上8点从{city}出发,酒店在会场附近。"), ("学校教务处", "期末考试安排通知", "本学期期末考试将于12月22日开始,请各位同学登录系统查看考场安排。"), ("{p}", "Re: Re: 接口文档", "第三版的字段有变化,我在文档里标黄了,麻烦前端同学看一下。"), ("{co}", "您的快递已到驿站", "您的包裹已到达小区驿站,取件码 {n},请于3天内取件。"), ("{p}", "招聘:高级设计师内推", "我们组在招高级视觉设计师,有合适的朋友可以推荐一下,有内推奖励。"), ("物业服务中心", "关于冬季供暖试运行的通知", "小区供暖将于11月28日开始试运行,请业主检查家中阀门是否关闭。"), ("{co}", "订阅周刊 · 第148期", "本期内容:冬季如何科学进补;五本值得读的新书;周末去哪儿。"), ("{p}", "周报模板更新了", "新版周报模板放在共享盘了,下周起按新模板填,有问题找我。"), ] CHAT_MSG = [ "好的收到", "我晚点看一下", "这个周五前能弄完吗?", "哈哈哈哈哈", "已经发你邮箱了", "明天几点集合?", "我到楼下了", "稍等,在开会", "可以的,没问题", "这个价格还能再便宜点吗", "[图片]", "[文件] 报价单_v3.xlsx", "辛苦啦~", "今天降温了记得多穿点", "晚上一起吃饭不", "那个链接打不开", "我刚问了,说下周二才有货", "👍", "OK", "等我五分钟", "这周末有空吗", "好嘞", "收到,马上处理", "会议纪要我整理好了", "群里统计一下人数", "+1", "我也去", "麻烦大家接龙一下", "地址发我一下", "已转账", "你先看看,有问题再说", "明白", "这个方案我觉得可以", "数据更新了吗", "孩子今天作业有点多", "快递到了吗", "我在地铁上,信号不好", "这个周三交", "[语音] 12\"", "那就这么定了", ] CHAT_NAMES = ["家人群", "产品设计组", "周末羽毛球", "三年二班家长群", "小区业主群", "大学室友", "项目对接群", "骑行俱乐部", "部门通知", "读书会", "老同学聚会", "租房交流", "宠物医院客服", "健身打卡", "装修群", "前端技术交流"] CAL_EV = ["周例会", "产品评审", "1:1 沟通", "需求对齐", "客户电话", "午饭", "健身", "设计走查", "面试:前端工程师", "周报整理", "接孩子", "预算复盘", "供应商会议", "培训:数据安全", "季度规划", "牙医复诊", "读书会", "版本发布", "跨部门同步", "部门聚餐", "瑜伽课", "看房", "团队分享", "代码评审"] CAL_PLACES = ["3楼 大会议室", "线上会议", "望京 星澜大厦", "A座 1206", "公司食堂", "小会议室 B", "国贸", "视频会议室", "前台", "线上", "8楼 茶水间"] FILES = [("季度汇报_终版.pptx", "演示文稿"), ("报价单_v3.xlsx", "表格"), ("合同扫描件.pdf", "PDF 文稿"), ("IMG_2031.HEIC", "HEIF 图像"), ("会议录音_1121.m4a", "音频"), ("设计稿", "文件夹"), ("发票", "文件夹"), ("简历_林晓.pdf", "PDF 文稿"), ("截屏 2026-11-23 15.42.10.png", "PNG 图像"), ("旅行攻略.docx", "文稿"), ("家庭账本2026.xlsx", "表格"), ("安装包.dmg", "磁盘映像"), ("壁纸", "文件夹"), ("项目资料.zip", "ZIP 归档"), ("体检报告.pdf", "PDF 文稿"), ("年会节目单.docx", "文稿"), ("视频素材", "文件夹"), ("VID_20261122.mov", "影片"), ("读书笔记.md", "Markdown"), ("租房合同.pdf", "PDF 文稿"), ("logo_草稿.png", "PNG 图像"), ("周报模板.docx", "文稿"), ("课程表.png", "PNG 图像"), ("备份", "文件夹")] SONGS = ["晚风吹过的街", "第七个冬天", "海边的便利店", "不说再见", "慢一点", "月亮在听", "山那边", "旧城夏日", "雨停之后", "你好,十一月", "回声", "南方的南方", "一个人的旅行", "白日梦", "像风一样", "星期天的早晨", "落日站台", "未寄出的信", "灯火", "春天的地铁", "橙色气球", "路过人间烟火"] ARTISTS = ["林知夏", "陈小屿", "北岛乐队", "程沐阳", "苏晚晴", "南风合唱团", "许一诺", "白鹭", "周予安", "海边的猫", "夏晨", "江野"] FORUM_REPLY = [ "同问,我家也是这种情况,蹲一个答案。", "楼主可以试试先恢复出厂设置,我上次就是这么好的。", "谢谢分享,已收藏!", "这个价格算贵了,我去年买的才两千多。", "建议去官方售后看看,保修期内应该免费。", "我用了半年了,说说感受:优点是续航真的强,缺点是有点重。", "前排围观", "顶一下,希望更多人看到。", "楼上说得对,买之前一定要看清楚型号。", "我也踩过这个坑,后来换了一家就好了。", "地址在哪里?周末想去看看。", "有没有更便宜的替代方案?", "mark 一下,回头细看。", "实测有效,感谢楼主!", "这种情况多半是网络问题,换个时间段再试试。", "求个链接,私信也行。", "同城的可以约一下一起去。", "说实话不太推荐,售后太难找人了。", "看完了,写得很详细,学到了。", "楼主后来怎么解决的?更新一下呗。", "这个我熟,第3步那里要注意别选错。", "已按楼主的方法设置好了,确实快了很多。", "坐标杭州,上周刚去过,人不多,体验不错。", "价格每天都在变,建议多比比。", ] DOC_PARA = [ "同步功能会在设备联网时自动运行。首次开启后,系统会将本机已有的数据上传到云端,这个过程可能需要几分钟,期间请勿关闭应用。", "如果你在多台设备上登录了同一个账号,修改会在约 30 秒内同步到其他设备。离线时的修改会先保存在本机,联网后自动合并。", "出现冲突时,系统会保留两个版本,并在文件名后加上设备名,方便你手动比较后删除不需要的那份。", "免费版每个账号可使用 5 GB 存储空间,单个文件不超过 200 MB;升级到专业版后空间扩大到 1 TB,单个文件上限为 10 GB。", "为保护数据安全,所有传输均经过加密。你也可以在「设置 - 安全」中开启两步验证,登录新设备时需要输入手机收到的验证码。", "删除的文件会在回收站中保留 30 天,期间可以随时恢复;超过 30 天后将被永久删除,无法找回。", "管理员可以在团队后台为成员分配角色。「编辑者」可以修改内容,「查看者」只能阅读和评论,「管理员」可以邀请和移除成员。", "导出时可选择 PDF、Word 或 Markdown 格式。图片会按原始分辨率导出,表格中的公式会转换为计算结果。", "如果同步长时间卡在「正在准备」,请先检查网络连接,然后在设置中点击「重新同步」。仍无法解决时,可以导出日志并联系客服。", "每次大版本更新后,旧版客户端会在 90 天后停止支持同步,请尽快升级到最新版本。", ] TERM_CMDS = [ ("git status", ["On branch main", "Your branch is up to date with 'origin/main'.", "", "Changes not staged for commit:", " modified: src/pages/order/list.tsx", " modified: src/api/order.ts", "", "no changes added to commit"]), ("ls -lh", ["total 48", "drwxr-xr-x 12 lin staff 384B 11 23 18:02 src", "-rw-r--r-- 1 lin staff 1.2K 11 20 09:15 package.json", "-rw-r--r-- 1 lin staff 2.4K 11 24 09:41 README.md", "drwxr-xr-x 5 lin staff 160B 11 18 14:30 public"]), ("npm run build", ["> admin-web@2.3.1 build", "> vite build", "vite v5.4.2 building for production...", "✓ 1286 modules transformed.", "dist/index.html 0.62 kB │ gzip: 0.39 kB", "dist/assets/index-4f2a1c.js 812.40 kB │ gzip: 243.18 kB", "✓ built in 8.42s"]), ("ping -c 3 api.qinghe.example", ["PING api.qinghe.example (10.0.3.21): 56 data bytes", "64 bytes from 10.0.3.21: icmp_seq=0 ttl=58 time=23.4 ms", "64 bytes from 10.0.3.21: icmp_seq=1 ttl=58 time=21.9 ms", "64 bytes from 10.0.3.21: icmp_seq=2 ttl=58 time=22.7 ms", "3 packets transmitted, 3 packets received, 0.0% packet loss"]), ("python3 report.py --month 11", ["读取 data/orders_2026_11.csv ... 共 12,408 行", "按城市汇总 ... 完成", "写出 out/report_11.xlsx", "耗时 3.2 秒"]), ("df -h /", ["Filesystem Size Used Avail Capacity Mounted on", "/dev/disk3s1s1 460Gi 238Gi 213Gi 53% /"]), ("git log --oneline -5", ["a41c9e2 修复订单导出时间格式", "7d03b18 列表页增加按城市筛选", "c92e0f4 更新依赖", "5f1aa73 首页数据看板", "08be2d1 初始化项目"]), ("brew upgrade", ["==> Upgrading 3 outdated packages:", "ffmpeg 7.0.2 -> 7.1", "node 22.9.0 -> 22.11.0", "sqlite 3.46.1 -> 3.47.0", "==> Pouring node--22.11.0.bottle.tar.gz"]), ("tail -n 4 logs/app.log", ["2026-11-24 09:52:11 INFO 用户登录 uid=10382", "2026-11-24 09:52:40 WARN 接口 /api/order/list 响应 1.8s", "2026-11-24 09:53:02 INFO 导出任务完成 task=8817", "2026-11-24 09:55:17 ERROR 短信发送失败 code=429 重试中"]), ] def news_title(rng, cat, used=None): pool = NEWS[cat] if used is not None: left = [t for t in pool if t not in used] or pool t = rng.choice(left) used.add(t) else: t = rng.choice(pool) return t.format(city=rng.choice(CITIES), district=rng.choice(DISTRICTS), n=rng.randint(2, 30), p=rng.randint(3, 28)) def clock(rng, lo=0, hi=600): m = rng.randint(lo, hi) return f"{m // 60:02d}:{m % 60:02d}" # ---------------------------------------------------------------- the desktop DOCK = [("文件管理", "🗂", "#4a8fe0"), ("青岚浏览器", "🌐", "#3b7dd8"), ("邮件", "✉️", "#5a9cf0"), ("知了", "💬", "#2fb36b"), ("日历", "📅", "#ffffff"), ("备忘录", "📝", "#f4d35e"), ("回声音乐", "🎵", "#e2475f"), ("格子表格", "📊", "#2e9e5b"), ("照片", "🖼", "#f0f0f0"), ("终端", ">_", "#2b2b2b"), ("系统设置", "⚙️", "#8e8e93"), ("应用市场", "🛍", "#6c6cf0"), ("影音", "🎬", "#333")] MENUS = {"青岚浏览器": ["文件", "编辑", "显示", "历史记录", "书签", "窗口", "帮助"], "邮件": ["文件", "编辑", "显示", "邮箱", "邮件", "格式", "窗口", "帮助"], "终端": ["Shell", "编辑", "显示", "窗口", "帮助"], "格子表格": ["文件", "编辑", "插入", "格式", "数据", "窗口", "帮助"], "回声音乐": ["文件", "编辑", "歌曲", "显示", "控制", "窗口", "帮助"], "日历": ["文件", "编辑", "显示", "窗口", "帮助"]} DESK_CSS = """ *{box-sizing:border-box;margin:0;padding:0} html,body{width:1680px;height:1050px;overflow:hidden} body{font-family:@F@;font-size:13px;line-height:1.45;color:#1d1d1f;-webkit-font-smoothing:antialiased;position:relative} a{color:inherit;text-decoration:none} .av{display:inline-flex;align-items:center;justify-content:center;color:#fff;flex:none;font-weight:500;line-height:1} .wall{position:absolute;inset:0} .mbar{position:absolute;left:0;top:0;right:0;height:26px;background:rgba(246,246,248,.86);border-bottom:1px solid rgba(0,0,0,.08);display:flex;align-items:center;padding:0 14px;font-size:13.5px;z-index:900;gap:19px;color:#111} .mbar b{font-weight:700}.mbar .r{margin-left:auto;display:flex;gap:16px;align-items:center} .mbar svg{display:block} .dock{position:absolute;bottom:6px;left:50%;transform:translateX(-50%);height:70px;padding:7px 10px;background:rgba(240,240,245,.62);border:1px solid rgba(255,255,255,.5);border-radius:20px;display:flex;gap:7px;z-index:900;box-shadow:0 4px 20px rgba(0,0,0,.18)} .dock .ic{width:54px;height:54px;border-radius:13px;display:flex;align-items:center;justify-content:center;font-size:29px;position:relative;box-shadow:0 1px 3px rgba(0,0,0,.25);font-family:@F@;color:#fff;font-weight:700} .dock .ic.dk{font-size:19px;color:#9fe39f} .dock .ic i{position:absolute;bottom:-7px;left:50%;width:4px;height:4px;margin-left:-2px;border-radius:50%;background:#333} .dock .sep{width:1px;background:rgba(0,0,0,.2);margin:4px 2px} .dock .ic em{position:absolute;top:-5px;right:-5px;background:#ff3b30;color:#fff;font-size:11px;font-style:normal;border-radius:9px;padding:0 5px;line-height:17px;font-weight:600;font-family:@F@} .dicon{position:absolute;width:86px;text-align:center;color:#fff;font-size:12px;text-shadow:0 1px 2px rgba(0,0,0,.6);z-index:1} .dicon div{width:56px;height:56px;margin:0 auto 4px;border-radius:8px;display:flex;align-items:center;justify-content:center;font-size:34px} .win{position:absolute;border-radius:11px;overflow:hidden;background:#fff;box-shadow:0 22px 60px rgba(0,0,0,.38),0 0 0 .5px rgba(0,0,0,.35)} .win.inact{box-shadow:0 12px 32px rgba(0,0,0,.22),0 0 0 .5px rgba(0,0,0,.25)} .win>.body{position:absolute;inset:0;overflow:hidden} .lights{position:absolute;left:13px;display:flex;gap:8px;z-index:50} .lights i{width:12px;height:12px;border-radius:50%;box-shadow:inset 0 0 0 .5px rgba(0,0,0,.18)} .inact .lights i{background:#d5d5d8!important} .tbar{background:#ececef;border-bottom:1px solid #d4d4d8} .inact .tbar{background:#f5f5f7;color:#8a8a8e} .std-tb{height:30px;display:flex;align-items:center;justify-content:center;font-size:13px;font-weight:600;color:#333} .inact .std-tb{color:#aaa} .note{position:absolute;right:12px;width:356px;background:rgba(246,246,248,.96);border-radius:15px;padding:11px 13px;display:flex;gap:10px;box-shadow:0 8px 28px rgba(0,0,0,.25);z-index:950;font-size:13px} .note .ni{width:36px;height:36px;border-radius:9px;flex:none;display:flex;align-items:center;justify-content:center;font-size:21px} .note .ntt{display:flex;justify-content:space-between;align-items:baseline}.note .ntt b{font-size:13px}.note .ntt span{color:#8a8a8e;font-size:12px} .note .nb{color:#333;line-height:1.4;margin-top:1px;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden} """.replace("@F@", FONT) WALLS = ["linear-gradient(160deg,#3a5f8f 0%,#7f95b8 40%,#d9a98c 75%,#e8c7a0 100%)", "linear-gradient(170deg,#1f3b4d 0%,#3d6d7a 45%,#9bb7a5 100%)", "radial-gradient(120% 90% at 20% 10%,#f1c6b3 0%,#b98aa8 35%,#5b5a8f 70%,#2c2f55 100%)", "linear-gradient(180deg,#8fb3d9 0%,#c8d8e8 55%,#e9e2d0 100%)"] WIFI = '' BATT = '' LOGO = '' SEARCH = '' CTRL = '' def notification(app, title, body, time="现在", icon=None, color=None): """A banner at the top right of the screen.""" ic, col = icon, color for name, e, c in DOCK: if name == app: ic, col = ic or e, col or c return {"app": app, "title": title, "body": body, "time": time, "icon": ic or "🔔", "color": col or "#5a9cf0"} def _date_label(now): y, mo, d = map(int, now[:10].split("-")) import datetime wd = datetime.date(y, mo, d).weekday() return f"{mo}月{d}日 周{WEEK[wd]} {now[11:16]}" def desktop(windows, *, now="2026-11-24 10:00", notifications=(), dock_apps=None, wallpaper=None, size=(1680, 1050), desktop_icons=None, battery=78, rng=None, title="桌面截图"): """A whole Mac-style screen. windows: list of dicts from at(...), front first. Returns a complete HTML page.""" rng = rng or random.Random(0) W, H = size front = windows[0] if windows else {"app": "文件管理"} menus = MENUS.get(front.get("app"), ["文件", "编辑", "显示", "前往", "窗口", "帮助"]) mb = (f'
{LOGO}{esc(front.get("app", ""))}' + "".join(f"{esc(m)}" for m in menus) + f'
拼{BATT % max(2, int(19 * battery / 100))}{battery}%' f'{WIFI}{SEARCH}{CTRL}{esc(_date_label(now))}
') running = {w.get("app") for w in windows} apps = dock_apps or DOCK dock = [] for i, (name, e, c) in enumerate(apps): cls = "ic dk" if e == ">_" else "ic" badge = "" if name == "邮件": badge = f"{rng.randint(3, 40)}" elif name == "知了": badge = f"{rng.randint(2, 19)}" dot = "" if name in running or name in ("文件管理",) else "" dock.append(f'
{esc(e)}{badge}{dot}
') dock.insert(len(dock) - 2, '
') icons = desktop_icons if desktop_icons is not None else [("💾", "系统盘"), ("📁", "2026 项目"), ("📄", "报价单_v3.xlsx"), ("🖼", "截屏 2026-11-23 15.42.10"), ("📁", "待整理"), ("📦", "安装包.dmg")] di = [] for k, (e, label) in enumerate(icons): col, row = divmod(k, 7) di.append(f'
{esc(e)}
{esc(label)}
') css = [DESK_CSS] seen = set() wins = [] n = len(windows) for i, w in enumerate(windows): if w.get("css") and w["css"] not in seen: seen.add(w["css"]) css.append(w["css"]) cls = "win" if i == 0 else "win inact" lt = w.get("lights_top", 9) lights = ('
' '
' % lt) wins.append(f'
' f'{lights}
{w["html"]}
') notes = [] y = 34 for nt in notifications: notes.append(f'
{esc(nt["icon"])}
' f'
{esc(nt["title"])}{esc(nt["time"])}
' f'
{esc(nt["app"])}
{esc(nt["body"])}
') y += 92 wall = wallpaper or rng.choice(WALLS) return (f'' f'{esc(title)}' f'
{mb}{"".join(di)}{"".join(wins)}{"".join(notes)}' f'
{"".join(dock)}
') def std_window(app, title, html, css="", toolbar=None): """Plain window with a 30px title bar (for content that has no toolbar of its own).""" tb = toolbar or f'
{esc(title)}
' return {"app": app, "title": title, "html": tb + html, "css": css} # ---------------------------------------------------------------- browser BROWSER_CSS = """ .bw{position:absolute;inset:0;display:flex;flex-direction:column;background:#fff} .bw-tabs{height:38px;display:flex;align-items:flex-end;padding:0 8px 0 84px;gap:1px;background:#dcdde2;border-bottom:none} .inact .bw-tabs{background:#e9e9ec} .bw-tab{flex:1 1 0;min-width:0;max-width:210px;height:31px;display:flex;align-items:center;gap:6px;padding:0 9px;font-size:12px;color:#444;border-radius:8px 8px 0 0;position:relative;white-space:nowrap} .bw-tab+.bw-tab:before{content:"";position:absolute;left:-1px;top:8px;bottom:8px;width:1px;background:#b9bac0} .bw-tab.on{background:#fff;color:#111}.bw-tab.on:before,.bw-tab.on+.bw-tab:before{display:none} .bw-tab .fv{width:14px;height:14px;border-radius:3px;flex:none;font-size:9px;color:#fff;display:flex;align-items:center;justify-content:center;font-weight:700} .bw-tab .tt{overflow:hidden;text-overflow:ellipsis;flex:1}.bw-tab .x{color:#888;font-size:11px} .bw-plus{width:28px;height:31px;display:flex;align-items:center;justify-content:center;color:#555;font-size:17px} .bw-nav{height:38px;display:flex;align-items:center;gap:12px;padding:0 12px;border-bottom:1px solid #e3e3e6;color:#555;font-size:15px} .bw-url{flex:1;height:28px;border-radius:14px;background:#f0f1f4;display:flex;align-items:center;padding:0 14px;font-size:13px;color:#222;gap:8px} .bw-url .h{color:#888} .bw-bm{height:28px;display:flex;align-items:center;gap:16px;padding:0 14px;border-bottom:1px solid #e3e3e6;font-size:12px;color:#444;white-space:nowrap;overflow:hidden} .bw-pg{flex:1;overflow:hidden;position:relative} """ TAB_POOL = ["东方快讯 - 新闻首页", "冬季羽绒服 - 禾木优选", "知识问答:电暖器哪种省电", "青岚邮箱 - 收件箱(23)", "订单管理 - 运营后台", "帮助中心 - 数据同步说明", "北辰户外论坛 - 徒步装备", "12月行程安排.docx - 在线文档", "租房 | 杭州西湖区两居室", "车次查询 - 行旅出行", "天气预报 - 上海 7天", "翻译 - 云栖翻译", "地图 - 从家到公司", "会员中心 - 回声音乐", "新标签页", "电影《北方的雪》- 购票", "期末复习资料 - 网盘", "菜谱:番茄牛腩的做法", "招聘 | 高级产品经理", "股票行情 - 财经频道", "外卖 - 小禾外卖", "快递查询 - 运单详情", "在线表格:部门预算", "社区 - 前端技术交流"] BOOKMARKS = ["📁 工作", "📁 常用", "东方快讯", "青岚邮箱", "运营后台", "📁 学习", "在线文档", "行旅出行", "网盘", "📁 购物", "地图", "翻译", "📁 其他"] def browser(page, *, rng, url, tabs=None, active=None, ntabs=None, bookmarks=None, app="青岚浏览器"): """Browser window. page: content dict (or HTML string); tabs: titles (filled up to 8–15 from TAB_POOL).""" if isinstance(page, str): page = {"html": page, "css": "", "title": "网页"} tabs = list(tabs or [page.get("title", "网页")]) n = ntabs or rng.randint(9, 13) extra = [t for t in TAB_POOL if t not in tabs] rng.shuffle(extra) cur = tabs[active or 0] while len(tabs) < n and extra: tabs.insert(rng.randint(0, len(tabs)), extra.pop()) active = tabs.index(cur) ts = [] for i, t in enumerate(tabs): c = f"hsl({hue(t)},55%,48%)" ts.append(f'
{esc(t[0])}' f'{esc(t)}{"✕" if i == active else ""}
') host, _, path = url.partition("/") bm = "".join(f"{esc(b)}" for b in (bookmarks or BOOKMARKS)) html = (f'
{"".join(ts)}
+
' f'
←→↻' f'
🔒{esc(host)}{"/" + esc(path) if path else ""}' f'☆
⬇⋯' f'林
' f'
{bm}
{page["html"]}
') return {"app": app, "title": tabs[active], "html": html, "css": BROWSER_CSS + page.get("css", ""), "lights_top": 13} # ---------------------------------------------------------------- web pages PORTAL_CSS = """ .pp{font-size:13px;color:#222;background:#fff;min-width:100%} .pp-top{height:28px;background:#f4f4f4;border-bottom:1px solid #e5e5e5;display:flex;align-items:center;padding:0 24px;gap:16px;font-size:12px;color:#666} .pp-top .r{margin-left:auto;display:flex;gap:14px} .pp-hd{display:flex;align-items:center;padding:12px 24px;gap:24px} .pp-logo{font-size:26px;font-weight:800;color:#b8262b;letter-spacing:2px}.pp-logo small{font-size:12px;color:#999;font-weight:400;letter-spacing:0;margin-left:6px} .pp-sch{flex:0 0 380px;height:32px;border:2px solid #b8262b;border-radius:4px;display:flex;align-items:center;justify-content:space-between;padding-left:10px;color:#999;font-size:12px} .pp-sch b{background:#b8262b;color:#fff;height:100%;padding:0 18px;display:flex;align-items:center;font-weight:400} .pp-wx{margin-left:auto;font-size:12px;color:#555;text-align:right;line-height:1.5} .pp-nav{background:#b8262b;display:flex;padding:0 24px;color:#fff;font-size:14px;white-space:nowrap;overflow:hidden} .pp-nav span{padding:7px 12px}.pp-nav span.on{background:#8f1b1f} .pp-sub{display:flex;gap:14px;padding:6px 24px;font-size:12px;color:#555;border-bottom:1px solid #eee;white-space:nowrap;overflow:hidden} .pp-main{display:flex;gap:20px;padding:12px 24px} .pp-l{flex:1;min-width:0}.pp-r{width:300px;flex:none} .pp-hl{text-align:center;padding:6px 0 10px;border-bottom:1px dashed #ddd} .pp-hl h1{font-size:22px;color:#1a3d7c;line-height:1.35}.pp-hl p{font-size:13px;color:#1a3d7c;margin-top:4px}.pp-hl p span{margin:0 8px} .pp-row{display:flex;gap:18px;margin-top:10px} .pp-pic{width:250px;flex:none}.pp-img{height:150px;border-radius:2px;position:relative;overflow:hidden} .pp-img i{position:absolute;left:0;right:0;bottom:0;background:rgba(0,0,0,.55);color:#fff;font-style:normal;font-size:12px;padding:4px 8px} .pp-sec{flex:1;min-width:0} .pp-st{display:flex;align-items:baseline;justify-content:space-between;border-bottom:2px solid #b8262b;margin-bottom:4px} .pp-st b{font-size:15px;color:#b8262b;padding:2px 0}.pp-st span{font-size:12px;color:#999} .pp-li{display:flex;gap:6px;font-size:13px;line-height:24px;white-space:nowrap} .pp-li:before{content:"·";color:#999}.pp-li .t{overflow:hidden;text-overflow:ellipsis;flex:1}.pp-li .ptm{color:#999;font-size:12px} .pp-li.k .t{color:#1a3d7c} .pp-box{border:1px solid #e5e5e5;margin-bottom:12px} .pp-box h4{font-size:14px;padding:6px 10px;background:#fafafa;border-bottom:1px solid #eee;display:flex;justify-content:space-between}.pp-box h4 span{font-size:12px;color:#999;font-weight:400} .pp-hot{display:flex;gap:8px;padding:4px 10px;font-size:13px;line-height:20px}.pp-hot em{font-style:normal;width:18px;height:18px;border-radius:3px;background:#ccc;color:#fff;font-size:11px;text-align:center;line-height:18px;flex:none} .pp-hot:nth-child(-n+4) em{background:#e2483c}.pp-hot .t{flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.pp-hot .n{color:#999;font-size:12px} .pp-ad{position:relative;padding:14px;color:#fff;margin-bottom:12px} .pp-ad b{font-size:18px;display:block}.pp-ad p{font-size:13px;margin:4px 0 10px}.pp-ad span{background:#fff;color:#c33;padding:3px 12px;border-radius:12px;font-size:12px} .pp-ad i{position:absolute;right:4px;bottom:3px;font-style:normal;font-size:10px;background:rgba(0,0,0,.35);padding:0 4px;color:#eee} .pp-wt{display:flex;justify-content:space-around;padding:8px 6px;font-size:12px;text-align:center;color:#555}.pp-wt b{display:block;font-size:20px} .pp-grid{display:grid;grid-template-columns:1fr 1fr;gap:4px 22px;margin-top:12px} .pp-ft{background:#f4f4f4;border-top:1px solid #e5e5e5;padding:14px 24px;font-size:12px;color:#888;text-align:center;line-height:1.9;margin-top:8px} """ def _hlist(rng, cat, n, key=(), lo=360, hi=599, used=None): items = [(clock(rng, lo, hi), news_title(rng, cat, used)) for _ in range(n)] items = mix(rng, items, [(t, s, True) for t, s in key]) items.sort(key=lambda it: it[0], reverse=True) out = [] for it in items: k = len(it) == 3 out.append(f'
{esc(it[1])}{esc(it[0])}
') return "".join(out) def portal_page(rng, *, site="东方快讯", domain="dongfang.example", headline=None, sub_headlines=(), news=(), hot=(), ad=None, city="上海", weather=("小雨", "9~14℃"), title=None): """News portal: headline, six sections of timed headlines (key `news` go into 要闻), hot list, weather, ads, footer.""" used = set() hl = headline or news_title(rng, "要闻", used) subs = list(sub_headlines) or [news_title(rng, "要闻", used) for _ in range(2)] nav = ["首页", "要闻", "国内", "国际", "财经", "科技", "体育", "娱乐", "汽车", "房产", "教育", "健康", "旅游", "本地", "视频", "图片", "评论"] subnav = ["专题", "快讯", "直播", "辟谣", "政务", "天气", "彩票", "游戏", "读书", "时尚", "育儿", "美食", "公益", "历史", "军事", "数码"] hot_items = mix(rng, [(h, f"{rng.randint(12, 980)}万") for h in pick(rng, HOT, 10)], [(h, f"{rng.randint(500, 1200)}万") for h in hot], positions=[0] * len(hot))[:10] ad1 = ad or rng.choice(ADS) ad2 = rng.choice([a for a in ADS if a != ad1]) sec = lambda name, n, key=(), lo=360, hi=599: (f'
{name}更多 ›
' f'{_hlist(rng, name, n, key, lo, hi, used)}
') pic = (f'
' f'{esc(news_title(rng, "国内", used))}
' f'
' f'{esc(news_title(rng, "本地", used))}
') hots = "".join(f'
{i + 1}{esc(h)}{esc(n)}
' for i, (h, n) in enumerate(hot_items)) html = (f'
设为首页手机版客户端下载
登录注册' f'我的订阅网站导航
' f'
搜索新闻、视频、话题搜 索
' f'
2026年11月24日 星期二 农历十月十六
{esc(city)} {esc(weather[0])} {esc(weather[1])} · 空气质量 良
' f'
{"".join(f"{n}" if i == 0 else f"{n}" for i, n in enumerate(nav))}
' f'
{"".join(f"{s}" for s in subnav)}
' f'

{esc(hl)}

{"".join(f"{esc(s)}" for s in subs)}

' f'
{pic}{sec("要闻", 11, news, 420, 599)}
' f'
{sec("国内", 8)}{sec("财经", 8)}{sec("科技", 8)}{sec("本地", 8)}{sec("体育", 6)}{sec("娱乐", 6)}
' f'
{esc(ad1[0])}

{esc(ad1[1])}

{esc(ad1[2])}广告
' f'

热榜实时 · 10:00 更新

{hots}
' f'

{esc(city)}天气7天预报 ›

' + "".join(f'
{d}{t}°{w}
' for d, t, w in [("今天", (re.findall(r"-?\d+", weather[1]) or ["14"])[-1], weather[0]), ("周三", 11, "阴"), ("周四", 8, "多云"), ("周五", 10, "晴")]) + f'
{esc(ad2[0])}

{esc(ad2[1])}

{esc(ad2[2])}广告
' f'

视频更多 ›

' + "".join(f'
▶{esc(news_title(rng, c, used))}
' for c in ["国内", "体育", "科技", "娱乐", "本地"]) + f'
关于我们 | 广告服务 | 联系我们 | 招聘信息 | 网站地图 | 隐私政策 | 意见反馈 | 违法和不良信息举报
' f'Copyright © 2008-2026 {esc(site)} {esc(domain)} 版权所有 · 举报电话:000-00000000 · 示例ICP备00000000号
') return {"title": title or f"{site} - 新闻首页", "html": html, "css": PORTAL_CSS} SHOP_CSS = """ .sp{font-size:12px;color:#333;background:#f5f5f5;min-height:100%} .sp-top{height:28px;background:#f0f0f0;border-bottom:1px solid #e3e3e3;display:flex;align-items:center;gap:16px;padding:0 24px;color:#777}.sp-top .r{margin-left:auto;display:flex;gap:14px} .sp-hd{background:#fff;display:flex;align-items:center;gap:26px;padding:12px 24px} .sp-logo{font-size:24px;font-weight:800;color:#e85d1f} .sp-sch{flex:0 0 520px}.sp-sch .b{height:34px;border:2px solid #e85d1f;border-radius:17px;display:flex;align-items:center;padding-left:14px;justify-content:space-between;font-size:13px} .sp-sch .b b{background:#e85d1f;color:#fff;height:100%;padding:0 22px;border-radius:0 15px 15px 0;display:flex;align-items:center;font-weight:400} .sp-sch .hw{color:#999;margin-top:4px;display:flex;gap:10px} .sp-cart{border:1px solid #e85d1f;color:#e85d1f;padding:6px 16px;border-radius:17px} .sp-cat{background:#fff;padding:0 24px;display:flex;gap:22px;font-size:14px;border-bottom:2px solid #e85d1f;white-space:nowrap;overflow:hidden} .sp-cat span{padding:8px 0}.sp-cat .on{color:#e85d1f;font-weight:600} .sp-in{padding:8px 24px} .sp-crumb{color:#888;margin-bottom:6px} .sp-flt{background:#fff;border:1px solid #e8e8e8} .sp-fr{display:flex;border-bottom:1px dashed #eee;line-height:26px}.sp-fr:last-child{border:none} .sp-fr b{width:80px;background:#f8f8f8;color:#777;font-weight:400;padding-left:10px;flex:none}.sp-fr div{display:flex;gap:18px;padding-left:12px;flex-wrap:nowrap;overflow:hidden;white-space:nowrap} .sp-sort{display:flex;align-items:center;gap:0;background:#fff;border:1px solid #e8e8e8;margin:8px 0;height:32px} .sp-sort span{padding:0 14px;border-right:1px solid #eee;line-height:30px}.sp-sort .on{color:#fff;background:#e85d1f} .sp-sort .r{margin-left:auto;color:#888;padding-right:10px;border:none} .sp-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(176px,1fr));gap:8px} .sp-card{background:#fff;padding:8px;border:1px solid #eee;position:relative} .sp-img{height:92px;font-size:44px;display:flex;align-items:center;justify-content:center;font-size:52px;border-radius:2px;position:relative} .sp-img i{position:absolute;left:0;top:0;background:#e85d1f;color:#fff;font-style:normal;font-size:11px;padding:0 5px} .sp-pr{margin-top:6px;color:#e85d1f;font-size:12px}.sp-pr b{font-size:18px}.sp-pr s{color:#aaa;margin-left:4px} .sp-nm{font-size:12px;line-height:17px;height:34px;overflow:hidden;margin:2px 0;color:#333} .sp-tg{display:flex;gap:4px;height:18px;overflow:hidden}.sp-tg span{border:1px solid #f3b08f;color:#e85d1f;font-size:11px;padding:0 3px;line-height:15px;white-space:nowrap} .sp-mt{display:flex;justify-content:space-between;color:#999;margin-top:4px;white-space:nowrap}.sp-mt span:first-child{overflow:hidden;text-overflow:ellipsis;max-width:60%} """ def _product(rng, cat=None): cat = cat or rng.choice(list(PRODUCT)) a, b, (lo, hi) = PRODUCT[cat] brand = rng.choice(CO_A) price = rng.randint(lo, hi) - 0.1 * rng.choice([0, 1, 1, 10]) extra = rng.choice(["2026新款", "冬季新款", "官方正品", "爆款", "", "加厚款", "限时特惠"]) tail = rng.choice(["", " 多色可选", " 送礼佳品", " 现货速发", " 支持以旧换新", " 学生党", " 家用"]) return {"name": f"{brand}{rng.choice(a)}{cat}{extra} {rng.choice(b)}{tail}", "price": f"{price:.2f}".rstrip("0").rstrip("."), "old": str(int(price * rng.uniform(1.2, 1.9))), "sales": rng.choice([f"已售{rng.randint(1, 9)}万+", f"已售{rng.randint(100, 9999)}", f"月销{rng.randint(200, 9000)}+"]), "shop": rng.choice(SHOPS), "tags": pick(rng, TAGS, rng.randint(1, 3)), "cat": cat, "region": rng.choice(CITIES)} EMOJI_OF = {"羽绒服": "🧥", "电暖器": "♨️", "保温杯": "🥤", "四件套": "🛏", "雪地靴": "🥾", "空气炸锅": "🍳", "电热毯": "🟥", "围巾": "🧣"} def shop_list_page(rng, *, site="禾木优选", query="羽绒服", category=None, products=(), total="2,318", title=None, nitems=28, key_within=12): """Product list: search, filters, sort bar, 28 cards; key products land among the first `key_within`. products: dicts {name, price, old?, sales, shop, tags, cat?} put among fillers.""" cat = category or (query if query in PRODUCT else None) fill = [_product(rng, cat if rng.random() < .9 else None) for _ in range(nitems - len(products))] items = mix(rng, fill, products, limit=key_within) cards = [] for p in items: c = p.get("cat") or cat or "羽绒服" badge = f"{esc(p['badge'])}" if p.get("badge") else ("热卖" if rng.random() < .2 else "") cards.append(f'
{EMOJI_OF.get(c, "📦")}{badge}
' f'
¥{esc(p["price"])}{f"¥{esc(p.get(chr(111)+chr(108)+chr(100)))}" if p.get("old") else ""}
' f'
{esc(p["name"])}
{"".join(f"{esc(t)}" for t in p.get("tags", []))}
' f'
{esc(p["shop"])}{esc(p["sales"])}
') brands = pick(rng, CO_A, 12) html = (f'
您好,林晓消息(3)
我的订单收藏夹购物车' f'商家中心客户服务网站导航
' f'
{esc(query)}搜索
' f'
{"".join(f"{esc(w)}" for w in ["羽绒服女", "电热毯", "保温杯", "雪地靴", "暖手宝", "加湿器", "围巾男"])}
' f'
🛒 购物车 12
' f'
{"".join(f"{c}" if c == "全部分类" else f"{c}" for c in ["全部分类", "女装", "男装", "鞋靴", "家居家纺", "家用电器", "数码", "美妆", "食品生鲜", "运动户外", "母婴", "百亿补贴", "直播", "年货节"])}
' f'
全部结果 › {esc(query)} › 共 {esc(total)} 件相关商品
' f'
品牌
{"".join(f"{b}" for b in brands)}更多 ⌄
' f'
价格
0-99100-199200-399400-699700以上自定义 ¥___ - ¥___
' f'
适用人群
男士女士儿童中老年情侣学生
' f'
发货地
{"".join(f"{c}" for c in CITIES[:12])}
' f'
服务
☐ 包邮☐ 7天无理由☐ 货到付款☐ 公益宝贝☐ 天天特价☐ 二手
' f'
综合销量 ↓价格 ↕新品评价数☐ 包邮☐ 只看有货' f'共 {esc(total)} 件   1/50   ‹ ›
{"".join(cards)}
') return {"title": title or f"{query} - {site}", "html": html, "css": SHOP_CSS} FORUM_CSS = """ .ft{font-size:13px;color:#333;background:#eef1f5;min-height:100%} .ft-hd{background:#2d4a6b;color:#fff;display:flex;align-items:center;padding:0 24px;height:44px;gap:22px} .ft-hd .lg{font-size:19px;font-weight:700}.ft-hd span{color:#d6e0ec;font-size:13px}.ft-hd .r{margin-left:auto;display:flex;gap:14px;align-items:center} .ft-hd .sb{background:#fff;color:#999;border-radius:3px;width:220px;height:26px;display:flex;align-items:center;padding-left:8px;font-size:12px} .ft-in{display:flex;gap:14px;padding:10px 24px} .ft-m{flex:1;min-width:0}.ft-s{width:270px;flex:none} .ft-crumb{color:#777;font-size:12px;margin-bottom:6px} .ft-tt{background:#fff;border:1px solid #dde3ea;padding:10px 14px}.ft-tt h1{font-size:18px;color:#1c3550}.ft-tt p{color:#888;font-size:12px;margin-top:3px;display:flex;gap:16px} .ft-p{background:#fff;border:1px solid #dde3ea;border-top:none;display:flex;gap:12px;padding:10px 14px} .ft-u{width:96px;flex:none;text-align:center;font-size:12px;color:#666;border-right:1px solid #f0f0f0;padding-right:8px} .ft-u b{display:block;color:#2d4a6b;font-size:12px;margin-top:4px;word-break:break-all}.ft-u em{font-style:normal;background:#f3a53d;color:#fff;font-size:10px;padding:0 4px;border-radius:2px} .ft-c{flex:1;min-width:0} .ft-meta{display:flex;justify-content:space-between;color:#999;font-size:12px;border-bottom:1px dashed #eee;padding-bottom:4px;margin-bottom:6px} .ft-meta b{color:#c33;font-weight:400} .ft-c .tx{font-size:13.5px;line-height:1.7}.ft-c .tx p+p{margin-top:6px} .ft-q{background:#f6f8fb;border-left:3px solid #c9d4e2;padding:4px 8px;color:#777;font-size:12px;margin-bottom:6px} .ft-ac{color:#999;font-size:12px;margin-top:6px;display:flex;gap:16px;justify-content:flex-end} .ft-box{background:#fff;border:1px solid #dde3ea;margin-bottom:10px}.ft-box h4{font-size:13px;padding:7px 10px;border-bottom:1px solid #eee} .ft-box div{padding:4px 10px;font-size:12px;line-height:20px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis} """ def forum_thread_page(rng, *, site="北辰户外论坛", board="装备讨论", title, author=None, body, replies=(), time="2026-11-23 21:46", views=None, nreplies=12): """Forum thread: OP plus 10+ floors. replies: dicts {user, text, time?, quote?} placed among filler floors.""" author = author or nick(rng) fill = [{"user": nick(rng), "text": rng.choice(FORUM_REPLY)} for _ in range(max(0, nreplies - len(replies)))] floors = mix(rng, fill, replies, limit=3) mins = sorted(rng.sample(range(5, 760), len(floors))) posts = [] stats = {} # one level and post count per user, whichever floors they write def post(u, txt, floor, tm, quote=None, op=False): lvl, n = stats.setdefault(u, (rng.randint(2, 12), rng.randint(3, 4800))) return (f'
{avatar(u, 44, "6px")}{esc(u)}Lv{lvl}
帖子 {n}
' f'
{"楼主 · " if op else ""}发表于 {esc(tm)}{floor}
' f'{f"
{esc(quote)}
" if quote else ""}
{para(txt)}
' f'
👍 {rng.randint(0, 80)}回复举报
') posts.append(post(author, body, "#1", time, op=True)) for i, (f, m) in enumerate(zip(floors, mins)): h, mm = divmod(21 * 60 + 46 + m, 60) tm = f.get("time") or (f"2026-11-23 {h:02d}:{mm:02d}" if h < 24 else f"2026-11-24 {h - 24:02d}:{mm:02d}") posts.append(post(f["user"], f["text"], f"#{i + 2}", tm, f.get("quote"))) side = (f'

{esc(board)} · 今日热帖

' + "".join(f"
· {esc(t)}
" for t in ["冬季徒步鞋怎么选?看这一篇就够了", "武功山两天一夜路线分享(附装备清单)", "二手帐篷出,九成新,同城自提", "冲锋衣内胆抓绒还是羽绒?", "第一次去雪山,求老驴指点", "四姑娘山大峰攻略2026版", "登山杖买碳素还是铝合金", "露营灯续航实测对比"]) + '
' f'

版块信息

今日: {rng.randint(100, 900)}   主题: {rng.randint(10000, 90000)}   排名: {rng.randint(3, 40)}
' f'
版主:{esc(nick(rng))}、{esc(nick(rng))}
' f'
长风户外 · 冬季清仓
冲锋衣 3 折起,满 500 减 100
广告
' f'

相关帖子

' + "".join(f"
· {esc(t)}
" for t in ["羽绒睡袋温标怎么看", "冬季露营防潮垫推荐", "{c}周边适合新手的徒步路线".format(c=rng.choice(CITIES)), "保温壶实测:12小时还剩多少度", "雪套有没有必要买"]) + '
') html = (f'
{esc(site)}首页版块活动游记二手市场' f'问答
搜索帖子、用户
消息{esc(nick(rng))}
' f'
首页 › 户外装备 › {esc(board)} › 正文
' f'

{esc(title)}

查看: {views or rng.randint(800, 30000)}回复: {len(floors)}收藏 {rng.randint(5, 300)}只看楼主倒序浏览

' f'{"".join(posts)}
{side}
') return {"title": f"{title} - {site}", "html": html, "css": FORUM_CSS} WEBMAIL_CSS = """ .wm{position:absolute;inset:0;display:flex;flex-direction:column;font-size:13px;color:#222;background:#fff} .wm-hd{height:48px;background:#1f5fa8;color:#fff;display:flex;align-items:center;padding:0 16px;gap:22px;flex:none} .wm-hd .lg{font-size:18px;font-weight:700}.wm-hd .sb{width:360px;height:30px;border-radius:4px;background:rgba(255,255,255,.2);display:flex;align-items:center;padding-left:10px;color:#dce8f6;font-size:12px} .wm-hd .r{margin-left:auto;display:flex;gap:16px;font-size:12px;align-items:center} .wm-b{flex:1;display:flex;min-height:0} .wm-f{width:176px;flex:none;background:#f4f6f9;border-right:1px solid #e1e5ea;padding:10px 8px;font-size:13px} .wm-f .wr{background:#1f5fa8;color:#fff;border-radius:4px;text-align:center;padding:7px 0;margin-bottom:8px} .wm-f div.i{display:flex;justify-content:space-between;padding:5px 10px;border-radius:4px}.wm-f div.i.on{background:#dbe7f5;color:#1f5fa8;font-weight:600} .wm-f div.i em{font-style:normal;color:#1f5fa8;font-size:12px}.wm-f h6{font-size:12px;color:#888;font-weight:400;padding:10px 10px 2px} .wm-l{width:390px;flex:none;border-right:1px solid #e1e5ea;display:flex;flex-direction:column;min-height:0} .wm-lt{display:flex;gap:12px;align-items:center;padding:7px 12px;border-bottom:1px solid #e8e8e8;font-size:12px;color:#555;flex:none} .wm-lt b{font-size:14px;color:#222}.wm-lt .r{margin-left:auto;color:#888} .wm-m{padding:6px 12px 6px 26px;border-bottom:1px solid #f0f0f0;position:relative;line-height:1.45} .wm-m.u:before{content:"";position:absolute;left:10px;top:12px;width:7px;height:7px;border-radius:50%;background:#1f5fa8} .wm-m.on{background:#e6eef8} .wm-m .r1{display:flex;justify-content:space-between;font-size:13px}.wm-m .r1 span{color:#999;font-size:12px;flex:none;margin-left:8px} .wm-m .r1 b{font-weight:400;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.wm-m.u .r1 b,.wm-m.u .sj{font-weight:600} .wm-m .sj{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.wm-m .pv{color:#999;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis} .wm-r{flex:1;min-width:0;padding:14px 22px;overflow:hidden} .wm-tl{display:flex;gap:8px;margin-bottom:12px}.wm-tl span{border:1px solid #d6dbe1;border-radius:3px;padding:2px 10px;font-size:12px;color:#444} .wm-r h2{font-size:19px;line-height:1.35;margin-bottom:10px} .wm-fr{display:flex;gap:10px;align-items:flex-start;padding-bottom:10px;border-bottom:1px solid #eee;font-size:12px;color:#666;line-height:1.6}.wm-fr b{color:#222;font-size:13px} .wm-bd{padding-top:12px;font-size:13.5px;line-height:1.75;color:#222}.wm-bd p+p{margin-top:8px} .wm-inv{border:1px solid #cfdcec;border-radius:6px;background:#f5f9fd;padding:10px 14px;margin:12px 0;display:flex;gap:14px;align-items:center} .wm-inv .d{width:54px;text-align:center;border-radius:5px;overflow:hidden;border:1px solid #cfdcec;background:#fff;flex:none}.wm-inv .d i{display:block;background:#d9534f;color:#fff;font-style:normal;font-size:11px}.wm-inv .d b{font-size:22px} .wm-inv .bt{margin-left:auto;display:flex;gap:6px;flex:none}.wm-inv .bt span{border:1px solid #c5ccd5;background:#fff;border-radius:3px;padding:3px 10px;font-size:12px}.wm-inv .bt span:first-child{background:#1f5fa8;color:#fff;border-color:#1f5fa8} .wm-at{display:flex;gap:10px;margin-top:12px;flex-wrap:wrap}.wm-at div{border:1px solid #e1e5ea;border-radius:4px;padding:6px 10px;font-size:12px;display:flex;gap:8px;align-items:center} """ def _mail_fill(rng, n, today_from=590, skip=()): out = [] t = today_from pool = [m for m in rng.sample(MAIL_SUBJ, len(MAIL_SUBJ)) if m[1] not in skip] for i in range(n): f, s, pv = pool[i % len(pool)] sender = person(rng) if f == "{p}" else (company(rng) if f == "{co}" else f) fmt = dict(n=rng.randint(10000, 99999), m=f"{rng.randint(30, 4999)}.{rng.randint(0, 99):02d}", city=rng.choice(CITIES)) if i < 5: t -= rng.randint(8, 70) when = f"{max(t, 0) // 60:02d}:{max(t, 0) % 60:02d}" elif i < 10: when = "昨天" else: when = rng.choice(["11月22日", "11月21日", "11月20日", "11月19日", "11月18日", "11月17日"]) out.append({"from": sender, "subject": s.format(**fmt), "preview": pv.format(**fmt), "time": when, "unread": i < 6 and rng.random() < .5, "attach": rng.random() < .25}) return out def _mail_key(t): """Newest first: today's HH:MM, then 昨天, then 11月22日 ...""" import re if re.match(r"^\d\d:\d\d$", t): return (0, -_tmin(t)) if t.startswith("昨天"): return (1, 0) m = re.match(r"(\d+)月(\d+)日", t) return (2, -(int(m.group(1)) * 32 + int(m.group(2)))) if m else (3, 0) def _invite_box(inv): return (f'
{esc(inv.get("month", "11月"))}{esc(inv.get("day", ""))}
' f'
{esc(inv.get("title", ""))}
{esc(inv.get("when", ""))}
{esc(inv.get("where", ""))}
' f'
接受暂定拒绝
') def webmail_page(rng, *, site="青岚邮箱", account="lin.xiao@qinglan.example", open_mail, mails=(), folder="收件箱", nmails=22): """Web mail: folders, 20+ mail list, the open mail on the right. open_mail: {from, from_addr, to, cc?, subject, time, body, invite?: {day, month, title, when, where}, attachments?: [(name, size)]}""" fill = _mail_fill(rng, nmails - len(mails) - 1, skip={open_mail["subject"]} | {m["subject"] for m in mails}) om = {"from": open_mail["from"], "subject": open_mail["subject"], "preview": open_mail.get("preview", str(open_mail["body"])[:40]), "time": open_mail.get("list_time", open_mail["time"][-5:]), "on": True, "attach": bool(open_mail.get("attachments"))} items = sorted(fill + list(mails) + [om], key=lambda m: _mail_key(m["time"])) rows = [] for m in items: cls = "wm-m" + (" u" if m.get("unread") else "") + (" on" if m.get("on") else "") rows.append(f'
{esc(m["from"])}{"📎 " if m.get("attach") else ""}{esc(m["time"])}
' f'
{esc(m["subject"])}
{esc(m.get("preview", ""))}
') folders = [("收件箱", str(rng.randint(12, 60))), ("红旗邮件", ""), ("待办邮件", "3"), ("已发送", ""), ("草稿箱", "2"), ("已删除", ""), ("垃圾邮件", str(rng.randint(1, 30)))] fh = "".join(f'
{n}{c}
' for n, c in folders) fh += '
我的文件夹
' + "".join(f'
📁 {n}{c}
' for n, c in [("工作", "5"), ("账单", ""), ("项目-星澜", "12"), ("订阅", "36"), ("家里", "")]) fh += '
其他
通讯录
日历
网盘
邮箱设置
' att = open_mail.get("attachments") or [] ath = ('
' + "".join(f'
📄{esc(n)}
{esc(s)}
' for n, s in att) + '
') if att else "" inv = _invite_box(open_mail["invite"]) if open_mail.get("invite") else "" cc = f'
抄 送:{esc(open_mail["cc"])}' if open_mail.get("cc") else "" html = (f'
✉ {esc(site)}
🔍 搜索邮件、联系人、附件
' f'邮箱首页通讯录日历网盘
{esc(account)}设置帮助退出
' f'
✎ 写 信
收 信
{fh}
' f'
{esc(folder)}(共 {rng.randint(800, 4000)} 封,未读 {rng.randint(10, 60)} 封)按时间 ⌄
{"".join(rows)}
' f'
↩ 回复回复全部↪ 转发删除标记为 ⌄移动到 ⌄更多 ⌄
' f'

{esc(open_mail["subject"])}

{avatar(open_mail["from"], 38)}
发件人:{esc(open_mail["from"])} <{esc(open_mail.get("from_addr", ""))}>
' f'收件人:{esc(open_mail.get("to", account))}{cc}
时 间:{esc(open_mail["time"])}
' f'{inv}
{para(open_mail["body"])}
{ath}
') return {"title": f"{site} - {open_mail['subject']}", "html": html, "css": WEBMAIL_CSS} ADMIN_CSS = """ .at{position:absolute;inset:0;display:flex;font-size:12.5px;color:#333;background:#f0f2f5} .at-sd{width:180px;flex:none;background:#1d2b3a;color:#aeb9c6;font-size:13px} .at-sd .lg{height:46px;display:flex;align-items:center;padding-left:16px;color:#fff;font-weight:700;font-size:15px;background:#17222e} .at-sd div{padding:7px 16px}.at-sd div.g{color:#fff}.at-sd div.s{padding-left:34px}.at-sd div.on{background:#2f6fde;color:#fff} .at-mn{flex:1;min-width:0;display:flex;flex-direction:column} .at-tp{height:46px;background:#fff;display:flex;align-items:center;padding:0 16px;gap:14px;border-bottom:1px solid #e6e6e6;flex:none} .at-tp .r{margin-left:auto;display:flex;gap:16px;align-items:center;color:#666} .at-tabs{display:flex;gap:4px;background:#fff;padding:4px 12px;border-bottom:1px solid #e6e6e6;font-size:12px;flex:none}.at-tabs span{border:1px solid #ddd;padding:1px 10px;border-radius:2px;color:#666}.at-tabs .on{background:#2f6fde;color:#fff;border-color:#2f6fde} .at-in{padding:10px 14px;overflow:hidden;flex:1} .at-cards{display:flex;gap:10px;margin-bottom:10px}.at-cards div{flex:1;background:#fff;padding:8px 14px;border-radius:3px;color:#888;font-size:12px}.at-cards b{display:block;font-size:20px;color:#222} .at-cards i{font-style:normal;color:#2a9d55;margin-left:6px} .at-q{background:#fff;padding:10px 14px;display:grid;grid-template-columns:repeat(4,1fr);gap:8px 18px;border-radius:3px;margin-bottom:10px} .at-q label{display:flex;align-items:center;gap:6px;white-space:nowrap}.at-q label span{border:1px solid #d9d9d9;border-radius:2px;flex:1;height:26px;display:flex;align-items:center;padding:0 8px;color:#aaa} .at-q .bt{display:flex;gap:8px;justify-content:flex-end}.at-q .bt span{padding:3px 14px;border:1px solid #d9d9d9;border-radius:2px}.at-q .bt span:first-child{background:#2f6fde;color:#fff;border-color:#2f6fde} .at-tb{background:#fff;border-radius:3px;padding:8px 14px} .at-tb .ops{display:flex;gap:8px;margin-bottom:8px;align-items:center}.at-tb .ops span{border:1px solid #d9d9d9;padding:2px 12px;border-radius:2px}.at-tb .ops .p{background:#2f6fde;color:#fff;border-color:#2f6fde} .at table{width:100%;border-collapse:collapse;table-layout:fixed} .at th{background:#fafafa;text-align:left;font-weight:600;padding:6px 8px;border-bottom:1px solid #e8e8e8;white-space:nowrap} .at td{padding:5px 8px;border-bottom:1px solid #f0f0f0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis} .at tr.k td{background:#fffbe6} .at .st{padding:0 6px;border-radius:2px;font-size:11.5px} .at .lk{color:#2f6fde} .at-pg{display:flex;gap:6px;justify-content:flex-end;align-items:center;margin-top:8px;color:#666}.at-pg span{border:1px solid #d9d9d9;padding:0 8px;border-radius:2px;line-height:22px}.at-pg .on{border-color:#2f6fde;color:#2f6fde} """ STATUS_COL = {"待发货": "#fff3e0;color:#d97706", "已发货": "#e6f0ff;color:#2f6fde", "已完成": "#e8f7ee;color:#2a9d55", "已取消": "#f2f2f2;color:#888", "退款中": "#fdecec;color:#d9363e", "待付款": "#fff8db;color:#b8860b"} ADMIN_COLS = ["订单号", "客户", "手机号", "城市", "商品", "数量", "金额(元)", "状态", "下单时间", "负责人"] def _order_row(rng, i): p = _product(rng) d = rng.choice(["11-24", "11-24", "11-23", "11-23", "11-22", "11-21"]) return [f"DD2026{d.replace('-', '')}{rng.randint(10000, 99999)}", person(rng), f"138****{rng.randint(1000, 9999)}", rng.choice(CITIES), p["name"][:14], str(rng.randint(1, 5)), f"{float(p['price']) * rng.randint(1, 3):,.2f}", rng.choice(list(STATUS_COL)), f"2026-{d} {clock(rng, 0, 1439) if d != '11-24' else clock(rng, 0, 595)}", rng.choice(["王敏", "陈思远", "刘洋", "周婷"])] def admin_table_page(rng, *, site="禾木优选 · 运营后台", title="订单列表", columns=None, rows=(), fill=None, nrows=28, total=None, menu=None, highlight=True, stats=None): """Admin back office: dark side menu, filter form, stat cards, a 28-row table, pagination. columns default ADMIN_COLS (orders); rows: lists matching columns (marked rows get a light highlight); fill(rng, i) -> row.""" cols = columns or ADMIN_COLS fill = fill or (_order_row if columns is None else None) filler = [fill(rng, i) for i in range(nrows - len(rows))] if fill else [] allrows = mix(rng, [(r, False) for r in filler], [(list(r), True) for r in rows]) if columns is None: allrows.sort(key=lambda t: t[0][8], reverse=True) trs = [] for r, key in allrows: tds = [] for c, v in zip(cols, r): if c == "状态" and v in STATUS_COL: tds.append(f'{esc(v)}') elif c in ("订单号", "编号"): tds.append(f'{esc(v)}') else: tds.append(f"{esc(v)}") trs.append(f'{"".join(tds)}查看 编辑') widths = {"订单号": 150, "客户": 64, "手机号": 98, "城市": 50, "数量": 42, "金额(元)": 80, "状态": 64, "下单时间": 126, "负责人": 58} th = "".join(f'{esc(c)}' for c in cols) menu = menu or [("首页", "g"), ("数据看板", "s"), ("订单管理", "g"), ("订单列表", "s on"), ("售后退款", "s"), ("发货管理", "s"), ("评价管理", "s"), ("商品管理", "g"), ("商品列表", "s"), ("库存预警", "s"), ("营销中心", "g"), ("优惠券", "s"), ("满减活动", "s"), ("客户管理", "g"), ("会员列表", "s"), ("财务结算", "g"), ("对账单", "s"), ("系统设置", "g"), ("账号权限", "s"), ("操作日志", "s")] st = stats or [("今日订单", f"{rng.randint(300, 1500):,}", f"↑{rng.randint(2, 30)}%"), ("今日成交额", f"¥{rng.randint(80000, 400000):,}", f"↑{rng.randint(2, 30)}%"), ("待发货", str(rng.randint(40, 300)), ""), ("退款中", str(rng.randint(3, 40)), ""), ("本月客单价", f"¥{rng.randint(120, 400)}.{rng.randint(0, 99):02d}", "")] tot = total or f"{rng.randint(1200, 9000):,}" html = (f'
{esc(site)}
' + "".join(f'
{esc(n)}
' for n, c in menu) + f'
☰订单管理 / {esc(title)}' f'
🔍🔔 5帮助文档{avatar("王敏", 24)}王敏(运营)
' f'
首页数据看板{esc(title)} ✕商品列表 ✕优惠券 ✕
' '
' + "".join(f'
{a}{b}{c}
' for a, b, c in st) + '
' '
' '' '
查询重置展开 ⌄
' '
+ 新建订单批量发货导出 Excel打印' '已选 0 项
' '' + "".join(f'' if c in widths else "" for c in cols) + '' f'{th}{"".join(trs)}
操作
' f'
共 {tot} 条 20条/页 ⌄‹12345…{rng.randint(60, 400)}› 跳至    页
' f'
') return {"title": f"{title} - {site}", "html": html, "css": ADMIN_CSS} DOCS_CSS = """ .dc{font-size:13.5px;color:#262626;background:#fff;min-height:100%} .dc-hd{height:52px;border-bottom:1px solid #eaeaea;display:flex;align-items:center;padding:0 24px;gap:26px;white-space:nowrap;overflow:hidden} .dc-hd .lg{font-size:17px;font-weight:700;color:#0d7a63}.dc-hd span{color:#555}.dc-hd .on{color:#0d7a63;font-weight:600} .dc-hd .sb{margin-left:auto;width:280px;height:30px;border:1px solid #ddd;border-radius:6px;display:flex;align-items:center;padding:0 10px;color:#aaa;font-size:12px;justify-content:space-between} .dc-b{display:flex} .dc-toc{width:230px;flex:none;border-right:1px solid #eee;padding:12px 0;font-size:13px;color:#444} .dc-toc h6{font-size:12px;color:#999;font-weight:500;padding:8px 20px 3px}.dc-toc div{padding:4px 20px 4px 28px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis} .dc-toc div.on{color:#0d7a63;background:#e9f6f2;border-right:2px solid #0d7a63;font-weight:600} .dc-a{flex:1;min-width:0;padding:16px 36px} .dc-crumb{font-size:12px;color:#888} .dc-a h1{font-size:26px;margin:8px 0 4px}.dc-meta{font-size:12px;color:#999;margin-bottom:12px;display:flex;gap:14px} .dc-a h2{font-size:18px;margin:18px 0 6px;padding-top:6px;border-top:1px solid #f0f0f0} .dc-a p{line-height:1.8;margin:6px 0} .dc-tip{background:#eef7ff;border-left:3px solid #3a86d6;padding:8px 12px;margin:10px 0;font-size:13px;line-height:1.7} .dc-a table{border-collapse:collapse;margin:8px 0;font-size:13px;width:100%}.dc-a td,.dc-a th{border:1px solid #e5e5e5;padding:5px 10px;text-align:left}.dc-a th{background:#fafafa} .dc-a ol{padding-left:22px;line-height:1.8} .dc-a code{font-family:Menlo,monospace;background:#f4f4f4;padding:1px 4px;border-radius:3px;font-size:12px} .dc-on{width:190px;flex:none;padding:16px 16px;font-size:12px;color:#666;line-height:2}.dc-on b{color:#333;display:block}.dc-on .on{color:#0d7a63} """ def docs_page(rng, *, site="云栖笔记 帮助中心", title, sections=(), toc=None, updated="2026-11-18", table=None, tip=None): """Docs / help centre: left TOC tree, long article (key `sections`: [(heading, text)]), right "on this page".""" secs = list(sections) filler_heads = ["开启与关闭", "同步规则", "冲突处理", "存储空间", "常见问题", "相关文档"] k = 0 while len(secs) < 5: h = filler_heads[k % len(filler_heads)] k += 1 if h not in [s[0] for s in secs]: secs.append((h, "\n\n".join(pick(rng, DOC_PARA, 2)))) tree = toc or [("快速入门", ["产品简介", "下载与安装", "注册与登录", "界面介绍"]), ("笔记与文档", ["新建笔记", "富文本编辑", "表格与附件", "模板中心", "导出与打印"]), ("同步与备份", [title, "多设备登录", "历史版本", "回收站"]), ("团队协作", ["邀请成员", "权限说明", "评论与提及"]), ("账号与付费", ["套餐对比", "发票申请", "注销账号"])] th = "" for g, items in tree: th += f"
{esc(g)}
" + "".join(f'
{esc(it)}
' for it in items) body = "" for i, (h, t) in enumerate(secs): body += f"

{esc(h)}

{para(t)}" if i == 0: body += f'
💡 {esc(tip or "提示:同步只在登录状态下进行。退出登录不会删除本机数据,再次登录后会自动继续同步。")}
' if i == 1: tb = table or [("套餐", "存储空间", "单文件上限", "历史版本"), ("免费版", "5 GB", "200 MB", "7 天"), ("专业版", "1 TB", "10 GB", "180 天"), ("团队版", "每人 2 TB", "20 GB", "永久")] body += "" + "".join("" + "".join(f"<{'th' if j == 0 else 'td'}>{esc(c)}" for c in row) + "" for j, row in enumerate(tb)) + "
" if i == 2: body += '
  1. 打开「设置 - 同步」,查看最近一次同步时间。
  2. 点击「立即同步」,等待进度条走完。
  3. 如仍失败,点击「导出日志」,把 sync.log 发给客服。
' html = (f'
{esc(site)}产品文档常见问题视频教程' f'更新日志开发者 API社区
搜索文档 ⌘K
联系客服
' f'
{th}
文档中心 › 同步与备份 › {esc(title)}
' f'

{esc(title)}

更新于 {esc(updated)}阅读约 {rng.randint(4, 9)} 分钟👍 {rng.randint(40, 900)} 人觉得有用
' f'{body}
本页目录' + "".join(f'
{esc(h)}
' for i, (h, _) in enumerate(secs)) + '
这篇文档有帮助吗?
👍 有用   👎 没用
') return {"title": f"{title} - {site}", "html": html, "css": DOCS_CSS} ACCOUNT_CSS = """ .ac{font-size:13px;color:#333;background:#f3f4f6;min-height:100%} .ac-hd{height:52px;background:#fff;display:flex;align-items:center;padding:0 28px;gap:26px;border-bottom:1px solid #e5e7eb} .ac-hd .lg{font-size:19px;font-weight:800;color:#6b4bd8}.ac-hd span{color:#555}.ac-hd .r{margin-left:auto;display:flex;gap:16px;align-items:center} .ac-b{display:flex;gap:14px;padding:12px 28px} .ac-nav{width:176px;flex:none;background:#fff;border-radius:6px;padding:8px 0;align-self:flex-start} .ac-nav h6{font-size:12px;color:#999;font-weight:500;padding:8px 18px 2px}.ac-nav div{padding:6px 18px 6px 26px}.ac-nav div.on{background:#f1edfd;color:#6b4bd8;font-weight:600;border-left:3px solid #6b4bd8;padding-left:23px} .ac-m{flex:1;min-width:0} .ac-card{background:#fff;border-radius:6px;padding:12px 16px;margin-bottom:12px} .ac-card h3{font-size:15px;margin-bottom:8px;display:flex;justify-content:space-between;align-items:baseline}.ac-card h3 span{font-size:12px;color:#6b4bd8;font-weight:400} .ac-pf{display:flex;gap:16px;align-items:center} .ac-pf .nm{font-size:18px;font-weight:700}.ac-pf .vip{background:linear-gradient(90deg,#c69b4c,#e9c98a);color:#fff;font-size:11px;padding:1px 8px;border-radius:9px;margin-left:6px;font-weight:400} .ac-pf .sub{color:#888;font-size:12px;margin-top:3px} .ac-num{margin-left:auto;display:flex;gap:22px;text-align:center;white-space:nowrap;flex:none}.ac-num b{display:block;font-size:19px}.ac-num span{color:#888;font-size:12px} .ac-grid{display:grid;grid-template-columns:1fr 1fr;gap:0 30px} .ac-kv{display:flex;padding:6px 0;border-bottom:1px solid #f3f3f3}.ac-kv b{width:84px;color:#888;font-weight:400;flex:none}.ac-kv span{flex:1}.ac-kv i{font-style:normal;color:#6b4bd8;font-size:12px} .ac-sec{display:flex;align-items:center;padding:7px 0;border-bottom:1px solid #f3f3f3;gap:12px}.ac-sec .ic{width:28px;height:28px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:14px;flex:none} .ac-sec .t{width:110px;flex:none}.ac-sec .d{flex:1;color:#888;font-size:12px}.ac-sec .s{width:70px;font-size:12px}.ac-sec .a{color:#6b4bd8;font-size:12px;width:40px;text-align:right} .ac table{width:100%;border-collapse:collapse;font-size:12.5px}.ac th{color:#888;font-weight:400;text-align:left;padding:4px 6px;background:#fafafa}.ac td{padding:5px 6px;border-bottom:1px solid #f3f3f3;white-space:nowrap} .ac-r{width:250px;flex:none} .ac-addr{border:1px solid #eee;border-radius:5px;padding:8px 10px;margin-bottom:6px;font-size:12.5px;line-height:1.6}.ac-addr em{font-style:normal;background:#6b4bd8;color:#fff;font-size:10px;padding:0 4px;border-radius:2px;margin-left:4px} .ac-li{display:flex;justify-content:space-between;gap:8px;padding:4px 0;font-size:12.5px;border-bottom:1px dashed #eee;white-space:nowrap}.ac-li span:first-child{overflow:hidden;text-overflow:ellipsis;min-width:0}.ac-li span:last-child{color:#888;flex:none} """ def account_page(rng, *, site="回声音乐", nickname="林间小鹿", uid="80231675", level="SVIP 年卡", expire="2027-03-15", fields=None, security=None, devices=None, addresses=None, orders=None, points=None, balance=None, coupons=None, active="个人资料"): """Account centre (个人中心): profile card, basic info grid, security list, login devices, addresses, orders, side boxes.""" f = {"昵称": nickname, "用户 ID": uid, "性别": "女", "生日": "1996-08-19", "所在地": "上海 徐汇区", "职业": "产品经理", "个性签名": "慢慢来,比较快", "绑定邮箱": "lin***@qinglan.example", "绑定手机": "138****0071", "注册时间": "2019-05-02", "实名认证": "已认证(*晓)", "会员到期": expire} f.update(fields or {}) sec = security or [("🔑", "登录密码", "建议定期更换,最近修改于 2026-06-11", "已设置", "修改"), ("📱", "手机绑定", f"已绑定 {f['绑定手机']},可用于登录和找回密码", "已绑定", "更换"), ("✉️", "邮箱绑定", f"已绑定 {f['绑定邮箱']}", "已绑定", "更换"), ("🛡", "两步验证", "登录新设备时需要短信验证码", "未开启", "开启"), ("🪪", "实名认证", f["实名认证"], "已认证", "查看"), ("🔗", "第三方账号", "已关联 2 个:青岚账号、知了", "", "管理"), ("💳", "支付密码", "用于余额支付和提现", "已设置", "修改")] dev = devices or [("笔记本电脑(本机)", "上海", "2026-11-24 09:58", "当前在线"), ("手机 · 星澜 X5", "上海", "2026-11-24 08:12", "在线"), ("客厅电视", "上海", "2026-11-22 21:40", "离线"), ("平板电脑", "杭州", "2026-11-09 14:03", "离线"), ("办公室台式机", "苏州", "2026-10-30 10:21", "离线")] addr = addresses or [("林晓", "138****0071", "上海市 徐汇区 漕河泾街道 宜山路 *** 弄 * 号 *** 室", True), ("林晓", "138****0071", "上海市 浦东新区 张江镇 祖冲之路 *** 号 A座 12层", False)] od = orders or [("SVIP 年卡(自动续费)", "2026-03-15", "¥238.00"), ("数字专辑《第七个冬天》", "2026-10-02", "¥15.00"), ("演唱会门票 · 上海站", "2026-09-18", "¥680.00"), ("SVIP 月卡", "2026-02-15", "¥25.00"), ("耳机 · 积分兑换", "2026-01-20", "3,000 积分")] sh = "".join(f'
{e}{esc(t)}{esc(d)}' f'{esc(s)}{esc(a)}
' for e, t, d, s, a in sec) dh = "".join(f"{esc(a)}{esc(b)}{esc(c)}{esc(d)}{'—' if '本机' in a else '移除'}" for a, b, c, d in dev) ah = "".join(f'
{esc(n)} {esc(p)}{"默认" if d else ""}
{esc(a)}
' for n, p, a, d in addr) oh = "".join(f'
{esc(a)}{esc(c)}
{esc(b)}
' for a, b, c in od) kv = "".join(f'
{esc(k)}{esc(v)}{"修改" if k in ("昵称", "所在地", "个性签名", "职业", "生日") else ""}
' for k, v in f.items()) nav = [("我的账号", ["个人资料", "账号安全", "登录设备", "收货地址", "实名认证"]), ("会员与订单", ["我的会员", "订单记录", "自动续费管理", "发票管理", "优惠券"]), ("偏好设置", ["消息通知", "隐私设置", "播放设置", "黑名单"]), ("其他", ["我的积分", "意见反馈", "注销账号"])] navh = "".join(f"
{g}
" + "".join(f'
{i}
' for i in items) for g, items in nav) pts = points or f"{rng.randint(1000, 30000):,}" bal = balance or f"¥{rng.randint(0, 200)}.{rng.randint(0, 99):02d}" cps = coupons or str(rng.randint(1, 9)) html = (f'
♪ {esc(site)}发现音乐排行榜歌单电台演出商城' f'
🔍 搜索歌曲、歌手消息 3{avatar(nickname, 28)}{esc(nickname)}
' f'
{navh}
' f'
{avatar(nickname, 62)}
{esc(nickname)}{esc(level)}' f'
ID:{esc(uid)} · 会员有效期至 {esc(expire)} · Lv.{rng.randint(5, 10)} 听歌 {rng.randint(3000, 30000):,} 首
' f'
关注 {rng.randint(20, 300)} · 粉丝 {rng.randint(5, 800)} · 动态 {rng.randint(1, 90)}
' f'
{esc(pts)}积分
{esc(bal)}余额
{esc(cps)}优惠券
' f'
{rng.randint(1, 20)}待评价
' f'

基本信息编辑资料

{kv}
' f'

账号安全安全等级:中

{sh}
' f'

登录设备全部移除

{dh}
设备登录地最近活跃状态操作
' f'

收货地址+ 新增

{ah}
' f'

最近订单全部 ›

{oh}
' '

会员权益

' + "".join(f'
{a}{b}
' for a, b in [("无损音质", "已开通"), ("免广告", "已开通"), ("下载额度", "300首/月"), ("演出优先购", "SVIP 专享"), ("每月赠券", "2 张")]) + '
' '
年末续费季
SVIP 年卡续费立减 40 元,12 月 31 日截止
推广
' '
') return {"title": f"个人中心 - {site}", "html": html, "css": ACCOUNT_CSS} # ---------------------------------------------------------------- desktop apps MAILAPP_CSS = """ .ma{position:absolute;inset:0;display:flex;flex-direction:column;font-size:13px} .ma-tb{height:52px;display:flex;align-items:center;padding:0 14px 0 90px;gap:18px;color:#555;font-size:16px;flex:none} .ma-tb .t{font-size:13px;color:#333;font-weight:600;margin-right:auto}.ma-tb .t span{display:block;font-weight:400;color:#888;font-size:11px} .ma-tb .s{width:200px;height:26px;border-radius:6px;background:#fff;border:1px solid #d6d6da;font-size:12px;color:#999;display:flex;align-items:center;padding-left:8px} .ma-b{flex:1;display:flex;min-height:0} .ma-sd{width:190px;flex:none;background:#eeeef1;border-right:1px solid #ddd;padding:8px;font-size:13px} .ma-sd h6{font-size:11px;color:#999;font-weight:600;padding:8px 8px 2px}.ma-sd div{display:flex;justify-content:space-between;padding:3px 8px;border-radius:5px}.ma-sd div.on{background:#d4d4da}.ma-sd em{font-style:normal;color:#888;font-size:12px} .ma-l{width:330px;flex:none;border-right:1px solid #e0e0e0;overflow:hidden} .ma-m{padding:7px 12px 7px 22px;border-bottom:1px solid #ececec;position:relative} .ma-m.u:before{content:"";position:absolute;left:8px;top:12px;width:7px;height:7px;border-radius:50%;background:#2f7cf6} .ma-m.on{background:#2f7cf6;color:#fff}.ma-m.on .pv,.ma-m.on .r1 span{color:#e3eeff} .ma-m .r1{display:flex;justify-content:space-between}.ma-m .r1 b{font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ma-m .r1 span{color:#888;font-size:12px;flex:none;margin-left:6px} .ma-m .sj{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:12.5px}.ma-m .pv{color:#888;font-size:12px;line-height:1.4;height:34px;overflow:hidden} .ma-r{flex:1;min-width:0;padding:16px 22px;overflow:hidden} .ma-r h2{font-size:18px;margin-bottom:8px}.ma-fr{display:flex;gap:10px;font-size:12px;color:#777;padding-bottom:10px;border-bottom:1px solid #eee}.ma-fr b{color:#222;font-size:13px} .ma-bd{padding-top:10px;line-height:1.75;font-size:13.5px}.ma-bd p+p{margin-top:8px} """ def mail_app(rng, *, open_mail, mails=(), account="林晓", nmails=16): """Desktop mail client (three panes). open_mail like webmail_page; mails: extra list items {from, subject, preview, time, unread?}.""" fill = _mail_fill(rng, nmails - len(mails) - 1, skip={open_mail["subject"]} | {m["subject"] for m in mails}) items = fill + list(mails) items.append({"from": open_mail["from"], "subject": open_mail["subject"], "preview": open_mail.get("preview", str(open_mail["body"])[:50]), "time": open_mail.get("list_time", open_mail["time"][-5:]), "on": True}) items.sort(key=lambda m: _mail_key(m["time"])) rows = "".join(f'
{esc(m["from"])}{esc(m["time"])}
' f'
{esc(m["subject"])}
{esc(m.get("preview", ""))}
' for m in items) unread = rng.randint(5, 40) sd = (f'
个人收藏
📥 收件箱{unread}
📤 已发送
📝 草稿2
🚩 旗标4
' f'
工作邮箱
📥 收件箱{rng.randint(1, 20)}
🗄 归档
🗑 废纸篓
⚠️ 垃圾邮件{rng.randint(1, 9)}
' f'
个人邮箱
📥 收件箱{rng.randint(1, 20)}
📁 账单
📁 旅行
📁 孩子学校
📁 订阅18
') inv = _invite_box(open_mail["invite"]).replace("wm-inv", "wm-inv") if open_mail.get("invite") else "" html = (f'
收件箱{rng.randint(300, 3000)} 封邮件,{unread} 封未读
' f'✉✎🗄🗑↩↩↩↪🚩
🔍 搜索
' f'
{sd}
{rows}

{esc(open_mail["subject"])}

' f'
{avatar(open_mail["from"], 36)}
{esc(open_mail["from"])} <{esc(open_mail.get("from_addr", ""))}>
' f'收件人:{esc(open_mail.get("to", account))}
{esc(open_mail["time"])}
{inv}
{para(open_mail["body"])}
') return {"app": "邮件", "title": "收件箱", "html": html, "css": MAILAPP_CSS + WEBMAIL_CSS, "lights_top": 20} CHAT_CSS = """ .ch{position:absolute;inset:0;display:flex;font-size:13px;background:#fff} .ch-rail{width:62px;flex:none;background:#e9eaed;display:flex;flex-direction:column;align-items:center;padding-top:42px;gap:18px;font-size:20px;color:#777} .ch-rail .on{color:#2fa865} .ch-ls{width:250px;flex:none;background:#f5f5f6;border-right:1px solid #e1e1e3;display:flex;flex-direction:column} .ch-sr{display:flex;gap:6px;padding:12px 10px 8px;flex:none}.ch-sr div{flex:1;height:26px;border-radius:5px;background:#e4e4e7;font-size:12px;color:#999;display:flex;align-items:center;padding-left:8px}.ch-sr span{width:26px;height:26px;border-radius:5px;background:#e4e4e7;display:flex;align-items:center;justify-content:center;color:#666} .ch-it{display:flex;gap:9px;padding:8px 10px;align-items:center;position:relative}.ch-it.on{background:#dcdcdf}.ch-it.pin{background:#ececee} .ch-it .c{flex:1;min-width:0}.ch-it .r1{display:flex;justify-content:space-between}.ch-it .r1 b{font-weight:500;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis} .ch-it .r1 span{font-size:11px;color:#aaa;flex:none;margin-left:4px}.ch-it .lm{font-size:12px;color:#999;white-space:nowrap;overflow:hidden;text-overflow:ellipsis} .ch-it em{position:absolute;left:38px;top:4px;background:#f43f3b;color:#fff;font-style:normal;font-size:10px;border-radius:8px;padding:0 4px;line-height:15px;min-width:15px;text-align:center} .ch-it em.m{background:#bbb} .ch-mn{flex:1;min-width:0;display:flex;flex-direction:column;background:#f3f3f4} .ch-hd{height:52px;border-bottom:1px solid #e1e1e3;display:flex;align-items:center;padding:0 18px;font-size:15px;font-weight:500;flex:none;justify-content:space-between} .ch-hd span{color:#888;font-size:17px;letter-spacing:6px} .ch-ms{flex:1;padding:6px 20px;overflow:hidden;display:flex;flex-direction:column;justify-content:flex-end} .ch-ts{text-align:center;color:#aaa;font-size:11.5px;margin:8px 0 4px} .ch-r{display:flex;gap:9px;margin:7px 0;align-items:flex-start}.ch-r.me{flex-direction:row-reverse} .ch-r .nm{font-size:11.5px;color:#999;margin-bottom:2px} .ch-bb{background:#fff;border-radius:6px;padding:7px 11px;font-size:13.5px;line-height:1.55;max-width:460px;word-break:break-all} .ch-r.me .ch-bb{background:#a5e88c} .ch-file{background:#fff;border-radius:6px;padding:10px 12px;width:240px;display:flex;justify-content:space-between;gap:8px}.ch-file b{font-weight:500;font-size:13px}.ch-file span{font-size:11px;color:#999;display:block} .ch-in{height:128px;border-top:1px solid #e1e1e3;flex:none;padding:8px 18px;background:#f3f3f4}.ch-in .ic{color:#777;font-size:17px;letter-spacing:12px} .ch-in .sd{float:right;margin-top:52px;background:#e9e9eb;color:#2fa865;padding:3px 18px;border-radius:4px;font-size:13px} """ def chat_app(rng, *, chat_name, messages=(), me="林晓", chats=(), members=None, app="知了", nchats=17, group=True): """Chat client: rail, 15+ conversations, open chat. messages: (who, text) / (who, text, time) / ("time", "10:02"); who == me puts it on the right; text "[文件] name|size" draws a file card. chats: (name, last_msg, time, unread) put first.""" fill_names = [n for n in CHAT_NAMES if n != chat_name] rng.shuffle(fill_names) people = [person(rng) for _ in range(12)] conv = list(chats) times = ["09:58", "09:41", "09:30", "09:12", "08:47", "08:05", "昨天", "昨天", "昨天", "星期日", "星期日", "星期六", "11/21", "11/20", "11/19", "11/18", "11/17", "11/15"] pool = fill_names + people k = 0 while len(conv) < nchats: name = pool[k] k += 1 who = rng.choice(people) msg = rng.choice(CHAT_MSG) conv.append((name, (f"{who}:" if name in CHAT_NAMES else "") + msg, None, rng.choice([0, 0, 0, 1, 2, 5, 12, 99]) if rng.random() < .5 else 0)) conv.insert(rng.randint(1, 3), (chat_name, "", None, 0, True)) li = [] ti = 0 for i, c in enumerate(conv): name, lm, tm, unread = c[:4] on = len(c) > 4 if on and messages: last = [m for m in messages if m[0] != "time"][-1] lm = (f"{last[0]}:" if group and last[0] != me else "") + last[1] tm = next((m[1] for m in reversed(messages) if m[0] == "time"), "10:00") tm = tm or times[min(ti, len(times) - 1)] ti += 1 badge = f'{unread if unread < 99 else "99+"}' if unread else "" li.append(f'
{avatar(name, 36, "5px")}{badge}
' f'
{esc(name)}{esc(tm)}
{esc(lm)}
') ms = [] for m in messages: if m[0] == "time": ms.append(f'
{esc(m[1])}
') continue who, text = m[0], m[1] if text.startswith("[文件] ") and "|" in text: fn, sz = text[5:].split("|", 1) bub = f'
{esc(fn)}{esc(sz)}
📄
' else: bub = f'
{esc(text)}
' nm = f'
{esc(who)}
' if group and who != me else "" ms.append(f'
{avatar(who, 34, "5px")}
{nm}{bub}
') title = f"{chat_name}({members})" if members else chat_name html = (f'
{avatar(me, 34, "5px")}💬👤⭐📁🗓' f'≡
' f'
🔍 搜索
+
{"".join(li)}
' f'
{esc(title)}📞📹⋯
{"".join(ms)}
' f'
☺ 📁 ✂ 🎤 📞
发送(S)
') return {"app": app, "title": chat_name, "html": html, "css": CHAT_CSS, "lights_top": 13} CAL_CSS = """ .ca{position:absolute;inset:0;display:flex;flex-direction:column;font-size:12px;background:#fff} .ca-tb{height:50px;display:flex;align-items:center;padding:0 14px 0 92px;gap:14px;flex:none} .ca-tb .seg{display:flex;border:1px solid #ccc;border-radius:6px;overflow:hidden;margin:0 auto}.ca-tb .seg span{padding:2px 14px;font-size:12px;border-left:1px solid #ccc}.ca-tb .seg span:first-child{border:none}.ca-tb .seg .on{background:#d6d6da} .ca-tb .s{width:170px;height:24px;border-radius:6px;background:#fff;border:1px solid #d0d0d4;color:#999;display:flex;align-items:center;padding-left:8px} .ca-b{flex:1;display:flex;min-height:0} .ca-sd{width:200px;flex:none;background:#f1f1f3;border-right:1px solid #ddd;padding:10px 12px} .ca-mini{font-size:11px;text-align:center}.ca-mini b{display:block;text-align:left;font-size:13px;margin-bottom:4px} .ca-mini .g{display:grid;grid-template-columns:repeat(7,1fr);row-gap:2px}.ca-mini .g span{line-height:20px}.ca-mini .g .o{color:#bbb}.ca-mini .g .t{background:#e5484d;color:#fff;border-radius:50%} .ca-mini .g .w{color:#999} .ca-cals{margin-top:14px;font-size:12.5px;line-height:24px}.ca-cals h6{font-size:11px;color:#999;font-weight:600}.ca-cals i{display:inline-block;width:11px;height:11px;border-radius:3px;margin-right:6px;vertical-align:-1px} .ca-mn{flex:1;min-width:0;display:flex;flex-direction:column} .ca-hd{display:flex;align-items:baseline;padding:6px 14px;flex:none}.ca-hd h2{font-size:22px}.ca-hd h2 span{font-weight:400}.ca-hd .r{margin-left:auto;display:flex;gap:6px}.ca-hd .r span{border:1px solid #ddd;border-radius:5px;padding:0 8px} .ca-days{display:flex;padding-left:50px;border-bottom:1px solid #ddd;flex:none}.ca-days div{flex:1;text-align:center;padding:4px 0;font-size:13px;color:#555}.ca-days b{font-size:17px;font-weight:400;margin-left:3px} .ca-days .t b{background:#e5484d;color:#fff;border-radius:50%;display:inline-block;width:26px;height:26px;line-height:26px} .ca-all{display:flex;padding-left:50px;border-bottom:1px solid #ddd;min-height:22px;position:relative;flex:none}.ca-all:before{content:"全天";position:absolute;left:12px;top:3px;color:#999;font-size:11px} .ca-all div{flex:1;padding:2px;border-left:1px solid #eee}.ca-all span{display:block;font-size:11px;border-radius:3px;padding:0 4px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis} .ca-grid{flex:1;position:relative;overflow:hidden} .ca-hr{position:absolute;left:0;right:0;border-top:1px solid #eee;font-size:10.5px;color:#999}.ca-hr span{position:absolute;left:8px;top:-8px;background:#fff;padding:0 2px} .ca-col{position:absolute;top:0;bottom:0;border-left:1px solid #eee}.ca-col.t{background:#fbfbfd} .ca-ev{position:absolute;border-radius:4px;padding:2px 5px;font-size:11.5px;line-height:1.3;overflow:hidden;border-left:3px solid} .ca-ev b{font-weight:600;display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ca-ev.sm{padding:0 4px;white-space:nowrap}.ca-ev.sm b{display:inline}.ca-ev span{opacity:.85;font-size:11px} .ca-now{position:absolute;height:2px;background:#e5484d}.ca-now:before{content:"";position:absolute;left:-5px;top:-4px;width:10px;height:10px;border-radius:50%;background:#e5484d} """ CAL_COLORS = {"工作": ("#dbe9ff", "#2f6fde", "#1b4ea8"), "个人": ("#ffe3d6", "#f0773d", "#a84617"), "家庭": ("#dcf5e3", "#2fa865", "#1d7346"), "学习": ("#efe2ff", "#8b5bd9", "#5b34a1"), "节假日": ("#fde2e2", "#e5484d", "#a6262b")} def _tmin(s): h, m = s.split(":") return int(h) * 60 + int(m) def calendar_app(rng, *, events=(), week_start="2026-11-23", today=1, now="10:00", hours=(8, 21), nfill=26, all_day=()): """Week view (Mon–Sun). events: dicts {day: 0-6, start: "09:30", end: "10:30", title, place?, cal?: 工作/个人/家庭/学习}. all_day: (day, title, cal).""" import datetime d0 = datetime.date.fromisoformat(week_start) h0, h1 = hours busy = {d: [] for d in range(7)} evs = [] for e in events: evs.append(dict(e, key=True)) busy[e["day"]].append((_tmin(e["start"]), _tmin(e["end"]))) tries = 0 while len(evs) < len(events) + nfill and tries < 500: tries += 1 d = rng.choice([0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 5, 6]) st = rng.randint(h0 * 2, (h1 - 2) * 2) * 30 du = rng.choice([30, 60, 60, 90, 120]) if any(st < b and st + du > a for a, b in busy[d]): continue busy[d].append((st, st + du)) title = rng.choice(CAL_EV) cal = "工作" if d < 5 and rng.random() < .75 else rng.choice(["个人", "家庭", "学习"]) evs.append({"day": d, "start": f"{st // 60:02d}:{st % 60:02d}", "end": f"{(st + du) // 60:02d}:{(st + du) % 60:02d}", "title": title, "place": rng.choice(CAL_PLACES) if rng.random() < .6 else "", "cal": cal}) return {"app": "日历", "title": "日历", "html": None, "css": CAL_CSS, "lights_top": 19, "_cal": (d0, today, now, hours, evs, list(all_day))} def _cal_html(c, w, h): d0, today, now, (h0, h1), evs, all_day = c import datetime days = [d0 + datetime.timedelta(i) for i in range(7)] grid_h = h - 50 - 44 - 30 - 23 hh = grid_h / (h1 - h0) col_w = (w - 200 - 50) / 7 dh = "".join(f'
周{WEEK[i]}{d.day}
' for i, d in enumerate(days)) ad = ["" for _ in range(7)] for d, t, cal in all_day: bg, bd, fg = CAL_COLORS.get(cal, CAL_COLORS["个人"]) ad[d] += f'{esc(t)}' adh = "".join(f"
{x}
" for x in ad) g = "".join(f'
{hr}:00
' for hr in range(h0 + 1, h1)) g += "".join(f'
' for i in range(7)) for e in evs: bg, bd, fg = CAL_COLORS.get(e.get("cal", "工作"), CAL_COLORS["工作"]) top = (_tmin(e["start"]) - h0 * 60) / 60 * hh ht = max(16, (_tmin(e["end"]) - _tmin(e["start"])) / 60 * hh - 2) pl = f'{esc(e["place"])}' if e.get("place") and ht > 34 else "" tm = f'{esc(e["start"])} ' if ht > 40 else "" g += (f'
{tm}{esc(e["title"])}{pl}
') nt = (_tmin(now) - h0 * 60) / 60 * hh g += f'
' # mini month (November 2026 starts on Sunday) first = days[0].replace(day=1) off = first.weekday() cells = [] prev = first - datetime.timedelta(off) for i in range(42): dd = prev + datetime.timedelta(i) cls = "o" if dd.month != first.month else ("t" if dd == days[today] else "") cells.append(f'{dd.day}') mini = (f'
{first.year}年{first.month}月
' + "".join(f'{x}' for x in WEEK) + "".join(cells) + '
') cals = ('
我的日历
' + "".join(f'
{k}
' for k in ["工作", "个人", "家庭", "学习"]) + '
其他
中国节假日
生日
') return (f'
▤ +
日周月年
' f'
🔍 搜索
{mini}{cals}
' f'

{days[0].year}年{days[0].month}月

‹今天›
' f'
{dh}
{adh}
{g}
') NOTES_CSS = """ .nt{position:absolute;inset:0;display:flex;font-size:13px;background:#fff} .nt-sd{width:180px;flex:none;background:#efeff1;border-right:1px solid #ddd;padding:40px 8px 8px} .nt-sd h6{font-size:11px;color:#999;padding:6px 8px 2px;font-weight:600}.nt-sd div{display:flex;justify-content:space-between;padding:3px 8px;border-radius:5px}.nt-sd div.on{background:#f8d978}.nt-sd em{font-style:normal;color:#999} .nt-ls{width:250px;flex:none;border-right:1px solid #e5e5e5;display:flex;flex-direction:column} .nt-ls .hd{height:40px;display:flex;align-items:center;padding:0 12px;color:#888;font-size:12px;justify-content:space-between} .nt-it{padding:7px 12px;border-bottom:1px solid #eee;margin:0 6px}.nt-it.on{background:#f8d978;border-radius:6px;border-color:transparent} .nt-it b{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:13px}.nt-it span{font-size:12px;color:#888;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;display:block} .nt-it span i{font-style:normal;color:#555;margin-right:6px} .nt-ed{flex:1;min-width:0;display:flex;flex-direction:column} .nt-ed .tb{height:40px;display:flex;align-items:center;justify-content:flex-end;gap:18px;padding:0 16px;color:#888;font-size:15px;flex:none} .nt-ed .dt{text-align:center;color:#aaa;font-size:11.5px} .nt-ed .bd{padding:8px 26px;line-height:1.8;font-size:14px;overflow:hidden}.nt-ed h1{font-size:21px;margin-bottom:4px}.nt-ed .bd p{margin:2px 0} .nt-ed .ck{display:flex;gap:8px;align-items:center}.nt-ed .ck i{width:15px;height:15px;border:1.5px solid #bbb;border-radius:50%;flex:none}.nt-ed .ck.d i{background:#e8b923;border-color:#e8b923}.nt-ed .ck.d span{color:#999;text-decoration:line-through} """ NOTE_TITLES = {"购物清单": "鸡蛋 牛奶 洗衣液 垃圾袋 猫砂", "年终总结提纲": "一、今年做了什么 二、数据 三、明年计划", "读书笔记:《慢慢来》": "第三章讲的是怎么和焦虑相处", "装修预算": "水电 1.8 万,瓷砖 9000,橱柜待定", "旅行要带的东西": "身份证 充电宝 转换插头 保温杯", "孩子疫苗时间": "流感疫苗第二针 12 月中旬,社区医院", "会议记录 11.20": "参会:产品、设计、研发;结论:先做列表页", "健身计划": "周一三五 力量,周二四 跑步 5 公里", "想看的电影": "《北方的雪》《小橘子》《旧城夏日》", "家里路由器": "管理地址 192.168.0.1,访客网络已开", "车辆保养记录": "上次保养 2026-08-03,里程 32,410", "生日礼物备选": "围巾 / 保温杯 / 按摩仪", "菜谱:番茄牛腩": "牛腩焯水,番茄炒出汁,小火炖 90 分钟", "周末计划": "周六上午打扫,下午去图书馆", "工作周报草稿": "本周完成:列表页改版、埋点上线", "租房要问的问题": "押几付几?物业费谁交?能不能养猫?", "猫粮品牌对比": "A 款蛋白 38%,B 款 42% 但贵 30 块"} def notes_app(rng, *, title, body, date="2026年11月24日 09:36", notes=(), folder="备忘录"): """Notes: folders, note list, editor. body: text; lines starting with "[ ] " / "[x] " become checklist items.""" items = [(t, rng.choice(["昨天", "星期日", "11/20", "11/18", "11/15", "11/9", "10/30"]), NOTE_TITLES[t]) for t in pick(rng, [t for t in NOTE_TITLES if t != title], 13)] items = list(notes) + items first = [l for l in body.split("\n") if l.strip() and l.strip() != title] items.insert(0, (title, date[-5:], (first[0] if first else "")[:30].replace("[ ] ", "").replace("[x] ", ""), True)) li = "".join(f'
3 else ""}">{esc(it[0])}{esc(it[1])}{esc(it[2])}
' for it in items) lines = [] for ln in body.split("\n"): if ln.startswith("[ ] ") or ln.startswith("[x] "): lines.append(f'
{esc(ln[4:])}
') elif ln.strip(): lines.append(f"

{esc(ln)}

") else: lines.append("

 

") sd = (f'
个人
📁 {esc(folder)}{len(items) + rng.randint(10, 60)}
📁 工作{rng.randint(5, 40)}
' f'
📁 生活{rng.randint(5, 40)}
📁 旅行{rng.randint(2, 12)}
📁 孩子{rng.randint(2, 20)}
' f'
🗑 最近删除{rng.randint(1, 9)}
共享
📁 家庭共享{rng.randint(2, 9)}
') html = (f'
{sd}
{esc(folder)}{len(items)} 个备忘录
{li}
' f'
Aa☑▦📎🔗⬆🔍
{esc(date)}
' f'

{esc(title)}

{"".join(lines[1:] if lines and body.split(chr(10))[0] == title else lines)}
') return {"app": "备忘录", "title": title, "html": html, "css": NOTES_CSS, "lights_top": 13} FINDER_CSS = """ .fd{position:absolute;inset:0;display:flex;font-size:13px;background:#fff} .fd-sd{width:170px;flex:none;background:#ececef;border-right:1px solid #ddd;padding:40px 8px 8px;font-size:13px} .fd-sd h6{font-size:11px;color:#999;padding:8px 8px 2px;font-weight:600}.fd-sd div{padding:3px 8px;border-radius:5px;white-space:nowrap}.fd-sd div.on{background:#d6d6db} .fd-sd i{display:inline-block;width:10px;height:10px;border-radius:50%;margin-right:6px} .fd-mn{flex:1;min-width:0;display:flex;flex-direction:column} .fd-tb{height:48px;display:flex;align-items:center;padding:0 12px;gap:14px;color:#666;font-size:15px;flex:none}.fd-tb b{color:#222;font-size:14px;margin-right:auto} .fd-tb .s{width:150px;height:24px;border-radius:6px;background:#fff;border:1px solid #d0d0d4;font-size:12px;color:#999;display:flex;align-items:center;padding-left:6px} .fd table{width:100%;border-collapse:collapse;font-size:12.5px;table-layout:fixed} .fd th{text-align:left;font-weight:400;color:#777;font-size:12px;padding:3px 8px;border-bottom:1px solid #e5e5e5;border-left:1px solid #eee} .fd td{padding:3px 8px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.fd tr:nth-child(even) td{background:#f5f5f7}.fd tr.on td{background:#2f7cf6;color:#fff} .fd td.g{color:#777}.fd tr.on td.g{color:#fff} .fd-st{height:24px;border-top:1px solid #e5e5e5;font-size:11px;color:#888;display:flex;align-items:center;justify-content:center;margin-top:auto;flex:none} """ def _age(when): """Sort key for Finder dates: 今天 < 昨天 < 2026年11月3日 ...""" import re if when.startswith("今天"): return (0, -_tmin(when.split()[1])) if when.startswith("昨天"): return (1, -_tmin(when.split()[1])) m = re.match(r"(\d+)年(\d+)月(\d+)日", when) return (2, -(int(m.group(1)) * 400 + int(m.group(2)) * 32 + int(m.group(3)))) if m else (3, 0) def finder(rng, *, folder="下载", files=(), selected=None, nfiles=24, path=None): """File manager, list view. files: (name, modified, size, kind) put among fillers; selected: name to highlight.""" fill = [] for name, kind in pick(rng, FILES, nfiles - len(files)): days = rng.randint(0, 40) when = "今天 " + clock(rng, 480, 595) if days == 0 else ("昨天 " + clock(rng, 480, 1380) if days == 1 else f"2026年{11 if days < 23 else 10}月{(24 - days) if days < 23 else 31 - (days - 23) % 30}日 {clock(rng, 480, 1380)}") size = "--" if kind == "文件夹" else rng.choice([f"{rng.randint(12, 980)} KB", f"{rng.uniform(1, 90):.1f} MB", f"{rng.uniform(1, 3):.2f} GB" if kind in ("影片", "磁盘映像") else f"{rng.randint(1, 400)} KB"]) fill.append((name, when, size, kind)) allf = mix(rng, fill, files) allf.sort(key=lambda r: _age(r[1])) rows = [] for nm, when, size, kind in allf: ic = "📁" if kind == "文件夹" else {"PDF 文稿": "📕", "表格": "📗", "演示文稿": "📙", "文稿": "📘", "PNG 图像": "🖼", "HEIF 图像": "🖼", "影片": "🎞", "音频": "🎧", "ZIP 归档": "🗜", "磁盘映像": "💿"}.get(kind, "📄") rows.append(f'{"›" if kind == "文件夹" else " "} {ic} {esc(nm)}{esc(when)}{esc(size)}{esc(kind)}') sd = ('
个人收藏
' + "".join(f'
{e} {n}
' for e, n in [("🕘", "最近使用"), ("🅰", "应用程序"), ("🖥", "桌面"), ("📄", "文稿"), ("⬇", "下载"), ("🎬", "影片"), ("🏠", "lin")]) + '
位置
☁ 云盘
💻 林晓的笔记本
💽 移动硬盘
🌐 网络
' + '
标签
' + "".join(f'
{n}
' for c, n in [("#ff5f57", "红色"), ("#febc2e", "橙色"), ("#28c840", "绿色"), ("#2f7cf6", "蓝色"), ("#999", "工作")])) html = (f'
{sd}
‹ ›{esc(folder)}' f'☰▦⇪🏷⋯
🔍 搜索
' f'{"".join(rows)}
名称修改日期 ⌄大小种类
' f'
{len(allf)} 项,{rng.randint(80, 300)}.{rng.randint(1, 9)} GB 可用
') return {"app": "文件管理", "title": folder, "html": html, "css": FINDER_CSS, "lights_top": 13} TERM_CSS = """ .tm{position:absolute;inset:0;background:#1e1f22;color:#d4d4d4;font-family:Menlo,"PingFang SC",monospace;font-size:12px;line-height:1.5;display:flex;flex-direction:column} .tm-tb{height:28px;background:#2b2c30;border-bottom:1px solid #111;color:#aaa;font-size:12.5px;display:flex;align-items:center;justify-content:center;font-family:"PingFang SC",sans-serif;flex:none} .inact .tm-tb{background:#2b2c30;color:#777} .tm-tabs{display:flex;background:#252629;font-size:11.5px;font-family:"PingFang SC",sans-serif;flex:none}.tm-tabs div{flex:1;text-align:center;padding:3px 0;color:#888;border-right:1px solid #111}.tm-tabs .on{background:#1e1f22;color:#ddd} .tm-b{padding:6px 10px;white-space:pre;overflow:hidden;flex:1;display:flex;flex-direction:column;justify-content:flex-end} .tm-b .p{color:#7fd17f}.tm-b .d{color:#6cb6ff}.tm-b .e{color:#ff7b72}.tm-b .w{color:#e3b341}.tm-b .cur{background:#d4d4d4;color:#1e1f22} """ def terminal(rng, *, cwd="~/work/admin-web", user="lin", host="lin-mbp", lines=(), ncmds=5, tabs=("admin-web", "~", "server")): """Terminal. lines: key output appended at the end — strings, or ("$", cmd) for a typed command.""" def prompt(cmd): return f'{esc(user)}@{esc(host)} {esc(cwd)} % {esc(cmd)}' out = [f"Last login: Mon Nov 23 18:02:41 on ttys00{rng.randint(1, 9)}"] for cmd, res in pick(rng, TERM_CMDS, ncmds): out.append(prompt(cmd)) for r in res: cls = "e" if "ERROR" in r else ("w" if "WARN" in r else "") out.append(f'{esc(r)}' if cls else esc(r)) for ln in lines: if isinstance(ln, tuple) and ln[0] == "$": out.append(prompt(ln[1])) else: cls = "e" if ("ERROR" in ln or "error" in ln) else ("w" if "WARN" in ln else "") out.append(f'{esc(ln)}' if cls else esc(ln)) out.append(prompt("") + ' ') tb = "".join(f'
{esc(t)}
' for i, t in enumerate(tabs)) html = (f'
{esc(cwd.split("/")[-1] or "~")} — {esc(user)}@{esc(host)} — zsh — 120×36
' f'
{tb}
{"".join(f"
{l or chr(32)}
" for l in out)}
') return {"app": "终端", "title": cwd, "html": html, "css": TERM_CSS, "lights_top": 8} SHEET_CSS = """ .ss{position:absolute;inset:0;display:flex;flex-direction:column;font-size:12px;background:#fff} .ss-tb{height:34px;display:flex;align-items:center;justify-content:center;font-weight:600;color:#333;font-size:13px;flex:none} .ss-tb span{font-weight:400;color:#999;font-size:12px;margin-left:6px} .ss-menu{display:flex;gap:16px;padding:3px 12px;background:#f7f7f8;font-size:12.5px;color:#444;border-bottom:1px solid #e2e2e2;flex:none}.ss-menu .on{color:#1f8a4c;font-weight:600;border-bottom:2px solid #1f8a4c} .ss-rb{display:flex;gap:10px;align-items:center;padding:5px 12px;background:#f7f7f8;border-bottom:1px solid #ddd;color:#444;font-size:12px;white-space:nowrap;overflow:hidden;flex:none} .ss-rb .b{border:1px solid #d4d4d4;background:#fff;border-radius:3px;padding:1px 8px}.ss-rb i{width:1px;height:18px;background:#ddd} .ss-fx{display:flex;border-bottom:1px solid #ddd;height:24px;align-items:center;font-size:12px;flex:none}.ss-fx b{width:70px;text-align:center;border-right:1px solid #ddd;font-weight:400}.ss-fx span{padding:0 8px;color:#777;border-right:1px solid #ddd}.ss-fx div{padding-left:8px} .ss-g{flex:1;overflow:hidden} .ss table{border-collapse:collapse;table-layout:fixed} .ss td,.ss th{border:1px solid #e3e3e3;height:21px;padding:0 5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-weight:400} .ss th{background:#f3f3f4;color:#666;text-align:center;font-size:11px}.ss td.n{text-align:right}.ss tr.h td{font-weight:600;background:#e8f3ec} .ss td.sel{outline:2px solid #1f8a4c;outline-offset:-2px} .ss-tabs{display:flex;gap:2px;padding:0 10px;border-top:1px solid #ddd;background:#f3f3f4;height:26px;align-items:center;font-size:12px;flex:none}.ss-tabs span{padding:2px 14px;color:#666}.ss-tabs .on{background:#fff;color:#1f8a4c;font-weight:600;border-bottom:2px solid #1f8a4c} .ss-tabs .r{margin-left:auto;color:#888} """ def _sales_row(rng, i): p = _product(rng) q = rng.randint(1, 60) pr = float(p["price"]) return [f"2026-11-{rng.randint(1, 23):02d}", rng.choice(CITIES), rng.choice(CO_A) + "店", p["cat"], str(q), f"{pr:.2f}", f"{q * pr:,.2f}", person(rng)] def spreadsheet(rng, *, name="11月销售明细.xlsx", columns=None, rows=(), fill=None, nrows=36, sheets=("明细", "按城市汇总", "按产品", "图表"), selected=None, formula=None): """Spreadsheet. columns default 日期/城市/门店/品类/数量/单价/金额/销售员; rows: key rows; fill(rng, i) -> row; selected: (row, col) 0-based in data.""" cols = columns or ["日期", "城市", "门店", "品类", "数量", "单价", "金额", "销售员"] fill = fill or (_sales_row if columns is None else None) data = mix(rng, [fill(rng, i) for i in range(nrows - len(rows))] if fill else [], [list(r) for r in rows]) if columns is None: data.sort(key=lambda r: r[0]) letters = "ABCDEFGHIJKLMNOP" ncol = len(cols) + 3 widths = [36] + [90 if i < len(cols) else 70 for i in range(ncol)] th = "" + "".join(f"{letters[i]}" for i in range(ncol)) + "" trs = ['1' + "".join(f"{esc(c)}" for c in cols) + "" * 3 + ""] for ri, r in enumerate(data): tds = [] for ci, v in enumerate(r): num = str(v).replace(",", "").replace(".", "").replace("-", "").isdigit() and ci > 0 sel = " sel" if selected == (ri, ci) else "" tds.append(f'{esc(v)}') trs.append(f"{ri + 2}{''.join(tds)}{'' * 3}") cg = "".join(f'' for w in widths) sr, sc = selected or (0, 0) cell = f"{letters[sc]}{sr + 2}" fx = formula if formula is not None else (data[sr][sc] if data else "") html = (f'
{esc(name)}— 已保存到本机
' f'
文件开始插入页面布局公式数据审阅视图
' f'
📋 粘贴默认字体 ⌄12 ⌄BIU' f'≡ ≣ ≡合并居中自动换行常规 ⌄% ‰ .00' f'条件格式套用表格Σ 求和 ⌄筛选排序
' f'
{cell}fx
{esc(fx)}
' f'
{cg}{th}{"".join(trs)}
' f'
' + "".join(f'{esc(s)}' for i, s in enumerate(sheets)) + f'+求和={sum(float(str(r[6]).replace(",", "")) for r in data if len(r) > 6 and str(r[6]).replace(",", "").replace(".", "").isdigit()):,.2f}   计数={len(data)}   100%
') return {"app": "格子表格", "title": name, "html": html, "css": SHEET_CSS, "lights_top": 11} MUSIC_CSS = """ .mu{position:absolute;inset:0;display:flex;flex-direction:column;font-size:13px;background:#fff;color:#222} .mu-b{flex:1;display:flex;min-height:0} .mu-sd{width:190px;flex:none;background:#f4f4f6;border-right:1px solid #e5e5e5;padding:40px 10px 10px;font-size:13px} .mu-sd h6{font-size:11px;color:#999;font-weight:500;padding:8px 8px 2px}.mu-sd div{padding:4px 8px;border-radius:5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mu-sd div.on{background:#fde4e8;color:#d7385e;font-weight:600} .mu-mn{flex:1;min-width:0;padding:14px 20px;overflow:hidden} .mu-hd{display:flex;gap:16px;margin-bottom:10px}.mu-cv{width:120px;height:120px;border-radius:8px;flex:none;display:flex;align-items:flex-end;padding:8px;color:#fff;font-weight:700;font-size:15px} .mu-hd h1{font-size:20px;margin:2px 0 6px}.mu-hd p{color:#888;font-size:12px;line-height:1.7}.mu-hd .bt{display:flex;gap:8px;margin-top:6px}.mu-hd .bt span{border:1px solid #ddd;border-radius:14px;padding:2px 12px;font-size:12px}.mu-hd .bt span:first-child{background:#d7385e;border-color:#d7385e;color:#fff} .mu table{width:100%;border-collapse:collapse;table-layout:fixed;font-size:12.5px}.mu th{text-align:left;color:#999;font-weight:400;padding:3px 6px;font-size:12px} .mu td{padding:4px 6px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mu tr:nth-child(even) td{background:#fafafa}.mu tr.on td{color:#d7385e}.mu td.g{color:#888} .mu-pl{height:60px;border-top:1px solid #e5e5e5;display:flex;align-items:center;padding:0 14px;gap:12px;flex:none;background:#fafafa} .mu-pl .cv{width:42px;height:42px;border-radius:5px;flex:none}.mu-pl .ti{width:200px;flex:none;line-height:1.4}.mu-pl .ti b{display:block;font-size:13px}.mu-pl .ti span{font-size:12px;color:#888} .mu-pl .ct{flex:1;text-align:center}.mu-pl .ct .bt{font-size:15px;letter-spacing:14px;color:#444}.mu-pl .pg{display:flex;gap:8px;align-items:center;font-size:11px;color:#999}.mu-pl .pg i{flex:1;height:3px;background:#e2e2e2;border-radius:2px;position:relative}.mu-pl .pg i b{position:absolute;left:0;top:0;bottom:0;background:#d7385e;border-radius:2px} .mu-pl .vo{width:150px;color:#888;font-size:12px;text-align:right} """ def music_player(rng, *, now_playing=None, playlist="冬日午后", creator=None, tracks=(), ntracks=22, app="回声音乐"): """Music player: sidebar, playlist with 20+ tracks, bottom player bar. now_playing: {title, artist, album?, pos: "01:23", dur: "04:05"}; tracks: (title, artist, album, dur).""" fill = [] for t in pick(rng, [s for s in SONGS if s not in {k[0] for k in tracks}], ntracks - len(tracks)): a = rng.choice(ARTISTS) fill.append((t, a, rng.choice(SONGS[:12]) if rng.random() < .5 else t, f"0{rng.randint(2, 5)}:{rng.randint(0, 59):02d}")) allt = mix(rng, fill, tracks, limit=10) np_ = now_playing or {"title": allt[2][0], "artist": allt[2][1], "pos": "01:23", "dur": allt[2][3]} rows = "".join(f'{"♪" if t[0] == np_["title"] else f"{i + 1:02d}"}{esc(t[0])}{esc(t[1])}' f'{esc(t[2])}{esc(t[3])}' for i, t in enumerate(allt)) pls = ["我喜欢的音乐", playlist, "通勤路上", "写代码专用", "睡前", "2025 年度歌单", "跑步 180BPM", "粤语老歌", "钢琴与雨", "车载歌单"] sd = ('
在线音乐
推荐
排行榜
歌单广场
播客
演出
我的音乐
最近播放
本地与下载
我的收藏
创建的歌单
' + "".join(f'
{"♡ " if i == 0 else "≡ "}{esc(p)}
' for i, p in enumerate(dict.fromkeys(pls)))) pos, dur = _tmin(np_["pos"]), _tmin(np_["dur"]) pct = 100 * pos / max(dur, 1) html = (f'
{sd}
' f'
{esc(playlist)}
' f'
歌单

{esc(playlist)}

' f'

{esc(creator or "林间小鹿")} · 2025-12-02 创建 · {len(allt)} 首歌 · 约 {len(allt) * 4} 分钟
标签:华语 / 民谣 / 安静   播放 {rng.randint(100, 9000)} 次

' f'
▶ 播放全部+ 收藏↗ 分享⬇ 下载全部
' f'' f'{rows}
标题歌手专辑时长
' f'
' f'
{esc(np_["title"])}{esc(np_["artist"])}{" — " + esc(np_["album"]) if np_.get("album") else ""}
' f'
⇄ ⏮ ⏸ ⏭ ↻
{esc(np_["pos"])}{esc(np_["dur"])}
' f'
🔈 ▬▬▬▭   词   ≡ {len(allt)}
') return {"app": app, "title": playlist, "html": html, "css": MUSIC_CSS, "lights_top": 13} SET_CSS = """ .st{position:absolute;inset:0;display:flex;font-size:13px;background:#fff} .st-sd{width:220px;flex:none;background:#ececef;border-right:1px solid #ddd;padding:40px 10px 10px;overflow:hidden} .st-sd .s{height:26px;border-radius:6px;background:#dcdce0;color:#888;font-size:12px;display:flex;align-items:center;padding-left:8px;margin-bottom:8px} .st-sd .u{display:flex;gap:8px;align-items:center;padding:6px;margin-bottom:6px}.st-sd .u b{display:block;font-size:13px}.st-sd .u span{font-size:11px;color:#888} .st-sd div.i{display:flex;gap:8px;align-items:center;padding:3px 6px;border-radius:6px;white-space:nowrap}.st-sd div.i.on{background:#2f7cf6;color:#fff} .st-sd div.i em{width:20px;height:20px;border-radius:5px;font-style:normal;font-size:12px;display:flex;align-items:center;justify-content:center;flex:none;color:#fff} .st-sd .gap{height:8px} .st-mn{flex:1;min-width:0;padding:10px 24px;overflow:hidden;background:#f5f5f7} .st-mn h1{font-size:15px;margin:2px 0 12px;text-align:left} .st-gr{background:#fff;border-radius:8px;border:1px solid #e3e3e6;margin-bottom:12px}.st-gt{font-size:12px;color:#777;font-weight:600;margin:0 4px 4px} .st-rw{display:flex;align-items:center;padding:7px 12px;border-bottom:1px solid #eee;gap:12px;min-height:34px}.st-rw:last-child{border:none} .st-rw .l{flex:1}.st-rw .l span{display:block;font-size:11.5px;color:#888}.st-rw .v{color:#777} .st-tg{width:32px;height:19px;border-radius:10px;background:#ddd;position:relative;flex:none}.st-tg:after{content:"";position:absolute;left:2px;top:2px;width:15px;height:15px;border-radius:50%;background:#fff;box-shadow:0 1px 2px rgba(0,0,0,.3)} .st-tg.on{background:#2fb34a}.st-tg.on:after{left:15px} """ SET_PANES = [("📶", "#2f7cf6", "无线局域网"), ("🔵", "#2f7cf6", "蓝牙"), ("🌐", "#2f7cf6", "网络"), ("🔋", "#2fb34a", "电池"), None, ("⚙️", "#8e8e93", "通用"), ("◐", "#333", "外观"), ("♿", "#2f7cf6", "辅助功能"), ("☰", "#8e8e93", "控制中心"), ("🔍", "#8e8e93", "搜索"), ("🖥", "#2f7cf6", "桌面与程序坞"), ("☀", "#2f7cf6", "显示器"), ("🏞", "#36aadc", "墙纸"), None, ("🔔", "#ff3b30", "通知"), ("🔊", "#ff3b30", "声音"), ("🌙", "#5856d6", "专注模式"), ("⏳", "#5856d6", "屏幕使用时间"), None, ("🔒", "#333", "锁定屏幕"), ("✋", "#2f7cf6", "隐私与安全性"), ("👆", "#ff3b30", "触控 ID 与密码"), ("👥", "#2f7cf6", "用户与群组"), None, ("🔑", "#8e8e93", "密码"), ("@", "#2f7cf6", "互联网账户"), ("⌨️", "#8e8e93", "键盘"), ("🖱", "#8e8e93", "鼠标"), ("▭", "#8e8e93", "触控板"), ("🖨", "#8e8e93", "打印机与扫描仪")] def settings_window(rng, *, pane="通用", groups=None, user="林晓", account="lin.xiao@qinglan.example"): """System settings. groups: [(group title or "", [(label, value) ...])]; value True/False draws a switch; label may be (label, sub).""" if groups is None: groups = [("", [("关于本机", "›"), ("软件更新", "有 1 个可用更新 ›"), ("储存空间", "已用 238 GB / 460 GB ›")]), ("", [("隔空投放与接力", "›"), ("登录项与扩展", "›"), ("语言与地区", "简体中文 ›"), ("日期与时间", "自动设置 ›"), ("共享", "›")]), ("", [("时间机器备份", "上次备份:昨天 22:41 ›"), ("设备管理", "›"), ("启动磁盘", "系统盘 ›"), ("传输或还原", "›")]), ("自动更新", [(("自动下载更新", "有可用的更新时在后台下载"), True), (("自动安装安全更新", ""), True), (("自动安装应用更新", ""), False)])] sd = [f'
🔍 搜索
{avatar(user, 34)}
{esc(user)}{esc(account)}
'] for p in SET_PANES: if p is None: sd.append('
') continue e, c, n = p sd.append(f'
{e}{esc(n)}
') gs = [] for gt, rows in groups: rh = [] for lab, val in rows: if isinstance(lab, tuple): lab, sub = lab else: sub = "" v = f'
' if isinstance(val, bool) else f'{esc(val)}' rh.append(f'
{esc(lab)}{f"{esc(sub)}" if sub else ""}
{v}
') gs.append((f'
{esc(gt)}
' if gt else "") + f'
{"".join(rh)}
') html = (f'
{"".join(sd)}

‹ ›  {esc(pane)}

{"".join(gs)}
') return {"app": "系统设置", "title": pane, "html": html, "css": SET_CSS, "lights_top": 13} # ---------------------------------------------------------------- finishing def _finish(windows): out = [] for w in windows: if w.get("_cal"): w = dict(w, html=_cal_html(w["_cal"], w["w"], w["h"])) out.append(w) return out _desktop = desktop def desktop(windows, **kw): # noqa: F811 (wraps the builder so size-dependent windows get laid out) return _desktop(_finish(windows), **kw) desktop.__doc__ = _desktop.__doc__