-
Notifications
You must be signed in to change notification settings - Fork 9.8k
feat: add China National Museum exhibition route #21891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
magazian
wants to merge
18
commits into
DIYgod:master
Choose a base branch
from
magazian:feat-chnmuseum
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+299
−0
Open
Changes from 4 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
6bbcc4d
feat: add China National Museum exhibition route
magazian 5ff9b51
Update route.ts
magazian 19a0712
Update zl.ts
magazian 8795c62
Update zl.ts
magazian 6656365
Update zl.ts
magazian 93b8e70
fix: refactor to JSX and fix cache import
magazian 36334e9
fix: refactor to JSX, fix duration and fix import
magazian 3787bd5
fix: replaceAll, if and regualr expression range
magazian 7aaf6d4
Update zl.ts
magazian daabbb0
fix: refactor extra output and import namespace
magazian 0d3c395
fix: fix error
magazian 0068743
fix: adjust fullduration logic
magazian 5ae90b7
feat: refactor route file with type and subtype used
magazian 4e6a74e
fix: reduce the complexity
magazian a2be2b4
fix: remove trim() for title
magazian b765327
fix: remove redundancy and fix error
magazian 03c2b18
fix: remove toLowerCase redundancy
magazian e6df7dc
fix: remove trim for title
magazian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import type { Router } from '@/types'; | ||
|
|
||
| const router = (router: Router) => { | ||
| router.get('/zl', './zl'); | ||
| }; | ||
|
|
||
| export default router; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import { load } from 'cheerio'; | ||
Check failureCode scanning / oxlint simple-import-sort(imports) Error
Run autofix to sort these imports!
|
||
|
github-advanced-security[bot] marked this conversation as resolved.
Fixed
github-advanced-security[bot] marked this conversation as resolved.
Fixed
github-advanced-security[bot] marked this conversation as resolved.
Fixed
|
||
| import type { Route } from '@/types'; | ||
|
github-advanced-security[bot] marked this conversation as resolved.
Fixed
|
||
| import got from '@/utils/got'; | ||
|
|
||
| export const route: Route = { | ||
| path: '/zl', | ||
| categories: ['travel'], | ||
| example: '/chnmuseum/zl', | ||
| name: '中国国家博物馆 - 展览', | ||
| maintainers: ['magazian'], | ||
| handler: async () => { | ||
| const baseUrl = 'https://www.chnmuseum.cn'; | ||
| const url = `${baseUrl}/zl/`; | ||
|
|
||
| const response = await got(url); | ||
| const $ = load(response.data); | ||
|
|
||
| const list = $('ul#div li') | ||
| .toArray() | ||
| .map((item) => { | ||
| const $item = $(item); | ||
| const $link = $item.find('a.recurl'); | ||
|
|
||
| const relativeLink = $link.attr('href') || ''; | ||
| const itemLink = relativeLink.startsWith('.') | ||
| ? new URL(relativeLink, url).href | ||
| : `${baseUrl}${relativeLink}`; | ||
|
|
||
| const title = $item.find('div.cj_zxx3 p').text().trim(); | ||
| const imgUrl = new URL($item.find('img').first().attr('src') || '', url).href; | ||
| const location = $item.find('div.cj_zxx1').text().trim(); | ||
| const duration = $item.find('div.cj_zxx2 p').text().trim(); | ||
|
|
||
| return { | ||
| title, | ||
| link: itemLink, | ||
| description: ` | ||
| <img src='${imgUrl}'><br> | ||
| <p><b>地点:</b>${location}</p> | ||
| <p><b>展期:</b>${duration}</p> | ||
| `.trim(), | ||
| }; | ||
| }); | ||
|
|
||
| return { | ||
| title: '中国国家博物馆 - 展览', | ||
| link: url, | ||
| item: list, | ||
| }; | ||
| }, | ||
| }; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.