Skip to content

Commit

Permalink
fix: replace jsdelivr cdn
Browse files Browse the repository at this point in the history
  • Loading branch information
xjh22222228 committed Aug 21, 2024
1 parent 3db7ff1 commit 0afc558
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 24 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<p align="center">
<a href="https://nav3.cn/?g">
<img src="https://cdn.jsdelivr.net/gh/xjh22222228/public@gh-pages/nav/logo.svg" width="130" />
<img src="https://gcore.jsdelivr.net/gh/xjh22222228/public@gh-pages/nav/logo.svg" width="130" />
</a>
<br />
<b>发现导航</b>
Expand Down Expand Up @@ -70,7 +70,7 @@
- [https://faxian.vercel.app/](https://faxian.vercel.app/)
- [https://xjh22222228.github.io/nav-web/](https://xjh22222228.github.io/nav-web/)

![Preview](https://cdn.jsdelivr.net/gh/xjh22222228/public@gh-pages/nav/preview.gif)
![Preview](https://gcore.jsdelivr.net/gh/xjh22222228/public@gh-pages/nav/preview.gif)

## 可以干嘛

Expand Down Expand Up @@ -112,7 +112,7 @@

自有部署一直不是发现导航的需求目标,但陆续有人问,决定从`v8.8.0`版本开始支持!

[成为我们的会员](https://cdn.jsdelivr.net/gh/xjh22222228/public@gh-pages/nav/support2.svg)
[成为我们的会员](https://gcore.jsdelivr.net/gh/xjh22222228/public@gh-pages/nav/support2.svg)

#### Fork vs 自有部署

Expand Down Expand Up @@ -193,9 +193,9 @@ yarn build

您可以请作者喝杯咖啡,继续战斗下去(请备注 GitHub 名字)~

<img src="https://cdn.jsdelivr.net/gh/xjh22222228/public@gh-pages/img/32.png" width="600">
<img src="https://gcore.jsdelivr.net/gh/xjh22222228/public@gh-pages/img/32.png" width="600">

<img src="https://cdn.jsdelivr.net/gh/xjh22222228/public@gh-pages/nav/thank.png" width="200" />
<img src="https://gcore.jsdelivr.net/gh/xjh22222228/public@gh-pages/nav/thank.png" width="200" />

## License

Expand Down
2 changes: 1 addition & 1 deletion scripts/db.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,7 @@ export default [
id: 103,
},
{
icon: 'https://cdn.jsdelivr.net/gh/txxxjs/fk/ifkdy/2020-03-16/favicon.ico',
icon: 'https://gcore.jsdelivr.net/gh/txxxjs/fk/ifkdy/2020-03-16/favicon.ico',
name: '疯狂影视搜索',
desc: '疯狂影视搜索是一款全能影视搜索引擎,帮你找到最新影视资源,一站拥有无尽影视资源',
url: 'http://ifkdy.com/',
Expand Down
2 changes: 1 addition & 1 deletion scripts/loading.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default {
`.trim(),

loading3: `
<style>.l__1{z-index:999;position:fixed;top:0;left:0;right:0;bottom:0;background-color:#fff;display:flex;align-items:center;justify-content:center;flex-direction:column;}.l__2{width:200px;height:200px;background:url("https://cdn.jsdelivr.net/gh/xjh22222228/public@gh-pages/nav/0020f4d5-9f70-4b7f-87d4-61310d1db8d1.svg");background-repeat:repeat;}.l__3{font-size:18px;margin-top:15px;font-weight:bold;color:#000;}</style>
<style>.l__1{z-index:999;position:fixed;top:0;left:0;right:0;bottom:0;background-color:#fff;display:flex;align-items:center;justify-content:center;flex-direction:column;}.l__2{width:200px;height:200px;background:url("https://gcore.jsdelivr.net/gh/xjh22222228/public@gh-pages/nav/0020f4d5-9f70-4b7f-87d4-61310d1db8d1.svg");background-repeat:repeat;}.l__3{font-size:18px;margin-top:15px;font-weight:bold;color:#000;}</style>
<div class="l__1"><div class="l__2"></div><div class="l__3">......</div></div>
`.trim(),

Expand Down
63 changes: 49 additions & 14 deletions scripts/start.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@
import fs from 'fs'
import path from 'path'
import defaultDb from './db.mjs'
import { TAG_ID1, TAG_ID2, TAG_ID3, getWebCount, setWeb } from './util.mjs'
import {
TAG_ID1,
TAG_ID2,
TAG_ID3,
getWebCount,
setWeb,
replaceJsdelivrCDN,
} from './util.mjs'

const packagePath = path.join('.', 'package.json')
const packageJson = JSON.parse(fs.readFileSync(packagePath).toString())
Expand Down Expand Up @@ -50,52 +57,52 @@ try {
search = [
{
name: '站内',
icon: 'https://cdn.jsdelivr.net/gh/xjh22222228/public@gh-pages/nav/logo.svg',
icon: 'https://gcore.jsdelivr.net/gh/xjh22222228/public@gh-pages/nav/logo.svg',
placeholder: '站内搜索',
blocked: false,
isInner: true,
},
{
name: '百度',
url: 'https://www.baidu.com/s?wd=',
icon: 'https://cdn.jsdelivr.net/gh/xjh22222228/nav-web@image/baidu.svg',
icon: 'https://gcore.jsdelivr.net/gh/xjh22222228/nav-web@image/baidu.svg',
placeholder: '百度一下',
blocked: false,
isInner: false,
},
{
name: 'Google',
url: 'https://www.google.com/search?q=',
icon: 'https://cdn.jsdelivr.net/gh/xjh22222228/nav-web@image/google.svg',
icon: 'https://gcore.jsdelivr.net/gh/xjh22222228/nav-web@image/google.svg',
blocked: false,
isInner: false,
},
{
name: '必应',
url: 'https://cn.bing.com/search?q=',
icon: 'https://cdn.jsdelivr.net/gh/xjh22222228/nav-web@image/bing.svg',
icon: 'https://gcore.jsdelivr.net/gh/xjh22222228/nav-web@image/bing.svg',
blocked: false,
isInner: false,
},
{
name: 'GitHub',
url: 'https://github.com/search?q=',
icon: 'https://cdn.jsdelivr.net/gh/xjh22222228/nav-web@image/github.svg',
icon: 'https://gcore.jsdelivr.net/gh/xjh22222228/nav-web@image/github.svg',
placeholder: 'Search GitHub',
blocked: false,
isInner: false,
},
{
name: '知乎',
url: 'https://www.zhihu.com/search?type=content&q=',
icon: 'https://cdn.jsdelivr.net/gh/xjh22222228/nav-web@image/zhihu.svg',
icon: 'https://gcore.jsdelivr.net/gh/xjh22222228/nav-web@image/zhihu.svg',
blocked: false,
isInner: false,
},
{
name: '豆瓣',
url: 'https://search.douban.com/book/subject_search?search_text=',
icon: 'https://cdn.jsdelivr.net/gh/xjh22222228/nav-web@image/douban.svg',
icon: 'https://gcore.jsdelivr.net/gh/xjh22222228/nav-web@image/douban.svg',
placeholder: '书名、作者、ISBN',
blocked: false,
isInner: false,
Expand All @@ -105,6 +112,11 @@ try {
encoding: 'utf-8',
})
}

search = search.map((item) => {
item.icon = replaceJsdelivrCDN(item.icon)
return item
})
}

{
Expand Down Expand Up @@ -152,14 +164,14 @@ try {

{
const banner1 =
'https://cdn.jsdelivr.net/gh/xjh22222228/public@gh-pages/nav/banner1.jpg'
'https://gcore.jsdelivr.net/gh/xjh22222228/public@gh-pages/nav/banner1.jpg'
const banner2 =
'https://cdn.jsdelivr.net/gh/xjh22222228/public@gh-pages/nav/banner2.jpg'
'https://gcore.jsdelivr.net/gh/xjh22222228/public@gh-pages/nav/banner2.jpg'
const backgroundImg =
'https://cdn.jsdelivr.net/gh/xjh22222228/public@gh-pages/nav/background.jpg'
'https://gcore.jsdelivr.net/gh/xjh22222228/public@gh-pages/nav/background.jpg'

settings.favicon ??=
'https://cdn.jsdelivr.net/gh/xjh22222228/public@gh-pages/nav/logo.svg'
'https://gcore.jsdelivr.net/gh/xjh22222228/public@gh-pages/nav/logo.svg'
settings.language ||= 'zh-CN'
settings.loading ??= 'random'
settings.allowCollect ??= true
Expand Down Expand Up @@ -210,11 +222,11 @@ try {
settings.superTitle ??= ''
const defImgs = [
{
src: 'https://cdn.jsdelivr.net/gh/xjh22222228/nav-web@image/nav-1717494364392-ad.jpg',
src: 'https://gcore.jsdelivr.net/gh/xjh22222228/nav-web@image/nav-1717494364392-ad.jpg',
url: 'https://haokawx.lot-ml.com/Product/index/454266',
},
{
src: 'https://cdn.jsdelivr.net/gh/xjh22222228/public@gh-pages/img/10.png',
src: 'https://gcore.jsdelivr.net/gh/xjh22222228/public@gh-pages/img/10.png',
url: '',
},
]
Expand Down Expand Up @@ -267,6 +279,29 @@ try {
settings.loadingCode ??= ''

settings.appCardStyle ??= 'common'

// 替换CDN
settings.favicon = replaceJsdelivrCDN(settings.favicon)
settings.simThemeImages = settings.simThemeImages.map((item) => {
item.src = replaceJsdelivrCDN(item.src)
return item
})
settings.superImages = settings.superImages.map((item) => {
item.src = replaceJsdelivrCDN(item.src)
return item
})
settings.lightImages = settings.lightImages.map((item) => {
item.src = replaceJsdelivrCDN(item.src)
return item
})
settings.sideThemeImages = settings.sideThemeImages.map((item) => {
item.src = replaceJsdelivrCDN(item.src)
return item
})
settings.shortcutThemeImages = settings.shortcutThemeImages.map((item) => {
item.src = replaceJsdelivrCDN(item.src)
return item
})
fs.writeFileSync(settingsPath, JSON.stringify(settings), {
encoding: 'utf-8',
})
Expand Down
8 changes: 8 additions & 0 deletions scripts/util.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export function setWeb(nav) {
webItem.name ||= ''
webItem.desc ||= ''
webItem.icon ||= ''
webItem.icon = replaceJsdelivrCDN(webItem.icon)
webItem.url = webItem.url.trim()
webItem.desc = webItem.desc.trim()

Expand Down Expand Up @@ -395,3 +396,10 @@ export async function spiderWeb(db, settings) {
time: diff,
}
}

export function replaceJsdelivrCDN(str = '') {
// testingcf.jsdelivr.net
// img.jsdmirror.com
// gcore.jsdelivr.net
return str.replace('cdn.jsdelivr.net', 'gcore.jsdelivr.net')
}
2 changes: 1 addition & 1 deletion src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export function getCDN(path: string, branch = 'image') {
if (isGitee()) {
return `https://gitee.com/${authorName}/${repoName}/raw/${branch}/${path}`
}
return `https://cdn.jsdelivr.net/gh/${authorName}/${repoName}@${branch}/${path}`
return `https://gcore.jsdelivr.net/gh/${authorName}/${repoName}@${branch}/${path}`
}

function requestActionUrl() {
Expand Down
2 changes: 1 addition & 1 deletion src/view/system/about/index.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
<p>在使用过程遇到任何问题可发送邮件寻求帮助</p>

<img
src="https://cdn.jsdelivr.net/gh/xjh22222228/public@gh-pages/img/32.png"
src="https://gcore.jsdelivr.net/gh/xjh22222228/public@gh-pages/img/32.png"
width="600"
/>
2 changes: 1 addition & 1 deletion src/view/system/vip-auth/index.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</button>
<div class="mt10">
<img
src="https://cdn.jsdelivr.net/gh/xjh22222228/public@gh-pages/nav/support2.svg"
src="https://gcore.jsdelivr.net/gh/xjh22222228/public@gh-pages/nav/support2.svg"
class="poster"
/>
</div>
Expand Down

0 comments on commit 0afc558

Please sign in to comment.