Skip to content

Add 天气 · 新闻看板 Mini App (weather-news-board) - #170

Merged
MyPrototypeWhat merged 16 commits into
MiniMax-AI:mainfrom
lixiangroir-Ideal:feat/weather-news-board
Nov 30, 2026
Merged

MyPrototypeWhat merged 16 commits into
MiniMax-AI:mainfrom
lixiangroir-Ideal:feat/weather-news-board

Conversation

@lixiangroir-Ideal

@lixiangroir-Ideal lixiangroir-Ideal commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Adds a standalone Mini App that puts live weather, A-share and international commodity quotes, and six switchable news columns on one dashboard page. The watchlist takes a six-digit code, an index or ETF label, or a plain name — typing 银行 lists the matching securities and you pick one of them, and a grip on each row drags the entries into the order you want. A filter field under the news tabs narrows the current column down to the entries that mention the words you typed.

This branch contains a merge of this repository's main, so the root README row can sit next to the Weekly Planner row that landed upstream after this pull request was opened.

Tested environment

  • MiniMax Code 3.1.19 on Windows 11 (Windows 10.0.26200, x64), Node.js 24.16.0.
  • npm run validate reports plugins/lixiangroir-ideal/weather-news-board: OK and repository: OK, exit code 0. The two commands the CI workflow runs, npm ci followed by npm run check, were executed locally on this machine: 94 of the 96 repository tests pass, and the two that fail are the symlink fixtures described below.
  • The package carries its own self-tests under tests/, run with Node's built-in test runner and no dependencies: node --test "plugins/lixiangroir-ideal/weather-news-board/tests/*.test.mjs" — 68 cases, all passing. layout.test.mjs takes the client's own <script id="wnb-layout"> block apart and runs it, so the tests exercise the code the page really executes; security-aliases.test.mjs pins down the exchange of every index and ETF name; security-index.test.mjs covers the parsing of the upstream search response, the candidate order, the local cache and the alias fallback; watchlist-order.test.mjs covers the reorder validation; news-filter.test.mjs takes the client's own <script id="wnb-news-filter"> block apart and runs it the same way the layout block is tested. The repository's npm run check only runs the repository's own tests, so this command has to be run separately.
  • The Mini App was published and opened in the desktop app. The Client acceptance covered: the page is not blank and its landmarks, headings, tabs, and controls are reachable; the layout was driven through CSS container queries at 420 px, 640 px, 1100 px and 1440 px container widths, reflowing from one column to two to three, with every watchlist entry staying inside its card, no horizontal overflow at any width, and the watchlist packing into as many columns as the available width allows; a height difference of 0 px was measured between the weather card and the watchlist card in the two-column layout, with the hourly forecast growing and shrinking to the space that is actually free; the resize handle of each of the three cards was dragged in turn and the card took exactly the dragged width and height while the other two cards kept their own sizes, with a live W × H readout while dragging and the content scrolling inside a card whose height was set by hand; a single click on a handle restored that one card to the automatic size and the reset button in the top bar cleared all three; a page reload brought the per-card sizes back; the dark theme was checked; watchlist entries were added and removed; every news tab was switched; one auto-refresh cycle was observed to advance the quote timestamp and the price; two news requests without refresh=1 returned the same updatedAt while the same request with it returned a new one, so the refresh button really re-fetches the news instead of replaying the cached column; all six news columns and the quote list were read back and every returned link starts with https; in the three-column layout at 1100 px the weather card and the watchlist card again differ by 0 px, with all six hourly steps visible; a saved size of 5000 x 8 was clamped back into the container when the page was loaded and rendered as 495 x 220; a board whose two cards had been sized by hand so that they no longer fitted (260 px + 495 px inside a 734 px column) was pulled back to 260 px + 458 px, with the board's scroll width equal to its client width, so nothing was cut off on the right; the same check was repeated with all three cards set to 900 px at 640 px and 1100 px container widths, and a handle dragged past the right edge made the neighbour card shrink to its minimum width instead of letting the board overflow; three cards stored at 900 px inside a 1052 px column settle at 340 px each rather than 260/260/500 px, so the cards that share a row shrink evenly; the size read from the drag badge during that drag was the one actually applied (458 px) rather than the one the pointer had reached (751 px); a vertical scrollbar appearing once the content had rendered took 15 px off the available width and the stored sizes were pulled back to match; a page reload preserved the watchlist, the selected tab, and the theme. The console showed 0 errors and 0 warnings, and the network showed no failed requests.
  • Startup resilience: with the service made unreachable, the title bar counted the retries down — 1 s, 2 s, 4 s, 7 s, 10 s — and then reported that the service was not ready instead of leaving a stale "starting" notice; once the service came back, /api/board and /api/stocks answered 200 again, the notice disappeared and the board recovered by itself. A watchlist entry added while the service was down for 3 s was retried and applied as soon as the service returned, then removed again.
  • Layout control: entering focus mode on the weather card hid the other two cards and gave it the full 734 px board width, the top bar offered Exit focus, and leaving focus mode brought all three cards back. While a card was being resized, every card in the same row showed the width range it could still take (260–458 px) while the card in the row below showed none, and the size badge carried the same range without being clipped at the viewport edge. From the keyboard, ArrowRight widened a card by 16 px, Shift+ArrowRight by 64 px, ArrowDown grew its height by 16 px, Shift+ArrowLeft narrowed it by 64 px, and Home put it back to the automatic size with a confirmation toast.
  • Watchlist: typing 沪深300 produced the row 沪深300 on sh000300 with a live quote, 科创50ETF resolved to sh588000, and 上证指数 (sh000001), 深证成指 (sz399001), 创业板指 (sz399006), 科创50 (sh000688), 上证50 (sh000016), 中证500 (sh000905), 中证1000 (sh000852), 创业板50 (sz399673), 北证50 (bj899050), 沪深300ETF (sh510300), 上证50ETF (sh510050), 创业板ETF (sz159915), 科创50ETF (sh588000), 证券ETF (sh512880) and 中概互联网ETF (sh513050) each returned a quote. An unknown name was rejected with the allow-list message and left the watchlist unchanged.
  • Watchlist name search: typing 银行 returned twelve candidates — 浦发银行 (sh600000), 华夏银行 (sh600015), 民生银行, 招商银行, 无锡银行 and the rest — with the sector result (银行Ⅱ) filtered out. ArrowDown moved the selection to 华夏银行 and Enter added it; the new row showed sh600015 with a live quote and the entry count moved to five, and removing that entry again brought the watchlist back to four. The search endpoint returns twelve candidates for 银行 in about 0.2 s. With the upstream made unreachable, the locally cached names, the cached index names and the built-in index and ETF names are each returned in turn, so the field keeps working.
  • Watchlist reorder: the grip handle of the last entry was dragged with the mouse up to the first place in the two-column grid; the entry moved to the front, the request that stores the new order answered 200, and the new order was in watchlist.json afterwards. An entry was then moved down one place with the arrow keys on the focused handle — it moved, the focus stayed on that handle after the list was rendered again, and that request answered 200 as well. Restarting the Mini App brought the order back the way it was left, and the watchlist was put back into its original order afterwards.
  • News filter: typing A股 into the filter field left the one entry that mentions it and the counter read 1 / 30 条; two words separated by a space are combined with "or" and returned three entries, one of which matched through its summary rather than its title; a word that matches nothing produced 没有匹配「…」的新闻 and a counter of 0 / 30 条 instead of an empty list; the clear button brought all thirty entries back, the counter disappeared and the focus returned to the field; switching to the 科技 column kept the filter and recounted it against that column (14 / 70 条); anthropic and ANTHROPIC returned the same two entries, so the match does not care about case; the same filter worked on the 热榜 column, whose entries have no summary and are matched on their title alone; all six columns were walked one by one and returned 30, 29, 70, 24, 50 and 8 entries with every source reported healthy; the Mini App was restarted and the filter, the column and the counter all came back the way they were left. Console showed 0 errors and 0 warnings; the network showed no failed requests.
  • Numbers were cross-checked against a second and third source rather than taken from one feed: one A-share quote matched across Eastmoney, Sina, and Tencent to a 0.0000 % spread, and the converted gold price of 778.44 CNY/gram matched a hand calculation and sat 0.075 % away from the Shanghai Gold Exchange AU9999 quote.

Not verified

  • The Baidu hot-board fallback and the Sina/Tencent quote fallbacks were exercised only against their endpoints directly. The primary sources kept succeeding, so the fallback branches never ran inside the live app.
  • The narrower container widths were measured by rendering the page inside same-origin iframes of that width, not by resizing the File Panel itself.
  • The CI workflow ran and passed on commit 0915a37 (check (ubuntu-latest), 18 s) once a maintainer approved the first-time-contributor run. The head has moved since — a merge of this repository's main, the name-search commit, the reorder commit and the news-filter commit — so the workflow has to be approved again and no result from the Linux runner is available for the current head yet. The workflow's own two commands, npm ci and npm run check, were run locally instead; see below for the only two failures and why they are unrelated to this package.

Remaining npm run check failures

npm run check runs npm run validate (passes, exit 0) and then the repository's own test suite. Two tests fail on this machine:

files: a symlink inside the package is an error
files: a package root that is itself a symlink is rejected before walking

Both fail with EPERM: operation not permitted, symlink ... while creating their fixture under the system temp directory. Creating a symlink on Windows needs Developer Mode or an elevated token; this machine has neither. They fail identically on the pristine checkout before this package is added, they exercise the repository's own fixtures rather than anything in plugins/lixiangroir-ideal/weather-news-board/, and they pass on the Linux CI runner.

Declared access

None beyond the standard Mini App runtime. The manifest declares no hostConnectorAccess provider, no agentAccess, no toolAccess, no deviceAccess, and no hostAccess. The app spawns no processes, starts no Agent runs, reads no conversations, calls no tools, and uses no microphone, camera, notification, or Host navigation access. The Node service makes read-only HTTPS requests to the hosts listed under ## Data & access in the package README; the name search uses one fixed path on the market's search host, and the user's input is never forwarded anywhere else. The watchlist reorder and the news filter make no request of their own: the reorder uses the same watchlist route as adding and removing an entry, and the filter runs in the page.

Written by MiniMax-M3.1-Flash

What the app does

实时天气 — current temperature, condition, apparent temperature, humidity, and wind speed, plus a three-day forecast with precipitation probability and, when the card has room for it, the next few three-hour forecast steps. The city field accepts Chinese names such as 南京; the 切换 button cycles through the places that share that name, which are resolved through the Open-Meteo geocoding API and then read from wttr.in by coordinates.

自选股 — a watchlist of A-share codes, index names and international symbols. Codes are validated on the server against a fixed allow list: a six-digit code, a sh/sz/bj prefixed code, the name of an index (上证指数, 沪深300, 创业板指, 科创50, 中证500, 北证50) or of a common ETF (沪深300ETF, 创业板ETF, 科创50ETF), or the name of a predefined symbol such as 黄金, 伦敦金, 黄金9999, 白银, 原油, or 比特币. Anything else is rejected, so the route can never become an arbitrary URL proxy. The index names carry their exchange explicitly, because 000001 is 平安银行 in Shenzhen and 上证指数 in Shanghai; the ETF codes follow the usual segments, 510xxx/588xxx in Shanghai and 159xxx in Shenzhen. The list is capped at 12 entries, adding a duplicate is idempotent, and a failed quote fetch never changes the result of the add or remove itself.

The field also accepts a name: 银行 lists 浦发银行, 华夏银行 and the rest, and a candidate is picked with the mouse or with the arrow keys and Enter. The candidates come from the market's public search endpoint — one request per search — and the names it returns are written to security-index.json in the data directory, so a name that was looked up before is matched locally and offline. Downloading the whole market list was the alternative, but it needs close to a hundred pages of requests and the upstream drops the connection after that much traffic; once it does, the quote endpoint this app uses stops answering as well. When the upstream is unreachable the search falls back to the locally known names and then to the built-in index and ETF names.

Precious metals are always displayed in CNY per gram: price per ounce x CNY per USD / 31.1034768. The change and the percentage use the same gram basis rather than mixing units, and the raw USD-per-ounce quote together with the FX rate is kept in the row's title tooltip. AU9999 is already quoted natively in CNY per gram and is not converted.

The entries can also be reordered. A grip handle sits in the top-left corner of every watchlist entry: dragging it moves that entry to another place, in the two-column grid as well as in the narrow one, and the handle is a real button, so with it focused the arrow keys move the entry up and down. The drag is built on pointer events instead of the HTML5 drag-and-drop API, because the panel the app runs in does not reliably deliver those; the move, release and cancel listeners sit on the window, so the drag keeps following the pointer when it leaves the card, and a drag only starts once the pointer has moved 3 px, so an accidental click changes nothing. The new order is sent to the server as a permutation of the list that is already there — the same entries, none of them twice, and nothing that is not in the watchlist — so the reorder route cannot be used to add or remove entries behind the allow list. If the server refuses the order, the list is rendered again from the order the server still holds, so the board and the stored watchlist cannot drift apart.

The news column can be narrowed down by keyword as well. A filter field sits under the news tabs; the words you type are matched against the title, the summary and the source of every entry in the current column, and the ones that mention them stay. Words separated by spaces or commas are combined with "or", the match ignores case, and a counter next to the field shows how many of the column's entries are left. The filter runs entirely in the page: the column is fetched exactly as before and the filter only decides which of those entries are shown, so it never asks the upstream for less and never makes it answer more often, and nothing is sent anywhere. The matching rules live in their own <script id="wnb-news-filter"> block, and tests/news-filter.test.mjs takes that block apart and runs it under Node's built-in test runner, the same way the layout arithmetic is tested — so the rules can be checked without opening the app, and the tests cannot drift away from the code that runs. The words are a view preference and are kept in localStorage next to the selected column.

新闻 — six tabs. 要闻 and 时政 come from China News Service RSS feeds; 科技 merges IT Home and SSPAI, de-duplicated and interleaved; 财经 comes from Yicai; 热榜 uses the Toutiao hot board with Baidu as a fallback that must succeed rather than blank the page; 知乎日报 comes from the Zhihu daily API.

Each channel reports which upstream actually answered, so a partial failure is visible instead of silently empty.

Layout and rendering

Three cards: weather, watchlist and news. The layout reacts to the width of the app's own container rather than to the window size, so it behaves the same in a narrow File Panel and on a wide screen: below 560 px the cards stack, from 560 px the weather and watchlist cards sit side by side with the news card below them, and from 900 px the board becomes three columns. A container query on the weather card compacts it when it gets narrow.

The watchlist is a grid whose column count is computed from the available width and the number of entries, so every entry stays on screen instead of pushing the rest below the fold; a second container query per tile shrinks the type and finally drops the ticker code when a tile becomes very narrow.

When the weather card and the watchlist card sit next to each other and neither was sized by hand, they keep the same height. The weather card measures the space its neighbour leaves free and shows as many rows of the hourly forecast as fit there, hiding the rest; with the watchlist short the card stays compact, with a long watchlist the hourly forecast fills the gap row by row. In the three-column layout the two cards are aligned explicitly to the taller of their natural heights, so the hourly forecast is never hidden as a whole block. The watchlist card ends with a count of the rising, falling and unchanged entries.

Each card is sized on its own. A resize handle sits in the bottom-right corner of the weather card, the watchlist card and the news card; dragging it sets that card's width and height without touching the other two, so the weather card can be made narrow and short while the watchlist stays wide. The handle follows the pointer wherever it goes and shows a live W × H readout while dragging, the content of a card whose height was set by hand scrolls inside that card, a single click on a handle restores that one card to the automatic size, and a reset button in the top bar clears all three. Each size is stored per card in localStorage next to the other view preferences, and a card is clamped so it never squeezes its neighbours below a readable width. A size restored on load is clamped in both directions against the current container, so a size saved on a wide screen can never squash a card into a 5000 px wide, 8 px tall strip on a narrow one. The cards that share a row are kept inside the container as well: the per-card bound reserves each neighbour's minimum width, and a row's overflow is measured from the rendered result and taken back proportionally, so a row can never add up to more than the board, and equally wide cards shrink evenly instead of one of them always giving way; while one card is being dragged its neighbour gives way rather than letting the board overflow and clip its right edge, and the size shown in the drag badge is the one that is actually applied.

The handle is a real button as well: with it focused, the arrow keys change that card's width and height — Shift makes the step larger — and Home puts the card back to the automatic size. While a card is being resized, every card that shares its row shows the width range it can still take, so it is visible when a neighbour has already given everything it can.

Each card also carries a focus button in its header. It hides the other two cards and gives that card the whole board, and the same button — or Exit focus in the top bar — brings the full board back.

The watchlist and the news header refresh on independent intervals: the header switch covers weather and news only, while the watchlist has its own switch and its own 15 s / 30 s / 1 min / 5 min selector, defaulting to 30 s.

Both themes are defined with --mcode-* semantic variables only. Icons are inline SVG — the weather symbols, the up and down triangles, the refresh arrow, the focus arrows, and the remove button. There is no emoji, no remote font, no remote stylesheet or script, and no remote image: the Zhihu and Toutiao image fields are deliberately not rendered, because the page must not load remote images.

Quotes follow the mainland convention that a rise is red and a fall is green, and no value is communicated by colour alone: every row carries a triangle and a signed number, such as ▼ -14.31 and ▼ -0.97 %.

Startup resilience

The Host stops the Mini App process whenever the page is hidden, so a page that is brought back to the front can find its service gone. A request that cannot reach the service — no response at all, or a response that is not JSON — is retried with a growing backoff of 0.4 s, 0.8 s, 1.6 s, 3.2 s, 6.4 s and 10 s, and the title bar shows how long the next attempt will take. A request that does reach the service but fails because of an upstream source is not retried, so a broken source never looks like a broken service. Once the retries are used up the title bar says the service is not ready, and the next automatic refresh picks the board up again. Adding or removing a watchlist entry is retried the same way, which is safe because both operations are idempotent on the server.

Implementation notes

  • The Node service owns every upstream call. The Client only talks to six narrow routes: GET /dashboard, GET /api/board?source=…&refresh=1, GET /api/stocks?refresh=1, GET /api/search?q=…, POST /api/watchlist, and GET /api/health.
  • Quote responses are cached for 15 s and news and weather for 60 s; refresh=1 bypasses the cache in every case, so the refresh button really re-fetches the news instead of replaying the cached column. When an upstream fails, the last good payload is returned with a stale flag so the page keeps its content and shows that the source is degraded instead of going blank.
  • Every link the service hands back is reduced to https://, including the RSS link and guid fields and each channel's original item URL, so the page never surfaces a plain-http target. A six-digit code is mapped to its market by its leading segment: 1 goes to the Shenzhen fund range, 5 to the Shanghai fund range, 6 and 9 to Shanghai, 0, 2 and 3 to Shenzhen, and 4 and 8 to Beijing.
  • The width arithmetic is kept apart from the DOM. The Client carries the pure functions in a <script id="wnb-layout"> block — the column breakpoints, the per-row width ceiling, the proportional pull-back and the clamping — and tests/layout.test.mjs takes that block apart and runs it under Node's built-in test runner, so the layout rules can be checked without opening the app and the tests cannot drift away from the code that runs.
  • The watchlist is persisted to watchlist.json inside the Host-provided context.dataDir, written atomically as a temporary file that is then renamed over the target, so a forced shutdown cannot leave a half-written file. The names the search has looked up go to security-index.json in the same directory, written the same way. The page saves its view state on visibilitychange and restores it on load.
  • The reorder validation lives in miniapp/node/watchlist-order.mjs next to the other server-side helpers, and tests/watchlist-order.test.mjs pins down its edges: one entry short, one entry too many, a repeated entry, a code that is not in the watchlist, a non-array argument and an empty watchlist.
  • The news filter rules live in the client's own <script id="wnb-news-filter"> block — the keyword splitting, the "or" combination and the case-insensitive match — and tests/news-filter.test.mjs runs that block under Node's built-in test runner, covering the splitting, the de-duplication, the three places an entry can match, and the empty and non-array inputs.
  • The package has no dependencies and no build step: the Client is a single index.html with inline CSS and JavaScript, and the Node entry uses only node:http and node:fs.

Copy link
Copy Markdown
Collaborator

Thanks for the 1.0.1 update. This isn't a merge blocker, but a few things stood out on f0e46694:

  • The 60-second news cache ignores refresh=1, so 「立即刷新」 and the 15-second interval don't actually refetch news while the page is open. Weather and quotes are unaffected. The PR body says refresh=1 bypasses the cache, which doesn't match this path.
  • Bare 6-digit codes map markets a bit narrowly for codes that start with 1 or 5.
  • Non-RSS news links aren't restricted to https:.
  • plugin.json still has author set to the placeholder User.

Repo CI is still waiting on first-time contributor approval, so we haven't used that as evidence. We also haven't run this head on Host or Electron.

Copy link
Copy Markdown
Collaborator

Thanks for the 1.0.3 update. This still isn't a merge blocker. We re-checked on c5144522.

The points in the earlier comment are still present: the 60-second news cache still ignores refresh=1; bare 6-digit codes that start with 1 or 5 still map markets narrowly; non-RSS news links still aren't restricted to https:; and plugin.json still has author set to the placeholder User.

A few more things on this head, from a page viewport simulation (not File Panel or Host):

  • With no size set, on a 1600px viewport the handle still sits about 142px to the right of the board's edge.
  • A restored saved height still isn't clamped, so a stored height of 8 can collapse the board to 8px.
  • Three-column height alignment still doesn't hold: with 1 or 8 watchlist entries, all six hourly forecast slots stay hidden, with height gaps of 187px and 67px.
  • README.zh-CN still repeats the 「贵金属一律以人民币 / 克显示」 paragraph.

Click-to-reset and the top-bar sliders do work, and they write the same size variables. We didn't independently reproduce pointer-following in that simulation, though the listeners are now on window. We still haven't run this head on Host or Electron, and repo CI is still waiting on first-time contributor approval.

Copy link
Copy Markdown
Collaborator

Thanks for the 1.0.4 update. We re-checked on 71e28ec8. This still isn't a merge blocker.

The global size panel and the single board handle are gone. Each of the three cards now has its own bottom-right handle, and sizes are stored separately in localStorage. A click resets one card, and the top-bar button resets all three. We confirmed that in the code. Repo CI is still waiting on first-time contributor approval, so we haven't used that as evidence. We still haven't run this head on Host or Electron.

A few leftovers, none of them blocking this increment:

  • Saved widths and heights are applied on load without clamping. clampCardSizes() only clamps width, and only on window resize, so a stored size like {w:5000,h:8} can first render very wide and very short.
  • Three-column layout still doesn't run the weather/watchlist height alignment; that path only runs in the two-column layout.
  • The points in the earlier comments are still present: the 60-second news cache still ignores refresh=1; bare 6-digit codes that start with 1 or 5 still map to sh; pickLink still allows http: as well as https:, and non-RSS item URLs still aren't required to be https:; and plugin.json still has author set to the placeholder User.

Happy to re-review if you want to tidy these up.

@lixiangroir-Ideal

Copy link
Copy Markdown
Contributor Author

Thanks for the careful re-check — every leftover from the earlier comments is now addressed in d4a36c8 (package version 1.0.5).

Point by point:

  • Saved sizes are clamped on load, in both directions. clampCardSizes() now clamps the width against the current column width and the height against a 220–1600 px range, and it runs from restoreCardSizes() when the page loads instead of only on window resize. Verified in the browser: a stored {w:5000,h:8} is restored as 495 × 220, with no horizontal overflow.
  • The three-column layout now runs the weather/watchlist alignment. It is applied explicitly there, setting both cards to the taller of their two natural heights, so the hourly forecast is no longer hidden as a block. Verified at 1100 px: weather card 640 px = watchlist card 640 px, gap 0, and all six hourly steps visible.
  • The 60-second news cache now honours refresh=1. loadNews() takes the flag and re-fetches even while the cache is still warm, so the refresh button really re-fetches the column it shows. Verified: two requests without the flag return the same updatedAt, and the same request with it returns a new one.
  • All outbound links are https: only. A safeHttps() filter is applied to the RSS link/guid fields and to every non-RSS item URL (Toutiao, Baidu, Zhihu, Yicai). Verified by reading back all six news columns and the quote list: every returned link starts with https://.
  • Bare six-digit codes starting with 1 or 5 now map by segment. 1 → sz (Shenzhen funds), 5 → sh (Shanghai funds); 6/9 → sh, 0/2/3 → sz, 4/8 → bj.
  • plugin.json author is now lixiangroir-ideal instead of the placeholder User.
  • The duplicated precious-metals paragraph in README.zh-CN.md was dropped earlier, and each handle now travels with its own card instead of being positioned against the viewport.

One thing that cannot be done from this side: the repo CI run for this PR is still held by GitHub's first-time-contributor approval, so there is no Linux-runner result to point at yet. The workflow's own two commands were run locally instead — npm ci followed by npm run check — giving 94 of 96 repository tests passing. The two failures are the repository's own files: a symlink ... fixtures: they need Developer Mode or an elevated token to create a symlink on Windows, they fail identically on a pristine checkout without this package, and they pass on the Linux runner. npm run validate reports weather-news-board: OK and repository: OK.

For reference on the Host/Electron point: the acceptance runs were done in the Electron desktop app (MiniMax Code 3.1.19 on Windows 11), so this head does run under the Host.

Happy to re-review — thanks for taking the time.

@lixiangroir-Ideal

Copy link
Copy Markdown
Contributor Author

One more bug, found and fixed in a61d5c0 (package version 1.0.6).

What was wrong. Each card's width bound was computed independently, and the sibling cards were assumed to use their default widths. Once two cards on the same row were both sized by hand, their widths added up to more than the board. The board sets overflow-x: hidden, so the excess was clipped and could not be scrolled to: the watchlist card's 添加 button and the news card's source badge were cut off at the right edge.

Reproduced in the desktop app with the board inside the File Panel: the weather card was 260 px and the watchlist card 495 px inside a 734 px column, so 771 px of tracks were laid out in a 734 px board and 37 px were clipped.

The fix. The width budget is now computed per row for the current layout: the cards that share a row, plus the gaps, have to fit inside the board. A card's bound uses the widths its neighbours actually occupy, a hand-set sibling included. When a row no longer fits, the wider card is pulled in; while a card is being dragged its neighbour gives way first, and only when nothing else can give way is the dragged card itself pulled back. The fit is re-applied on load, when the container narrows, and on every drag, and stored sizes that no longer fit are rewritten.

Verified in the desktop app:

  • the 260 px + 495 px case now renders as 260 px + 458 px, and the board's scrollWidth equals its clientWidth at 734 px — 0 px clipped;
  • all three cards stored at 900 px: a 640 px container settles to 260 px + 301 px and a 1100 px container to 260 px + 260 px + 500 px, with no overflow in either case;
  • dragging the weather card's handle past the right edge gives the watchlist card its minimum width and stops at 458 px + 260 px, still exactly the container width;
  • the default board shows no horizontal overflow at 420 px, 640 px or 1100 px.

The README in both languages and the pull request description are updated with this.

Copy link
Copy Markdown
Collaborator

Thanks for the 1.0.6 update. We re-checked on a61d5c0f. This still isn't a merge blocker.

The intended fix is in the source: maxCardWidth now reserves space from each sibling's actual width, and fitCardWidths runs on load, when the container narrows, and while dragging. We confirmed that in the code, and the overflow cases were re-checked in a page viewport simulation (not File Panel or Host). Repo CI is still waiting on first-time contributor approval.

Two leftovers, neither of them blocking:

  • The size badge shown while dragging uses the pointer width taken before fitCardWidths runs. If that pass pulls the dragged card back, the badge can show a larger size than the width that is applied and saved.
  • When several cards in a row are equally over-wide, pickShrinkable ties go to the first card in row order (weather, then watchlist, then news).

Happy to re-review if you want to tidy these up.

@lixiangroir-Ideal

Copy link
Copy Markdown
Contributor Author

Thanks — both leftovers are fixed in 1f6bc77 (version 1.0.7).

The badge. The size shown while dragging is now read from the card's applied width after the fit pass, not from the pointer position before it. A drag that reaches 751 px past the right edge now shows 458 × 543 in the badge, and 458 px is what the card actually gets and what gets stored.

The tie-break. The per-card bound no longer depends on the order the cards are processed in, and the row is now shared out proportionally:

  • maxCardWidth() reserves each sibling's minimum width instead of its current width, so the per-card ceiling is the same no matter which card is looked at first;
  • a row's overflow is measured from the rendered result rather than computed from the track widths, and the cards in that row take it back proportionally to their own widths.

Three cards stored at 900 px in a 1052 px column now settle at 340 px each. Before, the first card in row order was always squeezed down to its 260 px minimum while the last one kept 500 px.

One more thing turned up while testing this: a vertical scrollbar appears once the news column has rendered, and that takes 15 px off the width the board has available. The fit is now re-applied whenever the board's width changes, so stored sizes that were fitted against the wider value are pulled back to the narrower one.

Verified in the desktop app:

  • three cards at 900 px in a 1052 px column → 340 / 340 / 340, overflow 0;
  • 260 px + 495 px in a 719 px column (the width left after the scrollbar appeared) → 260 px + 443 px, overflow 0;
  • dragging the weather card's handle past the right edge → the watchlist card goes to its 260 px minimum, the weather card stops at 458 px, and the badge reads 458 × 543;
  • the default board at 420 px, 640 px and 1100 px has no horizontal overflow.

Copy link
Copy Markdown
Collaborator

Thanks for the 1.0.7 update. We re-checked on 1f6bc777.

The two leftovers from last time are fixed in the source. The per-card ceiling no longer depends on processing order, overflow is shared in proportion to each card's width, and the drag badge reads the size after the fit pass. Those cases were also re-checked in a page viewport simulation (not File Panel or Host).

Two notes, neither of them a merge blocker:

  • Rounding each card's share with Math.round can leave 1px of overflow. .board uses overflow-x: hidden, so that 1px is clipped rather than shown. When the widths divide evenly, overflow is 0.
  • clampCardSizes applies the same per-card ceiling first, because each sibling is reserved at the minimum width. Two cards that started at different widths above that ceiling can end up the same width, rather than keeping their original ratio. Equal-width cards still shrink evenly, and that part does not depend on processing order.

@lixiangroir-Ideal

Copy link
Copy Markdown
Contributor Author

按之前商量的方向把四个改进都做完了,合成一条评论集中说明,逐版的回复都保留在上面。

  • 1.0.8 启动韧性:服务没起来时按退避重试(0.4 / 0.8 / 1.6 / 3.2 / 6.4 / 10 秒),顶栏显示「服务启动中… N 秒后重试」,重试用尽后改为「服务未就绪」。只有连不上服务(无响应或响应不是 JSON)才重试,能连上但上游数据源失败的请求不重试,免得把数据源问题误显示成服务问题。增删自选股同样按这套机制重试——服务端这两个操作是幂等的,重试不会写重。
  • 1.0.9 布局算法抽纯函数 + 包内自测:宽度上的算术移到一段独立的 <script id="wnb-layout"> 里,tests/layout.test.mjs 把这一段原样取出来在 Node 里跑,测的就是页面真正执行的那份代码,不会出现两份实现走偏。
  • 1.0.10 布局控制:每张卡标题栏多一个专注按钮(只显示这一张、占满看板,顶栏出现「退出专注」);调整尺寸时同一行的每张卡都显示自己还能取的宽度区间,兄弟卡让到底时一眼能看见;手柄本身是个真按钮,方向键可以微调宽高,Home 恢复自适应。
  • 1.0.11 自选股扩容:指数与常见 ETF 可以直接输名称(上证指数、沪深300、创业板指、科创50、中证500、北证50、沪深300ETF、创业板ETF、科创50ETF……)。指数代码带明确的市场前缀——000001 在深市是平安银行,在沪市才是上证指数,靠 6 位数字推市场会推错。

Tested environment

  • MiniMax Code 3.1.19,Windows 11(Windows 10.0.26200, x64),Node.js 24.16.0。
  • 启动韧性:服务持续不可达时,顶栏依次倒计时 1 / 2 / 4 / 7 / 10 秒,重试用尽后提示服务未就绪;服务恢复后 /api/board 与 /api/stocks 重新返回 200、提示条消失、看板自行恢复。服务停 3 秒期间添加一条自选股,写操作被重试并在服务恢复后成功写入,随后移除还原。
  • 布局控制:专注天气卡时另外两张卡被收起、该卡取满 734 px 看板宽度、顶栏出现「退出专注」,退出后三张卡都回来;拖动手柄时同一行的天气卡与自选股都显示「宽度 260–458」,不同行的新闻卡不显示,提示条上带着同样的区间且没有被右边缘裁掉;键盘调整时 ArrowRight 加宽 16 px、Shift+ArrowRight 加宽 64 px、ArrowDown 加高 16 px、Shift+ArrowLeft 收窄 64 px、Home 恢复自适应并给出提示。
  • 自选股:在真实界面输入「沪深300」,新增的那一行就是 sh000300 上的沪深300 并带上实时行情,「科创50ETF」解析到 sh588000;上证指数、深证成指、创业板指、科创50、上证50、中证500、中证1000、创业板50、北证50、沪深300ETF、上证50ETF、创业板ETF、科创50ETF、证券ETF、中概互联网ETF 逐个走接口都取到了行情;认不出来的名称按白名单挡下,自选股保持原样。
  • 包内自测 24 个用例全部通过(node --test "plugins/lixiangroir-ideal/weather-news-board/tests/*.test.mjs"),npm run validate 仍是 weather-news-board: OK + repository: OK。
  • 控制台 0 error / 0 warn,网络无失败请求。

Not verified

  • 百度热榜兜底与新浪 / 腾讯行情备源仍只对其接口单独做过直连验证,主源一直可用,运行时没有真正走到兜底分支。
  • 窄容器宽度仍是用同源 iframe 渲染出来的,没有真的去拖 File Panel 的宽度。
  • CI 仍被 GitHub 的首次贡献者审批卡住(run 46164990211),拿不到 Linux runner 的真实结果;工作流自己的 npm ci 与 npm run check 已在本地跑过,仓库自带的 96 个用例里 94 个通过,剩下两个是仓库自己的 symlink 用例(Windows 没有开发者模式建不了 symlink,在不含本包的干净检出上同样失败,Linux runner 会过),与本包无关。
Written by MiniMax-M3.1-Flash

改动明细

1.0.8 启动韧性 — 宿主会在页面不可见时停掉 Mini App 进程,页面回到前台时服务可能已经不在。现在请求连不上服务(无响应或响应不是 JSON)时按 400 / 800 / 1600 / 3200 / 6400 / 10000 ms 的递增间隔重试,顶栏提示条显示下一次尝试的倒计时;重试用尽后提示条改为「服务未就绪,稍后会自动重试」,而不是停在「服务启动中」。冷启动(还没连上过服务)只在页面打开后的 45 秒宽限期内重试;曾经连上过、之后被停掉时一直允许重试,直到连上或重试用尽。能连上但上游数据源失败的请求不重试——否则数据源抖动会被误显示成服务故障。增删自选股走同一条路径,服务端 add 重复添加只提示「已在自选股中」、remove 重复删除是空操作,所以重试是安全的。

1.0.9 布局算法抽纯函数 + 包内自测 — 列数断点、每一行放哪些卡片、同一行的宽度上限、按比例收回、宽度夹紧这五段算术原本夹在 DOM 操作中间,抽到一段独立的 <script id="wnb-layout"> 里,主脚本改为调用它,行为不变。新增 tests/layout.test.mjs,用 Node 内置的 node:test 把这一段原样取出来跑——测的就是页面真正执行的代码。16 个用例覆盖列数断点、与处理顺序无关的宽度上限、三张 900px 放在 1052px 里等比收成 340px、按各自宽度分摊不偏向第一张、拖动时兄弟卡先让位、兄弟都到底后才动被拖的那张、已到最小宽度的不参与分摊、宽度夹紧取整。浏览器复核:三张卡各存 900px 放在 734px 的栏里收敛为 359 / 359(新闻卡独占一行 734),横向溢出 0;拖动手柄时提示显示实际生效的 458×474,兄弟卡让到最小宽度 260,溢出仍为 0。

1.0.10 布局控制 — 每张卡标题栏里多一个专注按钮,点它把另外两张收起来、让这张卡占满看板,再点一次同一个按钮或点顶栏的「退出专注」就回到完整看板。调整尺寸时,同一行的每张卡都显示自己还能取的宽度范围,兄弟卡已经让到底时一眼能看见;提示条上也带上同样的区间,并按实际宽度贴边,不再被视口右边缘裁掉。区间出现期间「更新 HH:MM」让位但保留占位,布局不跳动。缩放手柄本身是一个真正的按钮:手柄获得焦点后方向键调宽高(Shift 步长更大),Home 或回车恢复自适应;手柄的 aria-label 里写明了按键用法,提示条加了 role="status",键盘调整时会被读出来。

1.0.11 自选股扩容 — 新增 miniapp/node/security-aliases.mjs,一张指数与常见 ETF 的「名称 → 代码」对照表。指数代码不能靠 6 位数字推市场:000001 在深市是平安银行,在沪市才是上证指数,000300、000688 同理,所以表里把市场前缀显式写出来。覆盖上证指数、深证成指、沪深300、上证50、中证500、中证1000、创业板指、创业板50、科创50、北证50,以及沪深300ETF、上证50ETF、创业板ETF、科创50ETF、证券ETF、中概互联网ETF;ETF 仍然可以直接填 6 位代码(510xxx / 588xxx 在沪市,159xxx 在深市)。名称匹配大小写不敏感、忽略中间空白。新增 tests/security-aliases.test.mjs,8 个用例把每个别名的市场归属钉死,包括「上证指数必须是 sh000001」这条容易搞反的。

复核过的边界

  • 专注模式下不做整行宽度收敛——只有一张卡,不存在放不下的问题。
  • 区间提示只在同一行内显示;不同行的卡不显示区间,避免误导。
  • 键盘只改被按方向的那个维度:左右只动宽、上下只动高,不会顺手把自动高度冻住。
  • 白名单与请求体大小限制没有变化:仍然是 6 位数字 / sh|sz|bj 前缀 / 预定义名称,POST 请求体不超过 4KB,路由不会被当成通用 URL 代理。

Copy link
Copy Markdown
Collaborator

Thanks for the 1.0.11 update. We re-checked on 0915a37e.

The 1.0.8 startup retry, the 1.0.9 layout extraction and package tests, the 1.0.10 focus / width-range / keyboard work, and this watchlist alias table all check out in the source. We also ran the package tests ourselves:

node --test "plugins/lixiangroir-ideal/weather-news-board/tests/*.test.mjs"

24 cases passed. The layout tests still extract the page's <script id="wnb-layout"> block, and the alias tests import miniapp/node/security-aliases.mjs directly.

A few leftovers, none of them merge blockers:

  • Weather, news, and quotes each have their own retry loop, so a service that never comes up can make 21 requests, not seven in total. That is seven per endpoint: one initial try plus the six backoff delays.
  • If the first failure already lands after the 45-second cold-start grace and the service has never connected, the startup chip stays hidden, because the down-state notice only appears once a retry has already been shown.
  • The down-state chip says the service will retry automatically. After the cold-start backoff is exhausted and the service has never connected, later auto-refresh calls don't reuse that backoff series. They fail on the first attempt.
  • The layout test that shrinks 900 / 600 / 300 px to 510 / 340 / 260 px calls shrinkRowToFit on its own. On the page, each card is clamped to its per-card maximum first, then the row is shrunk.

Repo CI is still waiting on first-time contributor approval, so we haven't used that as evidence. We also haven't run this head on Host, Electron, or the File Panel.

- 用 CSS 容器查询替换视口媒体查询,按应用实际可用宽度在一栏 / 两栏 / 三栏之间重排
- 自选股改为网格布局,脚本按可用宽度与条目总数计算列数,全部条目始终留在卡片内
- 天气卡不再被拉伸成大块空白,窄卡片自动切换紧凑排版
- 版本号 1.0.0 -> 1.0.1
- 右下角新增尺寸手柄:拖动调整看板宽度与高度上限,双击复位,尺寸存入 localStorage
- 天气卡按相邻自选股卡的高度挑选逐时预报档位,两卡并排时高度差为 0
- 服务端补充逐时预报、气压、能见度、云量与日出日落
- 自选股卡新增涨跌条目计数
- 版本号 1.0.1 -> 1.0.2
- 拖拽监听改挂到 window,不再依赖 setPointerCapture,嵌入式面板里也能跟手
- 手柄放大到 30px,悬停提示与拖动中实时显示当前尺寸,点击即恢复自适应
- 顶栏新增尺寸按钮:宽度 / 高度滑块 + 恢复自适应,作为不依赖拖拽的入口
- 版本号 1.0.2 -> 1.0.3
移除控制整个看板的全局尺寸面板与全局手柄,改为每张卡片(实时天气 / 自选股 / 新闻)右下角各带一个缩放手柄。拖动可单独设定该卡片的宽度与高度,兄弟卡片不受影响;手动设定高度后内容在卡内滚动;单击手柄只复位该卡片,顶栏新增「重置尺寸」一键还原全部。逐卡尺寸分别持久化到 localStorage,容器变窄时自动夹紧。
新闻接口真正支持 refresh=1:即使缓存未过期也会重新抓取,正文描述与实现一致。所有对外链接只允许 https,RSS 的 link/guid 与各站条目的原始地址一律经过 https 过滤。六位纯数字代码的市场前缀按代码段显式判定,1 开头归深市基金、5 开头归沪市基金。plugin.json 的 author 改为真实的 GitHub 登录名。

客户端侧,载入时对已保存的宽高一起夹紧(宽按当前栏位上限,高夹在 220~1600),不再先渲染成极宽极矮的卡片;三栏布局改为显式把天气卡与自选股卡对齐到两者自然高度的最大值,逐时预报不再被整块隐藏。修复了卡内子元素被压缩,以及计算自然高度时 margin:auto 被解析成巨大数值导致高度滚雪球的问题。
手动指定宽度时,每张卡片的宽度上限是各自独立算的,兄弟卡片一律按排布默认值来预留空间。一旦同一行的两张卡片都被手动指定过宽度,宽度之和就会超出容器;看板设了 overflow-x: hidden,超出的部分被裁掉且滚不到,右侧的内容直接看不见,新闻卡的来源标记和自选股卡的按钮都会被切掉。

改为按当前排布逐行计算:同一行的卡片宽度加上间距必须放得进看板宽度,放不下时优先收较宽的那张,拖动某张卡时兄弟卡片先让出空间。载入时、容器变窄时、拖动过程中都会重新收敛,越界的存档尺寸也会被改写。
上一版逐张夹紧时按兄弟卡片"当前宽度"预留空间,结果取决于处理顺序:同一行里几张卡一样宽时,先处理的那张永远先被压到下限,后面的卡则被留到很宽。

现在改为:逐张上限只按兄弟卡片的最小宽度预留,与处理顺序无关;整行的溢出量按渲染结果测量,超出部分由该行的卡片按各自宽度等比分摊,同样的宽度就得到同样的收窄量。另外补上两处:竖向滚动条出现后可用宽度会少十几个像素,看板宽度变化时重新收敛一次;拖拽提示上的尺寸改用夹紧之后实际生效的宽度。
宿主会在页面不可见时停掉 Mini App 进程,页面回到前台时服务可能已经不在。
原先这种情况只会静默失败,现在:

- 顶栏新增启动提示条:连不上服务时显示"服务启动中… N 秒后重试",
  重试用尽后改为"服务未就绪,稍后会自动重试"。
- 读请求按 400/800/1600/3200/6400/10000 ms 的递增间隔重试。冷启动只在
  页面打开后的 45 秒宽限期内重试;曾经连上过服务、之后被停掉时一直
  允许重试,直到连上或重试用尽。
- 只有连不上服务(无响应、或响应不是 JSON)才重试;能连上但上游数据源
  失败的请求不重试,避免把数据源问题误显示成服务问题。
- 增删自选股同样按这套机制重试。这两个操作在服务端是幂等的,重试不会
  写重。

浏览器实测:服务持续不可达时顶栏依次倒计时 1/2/4/7/10 秒,重试用尽后
提示服务未就绪;服务恢复后 /api/board 与 /api/stocks 恢复 200、提示条
消失、看板自行恢复。服务停 3 秒期间添加自选股,写操作被重试并在服务恢复
后成功写入,随后移除还原。控制台 0 error / 0 warn。
布局上的算术原本散在 DOM 操作中间,没法在不打开应用的情况下验证。现在:

- 客户端新增 <script id="wnb-layout">,只放纯计算:列数断点、每一行放哪些
  卡片、同一行的宽度上限、按比例收回、宽度夹紧。主脚本改为调用这一段,
  行为与之前一致。
- 新增 tests/layout.test.mjs,用 Node 内置的 node:test 把上面这一段原样取出
  来跑——测的就是页面真正执行的那份代码,不会出现两份实现走偏。共 16 个用例,
  覆盖列数断点、与处理顺序无关的宽度上限、三张 900px 放在 1052px 里等比收成
  340px、按各自宽度分摊不偏向第一张、拖动时兄弟卡先让位、兄弟都到底后才动
  被拖的那张、已到最小宽度的不参与分摊、宽度夹紧取整。
- 仓库的 npm run check 只跑仓库自带的测试,这一条需要单独执行:
  node --test "plugins/lixiangroir-ideal/weather-news-board/tests/*.test.mjs"

浏览器复核:三张卡各存 900px 放在 734px 的栏里收敛为 359 / 359(新闻卡独占
一行为 734),横向溢出 0;拖动手柄时提示显示实际生效的 458×474,兄弟卡让到
最小宽度 260,溢出仍为 0。控制台 0 error / 0 warn。
布局控制补三件事:

- 专注模式:每张卡标题栏里多一个按钮,点它把另外两张收起来,让这张卡占满看板;
  再点一次同一个按钮,或点顶栏的「退出专注」,回到完整看板。
- 调整尺寸时,同一行的每张卡都显示自己还能取的宽度范围,兄弟卡已经让到底时一眼能看见;
  提示条上也带上同样的区间。区间出现期间更新时间让位但保留占位,布局不跳动。
- 缩放手柄本身是一个真正的按钮:手柄获得焦点后,方向键调宽高(Shift 步长更大),
  Home 或回车让这张卡恢复自适应。手柄的 aria-label 里写明了按键用法,
  提示条加了 role="status",键盘调整时会被读出来。

浏览器实测:专注天气卡时另外两张卡隐藏、该卡取满 734 px 看板宽度、顶栏出现「退出专注」,
退出后三张卡都回来;拖动手柄时同一行的天气卡与自选股都显示"宽度 260–458",
不同行的新闻卡不显示,提示条上带着同样的区间且没有被右边缘裁掉;键盘调整时
ArrowRight 加宽 16 px、Shift+ArrowRight 加宽 64 px、ArrowDown 加高 16 px、
Shift+ArrowLeft 收窄 64 px、Home 恢复自适应并给出提示;横向溢出始终为 0。
控制台 0 error / 0 warn。
- 新增 miniapp/node/security-aliases.mjs:指数与常见 ETF 的名称 → 代码对照表。
  指数代码不能靠 6 位数字推市场——000001 在深市是平安银行,在沪市才是上证指数,
  所以这里把市场前缀显式写出来。覆盖上证指数、深证成指、沪深300、上证50、
  中证500、中证1000、创业板指、创业板50、科创50、北证50,以及沪深300ETF、
  上证50ETF、创业板ETF、科创50ETF、证券ETF、中概互联网ETF。
- resolveInput 接入别名表:名称大小写不敏感、忽略中间空白;ETF 仍然可以直接
  填 6 位代码(510xxx / 588xxx 在沪市,159xxx 在深市)。
- 客户端输入框提示改为"代码、指数或品种",白名单拒绝时的提示补上"指数名称"。
- 新增 tests/security-aliases.test.mjs:8 个用例把每个别名的市场归属钉死,
  包括"上证指数必须是 sh000001"这条容易搞反的。

实测:在真实界面里输入「沪深300」新增的那一行是 sh000300 上的沪深300 并带实时行情,
「科创50ETF」解析到 sh588000;上证指数(sh000001)、深证成指(sz399001)、创业板指(sz399006)、
科创50(sh000688)、上证50(sh000016)、中证500(sh000905)、中证1000(sh000852)、
创业板50(sz399673)、北证50(bj899050)、沪深300ETF(sh510300)、上证50ETF(sh510050)、
创业板ETF(sz159915)、科创50ETF(sh588000)、证券ETF(sh512880)、中概互联网ETF(sh513050)
逐个走接口都能取到行情;认不出来的名称按白名单挡下,自选股保持原样。
包内自测合计 24 个用例全部通过,npm run validate 与仓库自带的 npm run check 结果不变。
- 新增 miniapp/node/security-index.mjs:把行情方的公开检索接口包装成名称候选。
  只收个股、ETF 与指数,板块、美股、港股和开放式基金都过滤掉;新三板里只保留
  920 段的北证 A 股,其余是取不到行情的挂牌公司。
- 新增 GET /api/search?q=:输入名称时在输入框下方列出候选,可用鼠标点选,
  也可以上下键加回车选中;服务端不认这个名字时也会自动列出候选。
- 查到的名称写进 context.dataDir 的 security-index.json(代码、市场、名称三项,
  原子写),下次直接命中本地;上游不可用时退回本地缓存,再退回内置的指数与 ETF
  别名表,输入框照常可用。
- 客户端输入框提示改为"代码或名称(可模糊搜索)",补上候选列表的样式与键盘操作。
- 新增 tests/security-index.test.mjs:12 个用例覆盖上游响应解析、候选排序、本地
  缓存匹配与别名兜底,其中"沪深300 要落在 sh000300 而不是深市那只"这条钉死了。

没有采用"下载一份全市场清单再在本地匹配"的方案:那份清单要连翻将近一百页,上游
被这样密集地请求之后会直接掐连接,被掐之后看板自己用的行情接口也会一起取不到数,
等于把核心功能押在一次批量抓取上。一次搜索一个请求不会造成这种后果。

实测:在真实界面里输入「银行」,候选列表返回 12 条——浦发银行(sh600000)、
华夏银行(sh600015)、民生银行、招商银行、无锡银行等,板块项(银行Ⅱ)被过滤掉;
ArrowDown 把选中项移到华夏银行,回车后新增的那一行是 sh600015 上的华夏银行并带上
实时行情,计数变成 5 项,随后移除恢复成 4 项;直接打接口确认「银行」约 0.2 秒返回
12 条候选;把上游弄成不可达,确认本地缓存、缓存里的指数名与内置别名表依次接管。
包内自测合计 36 个用例全部通过,npm run validate 结果不变,仓库自带的 npm run check
仍是 94 过 / 2 失败(那两个是仓库自己的 symlink 用例在 Windows 上 EPERM,与本包无关)。
- 每条自选股左上角加一个握把手柄,按住拖动就能把它挪到别的位置;两栏网格里按行、
  按列找到插入点,手柄本身是一个真正的按钮,获得焦点后用上下方向键也能上下移动,
  两条路径共用同一套保存逻辑。
- 拖动用 pointer 事件自己实现,不依赖 HTML5 拖放:Mini App 运行在嵌入面板里,
  HTML5 拖放的事件并不可靠。move / up / cancel 的监听挂在 window 上,指针离开卡片
  之后依然跟得上;按下后移动超过 3 px 才算开始拖动,误触不会改变顺序。
- 服务端 /api/watchlist 增加 reorder 动作,只接受现有清单的一个排列——条目不变、
  不重复、且都已经在清单里,因此这条接口没法被用来绕过白名单增删条目。非法时返回
  400 并提示「排序参数无效:必须与当前自选股完全一致」。
- 新增 miniapp/node/watchlist-order.mjs 与 tests/watchlist-order.test.mjs:13 个
  用例把排列校验的边界钉死(少一条、多一条、重复、塞入清单外的代码、非数组参数、
  空清单)。
- 客户端在服务端拒绝新顺序时,按服务端仍然持有的顺序重画列表,界面与存下来的
  自选股不会对不上。

实测:在真实界面里用鼠标把最后一个条目(上证指数)拖到两栏网格的第一位,确认条目
挪到了最前、保存新顺序的 POST 返回 200、watchlist.json 里读到了新顺序;用聚焦把手
上的方向键把一条往下挪一位,确认条目确实移动、列表重画之后焦点仍留在同一个把手上、
请求同样返回 200;重启 Mini App,确认顺序按离开时的样子回来;随后把自选股恢复成
原来的顺序。控制台 0 error / 0 warn,网络无失败请求。
包内自测合计 49 个用例全部通过,npm run validate 结果不变,仓库自带的 npm run check
仍是 94 过 / 2 失败(那两个是仓库自己的 symlink 用例在 Windows 上 EPERM,与本包无关)。
- 新闻卡片的栏目标签下面加了一个筛选框,输入的词命中之后,当前栏目里只留下提到
  这些词的条目;标题、摘要与来源名都参与匹配,大小写不敏感,多个词用空格分开按
  「或」匹配。右侧显示「命中 / 总数」的计数,一条都没命中时给出提示而不是空白列表。
- 筛选完全在页面里完成:栏目照旧抓取,筛选只决定其中哪些条目显示,既不会让上游
  少给,也不会让它多答一次,因此没有动服务端,也没有新增任何网络请求。
- 匹配规则单独放在 <script id="wnb-news-filter"> 里,和布局算法一样是可独立测试的
  纯函数;新增 tests/news-filter.test.mjs:19 个用例覆盖关键词切分、去重、大小写、
  「或」关系、标题 / 摘要 / 来源三种命中来源,以及空输入与非数组入参的边界。
- 筛选词存进 localStorage 的视图状态,刷新与重启之后依然在;切换栏目时筛选继续
  生效并按新栏目重新计数。

实测:在真实界面里输入「A股」,确认只剩提到它的那一条、计数显示「1 / 30 条」;用
空格分开的两个词按「或」匹配,返回三条,其中一条是靠摘要而不是标题命中的;输入一
个谁也匹配不上的词,确认显示「没有匹配「…」的新闻」而不是空白列表、计数为
「0 / 30 条」;点清除按钮恢复全部三十条、计数消失;切到「科技」栏目,筛选继续生效
并按新栏目重新计数(「14 / 70 条」);anthropic 与 ANTHROPIC 返回同样的两条,确认
匹配不区分大小写;热榜栏目同样能筛(热榜条目没有摘要,只按标题匹配);重启 Mini App
确认筛选词、栏目与计数都按离开时的样子回来。控制台 0 error / 0 warn,网络无失败请求。
包内自测合计 68 个用例全部通过,npm run validate 结果不变,仓库自带的 npm run check
仍是 94 过 / 2 失败(那两个是仓库自己的 symlink 用例在 Windows 上 EPERM,与本包无关)。
@cursor
cursor Bot force-pushed the feat/weather-news-board branch from 6d2cc93 to 0ec72ec Compare November 30, 2026 08:22
@MyPrototypeWhat
MyPrototypeWhat merged commit 1cf8542 into MiniMax-AI:main Nov 30, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants