diff --git a/plugins/newsnow/CHANGELOG.md b/plugins/newsnow/CHANGELOG.md new file mode 100644 index 00000000..e0dff078 --- /dev/null +++ b/plugins/newsnow/CHANGELOG.md @@ -0,0 +1,33 @@ +# Changelog + +## 2.0.0 + +### Added + +- 风格样式切换:支持风格1(侧栏)、风格2(卡片)、风格3(占位,即将推出) +- **风格1** 侧栏布局:左侧频道 Tab + 右侧资讯列表 +- 风格1 搜索:支持模糊搜索频道名称与当前频道内资讯 +- 风格1 关注:频道标题关注按钮、左侧「关注」分组展开已关注频道 +- 风格1 交互:右下角刷新 / 回到顶部悬浮按钮,资讯悬停蓝色高亮动效 +- 风格1 收藏:热搜与实时新闻列表均支持收藏 +- 设置项 `uiStyle`、`lastStyle1Source` 持久化 + +### Changed + +- 默认风格由风格2(卡片)调整为 **风格1(侧栏)** +- 共享逻辑集中于 `lib/newsnow/`(设置、元数据、收藏、栏目配置等) + +### Fixed + +- 风格1 搜索框输入时失焦(改为局部 DOM 更新) +- 侧栏无法滚动、设置入口被遮挡(底部固定悬浮设置栏) +- GitHub、百度、Freebuf 等频道热度/标题显示异常(修正 `extra` 字段解析与 HTML 转义) +- 模块初始化时 `style1SelectedSource` 暂时性死区导致页面空白 + +## 1.0.0 + +### Added + +- NewsNow 插件首版:多平台热搜与实时新闻订阅 +- 风格2 卡片网格布局,支持关注、收藏、搜索、数据源配置 +- ZTools preload 代理请求与本地调试(Vite HMR) diff --git a/plugins/newsnow/assets/main-BZwbOKIC.css b/plugins/newsnow/assets/main-BZwbOKIC.css new file mode 100644 index 00000000..728b96e4 --- /dev/null +++ b/plugins/newsnow/assets/main-BZwbOKIC.css @@ -0,0 +1 @@ +:root{--color-base: #27272a;--color-text: #d4d4d8;--color-accent: #71717a;--color-accent-hover: #a1a1aa;--color-highlight: #3b82f6;--radius-card: 12px;--card-height: 248px;--font-brand: "SF Mono", ui-monospace, Menlo, Monaco, Consolas, monospace}html.dark{color-scheme:dark;--color-base: #27272a;--color-text: #d4d4d8;--bg-page: #3f3f46}html.light{color-scheme:light;--color-base: #e4e4e7;--color-text: #27272a;--bg-page: #e4e4e7}*{box-sizing:border-box;margin:0;padding:0}html,body{width:100%;height:100%;overflow:hidden}body{font-family:system-ui,-apple-system,PingFang SC,Microsoft YaHei,sans-serif;font-size:13px;background:var(--bg-page);color:var(--color-text);-webkit-user-select:none;user-select:none}button,a{cursor:default;border:none;background:none;color:inherit;font:inherit;text-decoration:none}#app{width:100%;height:100%;display:flex;flex-direction:column;overflow:hidden;background:var(--bg-page)}#overlay-root{position:fixed;top:0;right:0;bottom:0;left:0;z-index:300;pointer-events:none}#overlay-root:not(:empty){pointer-events:auto}.btn-icon{opacity:.55;transition:opacity .2s;font-size:1.1rem;line-height:1;padding:2px}.btn-icon:hover{opacity:.9;cursor:pointer}.btn-icon.active{opacity:1;color:#fbbf24}.btn-icon.is-spinning{opacity:1;animation:nn-spin .8s linear infinite;pointer-events:none}@keyframes nn-spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.nn-header{display:grid;grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);align-items:center;padding:8px 12px 6px;flex-shrink:0;gap:8px}.nn-logo-wrap{display:flex;align-items:center;gap:6px;justify-self:start;min-width:0}.nn-logo-img{width:32px;height:32px;border-radius:8px;object-fit:cover;flex-shrink:0}.nn-logo{width:32px;height:32px;border-radius:8px;background:linear-gradient(135deg,#71717a,#a1a1aa);display:flex;align-items:center;justify-content:center;font-size:9px;font-weight:700;color:#fff;flex-shrink:0}.nn-brand{font-family:var(--font-brand);font-size:1rem;line-height:1.05}.nn-brand .accent{color:var(--color-highlight)}.nn-version{font-size:.65rem;font-family:monospace;opacity:.55;margin-left:2px;align-self:flex-start;margin-top:2px}.nn-navbar{display:flex;flex-wrap:wrap;justify-content:center;padding:6px 8px;border-radius:var(--radius-card);background:#71717a1f;box-shadow:0 1px 4px #0000001f;font-size:.75rem;gap:2px}.nn-navbar button{padding:3px 6px;border-radius:5px;opacity:.8;cursor:pointer;transition:background .15s;white-space:nowrap}.nn-navbar button:hover{background:#71717a2e}.nn-navbar button.active{color:var(--color-highlight);font-weight:600;opacity:1}.nn-header-actions{justify-self:end;display:flex;gap:6px;align-items:center;color:var(--color-accent);font-size:1.05rem}.nn-main{flex:1;overflow-x:hidden;overflow-y:auto;padding:0 12px 12px;display:flex;flex-direction:column;min-height:0}.nn-cards-wrap{position:relative;flex:1;min-height:0;min-width:0}.nn-cards{display:flex;flex-wrap:wrap;gap:10px;align-content:start}.nn-card{height:var(--card-height);flex:1 1 calc(33.333% - 7px);min-width:220px;max-width:100%;border-radius:var(--radius-card);padding:10px;display:flex;flex-direction:column;position:relative;background:#64748b59}.nn-cards.has-custom-width .nn-card{flex:0 0 var(--card-width);width:var(--card-width);min-width:0;max-width:none}.nn-card-resize-e{position:absolute;right:0;top:28px;bottom:6px;width:6px;cursor:ew-resize;opacity:0;border-radius:3px;z-index:2}.nn-card-resize-s{position:absolute;left:6px;right:6px;bottom:0;height:6px;cursor:ns-resize;opacity:0;border-radius:3px;z-index:2}.nn-card:hover .nn-card-resize-e,.nn-card:hover .nn-card-resize-s,.nn-card-resize-e:hover,.nn-card-resize-s:hover{opacity:.45;background:#3b82f659}.nn-item-star-inline{margin-left:6px;font-size:.7rem;vertical-align:middle;cursor:pointer}.nn-card[data-color=green]{background:#22c55e59}.nn-card[data-color=red]{background:#ef444459}.nn-card[data-color=blue]{background:#3b82f659}.nn-card[data-color=indigo]{background:#6366f159}.nn-card[data-color=slate]{background:#64748b59}.nn-card[data-color=orange]{background:#f9731659}.nn-card[data-color=gray]{background:#6b728059}.nn-card[data-color=emerald]{background:#10b98159}.nn-card[data-color=teal]{background:#14b8a659}.nn-card[data-color=yellow]{background:#eab30859}.nn-card[data-color=purple]{background:#a855f759}.nn-card[data-color=pink]{background:#ec489959}.nn-card[data-color=cyan]{background:#06b6d459}.nn-card.is-highlight{outline:2px solid var(--color-highlight)}.nn-card-head{display:flex;justify-content:space-between;align-items:flex-start;margin:0 4px 6px;gap:4px}.nn-card-source{display:flex;gap:6px;align-items:center;min-width:0}.nn-card-icon-img{width:28px;height:28px;border-radius:50%;object-fit:cover;background:var(--color-base);flex-shrink:0}.nn-card-title{font-size:.95rem;font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.nn-card-badge{font-size:.65rem;padding:1px 4px;border-radius:4px;background:#ffffff26;margin-left:4px}.nn-card-updated{font-size:.65rem;opacity:.65}.nn-card-actions{display:flex;gap:4px;flex-shrink:0}.nn-drag-handle{cursor:grab;touch-action:none}.nn-drag-handle:active{cursor:grabbing}.nn-card-body{flex:1;overflow-y:auto;border-radius:var(--radius-card);background:#27272ab3;padding:6px;margin-top:2px;min-height:0}html.light .nn-card-body{background:#ffffffbf}.nn-list-hot{list-style:none;display:flex;flex-direction:column;gap:4px}.nn-list-hot li a{display:flex;gap:6px;align-items:flex-start;padding:2px 3px;border-radius:5px;cursor:pointer;font-size:.8rem;line-height:1.35}.nn-list-hot li a:hover{background:#a3a3a326}.nn-rank{min-width:20px;height:20px;display:flex;align-items:center;justify-content:center;background:#a3a3a326;border-radius:5px;font-size:.75rem;flex-shrink:0}.nn-list-timeline{list-style:none;border-left:1px solid rgba(163,163,163,.5);margin-left:3px}.nn-list-timeline li{padding-left:6px;margin-bottom:6px}.nn-list-timeline .meta{font-size:.65rem;opacity:.5;display:flex;gap:4px;align-items:center}.nn-list-timeline .meta:before{content:"-";margin-left:-8px;margin-right:2px}.nn-list-timeline a{display:block;padding:2px 3px;margin-left:3px;border-radius:5px;cursor:pointer;line-height:1.35;font-size:.8rem}.nn-list-timeline a:hover{background:#a3a3a326}.nn-item-star{opacity:.35;font-size:.7rem;margin-left:auto;flex-shrink:0;cursor:pointer}.nn-item-star.active{opacity:1;color:#fbbf24}.nn-menu-wrap{position:relative}.nn-dropdown{position:absolute;right:0;top:calc(100% + 4px);z-index:150;min-width:168px;max-height:min(320px,50vh);overflow-y:auto}.nn-dropdown-inner{background:#27272af5;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);border-radius:8px;padding:4px;box-shadow:0 6px 20px #00000059;border:1px solid rgba(163,163,163,.15)}html.light .nn-dropdown-inner{background:#fffffffa}.nn-dropdown li{list-style:none;padding:5px 8px;border-radius:6px;display:flex;gap:6px;align-items:center;cursor:pointer;font-size:.75rem;color:var(--color-text)}.nn-dropdown li:hover{background:#a3a3a326}.nn-dropdown li.disabled{opacity:.45;cursor:not-allowed}.nn-card.dragging{opacity:.35;transform:scale(.96);transition:transform .12s ease,opacity .12s ease;pointer-events:none}.nn-card-ghost{position:fixed;z-index:400;pointer-events:none;flex:none;transform:scale(1.05) rotate(-2deg);box-shadow:0 16px 36px #00000073;opacity:.95;transition:none;overflow:hidden}.nn-card-ghost .nn-card-body{display:none}.nn-card.drag-over{outline:2px dashed var(--color-highlight)}.nn-webview{position:fixed;top:0;right:0;bottom:0;left:0;z-index:350;display:flex;flex-direction:column;background:var(--bg-page)}.nn-webview-toolbar{display:flex;align-items:center;gap:8px;padding:8px 10px;border-bottom:1px solid rgba(163,163,163,.2);flex-shrink:0}.nn-webview-toolbar button{padding:4px 10px;border-radius:6px;background:#71717a33;cursor:pointer;font-size:.75rem;flex-shrink:0}.nn-webview-title{flex:1;font-size:.7rem;opacity:.65;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.nn-webview-frame{flex:1;width:100%;border:none;background:#fff}.nn-empty{grid-column:1 / -1;width:100%;padding:32px 16px;text-align:center;opacity:.6;font-size:.85rem}.nn-overlay{position:fixed;top:0;right:0;bottom:0;left:0;display:flex;align-items:center;justify-content:center;padding:16px;z-index:300}.nn-backdrop{position:absolute;top:0;right:0;bottom:0;left:0;background:#00000073;cursor:pointer}.nn-modal{position:relative;width:min(480px,100%);max-height:min(480px,calc(100vh - 32px));overflow:auto;background:var(--bg-page);border-radius:10px;padding:14px;box-shadow:0 12px 40px #00000059;z-index:1}.nn-modal h2{font-size:.9rem;margin-bottom:10px;font-weight:600}.nn-modal input[type=search],.nn-modal input[type=text]{width:100%;padding:7px 9px;border-radius:7px;border:1px solid rgba(163,163,163,.35);background:var(--color-base);color:var(--color-text);margin-bottom:10px;font-size:.85rem}.nn-modal-list{list-style:none;display:flex;flex-direction:column;gap:2px;max-height:320px;overflow-y:auto}.nn-modal-list li{padding:7px 8px;border-radius:7px;cursor:pointer;display:flex;justify-content:space-between;gap:8px;font-size:.8rem;align-items:center}.nn-modal-list li:hover{background:#a3a3a326}.nn-modal-list li.is-selected{background:#3b82f62e;color:var(--color-highlight)}.nn-modal-actions{display:flex;gap:8px;justify-content:flex-end;margin-top:10px}.nn-modal-actions button{padding:5px 10px;border-radius:7px;background:#71717a33;cursor:pointer;font-size:.8rem}.nn-modal-actions button:hover{background:#71717a52}.nn-row-link{cursor:pointer;flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.nn-card.is-loading .nn-card-body{opacity:.45}.nn-card-error{padding:8px;font-size:.75rem;color:#f87171;word-break:break-word}.nn-settings-tabs{display:flex;gap:4px;margin-bottom:10px}.nn-settings-tab{padding:4px 10px;border-radius:6px;font-size:.75rem;cursor:pointer;background:#71717a26}.nn-settings-tab.active{background:#3b82f638;color:var(--color-highlight);font-weight:600}.nn-settings-list{list-style:none;display:flex;flex-direction:column;gap:4px;max-height:320px;overflow-y:auto}.nn-settings-list li{display:flex;align-items:center;gap:8px;padding:6px 8px;border-radius:7px;background:#71717a14}.nn-settings-list li.dragging{opacity:.45;pointer-events:none}.nn-settings-list li.drag-over{outline:1px dashed var(--color-highlight)}.nn-settings-drag{cursor:grab;opacity:.45;flex-shrink:0}.nn-settings-icon{width:22px;height:22px;border-radius:50%;object-fit:cover;background:var(--color-base);flex-shrink:0}.nn-settings-name{flex:1;min-width:0;font-size:.8rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.nn-settings-toggle{display:none}.nn-switch{position:relative;display:inline-flex;align-items:center;width:34px;height:18px;flex-shrink:0;cursor:pointer}.nn-switch input{opacity:0;width:0;height:0;position:absolute}.nn-switch-slider{position:absolute;top:0;right:0;bottom:0;left:0;border-radius:999px;background:#71717a73;transition:background .2s}.nn-switch-slider:before{content:"";position:absolute;width:14px;height:14px;left:2px;top:2px;border-radius:50%;background:#fff;transition:transform .2s}.nn-switch input:checked+.nn-switch-slider{background:#22c55ebf}.nn-switch input:checked+.nn-switch-slider:before{transform:translate(16px)}.nn-settings-ghost{position:fixed;z-index:500;pointer-events:none;list-style:none;opacity:.92;box-shadow:0 12px 28px #00000059;transform:scale(1.02);background:var(--bg-page);border-radius:7px;display:flex;align-items:center;gap:8px;padding:6px 8px;box-sizing:border-box}.nn-settings-hint{font-size:11px;opacity:.55;margin-top:8px}.nn-fav-header{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:8px}.nn-fav-header h2{margin:0;font-size:.9rem;font-weight:600;flex-shrink:0}.nn-fav-header input[type=text],.nn-fav-header input[type=search]{flex:1;max-width:200px;margin:0;padding:5px 8px;border-radius:6px;border:1px solid rgba(163,163,163,.35);background:var(--color-base);color:var(--color-text);font-size:.8rem}.nn-fav-modal-wrap{width:min(520px,calc(100vw - 32px))!important;height:min(480px,calc(100vh - 32px))!important;min-height:min(480px,calc(100vh - 32px))!important;max-height:min(480px,calc(100vh - 32px))!important;display:flex;flex-direction:column;overflow:hidden!important}.nn-fav-modal-wrap .nn-modal-list{max-height:none;flex:1;min-height:0}.nn-fav-body{flex:1;min-height:0;overflow-y:auto;display:flex;flex-direction:column}.nn-fav-body #fav-empty{flex:1;display:flex;align-items:center;justify-content:center;min-height:120px;margin:0}.nn-fav-list li{flex-direction:column;align-items:stretch;gap:6px}.nn-fav-row{display:flex;align-items:center;gap:6px;width:100%}.nn-tag-editor{width:100%;padding:6px 8px;border-radius:6px;background:#71717a1a}.nn-tag-input{width:100%;margin:0 0 6px;padding:5px 8px;border-radius:6px;border:1px solid rgba(163,163,163,.35);background:var(--color-base);color:var(--color-text);font-size:.75rem}.nn-tag-picks{display:flex;flex-wrap:wrap;gap:4px}.nn-tag-pick{cursor:pointer;border:none;font:inherit}.nn-tag-pick:hover{filter:brightness(1.1)}.nn-tag-empty{font-size:.7rem;opacity:.5}.nn-fav-tag{font-size:.65rem;padding:2px 7px;border-radius:999px;background:#3b82f633;color:var(--color-highlight);flex-shrink:0;line-height:1.4}.nn-fav-toolbar{display:flex;gap:6px;margin-bottom:8px;flex-wrap:wrap}.nn-fav-toolbar select{flex:1;min-width:90px;padding:4px 6px;border-radius:6px;border:1px solid rgba(163,163,163,.35);background:var(--color-base);color:var(--color-text);font-size:.75rem}.nn-fav-manage-btn{padding:4px 8px;border-radius:6px;font-size:.72rem;cursor:pointer;background:#71717a33;white-space:nowrap}.nn-fav-meta-panel{margin-bottom:8px;padding:8px;border-radius:7px;background:#71717a1a}.nn-fav-meta-row{display:flex;gap:6px;margin-bottom:6px}.nn-fav-meta-row:last-child{margin-bottom:0}.nn-fav-meta-row input{flex:1;margin:0;padding:5px 8px;border-radius:6px;border:1px solid rgba(163,163,163,.35);background:var(--color-base);color:var(--color-text);font-size:.75rem}.nn-fav-meta-row button{padding:4px 8px;border-radius:6px;font-size:.72rem;cursor:pointer;background:#71717a33;white-space:nowrap}.nn-settings-modal-wrap{width:min(480px,calc(100vw - 32px))!important}.nn-search-modal-wrap{width:min(680px,calc(100vw - 32px))!important;height:min(480px,calc(100vh - 32px))!important;max-height:min(480px,calc(100vh - 32px))!important;display:flex!important;flex-direction:column;overflow:hidden!important;padding:12px!important}.nn-search-modal-wrap>input[type=search]{flex-shrink:0;margin-bottom:10px;padding:10px 14px;border-radius:999px;border:none;background:#71717a38;font-size:.85rem}html.light .nn-search-modal-wrap>input[type=search]{background:#0000000f}.nn-search-body{flex:1;min-height:0;display:grid;grid-template-columns:minmax(0,38%) minmax(0,1fr);gap:10px}.nn-search-sidebar{overflow-y:auto;min-height:0;padding-right:4px}.nn-search-group{margin-bottom:10px}.nn-search-group-title{font-size:.7rem;font-weight:600;opacity:.45;margin-bottom:4px;padding:0 6px}.nn-search-list{list-style:none;display:flex;flex-direction:column;gap:2px}.nn-search-item{display:flex;align-items:center;gap:8px;padding:6px 8px;border-radius:10px;cursor:pointer;transition:background .12s}.nn-search-item:hover{background:#a3a3a31f}.nn-search-item.is-selected{background:#a3a3a333}.nn-search-icon{width:24px;height:24px;border-radius:50%;object-fit:cover;background:var(--color-base);flex-shrink:0}.nn-search-item-text{flex:1;min-width:0;display:flex;align-items:baseline;gap:6px}.nn-search-name{font-size:.82rem;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.nn-search-tag{font-size:.68rem;opacity:.45;white-space:nowrap;flex-shrink:0}.nn-search-star{flex-shrink:0;font-size:.95rem}.nn-search-empty,.nn-search-preview-empty{display:flex;align-items:center;justify-content:center;height:100%;opacity:.5;font-size:.8rem;text-align:center;padding:16px}.nn-search-preview{min-height:0;overflow:hidden;display:flex;flex-direction:column}.nn-search-preview-inner{flex:1;min-height:0;display:flex;flex-direction:column}.nn-search-preview .nn-card.is-preview{flex:1;min-height:0;height:auto;max-width:none;width:100%}.nn-fav-date{font-size:.68rem;opacity:.4;flex-shrink:0;font-family:ui-monospace,monospace}.nn-fav-group{display:none}.nn-fav-edit{padding:2px 5px;border-radius:4px;font-size:.7rem;cursor:pointer;background:#71717a26;flex-shrink:0}.nn-fav-list button[data-remove]{padding:2px 6px;border-radius:4px;font-size:.7rem;cursor:pointer;background:#ef444426;color:#f87171;flex-shrink:0}.nn-s1{display:flex;width:100%;height:100%;min-height:0;overflow:hidden;background:#fff}html.dark .nn-s1{background:#1f1f23}.nn-s1-sidebar{width:168px;flex-shrink:0;display:flex;flex-direction:column;background:#f5f5f5;border-right:1px solid rgba(0,0,0,.06);position:relative;min-height:0;overflow:hidden}html.dark .nn-s1-sidebar{background:#2a2a2e;border-right-color:#ffffff14}.nn-s1-search-wrap{padding:10px 10px 6px;flex-shrink:0}.nn-s1-search{width:100%;padding:6px 10px;border-radius:8px;border:1px solid rgba(0,0,0,.08);background:#fff;color:#333;font-size:.78rem;outline:none}html.dark .nn-s1-search{background:#1f1f23;border-color:#ffffff1a;color:var(--color-text)}.nn-s1-search:focus{border-color:#1677ff;box-shadow:0 0 0 2px #1677ff1f}.nn-s1-focus-block{flex-shrink:0}.nn-s1-focus-toggle,.nn-s1-group-title{width:100%;display:flex;align-items:center;gap:6px;padding:7px 12px;font-size:.78rem;color:#666;cursor:pointer;text-align:left}html.dark .nn-s1-focus-toggle,html.dark .nn-s1-group-title{color:#a1a1aa}.nn-s1-focus-toggle:hover,.nn-s1-group-title:hover{background:#0000000a}html.dark .nn-s1-focus-toggle:hover,html.dark .nn-s1-group-title:hover{background:#ffffff0d}.nn-s1-focus-icon{color:#f59e0b;font-size:.85rem}.nn-s1-focus-count{font-size:.65rem;padding:0 5px;border-radius:999px;background:#1677ff1f;color:#1677ff;line-height:1.5}.nn-s1-chevron{margin-left:auto;font-size:.65rem;opacity:.55}.nn-s1-focus-list,.nn-s1-group-items{display:flex;flex-direction:column;gap:1px;padding:0 6px 4px}.nn-s1-sidebar-scroll{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;padding-bottom:8px}.nn-s1-groups{padding-bottom:4px}.nn-s1-group{margin-top:2px}.nn-s1-nav-item{width:100%;display:flex;align-items:center;gap:8px;padding:7px 10px;border-radius:8px;font-size:.8rem;color:#333;cursor:pointer;text-align:left;transition:background .15s,color .15s}html.dark .nn-s1-nav-item{color:var(--color-text)}.nn-s1-nav-item:hover{background:#1677ff0f}.nn-s1-nav-item.active{background:#e6f4ff;color:#1677ff;font-weight:600}html.dark .nn-s1-nav-item.active{background:#1677ff2e;color:#60a5fa}.nn-s1-nav-icon{width:20px;height:20px;border-radius:50%;object-fit:cover;flex-shrink:0;background:#fff}.nn-s1-nav-label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.nn-s1-settings{width:100%;display:flex;align-items:center;gap:6px;padding:10px 14px;font-size:.8rem;color:#666;cursor:pointer;background:#f5f5f5}.nn-s1-footer{flex-shrink:0;position:relative;z-index:2;border-top:1px solid rgba(0,0,0,.06);background:#f5f5f5;box-shadow:0 -4px 12px #0000000a}html.dark .nn-s1-footer{background:#2a2a2e;border-top-color:#ffffff14;box-shadow:0 -4px 12px #0003}html.dark .nn-s1-settings{background:#2a2a2e;color:#a1a1aa}.nn-s1-settings:hover{color:#1677ff;background:#1677ff0d}.nn-s1-settings-icon{font-size:.95rem}.nn-s1-menu-wrap{position:absolute;left:10px;bottom:calc(100% + 4px)}.nn-s1-dropdown{left:0;right:auto;bottom:calc(100% + 4px);top:auto}.nn-s1-main{flex:1;min-width:0;display:flex;flex-direction:column;position:relative;background:#fff}html.dark .nn-s1-main{background:#1f1f23}.nn-s1-content-head{flex-shrink:0;padding:14px 18px 8px;border-bottom:1px solid rgba(0,0,0,.05);display:flex;align-items:center;justify-content:space-between;gap:10px}.nn-s1-focus-btn{flex-shrink:0;font-size:1.1rem}html.dark .nn-s1-content-head{border-bottom-color:#ffffff0f}.nn-s1-source{display:flex;align-items:center;gap:10px}.nn-s1-source-icon{width:32px;height:32px;border-radius:50%;object-fit:cover}.nn-s1-source-name{font-size:1rem;font-weight:700;color:#222}html.dark .nn-s1-source-name{color:var(--color-text)}.nn-s1-source-tag{margin-left:6px;font-size:.68rem;font-weight:400;opacity:.55}.nn-s1-source-updated{font-size:.68rem;opacity:.5;margin-top:2px}.nn-s1-content-body{flex:1;overflow-y:auto;padding:8px 18px 64px;min-height:0}.nn-s1-content-body.is-loading{opacity:.55}.nn-s1-list{list-style:none;display:flex;flex-direction:column;gap:2px}.nn-s1-item{display:flex;align-items:flex-start;gap:10px;padding:9px 10px;border-radius:8px;cursor:pointer;line-height:1.45;font-size:.88rem;color:#222;transition:color .2s ease,background .2s ease,transform .15s ease}html.dark .nn-s1-item{color:var(--color-text)}.nn-s1-item:hover{color:#1677ff;background:#1677ff14;transform:translate(3px)}html.dark .nn-s1-item:hover{color:#60a5fa;background:#60a5fa1f}.nn-s1-rank{min-width:24px;font-size:.82rem;color:#999;flex-shrink:0}.nn-s1-item:hover .nn-s1-rank{color:#1677ff}.nn-s1-title{flex:1;min-width:0}.nn-s1-heat{flex-shrink:0;font-size:.75rem;color:#f97316;white-space:nowrap}.nn-s1-list-timeline .nn-s1-item{align-items:flex-start}.nn-s1-item-main{flex:1;min-width:0;display:flex;flex-direction:column;gap:4px}.nn-s1-list-timeline .nn-s1-meta{font-size:.68rem;opacity:.5}.nn-s1-empty,.nn-s1-empty-side{padding:24px 12px;text-align:center;opacity:.5;font-size:.8rem}.nn-s1-error{padding:16px;color:#f87171;font-size:.8rem}.nn-s1-fabs{position:absolute;right:18px;bottom:18px;display:flex;flex-direction:column;gap:10px;z-index:5}.nn-s1-fab{width:40px;height:40px;border-radius:50%;background:#fff;box-shadow:0 2px 12px #0000001f;display:flex;align-items:center;justify-content:center;font-size:1.1rem;color:#666;cursor:pointer;transition:box-shadow .2s,color .2s,transform .15s}html.dark .nn-s1-fab{background:#2a2a2e;color:#a1a1aa;box-shadow:0 2px 12px #00000059}.nn-s1-fab:hover{color:#1677ff;box-shadow:0 4px 16px #1677ff33;transform:translateY(-1px)}.nn-s1-fab.is-spinning{animation:nn-spin .8s linear infinite;pointer-events:none}.nn-s1-fab-top[hidden]{display:none!important} diff --git a/plugins/newsnow/assets/main-D8qa8V4m.js b/plugins/newsnow/assets/main-D8qa8V4m.js new file mode 100644 index 00000000..3c5150d6 --- /dev/null +++ b/plugins/newsnow/assets/main-D8qa8V4m.js @@ -0,0 +1,251 @@ +(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))o(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const i of s.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&o(i)}).observe(document,{childList:!0,subtree:!0});function n(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function o(r){if(r.ep)return;r.ep=!0;const s=n(r);fetch(r.href,s)}})();function Q(e){const t=String(e||"").trim();return t?t.replace(/\/+$/,""):""}function ye(e,t,n={}){const o=Q(e);if(!o)throw new Error("API 基址不能为空");if(!t)throw new Error("sourceId 不能为空");const r=new URL("/api/s",`${o}/`);return r.searchParams.set("id",t),n.latest&&r.searchParams.set("latest","true"),r.toString()}function tt(e,t,n={}){if(!n.isDev)return e;try{const o=new URL(e),r=Q(t),s=Q("https://newsnow.busiyi.world");if(r===s&&o.pathname.startsWith("/api/"))return`${o.pathname}${o.search}`}catch{}return e}function xe(e){try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}const nt=["focus","hottest","realtime","updated"],ot=[{id:"focus",label:"关注",kind:"column"},{id:"hottest",label:"热搜",kind:"column"},{id:"realtime",label:"新闻",kind:"column"},{id:"search",label:"搜索",kind:"action"}],st={focus:"关注",hottest:"热搜",realtime:"新闻",updated:"更新"},rt={tech:"科技",china:"国内",world:"国际",finance:"财经",sports:"体育",other:"其他"},at=["tech","china","world","finance","sports","other"],it={"newsnow-news":"realtime","newsnow-hot":"hottest","newsnow-browse":"focus"},ct=["internal","ubrowser","external"],lt=["style1","style2","style3"],be={style1:"风格1(侧栏)",style2:"风格2(卡片)",style3:"风格3(即将支持)"};function ut(e){return it[e]??"realtime"}function Ae(e){return e==="updated"?"realtime":nt.includes(e)?e:"realtime"}const dt={redirect:"v2ex-share",name:"V2EX",column:"tech",home:"https://v2ex.com/",color:"slate",interval:6e5,title:"最新分享"},ft={name:"知乎",type:"hottest",column:"china",home:"https://www.zhihu.com",color:"blue",interval:6e5},pt={title:"实时热搜",name:"微博",type:"hottest",column:"china",home:"https://weibo.com",color:"red",interval:12e4},ht={name:"联合早报",type:"realtime",desc:"来自第三方网站: 早晨报",column:"world",home:"https://www.zaobao.com",color:"red",interval:18e5},mt={title:"今日最热",name:"酷安",type:"hottest",column:"tech",home:"https://coolapk.com",color:"green",interval:6e5},gt={redirect:"mktnews-flash",name:"MKTNews",column:"finance",home:"https://mktnews.net",color:"indigo",interval:12e4,title:"快讯"},vt={redirect:"wallstreetcn-quick",name:"华尔街见闻",type:"realtime",column:"finance",home:"https://wallstreetcn.com/",color:"blue",interval:3e5,title:"快讯"},yt={name:"抖音",type:"hottest",column:"china",home:"https://www.douyin.com",color:"gray",interval:6e5},bt={title:"主干道热帖",name:"虎扑",type:"hottest",column:"sports",home:"https://hupu.com",color:"red",interval:6e5},St={title:"头条",name:"懂球帝",type:"realtime",column:"sports",home:"https://www.dongqiudi.com",color:"green",interval:6e5},wt={name:"AIHOT",type:"realtime",column:"tech",home:"https://aihot.virxact.com/all",color:"blue",interval:3e5},$t={title:"热议",name:"百度贴吧",type:"hottest",column:"china",home:"https://tieba.baidu.com",color:"blue",interval:6e5},Lt={name:"今日头条",type:"hottest",column:"china",home:"https://www.toutiao.com",color:"red",interval:6e5},Et={name:"IT之家",type:"realtime",column:"tech",home:"https://www.ithome.com",color:"red",interval:6e5},qt={title:"热榜",name:"澎湃新闻",type:"hottest",column:"china",home:"https://www.thepaper.cn",color:"gray",interval:18e5},kt={name:"卫星通讯社",column:"world",home:"https://sputniknews.cn",color:"orange",interval:6e5},Ct={name:"参考消息",column:"world",home:"https://china.cankaoxiaoxi.com",color:"red",interval:18e5},Tt={redirect:"pcbeta-windows11",name:"远景论坛",type:"realtime",column:"tech",home:"https://bbs.pcbeta.com",color:"blue",interval:3e5,title:"Win11"},xt={redirect:"cls-telegraph",name:"财联社",type:"realtime",column:"finance",home:"https://www.cls.cn",color:"red",interval:3e5,title:"电报"},At={redirect:"xueqiu-hotstock",name:"雪球",type:"hottest",column:"finance",home:"https://xueqiu.com",color:"blue",interval:12e4,title:"热门股票"},Mt={title:"事件",name:"格隆汇",type:"realtime",column:"finance",home:"https://www.gelonghui.com",color:"blue",interval:12e4},Ot={redirect:"fastbull-express",name:"法布财经",type:"realtime",column:"finance",home:"https://www.fastbull.cn",color:"emerald",interval:12e4,title:"快讯"},Pt={name:"Solidot",column:"tech",home:"https://solidot.org",color:"teal",interval:36e5},Ut={name:"Hacker News",type:"hottest",column:"tech",home:"https://news.ycombinator.com/",color:"orange",interval:6e5},Ft={name:"Product Hunt",type:"hottest",column:"tech",home:"https://www.producthunt.com/",color:"red",interval:6e5},Dt={redirect:"github-trending-today",name:"Github",type:"hottest",column:"tech",home:"https://github.com/",color:"gray",interval:6e5,title:"Today"},Ht={redirect:"bilibili-hot-search",name:"哔哩哔哩",type:"hottest",column:"china",home:"https://www.bilibili.com",color:"blue",interval:6e5,title:"热搜"},Nt={name:"快手",type:"hottest",disable:"cf",column:"china",home:"https://www.kuaishou.com",color:"orange",interval:6e5},jt={name:"靠谱新闻",desc:"不一定靠谱,多看多思考",column:"world",home:"https://kaopu.news/",color:"gray",interval:18e5},Rt={name:"金十数据",type:"realtime",column:"finance",home:"https://www.jin10.com",color:"blue",interval:6e5},Bt={name:"百度热搜",type:"hottest",column:"china",home:"https://www.baidu.com",color:"blue",interval:6e5},_t={name:"牛客",type:"hottest",column:"china",home:"https://www.nowcoder.com",color:"blue",interval:6e5},Kt={name:"少数派",type:"hottest",column:"tech",home:"https://sspai.com",color:"red",interval:6e5},Gt={name:"稀土掘金",type:"hottest",column:"tech",home:"https://juejin.cn",color:"blue",interval:6e5},It={title:"热点资讯",name:"凤凰网",type:"hottest",column:"china",home:"https://www.ifeng.com",color:"red",interval:6e5},zt={redirect:"chongbuluo-latest",name:"虫部落",column:"china",home:"https://www.chongbuluo.com/forum.php?mod=guide&view=newthread",color:"green",interval:18e5,title:"最新"},Yt={title:"热门电影",name:"豆瓣",type:"hottest",column:"china",home:"https://www.douban.com",color:"green",interval:6e5},Xt={title:"在线人数",name:"Steam",type:"hottest",column:"world",home:"https://store.steampowered.com",color:"blue",interval:6e5},Wt={redirect:"tencent-hot",name:"腾讯新闻",type:"hottest",column:"china",home:"https://news.qq.com/tag/aEWqxLtdgmQ=",color:"blue",interval:18e5,title:"综合早报"},Vt={title:"网络安全",name:"Freebuf",type:"hottest",column:"china",home:"https://www.freebuf.com/",color:"green",interval:6e5},Qt={redirect:"qqvideo-tv-hotsearch",name:"腾讯视频",type:"hottest",column:"china",home:"https://v.qq.com/channel/tv",color:"blue",interval:18e5,title:"热搜榜"},Jt={redirect:"iqiyi-hot-ranklist",name:"爱奇艺",type:"hottest",column:"china",home:"https://www.iqiyi.com",color:"green",interval:18e5,title:"热播榜"},k={v2ex:dt,"v2ex-share":{name:"V2EX",column:"tech",home:"https://v2ex.com/",color:"slate",interval:6e5,title:"最新分享"},zhihu:ft,weibo:pt,zaobao:ht,coolapk:mt,mktnews:gt,"mktnews-flash":{name:"MKTNews",column:"finance",home:"https://mktnews.net",color:"indigo",interval:12e4,title:"快讯"},wallstreetcn:vt,"wallstreetcn-quick":{name:"华尔街见闻",type:"realtime",column:"finance",home:"https://wallstreetcn.com/",color:"blue",interval:3e5,title:"快讯"},"wallstreetcn-news":{name:"华尔街见闻",column:"finance",home:"https://wallstreetcn.com/",color:"blue",interval:18e5,title:"最新"},"wallstreetcn-hot":{name:"华尔街见闻",type:"hottest",column:"finance",home:"https://wallstreetcn.com/",color:"blue",interval:18e5,title:"最热"},"36kr":{redirect:"36kr-quick",name:"36氪",type:"realtime",disable:"cf",column:"tech",home:"https://36kr.com",color:"blue",interval:6e5,title:"快讯"},"36kr-quick":{name:"36氪",type:"realtime",disable:"cf",column:"tech",home:"https://36kr.com",color:"blue",interval:6e5,title:"快讯"},"36kr-renqi":{name:"36氪",type:"hottest",disable:"cf",column:"tech",home:"https://36kr.com",color:"blue",interval:6e5,title:"人气榜"},douyin:yt,hupu:bt,dongqiudi:St,aihot:wt,tieba:$t,toutiao:Lt,ithome:Et,thepaper:qt,sputniknewscn:kt,cankaoxiaoxi:Ct,pcbeta:Tt,"pcbeta-windows11":{name:"远景论坛",type:"realtime",column:"tech",home:"https://bbs.pcbeta.com",color:"blue",interval:3e5,title:"Win11"},cls:xt,"cls-telegraph":{name:"财联社",type:"realtime",column:"finance",home:"https://www.cls.cn",color:"red",interval:3e5,title:"电报"},"cls-depth":{name:"财联社",column:"finance",home:"https://www.cls.cn",color:"red",interval:6e5,title:"深度"},"cls-hot":{name:"财联社",type:"hottest",column:"finance",home:"https://www.cls.cn",color:"red",interval:6e5,title:"热门"},xueqiu:At,"xueqiu-hotstock":{name:"雪球",type:"hottest",column:"finance",home:"https://xueqiu.com",color:"blue",interval:12e4,title:"热门股票"},gelonghui:Mt,fastbull:Ot,"fastbull-express":{name:"法布财经",type:"realtime",column:"finance",home:"https://www.fastbull.cn",color:"emerald",interval:12e4,title:"快讯"},"fastbull-news":{name:"法布财经",column:"finance",home:"https://www.fastbull.cn",color:"emerald",interval:18e5,title:"头条"},solidot:Pt,hackernews:Ut,producthunt:Ft,github:Dt,"github-trending-today":{name:"Github",type:"hottest",column:"tech",home:"https://github.com/",color:"gray",interval:6e5,title:"Today"},bilibili:Ht,"bilibili-hot-search":{name:"哔哩哔哩",type:"hottest",column:"china",home:"https://www.bilibili.com",color:"blue",interval:6e5,title:"热搜"},"bilibili-hot-video":{name:"哔哩哔哩",type:"hottest",disable:"cf",column:"china",home:"https://www.bilibili.com",color:"blue",interval:6e5,title:"热门视频"},"bilibili-ranking":{name:"哔哩哔哩",type:"hottest",disable:"cf",column:"china",home:"https://www.bilibili.com",color:"blue",interval:18e5,title:"排行榜"},kuaishou:Nt,kaopu:jt,jin10:Rt,baidu:Bt,nowcoder:_t,sspai:Kt,juejin:Gt,ifeng:It,chongbuluo:zt,"chongbuluo-latest":{name:"虫部落",column:"china",home:"https://www.chongbuluo.com/forum.php?mod=guide&view=newthread",color:"green",interval:18e5,title:"最新"},"chongbuluo-hot":{name:"虫部落",type:"hottest",column:"china",home:"https://www.chongbuluo.com/forum.php?mod=guide&view=hot",color:"green",interval:18e5,title:"最热"},douban:Yt,steam:Xt,tencent:Wt,"tencent-hot":{name:"腾讯新闻",type:"hottest",column:"china",home:"https://news.qq.com/tag/aEWqxLtdgmQ=",color:"blue",interval:18e5,title:"综合早报"},freebuf:Vt,qqvideo:Qt,"qqvideo-tv-hotsearch":{name:"腾讯视频",type:"hottest",column:"china",home:"https://v.qq.com/channel/tv",color:"blue",interval:18e5,title:"热搜榜"},iqiyi:Jt,"iqiyi-hot-ranklist":{name:"爱奇艺",type:"hottest",column:"china",home:"https://www.iqiyi.com",color:"green",interval:18e5,title:"热播榜"}},Zt=["dongqiudi","producthunt","aihot","36kr-quick","36kr-renqi","cankaoxiaoxi","cls-telegraph","cls-depth","cls-hot","fastbull-express","fastbull-news","freebuf","jin10","kaopu","mktnews-flash","solidot","weibo","bilibili-hot-search","bilibili-hot-video","bilibili-ranking","kuaishou","toutiao"];function Z(e){return!(!e||e.redirect||e.disable===!0||e.disable==="cf")}function Se(e,t){return Object.entries(t).filter(([,n])=>n.type===e&&Z(n)).map(([n])=>n).sort((n,o)=>n.localeCompare(o))}function X(e,t){return Object.entries(t).filter(([,n])=>n.column===e&&Z(n)).map(([n])=>n)}function en(e=k){return{focus:[],hottest:Se("hottest",e),realtime:Se("realtime",e),updated:Zt.filter(t=>Z(e[t])),china:X("china",e),world:X("world",e),tech:X("tech",e),finance:X("finance",e),sports:X("sports",e)}}function H(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function tn(e=k){return Object.entries(e).filter(([,t])=>Z(t)).map(([t,n])=>({id:t,name:n.name,title:n.title,column:n.column,color:n.color,type:n.type}))}function Me(e,t=rt){const n=new Map;for(const o of e){const r=o.column||"other";n.has(r)||n.set(r,[]),n.get(r).push(o)}return at.filter(o=>n.has(o)).map(o=>({key:o,label:t[o]??o,items:n.get(o)}))}const nn=["focus","hottest","realtime"];function on(e){return st[e]??e}function Oe(e,t,n){return e==="focus"?[...t]:[...n[e]??[]]}function sn(e,t){if(!(t!=null&&t.length))return e;const n=new Set(t);return e.filter(o=>!n.has(o))}function pe(e,t){if(!(t!=null&&t.length))return e;const n=new Map(t.map((o,r)=>[o,r]));return[...e].sort((o,r)=>{const s=n.has(o)?n.get(o):Number.MAX_SAFE_INTEGER,i=n.has(r)?n.get(r):Number.MAX_SAFE_INTEGER;return s!==i?s-i:o.localeCompare(r)})}function we(e,t,n){const o=[...e[t]??[]],r=o.indexOf(n);return r===-1?o.push(n):o.splice(r,1),{...e,[t]:o}}function Pe(e,t,n){const o=e.filter(s=>s!==t),r=o.indexOf(n);return r===-1?(o.push(t),o):(o.splice(r,0,t),o)}function $e(e,t,n,o){const r=Oe(e,t,n),s=new Set(r),i=Object.entries(o).filter(([,c])=>Z(c)?e==="focus"?!0:c.type===e:!1).map(([c])=>c).filter(c=>!s.has(c));return[...r,...i]}function U(e,t,n,o,r){const s=Oe(e,t,n),i=sn(s,o[e]??[]),c=r[e];return c!=null&&c.length?pe(i,c):i}function rn(e,t,n){const o={focus:[],hottest:[],realtime:[]};if(!Array.isArray(e))return o;const r=new Set(e);for(const s of n)r.has(s)||o.focus.push(s);for(const s of t.hottest??[])r.has(s)||o.hottest.push(s);for(const s of t.realtime??[])r.has(s)||o.realtime.push(s);return o}function an(e,t=Date.now()){return{id:String(e.id),sourceId:e.sourceId,title:e.title,url:e.url,savedAt:e.savedAt??t,tags:Array.isArray(e.tags)?[...e.tags]:[]}}function Ue(e){if(!e)return"";const t=typeof e=="number"?e:Date.parse(String(e));if(Number.isNaN(t))return"";const n=new Date(t),o=n.getFullYear(),r=String(n.getMonth()+1).padStart(2,"0"),s=String(n.getDate()).padStart(2,"0");return`${o}-${r}-${s}`}function cn(e,t={}){var r,s;const n=((r=t.query)==null?void 0:r.trim().toLowerCase())??"",o=((s=t.tag)==null?void 0:s.trim())??"";return e.filter(i=>o&&!(i.tags??[]).includes(o)?!1:n?[i.title,i.url,i.sourceId,...i.tags??[],Ue(i.savedAt)].join(" ").toLowerCase().includes(n):!0)}function ln(e){const t=new Set;for(const n of e)for(const o of n.tags??[])t.add(o);return[...t].sort((n,o)=>n.localeCompare(o))}function un(e,t){const n=t.trim();return!n||e.includes(n)?e:[...e,n].sort((o,r)=>o.localeCompare(r))}function dn(e,t,n){const o=n.trim();return o?e.map(r=>{if(E(r)!==t)return r;const s=r.tags??[];return s.includes(o)?r:{...r,tags:[...s,o]}}):e}function K(e,t){return e.some(n=>E(n)===t)}function E(e){return`${e.sourceId}:${e.id}`}function Fe(e,t){const n=E(t);return e.some(o=>E(o)===n)?e:[an(t),...e]}function De(e,t){return e.filter(n=>E(n)!==t)}function fn(e,t){const n=E(t);return K(e,n)?De(e,n):Fe(e,t)}const Le={baseUrl:"https://newsnow.busiyi.world",theme:"dark",uiStyle:"style1",lastStyle1Source:null,openMode:"external",focusSources:[],enabledSources:null,disabledSources:{focus:[],hottest:[],realtime:[]},sourceOrder:{},cardLayout:{},cardSizes:{},favoriteTags:[],favorites:[],lastColumn:"updated"};function pn(e){if(!e||typeof e!="object")return{...Le,disabledSources:{focus:[],hottest:[],realtime:[]},sourceOrder:{},cardLayout:{},cardSizes:{},favoriteTags:[],favorites:[]};const t=e.disabledSources&&typeof e.disabledSources=="object"?{focus:Array.isArray(e.disabledSources.focus)?[...e.disabledSources.focus]:[],hottest:Array.isArray(e.disabledSources.hottest)?[...e.disabledSources.hottest]:[],realtime:Array.isArray(e.disabledSources.realtime)?[...e.disabledSources.realtime]:[]}:{focus:[],hottest:[],realtime:[]},n=e.uiStyle==="style2"||e.uiStyle==="style3"?e.uiStyle:"style1";return{...Le,...e,uiStyle:n,lastStyle1Source:typeof e.lastStyle1Source=="string"&&e.lastStyle1Source?e.lastStyle1Source:null,focusSources:Array.isArray(e.focusSources)?[...e.focusSources]:[],enabledSources:Array.isArray(e.enabledSources)?[...e.enabledSources]:e.enabledSources,disabledSources:t,sourceOrder:e.sourceOrder&&typeof e.sourceOrder=="object"?{...e.sourceOrder}:{},cardLayout:hn(e),cardSizes:mn(e),favoriteTags:Array.isArray(e.favoriteTags)?[...e.favoriteTags]:[],favorites:Array.isArray(e.favorites)?e.favorites.map(o=>({...o,tags:Array.isArray(o.tags)?[...o.tags]:[]})):[]}}function hn(e){return e!=null&&e.cardLayout&&typeof e.cardLayout=="object"?{...e.cardLayout}:{}}function mn(e){if(!(e!=null&&e.cardSizes)||typeof e.cardSizes!="object")return{};const t={};for(const[n,o]of Object.entries(e.cardSizes)){if(!o||typeof o!="object")continue;const r={};typeof o.width=="number"&&o.width>0&&(r.width=o.width),typeof o.height=="number"&&o.height>0&&(r.height=o.height),(r.width||r.height)&&(t[n]=r)}return t}function N(){return typeof ztools<"u"?ztools:null}function gn(e){try{const t=N();if(t!=null&&t.dbStorage)return t.dbStorage.getItem(e);const n=localStorage.getItem(e);return n?JSON.parse(n):null}catch{return null}}function vn(e,t){const n=N();n!=null&&n.dbStorage?n.dbStorage.setItem(e,t):localStorage.setItem(e,JSON.stringify(t))}function ee(e){const t=N();if(t!=null&&t.showNotification){t.showNotification(e);return}}function yn(e){const t=N();if(t!=null&&t.shellOpenExternal){t.shellOpenExternal(e);return}window.open(e,"_blank")}function bn(e){const t=N();if(!(t!=null&&t.createBrowserWindow)||!xe(e))return!1;const n=`./viewer.html?url=${encodeURIComponent(e)}`;try{return!!t.createBrowserWindow(n,{width:1024,height:720,center:!0,minWidth:480,minHeight:360})}catch{return!1}}function Sn(e,t,n){if(!e||e==="#")return;const o=N();if(!o){window.open(e,"_blank");return}if(t==="external"){o.shellOpenExternal(e);return}if(t==="ubrowser"){if(bn(e))return;if(o.shellOpenExternal){o.shellOpenExternal(e),ee("独立窗口打开失败,已改用系统浏览器");return}window.open(e,"_blank");return}n(e)}function wn(e){const t=N();t!=null&&t.onPluginEnter&&t.onPluginEnter(e)}const He="newsnow-settings",$n="2.0.0",C=en(),Ee=tn(),p=document.getElementById("app"),P=document.getElementById("overlay-root");let $=null,M="";const ae=new Set;let F=!0,ce=!1,a=Ln(),L=Ae(a.lastColumn),j=null;const m=new Map;let D=null;function Ln(){const e=pn(gn(He));return $=e.lastStyle1Source,e}function y(){a.lastColumn=L,a.uiStyle==="style1"&&$&&(a.lastStyle1Source=$),vn(He,a)}function te(){const e=a.disabledSources,t=!e.focus.length&&!e.hottest.length&&!e.realtime.length;Array.isArray(a.enabledSources)&&t&&(a.disabledSources=rn(a.enabledSources,C,a.focusSources),a.enabledSources=null,y())}function Ne(){const e=p.querySelector("#nn-main"),t={mainTop:(e==null?void 0:e.scrollTop)??0,mainLeft:(e==null?void 0:e.scrollLeft)??0,bodies:new Map};return p.querySelectorAll(".nn-card").forEach(n=>{const o=n.querySelector(".nn-card-body");o&&n.dataset.sourceId&&t.bodies.set(n.dataset.sourceId,o.scrollTop)}),t}function je(e){requestAnimationFrame(()=>{const t=p.querySelector("#nn-main");t&&(t.scrollTop=e.mainTop,t.scrollLeft=e.mainLeft),e.bodies.forEach((n,o)=>{const r=p.querySelector(`.nn-card[data-source-id="${o}"] .nn-card-body`);r&&(r.scrollTop=n)})})}function En(){if(a.cardLayout.width||a.cardLayout.height)return;const e=Object.values(a.cardSizes).find(t=>(t==null?void 0:t.width)||(t==null?void 0:t.height));e&&(a.cardLayout={width:e.width,height:e.height},a.cardSizes={},y())}function le(){const{width:e,height:t}=a.cardLayout,n=document.documentElement,o=p.querySelector("#nn-cards");t?n.style.setProperty("--card-height",`${t}px`):n.style.removeProperty("--card-height"),e?(n.style.setProperty("--card-width",`${e}px`),o==null||o.classList.add("has-custom-width")):(n.style.removeProperty("--card-width"),o==null||o.classList.remove("has-custom-width"))}function Re(){const e=document.documentElement;e.classList.toggle("dark",a.theme==="dark"),e.classList.toggle("light",a.theme==="light")}function ue(e){if(!e)return"";const t=typeof e=="number"?e:Date.parse(String(e));if(Number.isNaN(t))return"";const n=Date.now()-t,o=Math.floor(n/6e4);if(o<1)return"刚刚";if(o<60)return`${o}分钟前`;const r=Math.floor(o/60);return r<24?`${r}小时前`:`${Math.floor(r/24)}天前`}function Be(e){return!e.favId||!e.favSource?null:{id:e.favId,sourceId:e.favSource,title:decodeURIComponent(e.favTitle||""),url:decodeURIComponent(e.favUrl||"")}}function qn(e){const t=Be(e);if(t)return a.favorites=fn(a.favorites,t),y(),E(t)}function kn(e){const t=Be(e);if(!t)return;const n=E(t);return K(a.favorites,n)||(a.favorites=Fe(a.favorites,t),y()),n}function qe(e){if(!e.dataset.favId)return;const t=K(a.favorites,E({sourceId:e.dataset.favSource,id:e.dataset.favId}));e.classList.contains("nn-item-star")&&(e.classList.toggle("active",t),e.textContent=t?"★":"☆")}function de(e){e.querySelectorAll("[data-fav-id]").forEach(t=>{t.addEventListener("click",n=>{n.preventDefault(),n.stopPropagation(),qn(t.dataset),qe(t)})}),e.querySelectorAll(".nn-fav-link").forEach(t=>{t.addEventListener("auxclick",n=>{if(n.button!==1)return;n.preventDefault(),n.stopPropagation(),kn(t.dataset);const o=t.querySelector(".nn-item-star");o?qe(o):ee("已收藏")})})}function me(){return te(),U(L,a.focusSources,C,a.disabledSources,a.sourceOrder)}function ne(e){const t=Q(a.baseUrl),n=e.split("-")[0];return`${t}/icons/${n}.png`}function Cn(e){T(),P.innerHTML=` +
+
+ + ${e} + +
+ +
+ `,D=t=>{const n=t.target;n.dataset.action==="webview-close"&&T(),n.dataset.action==="webview-external"&&yn(e)},P.addEventListener("click",D)}function oe(e){Sn(e,a.openMode,Cn)}async function G(e,t={}){ye(a.baseUrl,e,t);const n=async o=>{var l;const r=ye(a.baseUrl,e,{latest:o});if((l=window.newsnowServices)!=null&&l.fetchSource)return window.newsnowServices.fetchSource(r);const s=tt(r,a.baseUrl,{isDev:!1}),i=await fetch(s);if(!i.ok)throw new Error(`HTTP ${i.status}`);const c=await i.json();if(c!=null&&c.error)throw new Error(c.message||"请求失败");return c};try{return await n(!!t.latest)}catch(o){if(t.latest)return n(!1);throw o}}async function O({refresh:e=!1,preserveScroll:t=!1}={}){var o,r;if(a.uiStyle==="style1"){z(),await Y($,{refresh:e,preserveScroll:t});return}const n=me();if(!n.length){m.clear(),A({preserveScroll:t});return}for(const s of n)!e&&((o=m.get(s))!=null&&o.data)||m.set(s,{loading:!0,data:((r=m.get(s))==null?void 0:r.data)??null,error:null});A({preserveScroll:t}),await Promise.all(n.map(async s=>{var i,c,l;if(!(!e&&((i=m.get(s))!=null&&i.data)&&!((c=m.get(s))!=null&&c.loading))){try{const u=await G(s,{latest:e});m.set(s,{loading:!1,data:u,error:null})}catch(u){m.set(s,{loading:!1,data:((l=m.get(s))==null?void 0:l.data)??null,error:u instanceof Error?u.message:"获取失败"})}A({preserveScroll:t})}})),Tn()}function Tn(){j&&requestAnimationFrame(()=>{const e=p.querySelector(`.nn-card[data-source-id="${j}"]`);e?(e.scrollIntoView({behavior:"smooth",block:"nearest"}),setTimeout(()=>{j=null,e.classList.remove("is-highlight")},2e3)):j=null})}function T(){D&&(P.removeEventListener("click",D),D=null),P.innerHTML=""}function I(e,t,n){T(),P.innerHTML=` +
+
+ +
+ `,D=r=>{r.target.dataset.action==="close"&&T()},P.addEventListener("click",D);const o=P.querySelector(".nn-modal");o&&n(o)}function ke(e){const t=k[e];if(t){if(a.uiStyle==="style1"){a.focusSources.includes(e)||(a.focusSources=H(a.focusSources,e)),$=e,F=!0,y(),T(),Y(e);return}t.type==="hottest"?L="hottest":t.type==="realtime"?L="realtime":L="focus",a.focusSources.includes(e)||(a.focusSources=H(a.focusSources,e)),j=e,y(),T(),O()}}function xn(e){const t=e.trim().toLowerCase();return t?Ee.filter(n=>n.name.toLowerCase().includes(t)||n.id.toLowerCase().includes(t)||n.title&&n.title.toLowerCase().includes(t)):Ee}function An(e,t){return e.length?e.map(n=>` +
+

${n.label}

+ +
`).join(""):'
无匹配数据源
'}function R(e){return e?`
${ve(e,{preview:!0})}
`:'
选择左侧数据源预览内容
'}async function Mn(e){var t;if(!(!e||(t=m.get(e))!=null&&t.data)){m.set(e,{loading:!0,data:null,error:null});try{const n=await G(e);m.set(e,{loading:!1,data:n,error:null})}catch(n){m.set(e,{loading:!1,data:null,error:n instanceof Error?n.message:"获取失败"})}}}function _e(){const e={query:"",selectedId:null,composing:!1};I("","",t=>{t.classList.add("nn-search-modal-wrap"),t.innerHTML=` + +
+ +
+
`;const n=t.querySelector("#search-input"),o=t.querySelector("#search-sidebar"),r=t.querySelector("#search-preview"),s=()=>{const f=xn(e.query);return{filtered:f,groups:Me(f)}},i=f=>{var h;(!e.selectedId||!f.some(v=>v.id===e.selectedId))&&(e.selectedId=((h=f[0])==null?void 0:h.id)??null)},c=f=>{const h=o.querySelector(`[data-search-focus="${f}"]`);if(!h)return;const v=a.focusSources.includes(f);h.classList.toggle("active",v),h.textContent=v?"★":"☆"},l=()=>({onFocusChange:c}),u=(f=!1)=>{var h;o.querySelectorAll(".nn-search-item").forEach(v=>{v.classList.toggle("is-selected",v.dataset.source===e.selectedId)}),f&&((h=o.querySelector(".nn-search-item.is-selected"))==null||h.scrollIntoView({block:"nearest"}))},d=()=>{const{filtered:f,groups:h}=s();i(f);const v=o.scrollTop;o.innerHTML=An(h,e.selectedId),o.scrollTop=v},g=async f=>{var h;r&&(r.innerHTML=R(f),B(r,f,l()),f&&!((h=m.get(f))!=null&&h.data)&&(await Mn(f),e.selectedId===f&&(r.innerHTML=R(f),B(r,f,l()))))},b=(f,h={})=>{e.selectedId!==f&&(e.selectedId=f,u(h.scrollIntoView??!1),g(f))};n.addEventListener("compositionstart",()=>{e.composing=!0}),n.addEventListener("compositionend",()=>{e.composing=!1,e.query=n.value,d(),g(e.selectedId)}),n.addEventListener("input",()=>{e.composing||(e.query=n.value,d(),g(e.selectedId))}),n.addEventListener("keydown",f=>{if(f.key==="Enter"&&e.selectedId&&(f.preventDefault(),ke(e.selectedId)),f.key==="ArrowDown"||f.key==="ArrowUp"){f.preventDefault();const{filtered:h}=s(),v=h.map(x=>x.id),S=v.indexOf(e.selectedId??"");if(S===-1)return;const w=f.key==="ArrowDown"?v[Math.min(S+1,v.length-1)]:v[Math.max(S-1,0)];w&&b(w,{scrollIntoView:!0})}}),o.addEventListener("click",f=>{const h=f.target.closest("[data-search-focus]");if(h){f.stopPropagation();const S=h.dataset.searchFocus;a.focusSources=H(a.focusSources,S),y();const w=a.focusSources.includes(S);h.classList.toggle("active",w),h.textContent=w?"★":"☆",e.selectedId===S&&(r.innerHTML=R(S),B(r,S,l()));return}const v=f.target.closest("[data-source]");if(v){if(f.detail===2){ke(v.dataset.source);return}b(v.dataset.source)}}),d(),g(e.selectedId),n.focus()})}function B(e,t,n={}){var r,s;if(!e||!t)return;const{onFocusChange:o}=n;(r=e.querySelector("[data-refresh]"))==null||r.addEventListener("click",async i=>{var l,u;i.stopPropagation();const c=e.querySelector("[data-refresh]");if(c){c.classList.add("is-spinning"),m.set(t,{loading:!0,data:((l=m.get(t))==null?void 0:l.data)??null,error:null}),e.innerHTML=R(t),B(e,t,n);try{const d=await G(t,{latest:!0});m.set(t,{loading:!1,data:d,error:null})}catch(d){m.set(t,{loading:!1,data:((u=m.get(t))==null?void 0:u.data)??null,error:d instanceof Error?d.message:"获取失败"})}e.innerHTML=R(t),B(e,t,n)}}),(s=e.querySelector("[data-focus]"))==null||s.addEventListener("click",i=>{i.stopPropagation(),a.focusSources=H(a.focusSources,t),y(),e.innerHTML=R(t),B(e,t,n),o==null||o(t)}),e.querySelectorAll("[data-url]").forEach(i=>{i.addEventListener("click",c=>{c.preventDefault(),c.stopPropagation(),oe(decodeURIComponent(i.dataset.url))})}),de(e)}function On(){const e={query:"",tag:"",editingKey:null,composing:!1},t=()=>[...new Set([...a.favoriteTags,...ln(a.favorites)])].sort((s,i)=>s.localeCompare(i)),n=s=>{const i=s.querySelector("#fav-list"),c=s.querySelector("#fav-empty");if(!i||!c)return;const l=cn(a.favorites,{query:e.query,tag:e.tag});if(!l.length){i.innerHTML="",i.hidden=!0,c.hidden=!1,c.textContent=a.favorites.length?"无匹配收藏":"暂无收藏资讯";return}if(i.hidden=!1,c.hidden=!0,i.innerHTML=l.map(u=>{const d=E(u),g=(u.tags??[]).map(h=>`${h}`).join(""),b=e.editingKey===d,f=t().map(h=>``).join("");return`
  • +
    + ${u.title} + ${g} + ${Ue(u.savedAt)} + + +
    +
    + +
    ${f||'暂无已有标签'}
    +
    +
  • `}).join(""),e.editingKey){const u=i.querySelector(`.nn-tag-input[data-key="${e.editingKey}"]`);u==null||u.focus()}},o=s=>{const i=s.querySelector("#fav-tag-filter");if(!i)return;const c=t();i.innerHTML=`${c.map(l=>``).join("")}`,i.value=e.tag},r=(s,i,c)=>{const l=c.trim();l&&(a.favorites=dn(a.favorites,i,l),a.favoriteTags=un(a.favoriteTags,l),y(),e.editingKey=i,o(s),n(s))};I("","",s=>{s.classList.add("nn-fav-modal-wrap"),s.innerHTML=` +
    +

    我的收藏

    + +
    +
    + +
    +
    + + +
    `;const i=s.querySelector("#fav-search"),c=s.querySelector("#fav-tag-filter");i.addEventListener("compositionstart",()=>{e.composing=!0}),i.addEventListener("compositionend",()=>{e.composing=!1,e.query=i.value,n(s)}),i.addEventListener("input",()=>{e.composing||(e.query=i.value,n(s))}),c.addEventListener("change",()=>{e.tag=c.value,n(s)}),s.addEventListener("click",l=>{const u=l.target.closest("[data-url]");if(u){oe(decodeURIComponent(u.dataset.url));return}const d=l.target.closest("[data-pick]");if(d){r(s,d.dataset.key,d.dataset.pick);return}const g=l.target.closest("[data-edit]");if(g){e.editingKey=e.editingKey===g.dataset.edit?null:g.dataset.edit,n(s);return}const b=l.target.closest("[data-remove]");b&&(a.favorites=De(a.favorites,b.dataset.remove),e.editingKey===b.dataset.remove&&(e.editingKey=null),y(),o(s),n(s),A({preserveScroll:!0}))}),s.addEventListener("keydown",l=>{const u=l.target.closest(".nn-tag-input");!u||l.key!=="Enter"||(l.preventDefault(),r(s,u.dataset.key,u.value),u.value="")}),o(s),n(s),i.focus()})}function Pn(){let e=L==="focus"||L==="hottest"||L==="realtime"?L:"realtime";I("","",t=>{t.classList.add("nn-settings-modal-wrap");const n=r=>{const s=t.querySelector("#source-settings");s&&(s.querySelectorAll("[data-toggle]").forEach(i=>{i.addEventListener("change",c=>{c.stopPropagation();const l=i.dataset.toggle,u=i.checked;r==="focus"?u?(a.focusSources.includes(l)||(a.focusSources=[...a.focusSources,l]),a.disabledSources={...a.disabledSources,focus:(a.disabledSources.focus??[]).filter(d=>d!==l)}):a.disabledSources=we(a.disabledSources,r,l):u?a.disabledSources={...a.disabledSources,[r]:(a.disabledSources[r]??[]).filter(d=>d!==l)}:a.disabledSources=we(a.disabledSources,r,l),y(),O({preserveScroll:!0})})}),s.querySelectorAll("li[data-id]").forEach(i=>{const c=i.querySelector(".nn-settings-drag");c==null||c.addEventListener("mousedown",l=>{l.preventDefault(),l.stopPropagation();const u=i.dataset.id,d=i.getBoundingClientRect(),g=i.cloneNode(!0);g.classList.add("nn-settings-ghost"),g.style.width=`${d.width}px`,g.style.height=`${d.height}px`,document.body.appendChild(g),i.classList.add("dragging");const b=(v,S)=>{g.style.left=`${v-d.width/2}px`,g.style.top=`${S-d.height/2}px`};b(l.clientX,l.clientY);const f=v=>{var w;b(v.clientX,v.clientY);const S=(w=document.elementFromPoint(v.clientX,v.clientY))==null?void 0:w.closest("li[data-id]");s.querySelectorAll("li").forEach(x=>x.classList.remove("drag-over")),S&&S!==i&&S.classList.add("drag-over")},h=v=>{var w,x;document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",h),g.remove(),i.classList.remove("dragging");const S=(w=document.elementFromPoint(v.clientX,v.clientY))==null?void 0:w.closest("li[data-id]");if(s.querySelectorAll("li").forEach(se=>se.classList.remove("drag-over")),u&&S&&S.dataset.id&&S!==i){const se=$e(r,a.focusSources,C,k),et=(x=a.sourceOrder[r])!=null&&x.length?pe(se,a.sourceOrder[r]):se;if(a.sourceOrder[r]=Pe(et,u,S.dataset.id),r==="focus"){const fe=a.sourceOrder[r].filter(re=>a.focusSources.includes(re));for(const re of a.sourceOrder[r])fe.includes(re)||fe.push(re);a.focusSources=fe}y(),o(),O({preserveScroll:!0})}};document.addEventListener("mousemove",f),document.addEventListener("mouseup",h)})}))},o=()=>{var l;const r=e,s=$e(r,a.focusSources,C,k),i=new Set(a.disabledSources[r]??[]),c=(l=a.sourceOrder[r])!=null&&l.length?pe(s,a.sourceOrder[r]):s;t.innerHTML=` +

    数据源设置

    +
    + ${nn.map(u=>``).join("")} +
    + +

    拖拽调整顺序;开关切换启用状态。各栏目与首页 Tab 一致。

    `,t.querySelectorAll("[data-settings-tab]").forEach(u=>{u.addEventListener("click",()=>{e=u.dataset.settingsTab,o()})}),n(r)};o()})}function Un(){I("API 基址",` +
    + + +
    `,e=>{var n,o;const t=e.querySelector("#api-input");(n=e.querySelector("[data-action='cancel']"))==null||n.addEventListener("click",r=>{r.stopPropagation(),T()}),(o=e.querySelector("[data-action='save']"))==null||o.addEventListener("click",r=>{r.stopPropagation();const s=Q(t.value);if(!xe(s)){ee("请输入有效的 http(s) 地址");return}a.baseUrl=s,m.clear(),y(),T(),O({refresh:!0})}),t.focus()})}function Fn(){const e={internal:"插件内 Web",ubrowser:"独立窗口",external:"系统浏览器"};I("打开方式",``,t=>{var n;(n=t.querySelector("#open-mode-list"))==null||n.addEventListener("click",o=>{const r=o.target.closest("li[data-mode]");r&&(o.stopPropagation(),a.openMode=r.dataset.mode,y(),t.querySelectorAll("#open-mode-list li").forEach(s=>{s.classList.toggle("is-selected",s.dataset.mode===a.openMode);const i=s.querySelector("span:last-child");i&&(i.textContent=s.dataset.mode===a.openMode?"✓":"")}),ee(`已切换为:${e[a.openMode]}`))})})}function Dn(){return te(),[...new Set([...U("focus",a.focusSources,C,a.disabledSources,a.sourceOrder),...U("hottest",a.focusSources,C,a.disabledSources,a.sourceOrder),...U("realtime",a.focusSources,C,a.disabledSources,a.sourceOrder)])]}function q(e){return String(e).replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}function Ce(e,t){let n=String(e);return t!=null&&t.startsWith("github")&&(n=n.replace(/\s*\/\s*/," / ").replace(/\s+/g," ").trim()),n}function Hn(e,t){var r,s;const n=t.trim().toLowerCase();return n?(((s=(r=m.get(e))==null?void 0:r.data)==null?void 0:s.items)??[]).some(i=>Ke(i,n)):!1}function Ke(e,t){var o,r;return[e.title,(o=e.extra)==null?void 0:o.info,(r=e.extra)==null?void 0:r.hover].filter(Boolean).map(s=>String(s).toLowerCase()).some(s=>s.includes(t))}function ie(e,t){const n=t.trim().toLowerCase();return n?e.filter(o=>{const r=k[o];return r?r.name.toLowerCase().includes(n)||o.toLowerCase().includes(n)||r.title&&r.title.toLowerCase().includes(n)||Hn(o,n):!1}):e}function Nn(e,t){const n=t.trim().toLowerCase();return n?e.filter(o=>Ke(o,n)):e}function ge(e=""){return te(),ie(U("focus",a.focusSources,C,a.disabledSources,a.sourceOrder),e)}function Ge(e=""){te();const t=ge(e),n=new Set(t),o=ie(U("hottest",a.focusSources,C,a.disabledSources,a.sourceOrder).filter(u=>!n.has(u)),e),r=ie(U("realtime",a.focusSources,C,a.disabledSources,a.sourceOrder).filter(u=>!n.has(u)),e),s=[];o.length&&s.push({key:"hottest",label:"热搜",items:o}),r.length&&s.push({key:"realtime",label:"新闻",items:r});const i=new Set([...t,...o,...r]),c=ie(Dn().filter(u=>!i.has(u)),e),l=Me(c.map(u=>{const d=k[u];return{id:u,name:(d==null?void 0:d.name)??u,title:d==null?void 0:d.title,column:d==null?void 0:d.column,color:d==null?void 0:d.color,type:d==null?void 0:d.type}}));for(const u of l)s.push({key:u.key,label:u.label,items:u.items.map(d=>d.id)});return s}function z(){const e=ge(M),t=Ge(M),n=[...new Set([...e,...t.flatMap(o=>o.items)])];return $&&n.includes($)||($=n[0]??null),$}function jn(e){const t=e.extra??{};if(t.num!=null&&t.num!=="")return String(t.num);if(t.hot!=null&&t.hot!=="")return String(t.hot);if(t.info){const o=String(t.info),r=o.match(/[\d,.]+/);if(r)return r[0];if(o.length<=12)return o}const n=t.hover;return n!=null&&String(n).length<=8&&/^[\d,.]+/.test(String(n))?String(n):""}function Rn(e,t,n,o=M){const r=Nn(t,o);return r.length?n.type==="hottest"?`
      ${r.map((s,i)=>{const c=E({sourceId:e,id:s.id}),l=K(a.favorites,c),u=s.url||"#",d=jn(s),g=q(Ce(s.title,e));return`
    1. + + ${i+1} + ${g} + ${d?`🔥 ${q(d)}`:""} + ${l?"★":"☆"} + +
    2. `}).join("")}
    `:`
      ${r.map(s=>{var f,h;const i=s.url||"#",c=s.id||`${s.title}-${s.pubDate||""}`,l=ue(s.pubDate||((f=s.extra)==null?void 0:f.date)),u=E({sourceId:e,id:c}),d=K(a.favorites,u),g=q(Ce(s.title,e)),b=(h=s.extra)!=null&&h.info?q(String(s.extra.info)):"";return`
    1. + + + ${q(l)}${b?` · ${b}`:""} + ${g} + + ${d?"★":"☆"} + +
    2. `}).join("")}
    `:o.trim()?'
    无匹配资讯
    ':'
    暂无数据
    '}function Ie(e){var c,l;if(!e)return'
    请选择左侧信息源
    ';const t=k[e];if(!t)return'
    信息源不可用
    ';const n=m.get(e)??{},o=n.error?n.error:n.loading?"加载中...":(c=n.data)!=null&&c.updatedTime?`${ue(n.data.updatedTime)}更新`:"",r=((l=n.data)==null?void 0:l.items)??[],s=n.error?`
    ${q(n.error)}
    `:Rn(e,r,t),i=a.focusSources.includes(e);return` +
    +
    + +
    +
    ${q(t.name)}${t.title?`${q(t.title)}`:""}
    +
    ${q(o)}
    +
    +
    + +
    +
    + ${s} +
    `}function ze(){const e=Ge(M),t=ge(M),n=z(),o=c=>{const l=k[c];return l?``:""},r=a.focusSources.length,s=`
    + +
    + ${t.length?t.map(o).join(""):'
    暂无关注频道
    '} +
    +
    `,i=e.map(c=>{const l=ae.has(c.key);return`
    + +
    + ${c.items.map(o).join("")} +
    +
    `}).join("");return` + ${s} +
    ${i||'
    无匹配信息源
    '}
    `}function Bn(){return` +
    + +
    +
    + ${ze()} +
    + `}function _n(){const e=a.theme==="dark"?"浅色模式":"深色模式";return` + `}function W(e={}){const n=e.preserveScroll??!1?Ye():null,o=z();p.innerHTML=` +
    + +
    + ${Ie(o)} +
    + + +
    +
    +
    `;const r=p.querySelector("#nn-s1-search");r&&(r.value=M),Kn(),n&&Xe(n)}function J(){const e=p.querySelector("#nn-s1-sidebar-scroll");if(!e)return;const t=e.scrollTop;e.innerHTML=ze(),e.scrollTop=t,We()}function V(){const e=p.querySelector("#nn-s1-main");if(!e)return;const t=Ye(),n=e.querySelector(".nn-s1-fabs"),o=Ie($),r=document.createElement("div");r.innerHTML=o+"";const s=r.querySelector(".nn-s1-content-head"),i=r.querySelector(".nn-s1-content-body"),c=e.querySelector(".nn-s1-content-head"),l=e.querySelector(".nn-s1-content-body");c&&s&&c.replaceWith(s),l&&i&&l.replaceWith(i),Ve(),Xe(t)}function Te(){z(),J(),V()}function Ye(){const e=p.querySelector("#nn-s1-scroll");return{scrollTop:(e==null?void 0:e.scrollTop)??0}}function Xe(e){requestAnimationFrame(()=>{const t=p.querySelector("#nn-s1-scroll");t&&(t.scrollTop=e.scrollTop),he()})}function he(){const e=p.querySelector("#nn-s1-scroll"),t=p.querySelector(".nn-s1-fab-top");!e||!t||(t.hidden=e.scrollTop<=8)}async function Y(e,{refresh:t=!1,preserveScroll:n=!1}={}){var o,r,s,i;if(!e){W({preserveScroll:n});return}if(!t&&((o=m.get(e))!=null&&o.data)){if(p.querySelector(".nn-s1")){V();return}W({preserveScroll:n});return}p.querySelector(".nn-s1")?(m.set(e,{loading:!0,data:((r=m.get(e))==null?void 0:r.data)??null,error:null}),V()):(m.set(e,{loading:!0,data:((s=m.get(e))==null?void 0:s.data)??null,error:null}),W({preserveScroll:n}));try{const c=await G(e,{latest:t});m.set(e,{loading:!1,data:c,error:null})}catch(c){m.set(e,{loading:!1,data:((i=m.get(e))==null?void 0:i.data)??null,error:c instanceof Error?c.message:"获取失败"})}p.querySelector(".nn-s1")?(V(),M.trim()&&J()):W({preserveScroll:n})}function We(){var e;(e=p.querySelector("[data-s1-toggle-focus]"))==null||e.addEventListener("click",()=>{F=!F,J()}),p.querySelectorAll("[data-s1-toggle-group]").forEach(t=>{t.addEventListener("click",()=>{const n=t.dataset.s1ToggleGroup;n&&(ae.has(n)?ae.delete(n):ae.add(n),J())})}),p.querySelectorAll("[data-s1-source]").forEach(t=>{t.addEventListener("click",()=>{const n=t.dataset.s1Source;!n||n===$||($=n,y(),Y(n))})})}function Ve(){var e,t;(e=p.querySelector("[data-s1-focus]"))==null||e.addEventListener("click",n=>{n.stopPropagation();const o=n.currentTarget.dataset.s1Focus;if(!o)return;const r=a.focusSources.includes(o);a.focusSources=H(a.focusSources,o),r||(F=!0),y(),J(),V()}),(t=p.querySelector("#nn-s1-scroll"))==null||t.addEventListener("scroll",he),p.querySelectorAll("#nn-s1-main [data-url]").forEach(n=>{n.addEventListener("click",o=>{o.preventDefault(),o.stopPropagation(),oe(decodeURIComponent(n.dataset.url))})}),de(p.querySelector("#nn-s1-main")??p),he()}function Kn(){var n,o,r;const e=p.querySelector("#nn-s1-search");let t=!1;e==null||e.addEventListener("compositionstart",()=>{t=!0}),e==null||e.addEventListener("compositionend",()=>{t=!1,e&&(M=e.value,Te())}),e==null||e.addEventListener("input",()=>{t||!e||(M=e.value,Te())}),(n=p.querySelector("[data-action='menu']"))==null||n.addEventListener("click",s=>{s.stopPropagation();const i=p.querySelector(".nn-s1-dropdown");i&&(i.hidden=!i.hidden)}),ce||(ce=!0,document.addEventListener("click",()=>{const s=p.querySelector(".nn-dropdown:not([hidden]), .nn-s1-dropdown:not([hidden])");s&&(s.hidden=!0)})),Qe(p.querySelector(".nn-s1-dropdown")),(o=p.querySelector("[data-action='go-top']"))==null||o.addEventListener("click",()=>{var s;(s=p.querySelector("#nn-s1-scroll"))==null||s.scrollTo({top:0,behavior:"smooth"})}),(r=p.querySelector("[data-action='refresh-s1']"))==null||r.addEventListener("click",async s=>{const i=s.currentTarget;$&&(i.classList.add("is-spinning"),await Y($,{refresh:!0,preserveScroll:!0}),i.classList.remove("is-spinning"))}),We(),Ve()}function Qe(e){e&&e.addEventListener("click",t=>{t.stopPropagation();const n=t.target.closest("li[data-menu]");if(!n||n.classList.contains("disabled"))return;const o=n.dataset.menu;e.hidden=!0,o==="theme"?(a.theme=a.theme==="dark"?"light":"dark",Re(),y(),A({preserveScroll:!0})):o==="style"?Gn():o==="favorites"?On():o==="sources"?Pn():o==="api"?Un():o==="open-mode"&&Fn()})}function Gn(){I("风格样式",` +

    风格1 为默认侧栏布局;风格3 即将推出。

    `,e=>{var t;(t=e.querySelector("#style-list"))==null||t.addEventListener("click",n=>{const o=n.target.closest("li[data-style]");if(!o||o.classList.contains("disabled"))return;n.stopPropagation();const r=o.dataset.style;!r||r===a.uiStyle||(a.uiStyle=r,m.clear(),y(),T(),A(),a.uiStyle==="style1"?(z(),Y($)):O(),ee(`已切换为:${be[r]}`))})})}function In(){return ot.map(e=>e.kind==="action"?``:``).join("")}function zn(){const e=a.theme==="dark"?"浅色模式":"深色模式";return` + `}function ve(e,t={}){var g,b;const{preview:n=!1}=t,o=k[e];if(!o)return"";const r=m.get(e)??{},s=a.focusSources.includes(e),i=j===e,c=r.error?r.error:r.loading?"加载中...":(g=r.data)!=null&&g.updatedTime?`${ue(r.data.updatedTime)}更新`:"",l=((b=r.data)==null?void 0:b.items)??[],u=l.length>0?o.type==="hottest"?`
      ${l.map((f,h)=>{const v=E({sourceId:e,id:f.id}),S=K(a.favorites,v),w=f.url||"#";return`
    1. + + ${h+1} + ${f.title} + ${S?"★":"☆"} + +
    2. `}).join("")}
    `:`
      ${l.map(f=>{var w,x;const h=f.url||"#",v=f.id||`${f.title}-${f.pubDate||""}`;return`
    1. +
      ${ue(f.pubDate||((w=f.extra)==null?void 0:w.date))}${((x=f.extra)==null?void 0:x.info)||""}
      + ${f.title} +
    2. `}).join("")}
    `:r.error?`
    ${r.error}
    `:'
    暂无数据
    ',d=o.color||"slate";return` +
    +
    +
    + +
    +
    + ${o.name} + ${o.title?`${o.title}`:""} +
    +
    ${c}
    +
    +
    +
    + + + ${n?"":`⋮⋮`} +
    +
    +
    ${u}
    + ${n?"":`
    +
    `} +
    `}function Yn(e={}){const n=e.preserveScroll??!1?Ne():null,o=me();p.innerHTML=` +
    +
    + NewsNow +
    +
    News
    +
    Now
    +
    + v${$n} +
    + +
    + + + + + ${zn()} + +
    +
    +
    +
    +
    + ${o.length?o.map(r=>ve(r)).join(""):`
    ${L==="focus"?"点击卡片 ☆ 或「搜索」添加关注频道":"当前栏目无可用数据源"}
    `} +
    +
    +
    + `,Xn(),le(),n&&je(n)}function A(e={}){if(a.uiStyle==="style1"){W(e);return}Yn(e)}function Xn(){var n,o,r;p.querySelectorAll("[data-column]").forEach(s=>{s.addEventListener("click",()=>{L=s.dataset.column,y(),O()})}),(n=p.querySelector("[data-action='search']"))==null||n.addEventListener("click",()=>{_e()}),(o=p.querySelector("[data-action='refresh-all']"))==null||o.addEventListener("click",s=>{const i=s.currentTarget;i.classList.add("is-spinning"),O({refresh:!0,preserveScroll:!0}).finally(()=>{i.classList.remove("is-spinning")})}),(r=p.querySelector("[data-action='go-top']"))==null||r.addEventListener("click",()=>{var s;(s=p.querySelector("#nn-main"))==null||s.scrollTo({top:0,behavior:"smooth"})});const e=p.querySelector("[data-action='menu']"),t=p.querySelector(".nn-dropdown");e==null||e.addEventListener("click",s=>{s.stopPropagation(),t&&(t.hidden=!t.hidden)}),ce||(ce=!0,document.addEventListener("click",()=>{const s=p.querySelector(".nn-dropdown:not([hidden]), .nn-s1-dropdown:not([hidden])");s&&(s.hidden=!0)})),Qe(t),p.querySelectorAll("[data-refresh]").forEach(s=>{s.addEventListener("click",async i=>{var l,u;i.stopPropagation();const c=s.dataset.refresh;s.classList.add("is-spinning"),m.set(c,{loading:!0,data:((l=m.get(c))==null?void 0:l.data)??null,error:null}),_(c);try{const d=await G(c,{latest:!0});m.set(c,{loading:!1,data:d,error:null})}catch(d){m.set(c,{loading:!1,data:((u=m.get(c))==null?void 0:u.data)??null,error:d instanceof Error?d.message:"获取失败"})}_(c)})}),p.querySelectorAll("[data-focus]").forEach(s=>{s.addEventListener("click",i=>{i.stopPropagation();const c=s.dataset.focus;a.focusSources=H(a.focusSources,c),y(),_(c)})}),p.querySelectorAll("[data-url]").forEach(s=>{s.addEventListener("click",i=>{i.preventDefault(),i.stopPropagation(),oe(decodeURIComponent(s.dataset.url))})}),de(p),Qn(),Wn()}function Wn(){const e=p.querySelector("#nn-cards");e&&e.querySelectorAll(".nn-drag-handle").forEach(t=>{Je(t,e)})}function Vn(e,t){const n=document.createElement("article");n.className=`${e.className} nn-card-ghost`.replace(/\bdragging\b/g,"").trim(),e.dataset.color&&(n.dataset.color=e.dataset.color),e.dataset.sourceId&&(n.dataset.sourceId=e.dataset.sourceId);const o=e.querySelector(".nn-card-head");return o&&n.appendChild(o.cloneNode(!0)),n.style.width=`${t.width}px`,n.style.height=`${t.height}px`,n}function Je(e,t){e.addEventListener("mousedown",n=>{n.preventDefault(),n.stopPropagation();const o=e.closest(".nn-card");if(!o)return;const r=o.dataset.sourceId,s=o.getBoundingClientRect(),i=Vn(o,s);document.body.appendChild(i),o.classList.add("dragging");const c=(d,g)=>{i.style.left=`${d-s.width/2}px`,i.style.top=`${g-s.height/2}px`};c(n.clientX,n.clientY);const l=d=>{var b;c(d.clientX,d.clientY);const g=(b=document.elementFromPoint(d.clientX,d.clientY))==null?void 0:b.closest(".nn-card");t.querySelectorAll(".nn-card").forEach(f=>f.classList.remove("drag-over")),g&&g!==o&&g.classList.add("drag-over")},u=d=>{var b;document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",u),i.remove(),o.classList.remove("dragging");const g=(b=document.elementFromPoint(d.clientX,d.clientY))==null?void 0:b.closest(".nn-card");if(t.querySelectorAll(".nn-card").forEach(f=>f.classList.remove("drag-over")),r&&g&&g!==o){const f=me(),h=Pe(f,r,g.dataset.sourceId);a.sourceOrder[L]=h,L==="focus"&&(a.focusSources=h),y(),A({preserveScroll:!0})}};document.addEventListener("mousemove",l),document.addEventListener("mouseup",u)})}function Ze(e){if(e.classList.contains("is-preview"))return;const t=e.querySelector("[data-resize-w]"),n=e.querySelector("[data-resize-h]");t==null||t.addEventListener("mousedown",o=>{o.preventDefault(),o.stopPropagation();const r=o.clientX,s=p.querySelector(".nn-card:not(.is-preview)"),i=(s==null?void 0:s.getBoundingClientRect().width)??a.cardLayout.width??280,c=u=>{const d=Math.max(180,Math.round(i+u.clientX-r));a.cardLayout={...a.cardLayout,width:d},le()},l=()=>{document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",l),y()};document.addEventListener("mousemove",c),document.addEventListener("mouseup",l)}),n==null||n.addEventListener("mousedown",o=>{o.preventDefault(),o.stopPropagation();const r=o.clientY,s=p.querySelector(".nn-card:not(.is-preview)"),i=(s==null?void 0:s.getBoundingClientRect().height)??a.cardLayout.height??248,c=u=>{const d=Math.max(160,Math.round(i+u.clientY-r));a.cardLayout={...a.cardLayout,height:d},le()},l=()=>{document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",l),y()};document.addEventListener("mousemove",c),document.addEventListener("mouseup",l)})}function Qn(e=p){e.querySelectorAll(".nn-card:not(.is-preview)").forEach(Ze)}function _(e){const t=p.querySelector("#nn-cards"),n=p.querySelector(`.nn-card[data-source-id="${e}"]`);if(!t||!n){A({preserveScroll:!0});return}const o=Ne(),r=document.createElement("div");r.innerHTML=ve(e);const s=r.firstElementChild;s&&(n.replaceWith(s),Jn(s),je(o))}function Jn(e){var o,r;(o=e.querySelector("[data-refresh]"))==null||o.addEventListener("click",async s=>{var l,u;s.stopPropagation();const i=e.querySelector("[data-refresh]"),c=i==null?void 0:i.dataset.refresh;if(!(!c||!i)){i.classList.add("is-spinning"),m.set(c,{loading:!0,data:((l=m.get(c))==null?void 0:l.data)??null,error:null}),_(c);try{const d=await G(c,{latest:!0});m.set(c,{loading:!1,data:d,error:null})}catch(d){m.set(c,{loading:!1,data:((u=m.get(c))==null?void 0:u.data)??null,error:d instanceof Error?d.message:"获取失败"})}_(c)}}),(r=e.querySelector("[data-focus]"))==null||r.addEventListener("click",s=>{s.stopPropagation();const i=e.querySelector("[data-focus]"),c=i==null?void 0:i.dataset.focus;c&&(a.focusSources=H(a.focusSources,c),y(),_(c))}),e.querySelectorAll("[data-url]").forEach(s=>{s.addEventListener("click",i=>{i.preventDefault(),i.stopPropagation(),oe(decodeURIComponent(s.dataset.url))})}),de(e);const t=e.querySelector(".nn-drag-handle"),n=p.querySelector("#nn-cards");t&&n&&Je(t,n),Ze(e)}function Zn({code:e}){if(L=Ae(ut(e)),y(),a.uiStyle==="style1"){z(),Y($);return}O()}function eo(){document.addEventListener("keydown",e=>{e.target.matches("input, textarea, [contenteditable]")||((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()==="k"&&(e.preventDefault(),_e()),e.key==="Escape"&&P.innerHTML&&T())})}function to(){wn(Zn)}Re();te();En();le();eo();to();A();O(); diff --git a/plugins/newsnow/index.html b/plugins/newsnow/index.html new file mode 100644 index 00000000..066b9ea0 --- /dev/null +++ b/plugins/newsnow/index.html @@ -0,0 +1,14 @@ + + + + + + NewsNow + + + + +
    +
    + + diff --git a/plugins/newsnow/logo.png b/plugins/newsnow/logo.png new file mode 100644 index 00000000..4878a79e Binary files /dev/null and b/plugins/newsnow/logo.png differ diff --git a/plugins/newsnow/package.json b/plugins/newsnow/package.json new file mode 100644 index 00000000..53820f7f --- /dev/null +++ b/plugins/newsnow/package.json @@ -0,0 +1,4 @@ +{ + "type": "commonjs", + "private": true +} diff --git a/plugins/newsnow/plugin.json b/plugins/newsnow/plugin.json new file mode 100644 index 00000000..52c68af9 --- /dev/null +++ b/plugins/newsnow/plugin.json @@ -0,0 +1,37 @@ +{ + "name": "newsnow", + "title": "NewsNow", + "description": "实时新闻快讯与多平台热搜订阅", + "version": "2.0.0", + "author": "crisy", + "logo": "logo.png", + "main": "index.html", + "preload": "preload.js", + "pluginSetting": { + "single": true, + "height": 640 + }, + "features": [ + { + "code": "newsnow-news", + "explain": "NewsNow - 实时新闻快讯", + "cmds": [ + "新闻" + ] + }, + { + "code": "newsnow-hot", + "explain": "NewsNow - 多平台热搜热榜", + "cmds": [ + "热搜" + ] + }, + { + "code": "newsnow-browse", + "explain": "NewsNow - 看一看订阅频道", + "cmds": [ + "看一看" + ] + } + ] +} diff --git a/plugins/newsnow/preload.js b/plugins/newsnow/preload.js new file mode 100644 index 00000000..2bde9ce3 --- /dev/null +++ b/plugins/newsnow/preload.js @@ -0,0 +1,91 @@ +/** + * NewsNow preload — 远程 API 请求(Node.js https) + */ +const https = require("node:https"); +const http = require("node:http"); + +function buildHeaders(origin) { + return { + Accept: "application/json, text/plain, */*", + "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8", + "User-Agent": + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36", + Referer: `${origin}/`, + }; +} + +function parseErrorMessage(body, statusCode) { + try { + const json = JSON.parse(body); + if (json.message) return String(json.message); + if (json.statusMessage) return String(json.statusMessage); + } catch { + // ignore + } + if (statusCode === 500) return "源站暂不可用"; + return `HTTP ${statusCode}`; +} + +function requestJson(urlString) { + return new Promise((resolve, reject) => { + let url; + try { + url = new URL(urlString); + } catch (error) { + reject(error); + return; + } + + const origin = `${url.protocol}//${url.host}`; + const lib = url.protocol === "https:" ? https : http; + const options = { + hostname: url.hostname, + port: url.port || (url.protocol === "https:" ? 443 : 80), + path: `${url.pathname}${url.search}`, + method: "GET", + headers: buildHeaders(origin), + }; + + const req = lib.request(options, (res) => { + if (res.statusCode && res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) { + requestJson(new URL(res.headers.location, urlString).toString()).then(resolve).catch(reject); + return; + } + let body = ""; + res.setEncoding("utf8"); + res.on("data", (chunk) => { + body += chunk; + }); + res.on("end", () => { + if (res.statusCode && res.statusCode >= 400) { + reject(new Error(parseErrorMessage(body, res.statusCode))); + return; + } + try { + const json = JSON.parse(body); + if (json.error) { + reject(new Error(json.message || json.statusMessage || "请求失败")); + return; + } + resolve(json); + } catch (error) { + reject(new Error("响应不是有效 JSON")); + } + }); + }); + + req.on("error", reject); + req.on("timeout", () => { + req.destroy(); + reject(new Error("请求超时")); + }); + req.setTimeout(20000); + req.end(); + }); +} + +window.newsnowServices = { + fetchSource(apiUrl) { + return requestJson(apiUrl); + }, +}; diff --git a/plugins/newsnow/viewer.html b/plugins/newsnow/viewer.html new file mode 100644 index 00000000..beab7f0c --- /dev/null +++ b/plugins/newsnow/viewer.html @@ -0,0 +1,43 @@ + + + + + + 加载中… + + + + + +