From 7dded9acf2cd40f9064351c519f6d72c0b455103 Mon Sep 17 00:00:00 2001 From: xjh22222228 Date: Sun, 14 Jul 2024 15:51:32 +0800 Subject: [PATCH 01/71] docs: update --- README.md | 54 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index a772d941cd..dffc002c51 100644 --- a/README.md +++ b/README.md @@ -17,48 +17,50 @@

-## 预览 - -- [https://nav3.cn/](https://nav3.cn/) -- [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/1.png) -![Preview](https://cdn.jsdelivr.net/gh/xjh22222228/public@gh-pages/nav/8.png) -![Preview](https://cdn.jsdelivr.net/gh/xjh22222228/public@gh-pages/nav/3.png) -![Preview](https://cdn.jsdelivr.net/gh/xjh22222228/public@gh-pages/nav/4.png) -![Preview](https://cdn.jsdelivr.net/gh/xjh22222228/public@gh-pages/nav/6.png) -![Preview](https://cdn.jsdelivr.net/gh/xjh22222228/public@gh-pages/nav/9.png) -![Preview](https://cdn.jsdelivr.net/gh/xjh22222228/public@gh-pages/nav/7.png) - ## 特性 +三不需:`无需数据库`、`无需服务器`、`无需成本` + `发现导航` 的理念就是做一款无需依赖后端服务既简单又方便,没有繁杂的配置和数据库等配置概念, 做到开箱即用。 - 🍰 内置 `800+` 优质网站 - 🍰 支持 [码云 Gitee](https://gitee.com/xiejiahe/nav) +- 🍰 支持从 Chrome 书签导入 - 🍰 支持用户提交收录 - 🍰 丰富的资源配置系统 - 🍰 支持 SEO 搜索引擎 -- 🍰 完全纯静态, 提供自动化部署功能 -- 🍰 三叉树分类、结构清晰、分类清晰 -- 🍰 支持一个网站关联多个网址 -- 🍰 颜值与简约并存,不再是杀马特时代 -- 🍰 完全开源,轻松定制化 +- 🍰 支持网站关联多个网址 +- 🍰 支持检测网站存活状态 +- 🍰 支持配置仅自己可见 +- 🍰 自动抓取网站图标/名称/描述 +- 🍰 支持暗黑模式 +- 🍰 支持后台管理, 无需部署 - 🍰 支持多种浏览模式,创新 - 🍰 支持足迹记忆 - 🍰 支持多种搜索查询 - 🍰 支持自定义引擎搜索 - 🍰 多款高颜值主题切换 -- 🍰 支持暗黑模式 -- 🍰 支持后台管理, 无需部署 -- 🍰 支持从 Chrome 书签导入 +- 🍰 强大的响应式系统 - 🍰 多种 Loading 加载动画 - 🍰 多种卡片风格设计 -- 🍰 支持检测网站存活状态 -- 🍰 支持配置仅自己可见 -- 🍰 强大的响应式系统 -- 🍰 自动抓取网站图标/名称/描述 +- 🍰 完全纯静态, 提供自动化部署功能 +- 🍰 三叉树分类、结构清晰、分类清晰 +- 🍰 颜值与简约并存,不再是杀马特时代 +- 🍰 完全开源,轻松定制化 + +## 预览 + +- [https://nav3.cn/](https://nav3.cn/) +- [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/1.png) +![Preview](https://cdn.jsdelivr.net/gh/xjh22222228/public@gh-pages/nav/8.png) +![Preview](https://cdn.jsdelivr.net/gh/xjh22222228/public@gh-pages/nav/3.png) +![Preview](https://cdn.jsdelivr.net/gh/xjh22222228/public@gh-pages/nav/4.png) +![Preview](https://cdn.jsdelivr.net/gh/xjh22222228/public@gh-pages/nav/6.png) +![Preview](https://cdn.jsdelivr.net/gh/xjh22222228/public@gh-pages/nav/9.png) +![Preview](https://cdn.jsdelivr.net/gh/xjh22222228/public@gh-pages/nav/7.png) ## 可以干嘛 From 7e80e4c174ab88390d1e5c5ada989756f07db939 Mon Sep 17 00:00:00 2001 From: xjh22222228 Date: Fri, 19 Jul 2024 15:17:42 +0800 Subject: [PATCH 02/71] =?UTF-8?q?feat:=20=E4=BA=8C=E4=B8=89=E7=BA=A7?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E7=A7=BB=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/move-web/index.component.html | 2 + src/components/move-web/index.component.ts | 104 ++++++++++++++----- src/locale/english.ts | 1 + src/locale/zh_CN.ts | 1 + src/view/system/collect/index.component.html | 4 +- src/view/system/web/index.component.html | 10 +- src/view/system/web/index.component.ts | 3 +- 7 files changed, 94 insertions(+), 31 deletions(-) diff --git a/src/components/move-web/index.component.html b/src/components/move-web/index.component.html index 895693131a..8e039dcef3 100644 --- a/src/components/move-web/index.component.html +++ b/src/components/move-web/index.component.html @@ -27,6 +27,7 @@ [nzPlaceHolder]="$t('_sel2')" (ngModelChange)="hanldeTwoSelect($event)" style="width: 160px; margin-left: 15px" + *ngIf="level > 2" > = [] + level = 4 constructor(private message: NzMessageService) { event.on('MOVE_WEB', (props: any) => { @@ -40,10 +41,12 @@ export class MoveWebComponent { props: { indexs: number[] data: IWebProps[] + level: number } ) { ctx.indexs = props.indexs ctx.moveSites = props.data + ctx.level = props.level ?? 4 ctx.showModal = true } @@ -77,38 +80,87 @@ export class MoveWebComponent { } hanldeOk() { - if (this.threeSelect == null) { - return this.message.error($t('_sel3')) - } const indexs = this.indexs.filter((i) => i != null) - if (indexs.length !== 4) { - return this.message.error(`move web: indexs数量不正确${indexs.join(',')}`) - } + const oneSelect = this.oneSelect as number + const twoSelect = this.twoSelect as number + const threeSelect = this.threeSelect as number try { - const oneSelect = this.oneSelect as number - const twoSelect = this.twoSelect as number - const threeSelect = this.threeSelect as number - this.moveSites.forEach((item: IWebProps) => { - const exists = this.websiteList[oneSelect].nav[twoSelect].nav[ - threeSelect - ].nav.find((el: IWebProps) => el.name === item.name) - - if (exists) { - this.message.error(`${$t('_repeatAdd')} "${item.name}"`) - } else { - this.websiteList[oneSelect].nav[twoSelect].nav[ - threeSelect - ].nav.unshift(item) + if (this.level === 2) { + if (this.oneSelect == null) { + return this.message.error($t('_sel1')) + } + this.moveSites.forEach((item: any) => { + const exists = this.websiteList[oneSelect].nav.find( + (el: any) => el.title === item.title + ) + + if (exists) { + this.message.error(`${$t('_repeatAdd')} "${item.title}"`) + } else { + this.websiteList[oneSelect].nav.unshift(item) - if (!this.checked) { - const [a, b, c, d] = indexs - this.websiteList[a].nav[b].nav[c].nav.splice(d, 1) + if (!this.checked) { + const [a, b, c, d] = indexs + this.websiteList[a].nav.splice(d, 1) + } + + this.message.success(`"${item.title}" ${$t('_moveSuccess')}`) } + }) + } else if (this.level === 3) { + if (this.twoSelect == null) { + return this.message.error($t('_sel2')) + } + this.moveSites.forEach((item: any) => { + const exists = this.websiteList[oneSelect].nav[twoSelect].nav.find( + (el: any) => el.title === item.title + ) + + if (exists) { + this.message.error(`${$t('_repeatAdd')} "${item.title}"`) + } else { + this.websiteList[oneSelect].nav[twoSelect].nav.unshift(item) + + if (!this.checked) { + const [a, b, c, d] = indexs + this.websiteList[a].nav[b].nav.splice(d, 1) + } - this.message.success(`"${item.name}" ${$t('_moveSuccess')}`) + this.message.success(`"${item.title}" ${$t('_moveSuccess')}`) + } + }) + } else if (this.level === 4) { + if (this.threeSelect == null) { + return this.message.error($t('_sel3')) + } + if (indexs.length !== 4) { + return this.message.error( + `move web: indexs数量不正确${indexs.join(',')}` + ) } - }) + this.moveSites.forEach((item: any) => { + const exists = this.websiteList[oneSelect].nav[twoSelect].nav[ + threeSelect + ].nav.find((el: any) => el.name === item.name) + + if (exists) { + this.message.error(`${$t('_repeatAdd')} "${item.name}"`) + } else { + this.websiteList[oneSelect].nav[twoSelect].nav[ + threeSelect + ].nav.unshift(item) + + if (!this.checked) { + const [a, b, c, d] = indexs + this.websiteList[a].nav[b].nav[c].nav.splice(d, 1) + } + + this.message.success(`"${item.name}" ${$t('_moveSuccess')}`) + } + }) + } + setWebsiteList(this.websiteList) this.handleCancel() } catch (error: any) { diff --git a/src/locale/english.ts b/src/locale/english.ts index f360da7a12..21f54ec4f5 100644 --- a/src/locale/english.ts +++ b/src/locale/english.ts @@ -217,6 +217,7 @@ const english: Record = { 'Due to network factors, some websites may not be accessible and can be skipped directly. For reference only', _spiderBuildTip: 'After the construction is completed, the data is correct. Please go to the website management and click save once, otherwise the data will not be permanently stored', + _associatedLabels: 'Labels', } export default english diff --git a/src/locale/zh_CN.ts b/src/locale/zh_CN.ts index 1404f6dffb..e91d218587 100644 --- a/src/locale/zh_CN.ts +++ b/src/locale/zh_CN.ts @@ -207,6 +207,7 @@ const zhCN: Record = { _spiderNetTip: '由于网络因素,部分网站可能无法访问直接跳过,仅供参考', _spiderBuildTip: '构建完成后对数据无误,请到网站管理点击一次保存,否则数据不会永久存储', + _associatedLabels: '关联标签', } export default zhCN diff --git a/src/view/system/collect/index.component.html b/src/view/system/collect/index.component.html index 35c0eef145..6d59150925 100644 --- a/src/view/system/collect/index.component.html +++ b/src/view/system/collect/index.component.html @@ -69,9 +69,9 @@ {{ $t('_action') }} {{ $t('_icon') }} {{ $t('_webName') }} - {{ $t('_webTag') }} + {{ $t('_associatedLabels') }} {{ $t('_webDesc') }} - 分类位置 + {{ $t('_webTag') }} {{ $t('_createAt') }} diff --git a/src/view/system/web/index.component.html b/src/view/system/web/index.component.html index d0a2d4858c..c8b5e21c1e 100644 --- a/src/view/system/web/index.component.html +++ b/src/view/system/web/index.component.html @@ -198,6 +198,9 @@ {{ data.createdAt }} {{ $t('_edit') }} + {{ + $t('_move') + }} {{ data.createdAt }} {{ $t('_edit') }} + {{ + $t('_move') + }} 状态 {{ $t('_icon') }} {{ $t('_webName') }} - {{ $t('_webTag') }} + {{ $t('_associatedLabels') }} {{ $t('_onlyOwnVisible') }} {{ $t('_webDesc') }} - 分类位置 + {{ $t('_webTag') }} {{ $t('_createAt') }} diff --git a/src/view/system/web/index.component.ts b/src/view/system/web/index.component.ts index 6abb4bc058..c1cbbf2a58 100644 --- a/src/view/system/web/index.component.ts +++ b/src/view/system/web/index.component.ts @@ -260,7 +260,7 @@ export default class WebpComponent { history.go(-1) } - openMoveWebModal(data: IWebProps, index: number) { + openMoveWebModal(data: any, index: number, level?: number) { const oneIndex = this.websiteList.findIndex( (item) => item.title === this.oneSelect ) @@ -273,6 +273,7 @@ export default class WebpComponent { event.emit('MOVE_WEB', { indexs: [oneIndex, twoIndex, threeIndex, index], data: [data], + level, }) } From 4e38756b94b0668656babaf620a85128c4c00d86 Mon Sep 17 00:00:00 2001 From: xjh22222228 Date: Thu, 25 Jul 2024 10:41:39 +0800 Subject: [PATCH 03/71] fix: reset data --- src/components/move-web/index.component.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/components/move-web/index.component.ts b/src/components/move-web/index.component.ts index 8a09c6a7e4..d82b264376 100644 --- a/src/components/move-web/index.component.ts +++ b/src/components/move-web/index.component.ts @@ -44,6 +44,11 @@ export class MoveWebComponent { level: number } ) { + ctx.oneSelect = undefined + ctx.twoSelect = undefined + ctx.threeSelect = undefined + ctx.twoOptList = [] + ctx.threeOptList = [] ctx.indexs = props.indexs ctx.moveSites = props.data ctx.level = props.level ?? 4 From 9bcb53f0e1547a20d99a459f46b0e26b819abd5c Mon Sep 17 00:00:00 2001 From: xjh22222228 Date: Fri, 26 Jul 2024 10:38:51 +0800 Subject: [PATCH 04/71] fix: add safeHtml --- src/view/sim/index.component.html | 5 ++++- src/view/system/web/index.component.html | 2 +- src/view/system/web/index.component.ts | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/view/sim/index.component.html b/src/view/sim/index.component.html index ce3c4b57e4..2929aae1cb 100644 --- a/src/view/sim/index.component.html +++ b/src/view/sim/index.component.html @@ -13,7 +13,10 @@

{{ settings.simTitle || settings.title }}

-

+      

       
     
   
diff --git a/src/view/system/web/index.component.html b/src/view/system/web/index.component.html
index c8b5e21c1e..1bc713b603 100644
--- a/src/view/system/web/index.component.html
+++ b/src/view/system/web/index.component.html
@@ -329,7 +329,7 @@
       
     
 
-    
+    
       
Date: Fri, 26 Jul 2024 19:51:05 +0800
Subject: [PATCH 05/71] feat: Export browser bookmarks

---
 README.md                                     |  1 +
 src/app/app-routing.module.ts                 | 10 ++++
 src/app/app.module.ts                         |  2 +
 src/locale/english.ts                         |  6 +-
 src/locale/zh_CN.ts                           |  5 +-
 src/services/index.ts                         |  4 ++
 src/utils/http.ts                             |  4 +-
 src/utils/index.ts                            | 14 +++++
 .../bookmark-export/index.component.html      |  7 +++
 .../bookmark-export/index.component.scss      |  4 ++
 .../system/bookmark-export/index.component.ts | 48 ++++++++++++++++
 src/view/system/collect/index.component.html  | 30 +---------
 src/view/system/index.component.html          | 14 +++++
 src/view/system/vip-auth/index.component.html | 35 ++++++++++++
 src/view/system/vip-auth/index.component.scss | 11 ++++
 src/view/system/vip-auth/index.component.ts   | 57 +++++++++++++++++++
 16 files changed, 218 insertions(+), 34 deletions(-)
 create mode 100644 src/view/system/bookmark-export/index.component.html
 create mode 100644 src/view/system/bookmark-export/index.component.scss
 create mode 100644 src/view/system/bookmark-export/index.component.ts
 create mode 100644 src/view/system/vip-auth/index.component.html
 create mode 100644 src/view/system/vip-auth/index.component.scss
 create mode 100644 src/view/system/vip-auth/index.component.ts

diff --git a/README.md b/README.md
index dffc002c51..2513647b0e 100644
--- a/README.md
+++ b/README.md
@@ -26,6 +26,7 @@
 - 🍰 内置 `800+` 优质网站
 - 🍰 支持 [码云 Gitee](https://gitee.com/xiejiahe/nav)
 - 🍰 支持从 Chrome 书签导入
+- 🍰 支持将数据导出到浏览器书签
 - 🍰 支持用户提交收录
 - 🍰 丰富的资源配置系统
 - 🍰 支持 SEO 搜索引擎
diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts
index bd26dd1ed5..a0e7ab4c67 100644
--- a/src/app/app-routing.module.ts
+++ b/src/app/app-routing.module.ts
@@ -11,6 +11,7 @@ import SimComponent from '../view/sim/index.component'
 import SystemComponent from '../view/system/index.component'
 import SystemInfoComponent from '../view/system/info/index.component'
 import SystemBookmarkComponent from '../view/system/bookmark/index.component'
+import SystemBookmarkExportComponent from '../view/system/bookmark-export/index.component'
 import SystemAboutComponent from '../view/system/about/index.component'
 import SystemTagComponent from '../view/system/tag/index.component'
 import SystemSearchComponent from '../view/system/search/index.component'
@@ -21,6 +22,7 @@ import SideComponent from '../view/side/index.component'
 import ShortcutComponent from '../view/shortcut/index.component'
 import CollectComponent from '../view/system/collect/index.component'
 import WebpComponent from '../view/app/default/app.component'
+import VipAuthComponent from '../view/system/vip-auth/index.component'
 
 const routes: Routes = [
   {
@@ -63,10 +65,18 @@ const routes: Routes = [
         path: 'bookmark',
         component: SystemBookmarkComponent,
       },
+      {
+        path: 'bookmarkExport',
+        component: SystemBookmarkExportComponent,
+      },
       {
         path: 'collect',
         component: CollectComponent,
       },
+      {
+        path: 'vip',
+        component: VipAuthComponent,
+      },
       {
         path: 'about',
         component: SystemAboutComponent,
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index c0f32bc01a..684e254e33 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -74,6 +74,7 @@ import SystemAngleMarkComponent from '../view/system/angle-mark/index.component'
 import SideComponent from '../view/side/index.component'
 import ShortcutComponent from '../view/shortcut/index.component'
 import WebpComponent from '../view/app/default/app.component'
+import VipAuthComponent from '../view/system/vip-auth/index.component'
 
 import { SafeHtmlPipe } from 'src/pipe/safeHtml.pipe'
 
@@ -121,6 +122,7 @@ const icons: IconDefinition[] = [
     SystemAngleMarkComponent,
     SystemWebComponent,
     WebpComponent,
+    VipAuthComponent,
     SwiperComponent,
     FixbarComponent,
     FooterComponent,
diff --git a/src/locale/english.ts b/src/locale/english.ts
index 21f54ec4f5..360f9e1b43 100644
--- a/src/locale/english.ts
+++ b/src/locale/english.ts
@@ -119,7 +119,9 @@ const english: Record = {
   _systemSet: 'Settings',
   _searchEngines: 'Engines',
   _userCollect: 'Collect',
-  _bookmarkImport: 'Bookmark',
+  _bookmarkImport: 'Book Import',
+  _bookmarkExport: 'Book Export',
+  _vipAuth: 'VIP Auth',
   _tagSettings: 'Tag settings',
   _websiteMang: 'Website',
   _addRow: 'Add',
@@ -197,7 +199,7 @@ const english: Record = {
   _defTitle4: 'Default website title, recommended to be within 4 words',
   _inputAuthCode: 'Please enter the authorization code',
   _payTip:
-    'Opening user enrollment requires a payment of ¥99 as a contribution to the stable operation of this website. Thank you for your understanding',
+    'Becoming a VIP allows you to enjoy the full site functionality, and you need to pay ¥99 as a contribution to the stable operation of this site. Thank you for your support',
   _waitHandle: 'Waiting for the stationmaster to handle',
   _collect: 'Get',
   _confirmCollect: 'Are you sure?',
diff --git a/src/locale/zh_CN.ts b/src/locale/zh_CN.ts
index e91d218587..9686c59477 100644
--- a/src/locale/zh_CN.ts
+++ b/src/locale/zh_CN.ts
@@ -117,6 +117,8 @@ const zhCN: Record = {
   _searchEngines: '搜索引擎',
   _userCollect: '用户收录',
   _bookmarkImport: '书签导入',
+  _bookmarkExport: '书签导出',
+  _vipAuth: '会员授权',
   _tagSettings: '标签设置',
   _websiteMang: '网站管理',
   _addRow: '新增一条',
@@ -186,7 +188,8 @@ const zhCN: Record = {
   _sidebarTitle: '侧栏标题',
   _defTitle4: '默认网站标题, 建议4字以内',
   _inputAuthCode: '请输入授权码',
-  _payTip: '开通用户收录功能需支付 ¥99 作为本站稳定运行的贡献,感谢您的理解',
+  _payTip:
+    '成为VIP可享受全站功能,需支付 ¥99 作为本站稳定运行的贡献,感谢您的支持',
   _waitHandle: '提交成功,等待站长处理',
   _collect: '收录',
   _confirmCollect: '您确定要收录吗?',
diff --git a/src/services/index.ts b/src/services/index.ts
index 0bdbc0ff62..d42244b558 100644
--- a/src/services/index.ts
+++ b/src/services/index.ts
@@ -127,6 +127,10 @@ export async function getIconUrl(url: string) {
   return httpNav.post('/api/icon', { url })
 }
 
+export async function bookmarksExport(data: any) {
+  return httpNav.post('/api/export', data)
+}
+
 export function getCDN(path: string, branch = 'image') {
   if (isGitee()) {
     return `https://gitee.com/${authorName}/${repoName}/raw/${branch}/${path}`
diff --git a/src/utils/http.ts b/src/utils/http.ts
index e94efcd5f0..120da079f9 100644
--- a/src/utils/http.ts
+++ b/src/utils/http.ts
@@ -64,8 +64,8 @@ httpInstance.interceptors.response.use(
 
 const httpNavInstance = axios.create({
   timeout: 10000,
-  baseURL: 'https://nav-server.netlify.app',
-  // baseURL: 'http://localhost:3000',
+  // baseURL: 'https://nav-server.netlify.app',
+  baseURL: 'http://localhost:3000',
 })
 
 httpNavInstance.interceptors.request.use(
diff --git a/src/utils/index.ts b/src/utils/index.ts
index e2adbc1531..4c7e8ce645 100644
--- a/src/utils/index.ts
+++ b/src/utils/index.ts
@@ -507,3 +507,17 @@ export function getOverIndex(selector: string): number {
   }
   return overIndex
 }
+
+export function downloadAsFile(str: string, fileName: string) {
+  const blob = new Blob([str], { type: 'text/html' })
+  const url = URL.createObjectURL(blob)
+
+  const a = document.createElement('a')
+  a.href = url
+  a.download = fileName
+  document.body.appendChild(a)
+  a.click()
+
+  document.body.removeChild(a)
+  URL.revokeObjectURL(url)
+}
diff --git a/src/view/system/bookmark-export/index.component.html b/src/view/system/bookmark-export/index.component.html
new file mode 100644
index 0000000000..de60e4dda8
--- /dev/null
+++ b/src/view/system/bookmark-export/index.component.html
@@ -0,0 +1,7 @@
+
+

由于浏览器书签的限制,只能导出对应的分类和网站名称链接

+
+ +

点我导出

+
+
diff --git a/src/view/system/bookmark-export/index.component.scss b/src/view/system/bookmark-export/index.component.scss new file mode 100644 index 0000000000..1c6d33c626 --- /dev/null +++ b/src/view/system/bookmark-export/index.component.scss @@ -0,0 +1,4 @@ +.book-wrapper { + cursor: pointer; + text-align: center; +} diff --git a/src/view/system/bookmark-export/index.component.ts b/src/view/system/bookmark-export/index.component.ts new file mode 100644 index 0000000000..a331e76d1a --- /dev/null +++ b/src/view/system/bookmark-export/index.component.ts @@ -0,0 +1,48 @@ +// @ts-nocheck +// Copyright @ 2018-present xiejiahe. All rights reserved. MIT license. +// See https://github.com/xjh22222228/nav + +import { Component } from '@angular/core' +import { $t } from 'src/locale' +import { NzNotificationService } from 'ng-zorro-antd/notification' +import { NzMessageService } from 'ng-zorro-antd/message' +import { downloadAsFile } from 'src/utils' +import { parseBookmark } from 'src/utils/bookmark' +import { INavProps } from 'src/types' +import { websiteList } from 'src/store' +import { bookmarksExport } from 'src/services' + +@Component({ + selector: 'system-bookmark-export', + templateUrl: './index.component.html', + styleUrls: ['./index.component.scss'], +}) +export default class SystemBookmarkExportComponent { + $t = $t + submitting = false + websiteList: INavProps[] = websiteList + + constructor( + private message: NzMessageService, + private notification: NzNotificationService + ) {} + + ngOnInit() {} + + bookmarksExport() { + if (this.submitting) { + return + } + this.submitting = true + bookmarksExport({ data: this.websiteList }) + .then((res) => { + if (res.data?.success) { + downloadAsFile(res.data.data, '发现导航导出.html') + this.message.success('Successed!') + } + }) + .finally(() => { + this.submitting = false + }) + } +} diff --git a/src/view/system/collect/index.component.html b/src/view/system/collect/index.component.html index 6d59150925..b6b8af76b4 100644 --- a/src/view/system/collect/index.component.html +++ b/src/view/system/collect/index.component.html @@ -1,33 +1,5 @@ -
- - -
-

{{ $t('_payTip') }}

-

- 发送到: xjh22222228@gmail.com - (备注开通域名,支付渠道和支付时间,我们会在24小时内发送授权码给您邮箱) -

-

一个授权码只绑定一个全站域名

- -
-
+
请到会员授权页面查看
+
+

{{ $t('_payTip') }}

+

+ 发送到: xjh22222228@gmail.com + (备注开通域名,支付渠道和支付时间,我们会在24小时内发送授权码给您邮箱) +

+

一个授权码只绑定一个全站域名

+ +
+
+ +
+
已授权!
+
+
diff --git a/src/view/system/vip-auth/index.component.scss b/src/view/system/vip-auth/index.component.scss new file mode 100644 index 0000000000..1bf1302a85 --- /dev/null +++ b/src/view/system/vip-auth/index.component.scss @@ -0,0 +1,11 @@ +.add-btn { + margin-bottom: 20px; + margin-right: 20px; +} +.desc { + width: 300px; + white-space: pre-wrap; +} +.ant-table-wrapper { + overflow: auto; +} diff --git a/src/view/system/vip-auth/index.component.ts b/src/view/system/vip-auth/index.component.ts new file mode 100644 index 0000000000..ee63189a7d --- /dev/null +++ b/src/view/system/vip-auth/index.component.ts @@ -0,0 +1,57 @@ +// Copyright @ 2018-present xiejiahe. All rights reserved. MIT license. +// See https://github.com/xjh22222228/nav + +import { Component } from '@angular/core' +import { $t } from 'src/locale' +import { NzMessageService } from 'ng-zorro-antd/message' +import { NzNotificationService } from 'ng-zorro-antd/notification' +import { NzModalService } from 'ng-zorro-antd/modal' +import { setAuthCode, getAuthCode, removeAuthCode } from 'src/utils/user' +import { getUserCollect } from 'src/services' + +@Component({ + selector: 'user-collect', + templateUrl: './index.component.html', + styleUrls: ['./index.component.scss'], +}) +export default class VipAuthComponent { + $t = $t + submitting: boolean = false + isPermission = !!getAuthCode() + authCode = '' + + constructor( + private message: NzMessageService, + private modal: NzModalService, + private notification: NzNotificationService + ) {} + + ngOnInit() { + this.getUserCollect() + } + + getUserCollect() { + this.submitting = true + getUserCollect() + .then((res: any) => { + this.isPermission = !!res.data.success + }) + .finally(() => { + this.submitting = false + }) + } + + handleSubmitAuthCode() { + if (this.submitting || !this.authCode) { + return + } + + setAuthCode(this.authCode) + this.getUserCollect() + } + + logoutAuthCode() { + removeAuthCode() + window.location.reload() + } +} From 546d33dd6d897e33875b86f385120593546f489c Mon Sep 17 00:00:00 2001 From: xjh22222228 Date: Fri, 26 Jul 2024 22:24:41 +0800 Subject: [PATCH 06/71] fix: Fix http base --- src/utils/http.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/http.ts b/src/utils/http.ts index 120da079f9..e94efcd5f0 100644 --- a/src/utils/http.ts +++ b/src/utils/http.ts @@ -64,8 +64,8 @@ httpInstance.interceptors.response.use( const httpNavInstance = axios.create({ timeout: 10000, - // baseURL: 'https://nav-server.netlify.app', - baseURL: 'http://localhost:3000', + baseURL: 'https://nav-server.netlify.app', + // baseURL: 'http://localhost:3000', }) httpNavInstance.interceptors.request.use( From 295a112ac869dcc156361d6f9283113d0c42fff9 Mon Sep 17 00:00:00 2001 From: xjh22222228 Date: Sat, 27 Jul 2024 16:41:33 +0800 Subject: [PATCH 07/71] feat: add theme footer html --- src/components/footer/footer.component.ts | 23 ++++++---- src/components/logo/logo.component.scss | 1 + src/locale/english.ts | 2 +- src/locale/zh_CN.ts | 2 +- src/types/index.d.ts | 4 ++ src/view/light/index.component.html | 2 +- src/view/side/index.component.html | 5 +- src/view/side/index.component.scss | 1 - src/view/sim/index.component.html | 5 +- src/view/super/index.component.html | 2 +- src/view/system/setting/index.component.html | 48 ++++++++++++++++++++ 11 files changed, 80 insertions(+), 15 deletions(-) diff --git a/src/components/footer/footer.component.ts b/src/components/footer/footer.component.ts index 7bd24a3d19..e3834f07f5 100644 --- a/src/components/footer/footer.component.ts +++ b/src/components/footer/footer.component.ts @@ -11,13 +11,20 @@ import { isLogin } from 'src/utils/user' styleUrls: ['./footer.component.scss'], }) export class FooterComponent { - footerContent: string = settings.footerContent - .replace( - '${total}', - String(isLogin ? internal.loginViewCount : internal.userViewCount) - ) - .replace('${hostname}', window.location.hostname) - .replace('${year}', String(new Date().getFullYear())) - @Input() className: string = '' + @Input() content: string = '' + + footerContent: string = '' + + constructor() {} + + ngOnInit() { + this.footerContent = (this.content || settings.footerContent) + .replace( + '${total}', + String(isLogin ? internal.loginViewCount : internal.userViewCount) + ) + .replace('${hostname}', window.location.hostname) + .replace('${year}', String(new Date().getFullYear())) + } } diff --git a/src/components/logo/logo.component.scss b/src/components/logo/logo.component.scss index 8e8b056df6..d0eca4abf8 100644 --- a/src/components/logo/logo.component.scss +++ b/src/components/logo/logo.component.scss @@ -4,6 +4,7 @@ pointer-events: none; background-color: #eee; border-radius: 3px; + object-fit: cover; } .circle { diff --git a/src/locale/english.ts b/src/locale/english.ts index 360f9e1b43..9e1c5f6e7b 100644 --- a/src/locale/english.ts +++ b/src/locale/english.ts @@ -106,7 +106,7 @@ const english: Record = { _iconAddr: 'Icon Link', _copyUpload: 'Support to paste screenshots or copy pictures here to upload', _upload: 'Upload', - _continueAdd: 'Continue to add affiliate links', + _continueAdd: 'Continue adding associated links or tags', _moveTo: 'Move to', _move: 'Move', _copy: 'Copy', diff --git a/src/locale/zh_CN.ts b/src/locale/zh_CN.ts index 9686c59477..4fe6fd7b65 100644 --- a/src/locale/zh_CN.ts +++ b/src/locale/zh_CN.ts @@ -103,7 +103,7 @@ const zhCN: Record = { _iconAddr: '图标地址', _copyUpload: '支持将截图或复制图片粘贴此处上传', _upload: '上传', - _continueAdd: '继续添加关联链接', + _continueAdd: '继续添加关联链接或标签', _moveTo: '移动到', _move: '移动', _copy: '复制', diff --git a/src/types/index.d.ts b/src/types/index.d.ts index 89d83a9d47..94af660824 100644 --- a/src/types/index.d.ts +++ b/src/types/index.d.ts @@ -114,6 +114,7 @@ export interface ISettings { lightCardStyle: string lightOverType: OverType lightImages: Record[] + lightFooterHTML: string simThemeImages: Record[] simThemeDesc: string @@ -122,12 +123,14 @@ export interface ISettings { simCardStyle: string simTitle: string simOverType: OverType + simFooterHTML: string sideThemeImages: Record[] sideThemeHeight: number sideThemeAutoplay: boolean sideCardStyle: string sideTitle: string + sideFooterHTML: string shortcutThemeImages: Record[] shortcutThemeShowWeather: boolean @@ -137,6 +140,7 @@ export interface ISettings { superOverType: OverType superCardStyle: string superImages: Record[] + superFooterHTML: string showRate: boolean mirrorList: Record[] diff --git a/src/view/light/index.component.html b/src/view/light/index.component.html index 0d1b8d24a6..d7b56469e4 100644 --- a/src/view/light/index.component.html +++ b/src/view/light/index.component.html @@ -119,7 +119,7 @@ - +
diff --git a/src/view/side/index.component.html b/src/view/side/index.component.html index 85ac5707e0..abb72078dc 100644 --- a/src/view/side/index.component.html +++ b/src/view/side/index.component.html @@ -116,7 +116,10 @@ - + diff --git a/src/view/side/index.component.scss b/src/view/side/index.component.scss index a939f123ac..243ca7e176 100644 --- a/src/view/side/index.component.scss +++ b/src/view/side/index.component.scss @@ -52,7 +52,6 @@ position: absolute; top: 50%; left: 50%; - margin-top: -20px; transform: translate(-50%, -50%); .input-wrapper { width: 330px !important; diff --git a/src/view/sim/index.component.html b/src/view/sim/index.component.html index 2929aae1cb..ad8b1e5d61 100644 --- a/src/view/sim/index.component.html +++ b/src/view/sim/index.component.html @@ -119,7 +119,10 @@

- + diff --git a/src/view/super/index.component.html b/src/view/super/index.component.html index 7ecbb03132..8aed023863 100644 --- a/src/view/super/index.component.html +++ b/src/view/super/index.component.html @@ -116,7 +116,7 @@ - + diff --git a/src/view/system/setting/index.component.html b/src/view/system/setting/index.component.html index 5e73de641a..18ebcf4e26 100644 --- a/src/view/system/setting/index.component.html +++ b/src/view/system/setting/index.component.html @@ -438,6 +438,18 @@

Light {{ $t('_theme') }}

+ + {{ $t('_footHtml') }} + + + + +

Super {{ $t('_theme') }}

@@ -534,6 +546,18 @@

Super {{ $t('_theme') }}

+ + {{ $t('_footHtml') }} + + + + +

Sim {{ $t('_theme') }}

@@ -660,6 +684,18 @@

Sim {{ $t('_theme') }}

+ + {{ $t('_footHtml') }} + + + + +

Side {{ $t('_theme') }}

@@ -765,6 +801,18 @@

Side {{ $t('_theme') }}

+ + {{ $t('_footHtml') }} + + + + +

Shortcut {{ $t('_theme') }}

From 1dd3e766cb836bc5669f318fcce637b4efb6f589 Mon Sep 17 00:00:00 2001 From: xjh22222228 Date: Sat, 27 Jul 2024 16:50:09 +0800 Subject: [PATCH 08/71] fix: FIx internal default --- scripts/internal.mjs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/internal.mjs b/scripts/internal.mjs index ee148e8e08..d9d281604f 100644 --- a/scripts/internal.mjs +++ b/scripts/internal.mjs @@ -107,6 +107,7 @@ const TAG_ID_NAME3 = 'Github' settings.showThemeToggle ??= true settings.lightCardStyle ||= 'standard' settings.lightOverType ||= 'overflow' + settings.lightFooterHTML ||= '' settings.simThemeImages ||= [ { src: banner1, @@ -128,8 +129,10 @@ const TAG_ID_NAME3 = 'Github' settings.simThemeHeight ??= 0 settings.simThemeAutoplay ??= true settings.simTitle ||= '' + settings.simFooterHTML ||= '' settings.superCardStyle ||= 'column' settings.superOverType ||= 'overflow' + settings.superFooterHTML ||= '' // 更名 if (settings.superCardStyle === 'super') { settings.superCardStyle = 'column' @@ -156,6 +159,7 @@ const TAG_ID_NAME3 = 'Github' } settings.sideTitle ||= '' settings.sideCardStyle ||= 'example' + settings.sideFooterHTML ||= '' settings.sideThemeHeight ??= 0 settings.sideThemeAutoplay ??= true settings.sideThemeImages ||= [ From 462dfae90d6c5f3438da4397b6b43c8a994dcaa3 Mon Sep 17 00:00:00 2001 From: xjh22222228 Date: Sat, 27 Jul 2024 20:10:54 +0800 Subject: [PATCH 09/71] style: system update --- src/view/system/setting/index.component.html | 989 +++++++++---------- src/view/system/setting/index.component.ts | 1 + 2 files changed, 495 insertions(+), 495 deletions(-) diff --git a/src/view/system/setting/index.component.html b/src/view/system/setting/index.component.html index 18ebcf4e26..03f4b7dc68 100644 --- a/src/view/system/setting/index.component.html +++ b/src/view/system/setting/index.component.html @@ -354,503 +354,502 @@

{{ $t('_spiderRule') }}

-

Light {{ $t('_theme') }}

- - {{ $t('_cardStyle') }} - - - - - - - - - - - {{ $t('_navOver') }} - - - - - - - - - - {{ $t('_sidebarImg') }} - - - - - {{ $t('_backgroundImage') }} - {{ $t('_jumpAddr') }} - {{ $t('_action') }} - - - - - - - - - - - - - -
- - {{ $t('_del') }} - - - - - - - {{ - $t('_add') - }} - - - - - {{ $t('_footHtml') }} - - - - - -
-

Super {{ $t('_theme') }}

- - - {{ $t('_title') }} - - - - - - - {{ $t('_cardStyle') }} - - - - - - - - - - - {{ $t('_navOver') }} - - - - - - - - - - {{ $t('_sidebarImg') }} - - - - - {{ $t('_backgroundImage') }} - {{ $t('_jumpAddr') }} - {{ $t('_action') }} - - - - - - - - - - - - - - - - {{ $t('_del') }} - - - - - - - {{ - $t('_add') - }} - - - - - {{ $t('_footHtml') }} - - - - - -
-

Sim {{ $t('_theme') }}

- - - {{ $t('_title') }} - - - - - - - {{ $t('_cardStyle') }} - - - - - - - - - - - {{ $t('_navOver') }} - - - - - - - - - - Banner - - - - - {{ $t('_backgroundImage') }} - {{ $t('_jumpAddr') }} - {{ $t('_action') }} - - - - - - - - - - - - - - - - {{ $t('_del') }} - - - - - - - {{ - $t('_add') - }} - - - - - {{ $t('_autoPlay') }} - - - - - - - {{ $t('_bannerHeight') }} - - -
{{ $t('_bannerTip') }}
-
-
- - - {{ $t('_desc') }} - - - - - - - {{ $t('_footHtml') }} - - - - - -
-

Side {{ $t('_theme') }}

- - - {{ $t('_sidebarTitle') }} - - - - - - - {{ $t('_cardStyle') }} - - - - - - - - - - - Banner - - - - - {{ $t('_backgroundImage') }} - {{ $t('_jumpAddr') }} - {{ $t('_action') }} - - - - - - - - - - - - - - - - {{ $t('_del') }} - - - - - - - {{ - $t('_add') - }} - - - - - {{ $t('_autoPlay') }} - - - - - - - {{ $t('_bannerHeight') }} - - -
{{ $t('_bannerTip') }}
-
-
- - - {{ $t('_footHtml') }} - - - - - -
-

Shortcut {{ $t('_theme') }}

- - - {{ $t('_title') }} - - - - - - - {{ - $t('_showWeather') - }} - - - - - - - {{ $t('_backgroundImage') }} - - - + + + + {{ $t('_cardStyle') }} + + + + + + + + + + + {{ $t('_navOver') }} + + + + + + + + + + {{ $t('_sidebarImg') }} + + + + + {{ $t('_backgroundImage') }} + {{ $t('_jumpAddr') }} + {{ $t('_action') }} + + + + + + + + + + + + + + + + {{ $t('_del') }} + + + + + + + {{ + $t('_add') + }} + + + + + {{ $t('_footHtml') }} + + + + + + + + + {{ $t('_title') }} + + + + + + + {{ $t('_cardStyle') }} + + + + + + + + + + + {{ $t('_navOver') }} + + + + + + + + + + {{ $t('_sidebarImg') }} + + + + + {{ $t('_backgroundImage') }} + {{ $t('_jumpAddr') }} + {{ $t('_action') }} + + + + + + + + + + + + + + + + {{ $t('_del') }} + + + + + + + {{ + $t('_add') + }} + + + + + {{ $t('_footHtml') }} + + + + + + + + + {{ $t('_title') }} + + + + + + + {{ $t('_cardStyle') }} + + + + + + + + + + + {{ $t('_navOver') }} + + + + + + + + + + Banner + + + + + {{ $t('_backgroundImage') }} + {{ $t('_jumpAddr') }} + {{ $t('_action') }} + + + + + + + + + + + + + + + + {{ $t('_del') }} + + + + + + + {{ + $t('_add') + }} + + + + + {{ $t('_autoPlay') }} + + + + + + + {{ $t('_bannerHeight') }} + + +
{{ $t('_bannerTip') }}
+
+
+ + + {{ $t('_desc') }} + + + + + + + {{ $t('_footHtml') }} + + + + +
+ + + + {{ $t('_sidebarTitle') }} + + + + + + + {{ $t('_cardStyle') }} + + + + + + + + + + + Banner + + + + + {{ $t('_backgroundImage') }} + {{ $t('_jumpAddr') }} + {{ $t('_action') }} + + + + + + + + + + + + + + + + {{ $t('_del') }} + + + + + + + {{ + $t('_add') + }} + + + + + {{ $t('_autoPlay') }} + + + + + + + {{ $t('_bannerHeight') }} + + +
{{ $t('_bannerTip') }}
+
+
+ + + {{ $t('_footHtml') }} + + + + +
+ + + + {{ $t('_title') }} + + + + + + + {{ + $t('_showWeather') + }} + + + + + + + {{ $t('_backgroundImage') }} + + + - - - + +
+
+ +

{{ $t('_mirrorList') }}{{ $t('_ignore') }}

diff --git a/src/view/system/setting/index.component.ts b/src/view/system/setting/index.component.ts index 0bd9c98e77..9bb6edf16e 100644 --- a/src/view/system/setting/index.component.ts +++ b/src/view/system/setting/index.component.ts @@ -20,6 +20,7 @@ export default class SystemSettingComponent { validateForm!: FormGroup submitting: boolean = false settings = settings + tabActive = 0 constructor( private fb: FormBuilder, From d4561bb39a3e81540d7497eafdd9b1f07acb1bba Mon Sep 17 00:00:00 2001 From: xjh22222228 Date: Sat, 27 Jul 2024 20:18:48 +0800 Subject: [PATCH 10/71] release: v8.5.0 --- package.json | 2 +- src/constants/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 73bc17cc0f..92624d7a61 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nav", - "version": "8.4.0", + "version": "8.5.0", "author": "xiejiahe", "bugs": { "url": "https://github.com/xjh22222228/nav/issues" diff --git a/src/constants/index.ts b/src/constants/index.ts index bd89670e90..e5d0749718 100644 --- a/src/constants/index.ts +++ b/src/constants/index.ts @@ -9,7 +9,7 @@ export const SETTING_PATH = 'data/settings.json' export const SEARCH_PATH = 'data/search.json' -export const VERSION = '8.4.0' +export const VERSION = '8.5.0' export const STORAGE_KEY_MAP = { token: 'token', From 755fe7f38a9ab2b104ffcc4681e2631065962707 Mon Sep 17 00:00:00 2001 From: xjh22222228 Date: Sat, 27 Jul 2024 23:35:36 +0800 Subject: [PATCH 11/71] style: update side theme --- src/view/side/index.component.html | 2 +- src/view/side/index.component.scss | 20 ++++++-------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/view/side/index.component.html b/src/view/side/index.component.html index abb72078dc..01ac406282 100644 --- a/src/view/side/index.component.html +++ b/src/view/side/index.component.html @@ -26,7 +26,7 @@ (click)="handleSidebarNav(pageIdx, idIdx)" > - {{ el.title }} + {{ el.title }}
Date: Sun, 28 Jul 2024 10:39:52 +0800 Subject: [PATCH 12/71] style: update ui --- scripts/build.mjs | 21 ++++++-------------- src/components/fixbar/index.component.html | 2 +- src/components/web-list/index.component.html | 3 ++- src/components/web-list/index.component.scss | 11 +++++++++- src/components/web-list/index.component.ts | 1 + src/styles.scss | 2 +- src/view/side/index.component.html | 5 ++--- src/view/side/index.component.scss | 16 +-------------- src/view/system/index.component.html | 6 ++++++ src/view/system/index.component.ts | 3 +++ src/view/system/info/index.component.ts | 2 +- 11 files changed, 34 insertions(+), 38 deletions(-) diff --git a/scripts/build.mjs b/scripts/build.mjs index 740fe68398..78d1d63b47 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -2,7 +2,6 @@ // See https://github.com/xjh22222228/nav import fs from 'fs' -import config from '../nav.config.js' import path from 'path' import LOAD_MAP from './loading.js' import dayjs from 'dayjs' @@ -27,13 +26,6 @@ const nowDate = dayjs.tz().format('YYYY-MM-DD HH:mm:ss') const { description, title, keywords, loading, favicon, headerContent } = settings -const { gitRepoUrl } = config.default - -const s = gitRepoUrl.split('/') - -const authorName = s[s.length - 2] -const repoName = s[s.length - 1] - const htmlTemplate = ` ${title} @@ -57,16 +49,15 @@ async function buildSeo() { if (Array.isArray(value.nav)) { r(value.nav) } - - seoTemplate += `

${value.title || value.name || title}

${ - value.icon ? `${value.icon}` : '' - }

${value.desc || description}

` + if (value.name) { + seoTemplate += `

${value.name || title}

${ + value.desc || description + }

` + } if (value.urls && typeof value.urls === 'object') { for (let k in value.urls) { - seoTemplate += `` + seoTemplate += `` } } } diff --git a/src/components/fixbar/index.component.html b/src/components/fixbar/index.component.html index d792088713..1d5b295efe 100644 --- a/src/components/fixbar/index.component.html +++ b/src/components/fixbar/index.component.html @@ -84,7 +84,7 @@
  • - + {{ item['name'] }}
  • diff --git a/src/components/web-list/index.component.html b/src/components/web-list/index.component.html index 2728353849..13a8a6daa7 100644 --- a/src/components/web-list/index.component.html +++ b/src/components/web-list/index.component.html @@ -1,5 +1,6 @@
    = [] export class WebListComponent implements OnInit { @Input() max: number = 110 @Input() search = true + @Input() overflow = false websiteList: INavProps[] = websiteList dataList: IWebProps[] = [] diff --git a/src/styles.scss b/src/styles.scss index 1dd87b7d8d..53d26a550f 100644 --- a/src/styles.scss +++ b/src/styles.scss @@ -133,7 +133,7 @@ b { .down-arrow { display: inline-block; align-self: center; - margin-left: 15px; + margin-left: 5px; cursor: pointer; transition: 0.1s linear; color: #666; diff --git a/src/view/side/index.component.html b/src/view/side/index.component.html index 01ac406282..48712b6855 100644 --- a/src/view/side/index.component.html +++ b/src/view/side/index.component.html @@ -51,13 +51,12 @@ [autoplay]="settings.sideThemeAutoplay" [height]="settings.sideThemeHeight" /> -
    -
+ + +
@@ -72,7 +96,6 @@ [dataSource]="item" (onCollapse)="onCollapse(item, i)" [index]="i" - arrowType="2" > @@ -98,7 +121,7 @@ [nzXXl]="settings.sideCardStyle === 'example' ? 4 : 6" > - - + diff --git a/src/view/side/index.component.scss b/src/view/side/index.component.scss index 89e3dd5f54..84bcfa047b 100644 --- a/src/view/side/index.component.scss +++ b/src/view/side/index.component.scss @@ -2,28 +2,15 @@ .content { padding-right: 12px !important; } - .layout { - --sideWidth: 150px !important; - } .sider { --menuTitleWidth: 85px; padding-top: 40px !important; } - .logo-img { - width: 30px !important; - height: 30px !important; - } - .web-title { - font-size: 14px !important; - } } .layout { - --sideWidth: 200px; min-height: 100vh; - .inner-layout { - margin-left: var(--sideWidth); .content { padding: 10px 70px 0 20px; display: flex; @@ -65,7 +52,6 @@ display: flex; align-items: center; } - ::ng-deep .web-list { max-width: 100% !important; } @@ -78,16 +64,15 @@ .logo { z-index: 11; - position: fixed; - top: 0; - left: 0; - width: var(--sideWidth); + width: 100%; padding: 10px; padding-left: 15px; background-color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; + cursor: pointer; + user-select: none; .logo-img { width: 50px; @@ -103,41 +88,40 @@ } } -.sider { - position: fixed; - height: 100vh; +.sider-compnent { + position: sticky; + top: 0; left: 0; - overflow: auto; - width: var(--sideWidth); - padding-top: 70px; - .sideicon { - width: 20px; - height: 20px; - margin-right: 12px; - object-fit: cover; - border-radius: 50%; - } - .fixicon { - margin-right: 8px; - } - &::-webkit-scrollbar { - width: 6px; - height: 6px; - } - - &::-webkit-scrollbar-thumb { - background-color: hsla(0, 0%, 100%, 0.2); - border-radius: 3px; + height: 100vh; + background-color: #fff; + ::ng-deep { + .ant-layout-sider-children { + display: flex; + flex-direction: column; + } } +} - &::-webkit-scrollbar-track { - background-color: hsla(0, 0%, 100%, 0.15); - border-radius: 3px; - } +.sider { + height: 100vh; + overflow: hidden; + overflow-y: auto; + flex: 1; + padding-bottom: 30px; .menu-title { max-width: var(--menuTitleWidth, 130px); } } +.sideicon { + width: 20px; + height: 20px; + margin-right: 12px; + object-fit: cover; + border-radius: 50%; + &.fixicon { + margin-right: 8px; + } +} ::ng-deep { #app-footer { diff --git a/src/view/side/index.component.ts b/src/view/side/index.component.ts index bf56de8fa6..aa90ac76ca 100644 --- a/src/view/side/index.component.ts +++ b/src/view/side/index.component.ts @@ -1,3 +1,4 @@ +// 开源项目MIT,未经作者同意,不得以抄袭/复制代码/修改源代码版权信息,允许商业途径。 // Copyright @ 2018-present xiejiahe. All rights reserved. MIT license. // See https://github.com/xjh22222228/nav @@ -10,10 +11,13 @@ import { setWebsiteList, toggleCollapseAll, matchCurrentList, + isMobile, } from 'src/utils' import { isLogin } from 'src/utils/user' import { websiteList } from 'src/store' import { settings, searchEngineList } from 'src/store' +import { $t } from 'src/locale' +import event from 'src/utils/mitt' @Component({ selector: 'app-side', @@ -21,7 +25,7 @@ import { settings, searchEngineList } from 'src/store' styleUrls: ['./index.component.scss'], }) export default class SideComponent { - LOGO_CDN = settings.favicon + $t = $t websiteList: INavProps[] = websiteList currentList: INavThreeProp[] = [] id: number = 0 @@ -30,30 +34,40 @@ export default class SideComponent { searchEngineList = searchEngineList isLogin = isLogin settings = settings - sliceMax = 1 + sliceMax = 0 searchKeyword = '' + isCollapsed = isMobile() ? true : settings.sideCollapsed - constructor(private router: Router, private activatedRoute: ActivatedRoute) {} + constructor(private router: Router, private activatedRoute: ActivatedRoute) { + const init = () => { + this.activatedRoute.queryParams.subscribe(() => { + const { id, page, q } = queryString() + this.page = page + this.id = id + this.searchKeyword = q + this.sliceMax = 0 - ngOnInit() { - this.activatedRoute.queryParams.subscribe(() => { - const { id, page, q } = queryString() - this.page = page - this.id = id - this.searchKeyword = q - this.sliceMax = 1 - - if (q) { - this.currentList = fuzzySearch(this.websiteList, q) - } else { - this.currentList = matchCurrentList() - } - setTimeout(() => { - this.sliceMax = Number.MAX_SAFE_INTEGER - }, 25) - }) + if (q) { + this.currentList = fuzzySearch(this.websiteList, q) + } else { + this.currentList = matchCurrentList() + } + setTimeout(() => { + this.sliceMax = Number.MAX_SAFE_INTEGER + }, 100) + }) + } + if (window.__FINISHED__) { + init() + } else { + event.on('WEB_FINISH', () => { + init() + }) + } } + ngOnInit() {} + handleSidebarNav(page: any, id: any) { this.websiteList[page].id = id this.router.navigate([this.router.url.split('?')[0]], { @@ -62,21 +76,6 @@ export default class SideComponent { id, }, }) - this.handlePositionTop() - } - - handlePositionTop() { - setTimeout(() => { - const el = document.querySelector('.search-header') as HTMLDivElement - if (el) { - const h = el.offsetHeight - window.scroll({ - top: h, - left: 0, - behavior: 'smooth', - }) - } - }, 30) } openMenu(item: any, index: number) { @@ -99,7 +98,6 @@ export default class SideComponent { onCollapseAll = (e: Event) => { e?.stopPropagation() toggleCollapseAll(this.websiteList) - this.handlePositionTop() } collapsed() { diff --git a/src/view/sim/index.component.html b/src/view/sim/index.component.html index ad8b1e5d61..9c45b9c79c 100644 --- a/src/view/sim/index.component.html +++ b/src/view/sim/index.component.html @@ -1,4 +1,6 @@
+ +
*ngFor="let el of item.nav; index as j; trackBy: trackByItemWeb" > { + this.activatedRoute.queryParams.subscribe(() => { + const { id, page, q } = queryString() + this.page = page + this.id = id + this.searchKeyword = q + this.sliceMax = 0 - ngOnInit() { - this.activatedRoute.queryParams.subscribe(() => { - const { id, page, q } = queryString() - this.page = page - this.id = id - this.searchKeyword = q - this.sliceMax = 1 + if (q) { + this.currentList = fuzzySearch(this.websiteList, q) + } else { + this.currentList = matchCurrentList() + } + setTimeout(() => { + this.sliceMax = Number.MAX_SAFE_INTEGER + }, 100) + }) + } - if (q) { - this.currentList = fuzzySearch(this.websiteList, q) - } else { - this.currentList = matchCurrentList() - } - setTimeout(() => { - this.sliceMax = Number.MAX_SAFE_INTEGER - }, 100) - }) + if (window.__FINISHED__) { + init() + } else { + event.on('WEB_FINISH', () => { + init() + }) + } } - ngOnDestroy() {} + ngOnInit() {} ngAfterViewInit() { if (this.settings.simOverType === 'ellipsis') { diff --git a/src/view/super/index.component.html b/src/view/super/index.component.html index 8aed023863..7ae9ee6b10 100644 --- a/src/view/super/index.component.html +++ b/src/view/super/index.component.html @@ -1,4 +1,6 @@
+ +
@@ -23,7 +25,7 @@ { + this.activatedRoute.queryParams.subscribe(() => { + const { id, page, q } = queryString() + this.page = page + this.id = id + this.searchKeyword = q + this.handleCheckThree(0) + this.sliceMax = 0 - ngOnInit() { - this.activatedRoute.queryParams.subscribe(() => { - const { id, page, q } = queryString() - this.page = page - this.id = id - this.searchKeyword = q - this.handleCheckThree(0) - - if (q) { - this.currentList = fuzzySearch(this.websiteList, q) - } else { - this.currentList = matchCurrentList() - } - }) + if (q) { + this.currentList = fuzzySearch(this.websiteList, q) + } else { + this.currentList = matchCurrentList() + } + setTimeout(() => { + this.sliceMax = Number.MAX_SAFE_INTEGER + }, 100) + }) + } + if (window.__FINISHED__) { + init() + } else { + event.on('WEB_FINISH', () => { + init() + }) + } } ngAfterViewInit() { diff --git a/src/view/system/about/index.component.ts b/src/view/system/about/index.component.ts index c4a70fd1cb..415b898ea6 100644 --- a/src/view/system/about/index.component.ts +++ b/src/view/system/about/index.component.ts @@ -1,4 +1,4 @@ -// @ts-nocheck +// 开源项目MIT,未经作者同意,不得以抄袭/复制代码/修改源代码版权信息,允许商业途径。 // Copyright @ 2018-present xiejiahe. All rights reserved. MIT license. // See https://github.com/xjh22222228/nav @@ -8,14 +8,12 @@ import { $t } from 'src/locale' @Component({ selector: 'system-about', templateUrl: './index.component.html', - styleUrls: ['./index.component.scss'] + styleUrls: ['./index.component.scss'], }) export default class SystemAboutComponent { $t = $t - constructor ( - ) {} + constructor() {} - ngOnInit () { - } + ngOnInit() {} } diff --git a/src/view/system/angle-mark/index.component.ts b/src/view/system/angle-mark/index.component.ts index 81e958a891..fabd4374ef 100644 --- a/src/view/system/angle-mark/index.component.ts +++ b/src/view/system/angle-mark/index.component.ts @@ -1,4 +1,4 @@ -// @ts-nocheck +// 开源项目MIT,未经作者同意,不得以抄袭/复制代码/修改源代码版权信息,允许商业途径。 // Copyright @ 2018-present xiejiahe. All rights reserved. MIT license. // See https://github.com/xjh22222228/nav @@ -8,18 +8,14 @@ import { $t } from 'src/locale' @Component({ selector: 'system-angle-mark', templateUrl: './index.component.html', - styleUrls: ['./index.component.scss'] + styleUrls: ['./index.component.scss'], }) export default class SystemAngleMarkComponent { $t = $t - constructor ( - ) {} + constructor() {} - ngOnInit () { - } + ngOnInit() {} - submitForm() { - - } + submitForm() {} } diff --git a/src/view/system/bookmark-export/index.component.ts b/src/view/system/bookmark-export/index.component.ts index a331e76d1a..5c7f7cf524 100644 --- a/src/view/system/bookmark-export/index.component.ts +++ b/src/view/system/bookmark-export/index.component.ts @@ -1,4 +1,5 @@ // @ts-nocheck +// 开源项目MIT,未经作者同意,不得以抄袭/复制代码/修改源代码版权信息,允许商业途径。 // Copyright @ 2018-present xiejiahe. All rights reserved. MIT license. // See https://github.com/xjh22222228/nav diff --git a/src/view/system/bookmark/index.component.ts b/src/view/system/bookmark/index.component.ts index 82972a53c3..4aa87e4d0d 100644 --- a/src/view/system/bookmark/index.component.ts +++ b/src/view/system/bookmark/index.component.ts @@ -1,4 +1,5 @@ // @ts-nocheck +// 开源项目MIT,未经作者同意,不得以抄袭/复制代码/修改源代码版权信息,允许商业途径。 // Copyright @ 2018-present xiejiahe. All rights reserved. MIT license. // See https://github.com/xjh22222228/nav diff --git a/src/view/system/collect/index.component.html b/src/view/system/collect/index.component.html index b6b8af76b4..999025eb54 100644 --- a/src/view/system/collect/index.component.html +++ b/src/view/system/collect/index.component.html @@ -12,17 +12,6 @@ {{ $t('_save') }} - -
-
-
已授权!
+
+

已授权!

+
diff --git a/src/view/system/vip-auth/index.component.ts b/src/view/system/vip-auth/index.component.ts index ee63189a7d..e926d45c60 100644 --- a/src/view/system/vip-auth/index.component.ts +++ b/src/view/system/vip-auth/index.component.ts @@ -1,3 +1,4 @@ +// 开源项目MIT,未经作者同意,不得以抄袭/复制代码/修改源代码版权信息,允许商业途径。 // Copyright @ 2018-present xiejiahe. All rights reserved. MIT license. // See https://github.com/xjh22222228/nav diff --git a/src/view/system/web/index.component.ts b/src/view/system/web/index.component.ts index 8e035103cf..ffd54fcc93 100644 --- a/src/view/system/web/index.component.ts +++ b/src/view/system/web/index.component.ts @@ -1,4 +1,5 @@ // @ts-nocheck +// 开源项目MIT,未经作者同意,不得以抄袭/复制代码/修改源代码版权信息,允许商业途径。 // Copyright @ 2018-present xiejiahe. All rights reserved. MIT license. // See https://github.com/xjh22222228/nav diff --git a/yarn.lock b/yarn.lock index bc0fbda4d1..8dfa5c2b4d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4077,6 +4077,11 @@ image-size@~0.5.0: resolved "https://registry.yarnpkg.com/image-size/-/image-size-0.5.5.tgz#09dfd4ab9d20e29eb1c3e80b8990378df9e3cb9c" integrity sha512-6TDAlDPZxUFCv+fuOkIoXT/V/f3Qbq8e37p+YOiYrUv3v9cc3/6x78VdfPgFVaB9dZYeLUfKgHRebpkm/oP2VQ== +immediate@~3.0.5: + version "3.0.6" + resolved "https://registry.yarnpkg.com/immediate/-/immediate-3.0.6.tgz#9db1dbd0faf8de6fbe0f5dd5e56bb606280de69b" + integrity sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ== + immutable@^4.0.0: version "4.3.6" resolved "https://registry.yarnpkg.com/immutable/-/immutable-4.3.6.tgz#6a05f7858213238e587fb83586ffa3b4b27f0447" @@ -4589,6 +4594,13 @@ license-webpack-plugin@4.0.2: dependencies: webpack-sources "^3.0.0" +lie@3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/lie/-/lie-3.1.1.tgz#9a436b2cc7746ca59de7a41fa469b3efb76bd87e" + integrity sha512-RiNhHysUjhrDQntfYSfY4MU24coXXdEOgw9WGcKHNeEwffDYbF//u87M1EWaMGzuFoSbqW0C9C6lEEhDOAswfw== + dependencies: + immediate "~3.0.5" + lines-and-columns@^1.1.6: version "1.2.4" resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632" @@ -4631,6 +4643,13 @@ loader-utils@^2.0.0: emojis-list "^3.0.0" json5 "^2.1.2" +localforage@^1.10.0: + version "1.10.0" + resolved "https://registry.yarnpkg.com/localforage/-/localforage-1.10.0.tgz#5c465dc5f62b2807c3a84c0c6a1b1b3212781dd4" + integrity sha512-14/H1aX7hzBBmmh7sGPd+AOMkkIrHM3Z1PAyGgZigA1H1p5O5ANnMyWzvpAETtG68/dC4pC0ncy3+PPGzXZHPg== + dependencies: + lie "3.1.1" + locate-path@^7.1.0: version "7.2.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-7.2.0.tgz#69cb1779bd90b35ab1e771e1f2f89a202c2a8a8a" From 2721de2069cd40438d29a250f0c94d39827af4eb Mon Sep 17 00:00:00 2001 From: xjh22222228 Date: Tue, 30 Jul 2024 14:36:56 +0800 Subject: [PATCH 17/71] fix: update budgets maximumError --- angular.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angular.json b/angular.json index b1f5f253c9..07cb5f47ac 100644 --- a/angular.json +++ b/angular.json @@ -40,7 +40,7 @@ { "type": "initial", "maximumWarning": "5mb", - "maximumError": "5mb" + "maximumError": "500mb" }, { "type": "anyComponentStyle", From 456a7a26d709819084caebdf7f87389535ee3605 Mon Sep 17 00:00:00 2001 From: xjh22222228 Date: Tue, 30 Jul 2024 14:43:00 +0800 Subject: [PATCH 18/71] release: v8.6.0 --- package.json | 2 +- src/constants/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e28e42daa1..131b5cd446 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nav", - "version": "8.5.0", + "version": "8.6.0", "author": "xiejiahe", "bugs": { "url": "https://github.com/xjh22222228/nav/issues" diff --git a/src/constants/index.ts b/src/constants/index.ts index d2e95435df..2e808a45cc 100644 --- a/src/constants/index.ts +++ b/src/constants/index.ts @@ -10,7 +10,7 @@ export const SETTING_PATH = 'data/settings.json' export const SEARCH_PATH = 'data/search.json' -export const VERSION = '8.5.0' +export const VERSION = '8.6.0' export const STORAGE_KEY_MAP = { token: 'token', From 2f25fdd27b3757540f08a6ca3285cf8cf1df6eca Mon Sep 17 00:00:00 2001 From: xjh22222228 Date: Tue, 30 Jul 2024 15:02:48 +0800 Subject: [PATCH 19/71] fix: rename db --- src/constants/index.ts | 2 +- src/utils/user.ts | 2 +- src/view/system/web/index.component.ts | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/constants/index.ts b/src/constants/index.ts index 2e808a45cc..7111d433da 100644 --- a/src/constants/index.ts +++ b/src/constants/index.ts @@ -17,7 +17,7 @@ export const STORAGE_KEY_MAP = { location: 'location', s_url: 's_url', isDark: 'isDark', - website: 'website', + website: 'WEBSITE_DB', engine: 'engine', language: 'language', total: 'total', diff --git a/src/utils/user.ts b/src/utils/user.ts index 3339d011c0..314b7ace8a 100644 --- a/src/utils/user.ts +++ b/src/utils/user.ts @@ -28,7 +28,7 @@ export function removeToken() { } export function removeWebsite() { - return window.localStorage.removeItem('website') + return localforage.removeItem('WEBSITE_DB') } export function userLogout() { diff --git a/src/view/system/web/index.component.ts b/src/view/system/web/index.component.ts index ffd54fcc93..33a20ead12 100644 --- a/src/view/system/web/index.component.ts +++ b/src/view/system/web/index.component.ts @@ -7,7 +7,7 @@ import { Component } from '@angular/core' import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop' import { INavProps, INavTwoProp, INavThreeProp, IWebProps } from 'src/types' import { websiteList, settings, tagMap, internal } from 'src/store' -import { isLogin } from 'src/utils/user' +import { isLogin, removeWebsite } from 'src/utils/user' import { NzMessageService } from 'ng-zorro-antd/message' import { NzModalService } from 'ng-zorro-antd/modal' import { NzNotificationService } from 'ng-zorro-antd/notification' @@ -221,7 +221,7 @@ export default class WebpComponent { nzContent: $t('_warnReset'), nzOnOk: () => { this.message.success($t('_actionSuccess')) - window.localStorage.removeItem(STORAGE_KEY_MAP.website) + removeWebsite() window.localStorage.removeItem(STORAGE_KEY_MAP.s_url) setTimeout(() => { window.location.reload() From bbf0f8983fc42d4bb8b2a5efb6fd6a6d073e685c Mon Sep 17 00:00:00 2001 From: xjh22222228 Date: Tue, 30 Jul 2024 18:20:55 +0800 Subject: [PATCH 20/71] chore: info-web@0.0.17 --- package.json | 2 +- scripts/build.mjs | 9 +++++---- src/utils/user.ts | 15 ++++++++------- yarn.lock | 8 ++++---- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 131b5cd446..79deae9402 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "@angular/compiler-cli": "^18.0.1", "@types/jasmine": "~5.1.4", "@types/nprogress": "^0.2.3", - "info-web": "^0.0.15", + "info-web": "^0.0.16", "jasmine-core": "~5.1.2", "karma": "~6.4.3", "karma-chrome-launcher": "~3.2.0", diff --git a/scripts/build.mjs b/scripts/build.mjs index 78d1d63b47..1423ed94bc 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -139,22 +139,23 @@ let errorUrlCount = 0 r(db) - console.log('Getting...') const max = settings.spiderQty ?? 20 const count = Math.ceil(items.length / max) let current = 0 const now = Date.now() + console.log(`正在爬取信息... 并发数量:${max}`) + while (current < count) { - const request = [] + const requestPromises = [] for (let i = current * max; i < current * max + max; i++) { const item = items[i] if (item) { - request.push(getWebInfo(item.url, { timeout: 3000 })) + requestPromises.push(getWebInfo(item.url, { timeout: 1000 })) } } - const promises = await Promise.allSettled(request) + const promises = await Promise.allSettled(requestPromises) for (let i = 0; i < promises.length; i++) { const idx = current * max + i diff --git a/src/utils/user.ts b/src/utils/user.ts index 314b7ace8a..3bfa0cbcbd 100644 --- a/src/utils/user.ts +++ b/src/utils/user.ts @@ -2,33 +2,34 @@ // Copyright @ 2018-present xiejiahe. All rights reserved. MIT license. // See https://github.com/xjh22222228/nav import localforage from 'localforage' +import { STORAGE_KEY_MAP } from 'src/constants' export function getToken() { - return window.localStorage.getItem('token') || '' + return window.localStorage.getItem(STORAGE_KEY_MAP.token) || '' } export function getAuthCode() { - return window.localStorage.getItem('AUTH_CODE') || '' + return window.localStorage.getItem(STORAGE_KEY_MAP.authCode) || '' } export function removeAuthCode() { - return window.localStorage.removeItem('AUTH_CODE') + return window.localStorage.removeItem(STORAGE_KEY_MAP.authCode) } export function setAuthCode(c: string) { - return window.localStorage.setItem('AUTH_CODE', c.trim()) + return window.localStorage.setItem(STORAGE_KEY_MAP.authCode, c.trim()) } export function setToken(token: string) { - return window.localStorage.setItem('token', token) + return window.localStorage.setItem(STORAGE_KEY_MAP.token, token) } export function removeToken() { - return window.localStorage.removeItem('token') + return window.localStorage.removeItem(STORAGE_KEY_MAP.token) } export function removeWebsite() { - return localforage.removeItem('WEBSITE_DB') + return localforage.removeItem(STORAGE_KEY_MAP.website) } export function userLogout() { diff --git a/yarn.lock b/yarn.lock index 8dfa5c2b4d..d13b1d79b6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4113,10 +4113,10 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -info-web@^0.0.15: - version "0.0.15" - resolved "https://registry.yarnpkg.com/info-web/-/info-web-0.0.15.tgz#67dab586e53ed135ed6f2f1477bdb57ab632aa3a" - integrity sha512-Jl50WthP3q8RJ/J4pnAz0/4prq9SFCuYu95/NROIcwjyTUqHHYJJiIXr8kQ7oEyhkRQlP/HQCdXxmdCaJgBZ3g== +info-web@^0.0.16: + version "0.0.16" + resolved "https://registry.yarnpkg.com/info-web/-/info-web-0.0.16.tgz#734b80b5fb954b6988a521dc730127c3208c2891" + integrity sha512-9leCrSm1cV+AGI1Gcyvov6Rb185tP35h2tjpGlNSnww/rZcTHk+/BCL/ljBeaAzej3NFaUW+oa4o5nMU487thw== dependencies: axios "^1.7.2" rollup "^4.18.0" From 17691415e85a51153b6dfa5e7f56247533d682bd Mon Sep 17 00:00:00 2001 From: xjh22222228 Date: Tue, 30 Jul 2024 18:21:20 +0800 Subject: [PATCH 21/71] chore: info-web@0.0.17 --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 79deae9402..82596cd50b 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "@angular/compiler-cli": "^18.0.1", "@types/jasmine": "~5.1.4", "@types/nprogress": "^0.2.3", - "info-web": "^0.0.16", + "info-web": "^0.0.17", "jasmine-core": "~5.1.2", "karma": "~6.4.3", "karma-chrome-launcher": "~3.2.0", diff --git a/yarn.lock b/yarn.lock index d13b1d79b6..bb782c113f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4113,10 +4113,10 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -info-web@^0.0.16: - version "0.0.16" - resolved "https://registry.yarnpkg.com/info-web/-/info-web-0.0.16.tgz#734b80b5fb954b6988a521dc730127c3208c2891" - integrity sha512-9leCrSm1cV+AGI1Gcyvov6Rb185tP35h2tjpGlNSnww/rZcTHk+/BCL/ljBeaAzej3NFaUW+oa4o5nMU487thw== +info-web@^0.0.17: + version "0.0.17" + resolved "https://registry.yarnpkg.com/info-web/-/info-web-0.0.17.tgz#78217b0c37267ed14083ab780b7fe8b7c3a9b749" + integrity sha512-z2zsi3CbdESzeN9NKS75bSALkger76BCxYkxh1za3aoHIl28R7O3ENQSwW6PmKZRdkVZ+7yUcy5KPt/RhOGS0A== dependencies: axios "^1.7.2" rollup "^4.18.0" From 309c14906baa1dcc51d3f8fc14892446b5bae0cd Mon Sep 17 00:00:00 2001 From: xjh22222228 Date: Tue, 30 Jul 2024 19:17:04 +0800 Subject: [PATCH 22/71] chore: info-web@0.0.19 --- package.json | 2 +- scripts/build.mjs | 2 +- yarn.lock | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 82596cd50b..22886c3376 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "@angular/compiler-cli": "^18.0.1", "@types/jasmine": "~5.1.4", "@types/nprogress": "^0.2.3", - "info-web": "^0.0.17", + "info-web": "^0.0.19", "jasmine-core": "~5.1.2", "karma": "~6.4.3", "karma-chrome-launcher": "~3.2.0", diff --git a/scripts/build.mjs b/scripts/build.mjs index 1423ed94bc..ad2373d7bd 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -151,7 +151,7 @@ let errorUrlCount = 0 for (let i = current * max; i < current * max + max; i++) { const item = items[i] if (item) { - requestPromises.push(getWebInfo(item.url, { timeout: 1000 })) + requestPromises.push(getWebInfo(item.url, { timeout: 3000 })) } } diff --git a/yarn.lock b/yarn.lock index bb782c113f..45780fbc3f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4113,10 +4113,10 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -info-web@^0.0.17: - version "0.0.17" - resolved "https://registry.yarnpkg.com/info-web/-/info-web-0.0.17.tgz#78217b0c37267ed14083ab780b7fe8b7c3a9b749" - integrity sha512-z2zsi3CbdESzeN9NKS75bSALkger76BCxYkxh1za3aoHIl28R7O3ENQSwW6PmKZRdkVZ+7yUcy5KPt/RhOGS0A== +info-web@^0.0.19: + version "0.0.19" + resolved "https://registry.yarnpkg.com/info-web/-/info-web-0.0.19.tgz#7b44c1506b4aec7b9e60009a3ad813f2fb05f0c1" + integrity sha512-LMSLmv35H2UQ1e4ZLFtJWyu2PDOw80la/Ay6/G5G7XZNNRdwpeErEKH8Ifq6GU5L7+YYpmCrlaM0RamYYxXYuA== dependencies: axios "^1.7.2" rollup "^4.18.0" From 5d78710dbbd189416e0266fbaa2b347bfe5d5272 Mon Sep 17 00:00:00 2001 From: xjh22222228 Date: Tue, 30 Jul 2024 21:13:26 +0800 Subject: [PATCH 23/71] feat: add spider timeout --- package.json | 2 +- scripts/build.mjs | 8 ++++++-- scripts/internal.mjs | 4 +++- src/locale/english.ts | 3 +++ src/locale/zh_CN.ts | 2 ++ src/types/index.d.ts | 1 + src/view/system/setting/index.component.html | 10 +++++++++- yarn.lock | 8 ++++---- 8 files changed, 29 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 22886c3376..2716a693de 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "@angular/compiler-cli": "^18.0.1", "@types/jasmine": "~5.1.4", "@types/nprogress": "^0.2.3", - "info-web": "^0.0.19", + "info-web": "^0.0.20", "jasmine-core": "~5.1.2", "karma": "~6.4.3", "karma-chrome-launcher": "~3.2.0", diff --git a/scripts/build.mjs b/scripts/build.mjs index ad2373d7bd..8ba640edce 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -144,14 +144,18 @@ let errorUrlCount = 0 let current = 0 const now = Date.now() - console.log(`正在爬取信息... 并发数量:${max}`) + console.log( + `正在爬取信息... 并发数量:${max} 超时: ${settings.spiderTimeout}秒` + ) while (current < count) { const requestPromises = [] for (let i = current * max; i < current * max + max; i++) { const item = items[i] if (item) { - requestPromises.push(getWebInfo(item.url, { timeout: 3000 })) + requestPromises.push( + getWebInfo(item.url, { timeout: settings.spiderTimeout * 1000 }) + ) } } diff --git a/scripts/internal.mjs b/scripts/internal.mjs index 22efa39f62..544483ae3f 100644 --- a/scripts/internal.mjs +++ b/scripts/internal.mjs @@ -191,7 +191,9 @@ const TAG_ID_NAME3 = 'Github' settings.spiderIcon ??= 'NO' settings.spiderDescription ??= 'NO' settings.spiderTitle ??= 'NO' - settings.spiderQty ??= 20 + settings.spiderQty ??= 200 + settings.spiderTimeout ??= 3 + settings.spiderTimeout = Number(settings.spiderTimeout) || 3 settings.loadingCode ??= '' settings.appCardStyle ??= 'common' diff --git a/src/locale/english.ts b/src/locale/english.ts index cd048a34ae..e3cd665c72 100644 --- a/src/locale/english.ts +++ b/src/locale/english.ts @@ -224,6 +224,9 @@ const english: Record = { _associatedLabels: 'Labels', _menuCollapse: 'Menu Collapse', _retro: 'Retro', + _accessTimeout: 'Access timeout (seconds)', + _accessTimeoutTip: + 'Crawl the website for a specified number of seconds with no response, skip', } export default english diff --git a/src/locale/zh_CN.ts b/src/locale/zh_CN.ts index fdd5d32461..7aedc8e4f2 100644 --- a/src/locale/zh_CN.ts +++ b/src/locale/zh_CN.ts @@ -215,6 +215,8 @@ const zhCN: Record = { _associatedLabels: '关联标签', _menuCollapse: '菜单默认收起', _retro: '复古', + _accessTimeout: '爬取超时(秒)', + _accessTimeoutTip: '爬取网站指定秒数无响应跳过', } export default zhCN diff --git a/src/types/index.d.ts b/src/types/index.d.ts index fa99956034..56a047dd35 100644 --- a/src/types/index.d.ts +++ b/src/types/index.d.ts @@ -158,6 +158,7 @@ export interface ISettings { spiderDescription: Spider spiderTitle: Spider spiderQty: number + spiderTimeout: number | string loadingCode: string } diff --git a/src/view/system/setting/index.component.html b/src/view/system/setting/index.component.html index b571d8c72f..f7ce6b3d12 100644 --- a/src/view/system/setting/index.component.html +++ b/src/view/system/setting/index.component.html @@ -347,12 +347,20 @@

{{ $t('_spiderRule') }}

{{ $t('_spiderQtyTip') }}
+ + {{ $t('_accessTimeout') }} + + +

{{ $t('_accessTimeoutTip') }}

+
+
+
diff --git a/yarn.lock b/yarn.lock index 45780fbc3f..e9387e90c4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4113,10 +4113,10 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -info-web@^0.0.19: - version "0.0.19" - resolved "https://registry.yarnpkg.com/info-web/-/info-web-0.0.19.tgz#7b44c1506b4aec7b9e60009a3ad813f2fb05f0c1" - integrity sha512-LMSLmv35H2UQ1e4ZLFtJWyu2PDOw80la/Ay6/G5G7XZNNRdwpeErEKH8Ifq6GU5L7+YYpmCrlaM0RamYYxXYuA== +info-web@^0.0.20: + version "0.0.20" + resolved "https://registry.yarnpkg.com/info-web/-/info-web-0.0.20.tgz#9f1e3d3802b37701997943dcb01dd05e06d5db04" + integrity sha512-s/jUIyRmuFMI2WxGjnvJBZzAlpfDJWX838N7IrxJXBxRn1zAb6iUfAn0gx/KlmtT+o819wzQDHpBLCkUGHwSMw== dependencies: axios "^1.7.2" rollup "^4.18.0" From 501c6c3bd9243cdf903ffd4abf24401af91a322c Mon Sep 17 00:00:00 2001 From: xjh22222228 Date: Tue, 30 Jul 2024 23:27:12 +0800 Subject: [PATCH 24/71] feat: Support exporting bookmark icons --- package.json | 2 +- src/app/app.module.ts | 2 ++ src/locale/english.ts | 2 -- src/locale/zh_CN.ts | 2 -- src/services/index.ts | 4 +++- .../system/bookmark-export/index.component.html | 9 ++++++++- .../system/bookmark-export/index.component.ts | 9 ++++++++- src/view/system/vip-auth/index.component.html | 17 +++++++++++++---- yarn.lock | 14 ++++++++++---- 9 files changed, 45 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 2716a693de..aadd2629d5 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "@angular/compiler-cli": "^18.0.1", "@types/jasmine": "~5.1.4", "@types/nprogress": "^0.2.3", - "info-web": "^0.0.20", + "info-web": "^0.0.22", "jasmine-core": "~5.1.2", "karma": "~6.4.3", "karma-chrome-launcher": "~3.2.0", diff --git a/src/app/app.module.ts b/src/app/app.module.ts index c8e1963df2..9a9b48314e 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -65,6 +65,7 @@ import SimComponent from '../view/sim/index.component' import SystemComponent from '../view/system/index.component' import SystemInfoComponent from '../view/system/info/index.component' import SystemBookmarkComponent from '../view/system/bookmark/index.component' +import SystemBookmarkExportComponent from '../view/system/bookmark-export/index.component' import SystemAboutComponent from '../view/system/about/index.component' import SystemTagComponent from '../view/system/tag/index.component' import SystemSearchComponent from '../view/system/search/index.component' @@ -115,6 +116,7 @@ const icons: IconDefinition[] = [ SystemComponent, SystemInfoComponent, SystemBookmarkComponent, + SystemBookmarkExportComponent, SystemAboutComponent, SystemTagComponent, SystemSearchComponent, diff --git a/src/locale/english.ts b/src/locale/english.ts index e3cd665c72..9fe402abd0 100644 --- a/src/locale/english.ts +++ b/src/locale/english.ts @@ -200,8 +200,6 @@ const english: Record = { _sidebarTitle: 'Sidebar title', _defTitle4: 'Default website title, recommended to be within 4 words', _inputAuthCode: 'Please enter the authorization code', - _payTip: - 'Becoming a VIP allows you to enjoy the full site functionality, and you need to pay ¥99 as a contribution to the stable operation of this site. Thank you for your support', _waitHandle: 'Waiting for the stationmaster to handle', _collect: 'Get', _confirmCollect: 'Are you sure?', diff --git a/src/locale/zh_CN.ts b/src/locale/zh_CN.ts index 7aedc8e4f2..66e929e179 100644 --- a/src/locale/zh_CN.ts +++ b/src/locale/zh_CN.ts @@ -190,8 +190,6 @@ const zhCN: Record = { _sidebarTitle: '侧栏标题', _defTitle4: '默认网站标题, 建议4字以内', _inputAuthCode: '请输入授权码', - _payTip: - '成为VIP可享受全站功能,需支付 ¥99 作为本站稳定运行的贡献,感谢您的支持', _waitHandle: '提交成功,等待站长处理', _collect: '收录', _confirmCollect: '您确定要收录吗?', diff --git a/src/services/index.ts b/src/services/index.ts index 0fd8d97996..5d157821c4 100644 --- a/src/services/index.ts +++ b/src/services/index.ts @@ -129,7 +129,9 @@ export async function getIconUrl(url: string) { } export async function bookmarksExport(data: any) { - return httpNav.post('/api/export', data) + return httpNav.post('/api/export', data, { + timeout: Number.MAX_SAFE_INTEGER, + }) } export function getCDN(path: string, branch = 'image') { diff --git a/src/view/system/bookmark-export/index.component.html b/src/view/system/bookmark-export/index.component.html index de60e4dda8..2426d69ffd 100644 --- a/src/view/system/bookmark-export/index.component.html +++ b/src/view/system/bookmark-export/index.component.html @@ -1,5 +1,12 @@ + +
+ + 同时导出网站图标,耗时较久,某些网站无法访问图标为空,即使网站没有设置图标也会根据链接尝试抓取 +

已等待{{ seconds }}秒

+
-

由于浏览器书签的限制,只能导出对应的分类和网站名称链接

点我导出

diff --git a/src/view/system/bookmark-export/index.component.ts b/src/view/system/bookmark-export/index.component.ts index 5c7f7cf524..0f638054b8 100644 --- a/src/view/system/bookmark-export/index.component.ts +++ b/src/view/system/bookmark-export/index.component.ts @@ -22,6 +22,8 @@ export default class SystemBookmarkExportComponent { $t = $t submitting = false websiteList: INavProps[] = websiteList + isExportIcon = false + seconds = 0 constructor( private message: NzMessageService, @@ -34,8 +36,12 @@ export default class SystemBookmarkExportComponent { if (this.submitting) { return } + this.seconds = 0 this.submitting = true - bookmarksExport({ data: this.websiteList }) + const interval = setInterval(() => { + this.seconds += 1 + }, 1000) + bookmarksExport({ data: this.websiteList, icon: this.isExportIcon }) .then((res) => { if (res.data?.success) { downloadAsFile(res.data.data, '发现导航导出.html') @@ -44,6 +50,7 @@ export default class SystemBookmarkExportComponent { }) .finally(() => { this.submitting = false + clearInterval(interval) }) } } diff --git a/src/view/system/vip-auth/index.component.html b/src/view/system/vip-auth/index.component.html index 55735c8c3b..6c6d617897 100644 --- a/src/view/system/vip-auth/index.component.html +++ b/src/view/system/vip-auth/index.component.html @@ -16,12 +16,21 @@ {{ $t('_save') }}
-

{{ $t('_payTip') }}

- 发送到: xjh22222228@gmail.com - (备注开通域名,支付渠道和支付时间,我们会在24小时内发送授权码给您邮箱) + 成为VIP可享受全站功能,需支付 ¥99 支持作者稳定持续开发,感谢您的支持

-

一个授权码只绑定一个全站域名

+

+ 发送到: xjh22222228@gmail.com (备注开通域名,Github + ID,我们会在24小时内发送授权码给您邮箱) +

+

一个授权码只绑定一个全站域名,后续可更改

+
+ +
Date: Wed, 31 Jul 2024 23:43:06 +0800 Subject: [PATCH 25/71] fix: update export bookmarks --- README.md | 29 +----- package.json | 2 +- scripts/build.mjs | 14 ++- scripts/internal.mjs | 22 ++--- src/components/create-web/index.component.ts | 2 +- src/locale/english.ts | 5 +- src/locale/zh_CN.ts | 5 +- src/utils/index.ts | 14 --- .../bookmark-export/index.component.html | 22 +++-- .../bookmark-export/index.component.scss | 5 +- .../system/bookmark-export/index.component.ts | 90 +++++++++++++++++-- src/view/system/bookmark/index.component.html | 13 ++- src/view/system/index.component.html | 11 ++- src/view/system/info/index.component.html | 4 +- src/view/system/setting/index.component.html | 2 +- yarn.lock | 8 +- 16 files changed, 154 insertions(+), 94 deletions(-) diff --git a/README.md b/README.md index 78cb8d89cf..1d209c5f17 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ - 🍰 内置 `800+` 优质网站 - 🍰 支持 [码云 Gitee](https://gitee.com/xiejiahe/nav) -- 🍰 支持从 Chrome 书签导入 +- 🍰 支持从浏览器书签导入 - 🍰 支持将数据导出到浏览器书签 - 🍰 支持用户提交收录 - 🍰 丰富的资源配置系统 @@ -124,14 +124,6 @@ npm run server 将路由地址修改为 `system` 即可进入,如: https://www.nav3.cn/#/light 修改为 https://www.nav3.cn/#/system -## 书签导入 - -自动检测满足三级分类导航,其他一律设为未分类: - -![](https://raw.githubusercontent.com/xjh22222228/public/gh-pages/nav/import.png) - -浏览器打开 [chrome://bookmarks/](chrome://bookmarks/) 导出书签得到 html 文件, 接着从导航网站后台导入即可。 - ## 升级 将你的仓库克隆下来执行以下命令 @@ -143,7 +135,7 @@ git fetch upstream main git merge upstream/main --allow-unrelated-histories --no-edit git push -# 或者执行 +# 如果安装了node只需执行 npm run update ``` @@ -171,23 +163,6 @@ yarn start yarn build ``` -## 贡献 - -Thank you for your [contribution](https://github.com/xjh22222228/nav/issues), men. - - - - - - - - - - - - - - ## 建议 如果有任何功能上的建议可通过 [issue](https://github.com/xjh22222228/nav/issues) 发起, Thank you. diff --git a/package.json b/package.json index aadd2629d5..9efdeb67fd 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "@angular/compiler-cli": "^18.0.1", "@types/jasmine": "~5.1.4", "@types/nprogress": "^0.2.3", - "info-web": "^0.0.22", + "info-web": "^0.0.23", "jasmine-core": "~5.1.2", "karma": "~6.4.3", "karma-chrome-launcher": "~3.2.0", diff --git a/scripts/build.mjs b/scripts/build.mjs index 8ba640edce..72f3c68537 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -144,9 +144,11 @@ let errorUrlCount = 0 let current = 0 const now = Date.now() - console.log( - `正在爬取信息... 并发数量:${max} 超时: ${settings.spiderTimeout}秒` - ) + if (items.length) { + console.log( + `正在爬取信息... 并发数量:${max} 超时: ${settings.spiderTimeout}秒` + ) + } while (current < count) { const requestPromises = [] @@ -165,7 +167,11 @@ let errorUrlCount = 0 const idx = current * max + i const item = items[idx] const res = promises[i].value - console.log(`${idx}:${res.status ? '正常' : '疑似异常'} ${item.url}`) + console.log( + `${idx}:${res.status ? '正常' : `疑似异常: ${res.errorMsg}`} ${ + item.url + }` + ) if (settings.checkUrl) { if (!res.status) { errorUrlCount += 1 diff --git a/scripts/internal.mjs b/scripts/internal.mjs index 544483ae3f..6f6a744a80 100644 --- a/scripts/internal.mjs +++ b/scripts/internal.mjs @@ -10,17 +10,17 @@ const internalPath = path.join('.', 'data', 'internal.json') const settingsPath = path.join('.', 'data', 'settings.json') const tagPath = path.join('.', 'data', 'tag.json') -let internal, db, settings, tags +let internal = {} +let db = [] +let settings = {} +let tags = [] try { - internal = JSON.parse(fs.readFileSync(internalPath).toString()) - db = JSON.parse(fs.readFileSync(dbPath).toString()) - settings = JSON.parse(fs.readFileSync(settingsPath).toString()) - tags = JSON.parse(fs.readFileSync(tagPath).toString()) + internal = JSON.parse(fs.readFileSync(internalPath).toString() || '{}') + db = JSON.parse(fs.readFileSync(dbPath).toString() || '[]') + settings = JSON.parse(fs.readFileSync(settingsPath).toString() || '{}') + tags = JSON.parse(fs.readFileSync(tagPath).toString() || '[]') } catch (error) { - internal = {} - db = [] - settings = {} - tags = [] + console.log('parse JSON: ', error.message) } const TAG_ID1 = -1 @@ -251,10 +251,6 @@ export function getWebCount(websiteList) { const { userViewCount, loginViewCount } = getWebCount(db) internal.userViewCount = userViewCount < 0 ? loginViewCount : userViewCount internal.loginViewCount = loginViewCount -console.log(` -userViewCount: ${internal.userViewCount} -loginViewCount: ${internal.loginViewCount} -`) fs.writeFileSync(internalPath, JSON.stringify(internal), { encoding: 'utf-8' }) // 设置网站的面包屑类目显示 diff --git a/src/components/create-web/index.component.ts b/src/components/create-web/index.component.ts index 61b8211bc8..15a506b7f9 100644 --- a/src/components/create-web/index.component.ts +++ b/src/components/create-web/index.component.ts @@ -142,7 +142,7 @@ export class CreateWebComponent { this.validateForm.get('desc')!.setValue(res['description']) } if (res['status'] === false) { - this.message.error('自动抓取失败,请手动写入') + this.message.error(`自动抓取失败,请手动填写:${res['message']}`) } this.getting = false } diff --git a/src/locale/english.ts b/src/locale/english.ts index 9fe402abd0..3e840be151 100644 --- a/src/locale/english.ts +++ b/src/locale/english.ts @@ -79,7 +79,6 @@ const english: Record = { _addTag: 'Add category', _addWeb: 'Add site', _clickEdit: 'Click Edit', - _importChrome: 'Import from Chrome bookmarks', _allContentMsg1: '1. After setting all data, click "synchronize to remote end" and drag the table to sort', _allContentMsg2: '2. Website category needs to be maintained manually,', @@ -127,7 +126,7 @@ const english: Record = { _tagSettings: 'Tag settings', _websiteMang: 'Website', _addRow: 'Add', - _bookImportTip: `

Supports most mainstream browsers based on the webkit kernel. If the import fails, it is temporarily not supported

`, + _bookImportTip: `

Supports most mainstream browsers. If the import fails, it is temporarily not supported

`, _engineName: 'Engine name', _status: 'Status', _isDisable: 'Disable', @@ -224,7 +223,7 @@ const english: Record = { _retro: 'Retro', _accessTimeout: 'Access timeout (seconds)', _accessTimeoutTip: - 'Crawl the website for a specified number of seconds with no response, skip', + 'Crawl the website for a specified number of seconds with no response, skip, The larger the number, the higher the success rate, but the slower it is', } export default english diff --git a/src/locale/zh_CN.ts b/src/locale/zh_CN.ts index 66e929e179..22aba0aec6 100644 --- a/src/locale/zh_CN.ts +++ b/src/locale/zh_CN.ts @@ -78,7 +78,6 @@ const zhCN: Record = { _addTag: '添加分类', _addWeb: '添加网站', _clickEdit: '点击编辑', - _importChrome: '从Chrome书签导入', _allContentMsg1: '1、所有数据设置完毕后点击 “同步到远端”,拖拽表格进行排序', _allContentMsg2: '2、网站分类需手动维护,', _updateLogo: '更换LOGO', @@ -124,7 +123,7 @@ const zhCN: Record = { _tagSettings: '标签设置', _websiteMang: '网站管理', _addRow: '新增一条', - _bookImportTip: `

支持大部分主流浏览器基于webkit内核,若导入失败表示暂不支持

自动检测满足三级分类导航,其他一律设为未分类

`, + _bookImportTip: `

支持大部分主流浏览器,若导入失败表示暂不支持

自动检测满足三级分类导航,其他一律设为未分类

`, _engineName: '引擎名称', _status: '状态', _isDisable: '是否禁用', @@ -214,7 +213,7 @@ const zhCN: Record = { _menuCollapse: '菜单默认收起', _retro: '复古', _accessTimeout: '爬取超时(秒)', - _accessTimeoutTip: '爬取网站指定秒数无响应跳过', + _accessTimeoutTip: '爬取网站指定秒数无响应跳过,数字越大成功率越高,但是越慢', } export default zhCN diff --git a/src/utils/index.ts b/src/utils/index.ts index a8d666129a..23c3330a1c 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -516,20 +516,6 @@ export function getOverIndex(selector: string): number { return overIndex } -export function downloadAsFile(str: string, fileName: string) { - const blob = new Blob([str], { type: 'text/html' }) - const url = URL.createObjectURL(blob) - - const a = document.createElement('a') - a.href = url - a.download = fileName - document.body.appendChild(a) - a.click() - - document.body.removeChild(a) - URL.revokeObjectURL(url) -} - export function isMobile() { return 'ontouchstart' in window } diff --git a/src/view/system/bookmark-export/index.component.html b/src/view/system/bookmark-export/index.component.html index 2426d69ffd..b4b00889b0 100644 --- a/src/view/system/bookmark-export/index.component.html +++ b/src/view/system/bookmark-export/index.component.html @@ -1,14 +1,22 @@
- 同时导出网站图标,耗时较久,某些网站无法访问图标为空,即使网站没有设置图标也会根据链接尝试抓取 -

已等待{{ seconds }}秒

+ 同时导出网站图标,耗时较久 +

耗时 {{ seconds }} 秒

+

+ 正在处理 {{ currentNumber }} / {{ countAll }} +

-
+
- -

点我导出

+ +

+ 点我导出 +

diff --git a/src/view/system/bookmark-export/index.component.scss b/src/view/system/bookmark-export/index.component.scss index 1c6d33c626..8331fb2c97 100644 --- a/src/view/system/bookmark-export/index.component.scss +++ b/src/view/system/bookmark-export/index.component.scss @@ -1,4 +1,7 @@ .book-wrapper { - cursor: pointer; text-align: center; + .logo, + p { + cursor: pointer; + } } diff --git a/src/view/system/bookmark-export/index.component.ts b/src/view/system/bookmark-export/index.component.ts index 0f638054b8..6e0d29da1b 100644 --- a/src/view/system/bookmark-export/index.component.ts +++ b/src/view/system/bookmark-export/index.component.ts @@ -7,11 +7,12 @@ import { Component } from '@angular/core' import { $t } from 'src/locale' import { NzNotificationService } from 'ng-zorro-antd/notification' import { NzMessageService } from 'ng-zorro-antd/message' -import { downloadAsFile } from 'src/utils' import { parseBookmark } from 'src/utils/bookmark' -import { INavProps } from 'src/types' +import { INavProps, IWebProps } from 'src/types' import { websiteList } from 'src/store' import { bookmarksExport } from 'src/services' +import { saveAs } from 'file-saver' +import { getAuthCode } from 'src/utils/user' @Component({ selector: 'system-bookmark-export', @@ -24,6 +25,8 @@ export default class SystemBookmarkExportComponent { websiteList: INavProps[] = websiteList isExportIcon = false seconds = 0 + currentNumber = 0 + countAll = 0 constructor( private message: NzMessageService, @@ -32,20 +35,95 @@ export default class SystemBookmarkExportComponent { ngOnInit() {} - bookmarksExport() { + loadImage(url: string) { + return new Promise((resolve) => { + if (!url) { + return resolve(null) + } + const img = new Image() + img.crossOrigin = 'Anonymous' + img.onload = function () { + resolve(img) + } + img.onerror = function () { + resolve(null) + } + img.src = url + }) + } + + async imageToBase64(item: IWebProps) { + if (item.icon?.startsWith('data:image')) { + return + } + + const img = await this.loadImage(item.icon) + if (img) { + try { + const canvas = document.createElement('canvas') + canvas.width = img.width + canvas.height = img.height + const ctx = canvas.getContext('2d') + ctx.drawImage(img, 0, 0) + const dataURL = canvas.toDataURL('image/png') + item.icon = dataURL + return dataURL + } catch (error) {} + } + } + + async bookmarksExport() { + if (!getAuthCode()) { + return this.notification.error('Error', '请授权') + } + if (this.submitting) { return } + const that = this this.seconds = 0 + this.countAll = 0 this.submitting = true const interval = setInterval(() => { this.seconds += 1 }, 1000) - bookmarksExport({ data: this.websiteList, icon: this.isExportIcon }) + + const webs: INavProps = JSON.parse(JSON.stringify(this.websiteList)) + const promiseItems = [] + function getIconItems(data) { + if (!Array.isArray(data)) { + return + } + data.forEach((item) => { + if (Array.isArray(item.nav)) { + getIconItems(item.nav) + } + if (item.url) { + promiseItems.push( + that.imageToBase64(item).finally(() => { + that.currentNumber += 1 + }) + ) + } + }) + } + if (this.isExportIcon) { + getIconItems(webs) + this.countAll = promiseItems.length + await Promise.allSettled(promiseItems) + } + + bookmarksExport({ data: webs }) .then((res) => { if (res.data?.success) { - downloadAsFile(res.data.data, '发现导航导出.html') - this.message.success('Successed!') + const fileName = '发现导航书签.html' + const blob = new Blob([res.data.data], { + type: 'text/html;charset=utf-8', + }) + saveAs(blob, fileName) + this.notification.success('导出成功', fileName, { + nzDuration: 0, + }) } }) .finally(() => { diff --git a/src/view/system/bookmark/index.component.html b/src/view/system/bookmark/index.component.html index 7c9c4f7da8..c51303fd84 100644 --- a/src/view/system/bookmark/index.component.html +++ b/src/view/system/bookmark/index.component.html @@ -1,14 +1,19 @@
-
+
+ 在浏览器输入 + chrome://bookmarks/ + 找到导出书签,导出 HTML 文件点击下面导入 +
+ +
diff --git a/src/view/system/index.component.html b/src/view/system/index.component.html index 88c7c7c3d0..c3904e329a 100644 --- a/src/view/system/index.component.html +++ b/src/view/system/index.component.html @@ -90,10 +90,13 @@ {{ $t('_logout') }} - + + + + {{ date }}
diff --git a/src/view/system/info/index.component.html b/src/view/system/info/index.component.html index dc195b4520..4d18e18710 100644 --- a/src/view/system/info/index.component.html +++ b/src/view/system/info/index.component.html @@ -5,7 +5,9 @@

{{ $t('_curVer') }}:

{{ $t('_newVer') }}: - + + +

{{ $t('_updateTip') }} diff --git a/src/view/system/setting/index.component.html b/src/view/system/setting/index.component.html index f7ce6b3d12..a39c82fcee 100644 --- a/src/view/system/setting/index.component.html +++ b/src/view/system/setting/index.component.html @@ -347,7 +347,7 @@

{{ $t('_spiderRule') }}

{{ $t('_spiderQtyTip') }}
diff --git a/yarn.lock b/yarn.lock index 0b8c7002a0..2422bf9679 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4113,10 +4113,10 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -info-web@^0.0.22: - version "0.0.22" - resolved "https://registry.yarnpkg.com/info-web/-/info-web-0.0.22.tgz#aa3f132e89f757bdf092cd6bae69930dcd97c301" - integrity sha512-YmL4r4KXKTyrswqJpKX/90Op65JtiMUP36vRvILd86y4ZiVuxUhlsVtnBLSvN8fCAgTGm+W4/65Fo7We7gc0fg== +info-web@^0.0.23: + version "0.0.23" + resolved "https://registry.yarnpkg.com/info-web/-/info-web-0.0.23.tgz#2d94ae33be28d2bd0438c98f9f472f2b24de4920" + integrity sha512-0FODXwVcw8JiQJzjWe5hL0i9WHBbEu1Sp7RFQ3iKC113LCiVuWD9yKvOt49Kh2cf/PvpUO510K/nrfmhY1gOTg== dependencies: axios "^1.7.2" jschardet "^3.1.3" From cdaca0d622c326df428645d8c8564594faf15a43 Mon Sep 17 00:00:00 2001 From: xjh22222228 Date: Thu, 1 Aug 2024 15:47:58 +0800 Subject: [PATCH 26/71] refactor: register common service --- README.md | 3 - src/{services => api}/index.ts | 0 src/app/app.component.ts | 2 +- src/app/app.module.ts | 3 +- src/components/create-web/index.component.ts | 2 +- src/components/fixbar/index.component.ts | 7 +- src/components/login/login.component.ts | 2 +- src/components/logo/logo.component.ts | 2 +- src/components/upload/index.component.ts | 2 +- src/components/web-list/index.component.html | 2 +- src/components/web-list/index.component.ts | 10 +- src/constants/index.ts | 1 + src/services/common.ts | 127 ++++++++++++++++++ src/utils/index.ts | 2 +- src/view/app/default/app.component.html | 39 ++++-- src/view/app/default/app.component.ts | 68 +--------- src/view/light/index.component.html | 76 ++++++----- src/view/light/index.component.ts | 113 +--------------- src/view/side/index.component.html | 71 ++++++---- src/view/side/index.component.ts | 93 +------------ src/view/sim/index.component.html | 80 ++++++----- src/view/sim/index.component.ts | 110 +-------------- src/view/super/index.component.html | 104 +++++++++----- src/view/super/index.component.ts | 100 +------------- .../system/bookmark-export/index.component.ts | 2 +- src/view/system/collect/index.component.ts | 2 +- src/view/system/search/index.component.ts | 2 +- src/view/system/setting/index.component.ts | 2 +- src/view/system/tag/index.component.ts | 2 +- src/view/system/vip-auth/index.component.ts | 2 +- src/view/system/web/index.component.ts | 2 +- 31 files changed, 408 insertions(+), 625 deletions(-) rename src/{services => api}/index.ts (100%) create mode 100644 src/services/common.ts diff --git a/README.md b/README.md index 1d209c5f17..1ea7d26c2f 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,6 @@

一个纯静态、支持SEO、在线编辑的强大导航网站,希望您会喜欢

内置收录多达 800+ 优质网站, 助您工作、学习和生活

- Stars Angular diff --git a/src/services/index.ts b/src/api/index.ts similarity index 100% rename from src/services/index.ts rename to src/api/index.ts diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 74a64795f6..1efcdd16aa 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -8,7 +8,7 @@ import { queryString, setLocation, isMobile } from '../utils' import { en_US, NzI18nService, zh_CN } from 'ng-zorro-antd/i18n' import { getLocale } from 'src/locale' import { settings } from 'src/store' -import { verifyToken } from 'src/services' +import { verifyToken } from 'src/api' import { getToken, userLogout, isLogin } from 'src/utils/user' import { NzMessageService } from 'ng-zorro-antd/message' import { NzNotificationService } from 'ng-zorro-antd/notification' diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 9a9b48314e..cd27fc70d2 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -79,6 +79,7 @@ import WebpComponent from '../view/app/default/app.component' import VipAuthComponent from '../view/system/vip-auth/index.component' import { SafeHtmlPipe } from 'src/pipe/safeHtml.pipe' +import { ServiceCommonService } from 'src/services/common' import { CheckOutline, @@ -178,7 +179,7 @@ const icons: IconDefinition[] = [ BrowserModule, AppRoutingModule, ], - providers: [{ provide: NZ_I18N, useValue: zh_CN }], + providers: [{ provide: NZ_I18N, useValue: zh_CN }, ServiceCommonService], bootstrap: [AppComponent], }) export class AppModule {} diff --git a/src/components/create-web/index.component.ts b/src/components/create-web/index.component.ts index 15a506b7f9..b13ae1159e 100644 --- a/src/components/create-web/index.component.ts +++ b/src/components/create-web/index.component.ts @@ -13,7 +13,7 @@ import { import { FormBuilder, FormGroup, Validators, FormArray } from '@angular/forms' import { IWebProps } from 'src/types' import { NzMessageService } from 'ng-zorro-antd/message' -import { createFile, saveUserCollect } from 'src/services' +import { createFile, saveUserCollect } from 'src/api' import { $t } from 'src/locale' import { settings, websiteList, tagList, tagMap } from 'src/store' import event from 'src/utils/mitt' diff --git a/src/components/fixbar/index.component.ts b/src/components/fixbar/index.component.ts index 82cf97a378..c2790d372a 100644 --- a/src/components/fixbar/index.component.ts +++ b/src/components/fixbar/index.component.ts @@ -13,7 +13,7 @@ import { isDark as isDarkFn, randomBgImg, queryString } from 'src/utils' import { NzModalService } from 'ng-zorro-antd/modal' import { NzMessageService } from 'ng-zorro-antd/message' import { isLogin } from 'src/utils/user' -import { updateFileContent } from 'src/services' +import { updateFileContent } from 'src/api' import { websiteList, settings } from 'src/store' import { DB_PATH, STORAGE_KEY_MAP } from 'src/constants' import { Router, ActivatedRoute } from '@angular/router' @@ -86,7 +86,10 @@ export class FixbarComponent { toggleTheme(theme: any) { this.router.navigate([theme.url], { - queryParams: queryString(), + queryParams: { + ...queryString(), + _: Date.now(), + }, }) this.removeBackground() } diff --git a/src/components/login/login.component.ts b/src/components/login/login.component.ts index 0f1d813982..c237bf4c47 100644 --- a/src/components/login/login.component.ts +++ b/src/components/login/login.component.ts @@ -4,7 +4,7 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core' import { NzMessageService } from 'ng-zorro-antd/message' -import { verifyToken, updateFileContent, createBranch } from 'src/services' +import { verifyToken, updateFileContent, createBranch } from 'src/api' import { setToken, removeToken, removeWebsite } from 'src/utils/user' import { $t } from 'src/locale' diff --git a/src/components/logo/logo.component.ts b/src/components/logo/logo.component.ts index 650b86d3bd..7860437d10 100644 --- a/src/components/logo/logo.component.ts +++ b/src/components/logo/logo.component.ts @@ -1,6 +1,6 @@ // 开源项目MIT,未经作者同意,不得以抄袭/复制代码/修改源代码版权信息,允许商业途径。 import { Component, Input } from '@angular/core' -import { getCDN } from 'src/services' +import { getCDN } from 'src/api' @Component({ selector: 'app-logo', diff --git a/src/components/upload/index.component.ts b/src/components/upload/index.component.ts index 9a2e0edefd..2ac8fe1b7a 100644 --- a/src/components/upload/index.component.ts +++ b/src/components/upload/index.component.ts @@ -5,7 +5,7 @@ import { Component, EventEmitter, Output } from '@angular/core' import { $t } from 'src/locale' import { NzMessageService } from 'ng-zorro-antd/message' -import { createFile, getCDN } from 'src/services' +import { createFile, getCDN } from 'src/api' @Component({ selector: 'app-upload', diff --git a/src/components/web-list/index.component.html b/src/components/web-list/index.component.html index 8ab5364324..7e7db40a24 100644 --- a/src/components/web-list/index.component.html +++ b/src/components/web-list/index.component.html @@ -9,7 +9,7 @@ nzTooltipPlacement="bottom" nz-button nz-tooltip - *ngFor="let item of dataList; trackBy: trackByItemWeb" + *ngFor="let item of dataList; trackBy: serviceCommon.trackByItemWeb" (click)="goUrl(item.url)" > diff --git a/src/components/web-list/index.component.ts b/src/components/web-list/index.component.ts index cef42283cc..a48e28e774 100644 --- a/src/components/web-list/index.component.ts +++ b/src/components/web-list/index.component.ts @@ -9,6 +9,7 @@ import { queryString, fuzzySearch } from 'src/utils' import { isLogin } from 'src/utils/user' import { ActivatedRoute } from '@angular/router' import event from 'src/utils/mitt' +import { ServiceCommonService } from 'src/services/common' let DEFAULT_WEBSITE: Array = [] @@ -25,7 +26,10 @@ export class WebListComponent implements OnInit { websiteList: INavProps[] = websiteList dataList: IWebProps[] = [] - constructor(private activatedRoute: ActivatedRoute) { + constructor( + private activatedRoute: ActivatedRoute, + public serviceCommon: ServiceCommonService + ) { const init = () => { this.getTopWeb() this.activatedRoute.queryParams.subscribe(() => { @@ -95,8 +99,4 @@ export class WebListComponent implements OnInit { window.open(url) } } - - trackByItemWeb(a: any, item: any) { - return item.id - } } diff --git a/src/constants/index.ts b/src/constants/index.ts index 7111d433da..394c234aeb 100644 --- a/src/constants/index.ts +++ b/src/constants/index.ts @@ -22,4 +22,5 @@ export const STORAGE_KEY_MAP = { language: 'language', total: 'total', authCode: 'AUTH_CODE', + sideCollapsed: 'SIDE_COLLAPSED', } diff --git a/src/services/common.ts b/src/services/common.ts new file mode 100644 index 0000000000..85960a1b8f --- /dev/null +++ b/src/services/common.ts @@ -0,0 +1,127 @@ +// 开源项目MIT,未经作者同意,不得以抄袭/复制代码/修改源代码版权信息,允许商业途径。 +// Copyright @ 2018-present xiejiahe. All rights reserved. MIT license. +// See https://github.com/xjh22222228/nav + +import { Injectable } from '@angular/core' +import { Router, ActivatedRoute } from '@angular/router' +import { websiteList, settings } from 'src/store' +import { + queryString, + toggleCollapseAll, + fuzzySearch, + matchCurrentList, + setWebsiteList, + getOverIndex, +} from 'src/utils' +import { INavProps, INavThreeProp } from 'src/types' +import { isLogin } from 'src/utils/user' +import event from 'src/utils/mitt' + +@Injectable({ + providedIn: 'root', +}) +export class ServiceCommonService { + isLogin = isLogin + settings = settings + websiteList: INavProps[] = websiteList + currentList: INavThreeProp[] = [] + id = 0 + page = 0 + sliceMax = 0 + selectedIndex = 0 // 第三级菜单选中 + searchKeyword = '' + overIndex = Number.MAX_SAFE_INTEGER + title: string = settings.title.trim().split(/\s/)[0] + + constructor(private router: Router, private activatedRoute: ActivatedRoute) { + const init = () => { + this.activatedRoute.queryParams.subscribe(() => { + const { id, page, q } = queryString() + this.page = page + this.id = id + this.searchKeyword = q + this.handleCheckThree(0) + this.sliceMax = 0 + + if (q) { + this.currentList = fuzzySearch(websiteList, q) + } else { + this.currentList = matchCurrentList() + } + setTimeout(() => { + this.sliceMax = Number.MAX_SAFE_INTEGER + }, 100) + }) + } + if (window.__FINISHED__) { + init() + } else { + event.on('WEB_FINISH', () => { + init() + }) + } + } + + handleCilckTopNav(index: number) { + const id = websiteList[index].id || 0 + this.router.navigate([this.router.url.split('?')[0]], { + queryParams: { + page: index, + id, + _: Date.now(), + }, + }) + } + handleSidebarNav(index: number) { + const { page } = queryString() + websiteList[page].id = index + this.router.navigate([this.router.url.split('?')[0]], { + queryParams: { + page, + id: index, + _: Date.now(), + }, + }) + } + + handleCheckThree(index: number) { + this.selectedIndex = index + } + + onCollapseAll = (e?: Event) => { + e?.stopPropagation() + toggleCollapseAll(websiteList) + } + + trackByItem(a: any, item: any) { + return item.title + } + + trackByItemWeb(a: any, item: any) { + return item.id + } + + get collapsed() { + try { + return !!websiteList[this.page].nav[this.id].collapsed + } catch (error) { + return false + } + } + + onCollapse = (item: any, index: number) => { + item.collapsed = !item.collapsed + this.websiteList[this.page].nav[this.id].nav[index] = item + setWebsiteList(this.websiteList) + } + + getOverIndex(selector: string) { + queueMicrotask(() => { + const overIndex = getOverIndex(selector) + if (this.overIndex === overIndex) { + return + } + this.overIndex = overIndex + }) + } +} diff --git a/src/utils/index.ts b/src/utils/index.ts index 23c3330a1c..cb38d3e962 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -15,7 +15,7 @@ import * as s from '../../data/search.json' import { STORAGE_KEY_MAP } from 'src/constants' import { isLogin } from './user' import { SearchType } from 'src/components/search-engine/index' -import { getIconUrl } from 'src/services' +import { getIconUrl } from 'src/api' import localforage from 'localforage' import event from 'src/utils/mitt' diff --git a/src/view/app/default/app.component.html b/src/view/app/default/app.component.html index c9031dd909..60f7bb5660 100644 --- a/src/view/app/default/app.component.html +++ b/src/view/app/default/app.component.html @@ -1,7 +1,7 @@

- +
@@ -11,9 +11,13 @@
-
-
+
+ diff --git a/src/view/light/index.component.ts b/src/view/light/index.component.ts index 81f91ea278..b1c866166c 100644 --- a/src/view/light/index.component.ts +++ b/src/view/light/index.component.ts @@ -3,20 +3,8 @@ // See https://github.com/xjh22222228/nav import { Component } from '@angular/core' -import { Router, ActivatedRoute } from '@angular/router' -import { INavProps, INavThreeProp } from 'src/types' -import { - fuzzySearch, - randomBgImg, - queryString, - setWebsiteList, - toggleCollapseAll, - matchCurrentList, - getOverIndex, -} from 'src/utils' -import { isLogin } from 'src/utils/user' -import { websiteList, settings } from 'src/store' -import event from 'src/utils/mitt' +import { randomBgImg } from 'src/utils' +import { ServiceCommonService } from 'src/services/common' @Component({ selector: 'app-light', @@ -24,106 +12,15 @@ import event from 'src/utils/mitt' styleUrls: ['./index.component.scss'], }) export default class LightComponent { - websiteList: INavProps[] = websiteList - currentList: INavThreeProp[] = [] - id: number = 0 - page: number = 0 - isLogin = isLogin - sliceMax = 0 - settings = settings - overIndex = Number.MAX_SAFE_INTEGER - searchKeyword = '' - - constructor(private router: Router, private activatedRoute: ActivatedRoute) { - const init = () => { - this.activatedRoute.queryParams.subscribe(() => { - const { id, page, q } = queryString() - this.page = page - this.id = id - this.searchKeyword = q - this.sliceMax = 0 - if (q) { - this.currentList = fuzzySearch(this.websiteList, q) - } else { - this.currentList = matchCurrentList() - } - setTimeout(() => { - this.sliceMax = Number.MAX_SAFE_INTEGER - }, 100) - }) - } - - if (window.__FINISHED__) { - init() - } else { - event.on('WEB_FINISH', () => { - init() - }) - } - } + constructor(public serviceCommon: ServiceCommonService) {} ngOnInit() { randomBgImg() } - trackByItem(a: any, item: any) { - return item.title - } - - trackByItemWeb(a: any, item: any) { - return item.id - } - - collapsed() { - try { - return !!websiteList[this.page].nav[this.id].collapsed - } catch (error) { - return false - } - } - - handleCilckTopNav(index: number) { - const id = this.websiteList[index].id || 0 - this.router.navigate([this.router.url.split('?')[0]], { - queryParams: { - page: index, - id, - _: Date.now(), - }, - }) - } - - handleSidebarNav(index: number) { - const { page } = queryString() - this.websiteList[page].id = index - this.router.navigate([this.router.url.split('?')[0]], { - queryParams: { - page, - id: index, - _: Date.now(), - }, - }) - } - ngAfterViewInit() { - if (this.settings.lightOverType === 'ellipsis') { - queueMicrotask(() => { - const overIndex = getOverIndex('.top-nav .over-item') - if (this.overIndex === overIndex) { - return - } - this.overIndex = overIndex - }) + if (this.serviceCommon.settings.lightOverType === 'ellipsis') { + this.serviceCommon.getOverIndex('.top-nav .over-item') } } - - onCollapse = (item: any, index: number) => { - item.collapsed = !item.collapsed - this.websiteList[this.page].nav[this.id].nav[index] = item - setWebsiteList(this.websiteList) - } - - onCollapseAll = () => { - toggleCollapseAll(this.websiteList) - } } diff --git a/src/view/side/index.component.html b/src/view/side/index.component.html index 8df68b3cae..35f4d7f673 100644 --- a/src/view/side/index.component.html +++ b/src/view/side/index.component.html @@ -1,5 +1,9 @@ - + @@ -18,9 +22,9 @@
  • {{ el.title }}
    @@ -69,11 +77,14 @@ -
    +
    @@ -83,18 +94,21 @@
    -
    +
    @@ -140,11 +156,14 @@ - + diff --git a/src/view/side/index.component.ts b/src/view/side/index.component.ts index aa90ac76ca..81f04dc9db 100644 --- a/src/view/side/index.component.ts +++ b/src/view/side/index.component.ts @@ -3,21 +3,12 @@ // See https://github.com/xjh22222228/nav import { Component } from '@angular/core' -import { Router, ActivatedRoute } from '@angular/router' -import { INavProps, INavThreeProp } from 'src/types' -import { - fuzzySearch, - queryString, - setWebsiteList, - toggleCollapseAll, - matchCurrentList, - isMobile, -} from 'src/utils' -import { isLogin } from 'src/utils/user' +import { INavProps } from 'src/types' +import { setWebsiteList, isMobile } from 'src/utils' import { websiteList } from 'src/store' -import { settings, searchEngineList } from 'src/store' +import { settings } from 'src/store' import { $t } from 'src/locale' -import event from 'src/utils/mitt' +import { ServiceCommonService } from 'src/services/common' @Component({ selector: 'app-side', @@ -27,57 +18,12 @@ import event from 'src/utils/mitt' export default class SideComponent { $t = $t websiteList: INavProps[] = websiteList - currentList: INavThreeProp[] = [] - id: number = 0 - page: number = 0 - title: string = settings.title.trim().split(/\s/)[0] - searchEngineList = searchEngineList - isLogin = isLogin - settings = settings - sliceMax = 0 - searchKeyword = '' - isCollapsed = isMobile() ? true : settings.sideCollapsed + isCollapsed = isMobile() || settings.sideCollapsed - constructor(private router: Router, private activatedRoute: ActivatedRoute) { - const init = () => { - this.activatedRoute.queryParams.subscribe(() => { - const { id, page, q } = queryString() - this.page = page - this.id = id - this.searchKeyword = q - this.sliceMax = 0 - - if (q) { - this.currentList = fuzzySearch(this.websiteList, q) - } else { - this.currentList = matchCurrentList() - } - setTimeout(() => { - this.sliceMax = Number.MAX_SAFE_INTEGER - }, 100) - }) - } - if (window.__FINISHED__) { - init() - } else { - event.on('WEB_FINISH', () => { - init() - }) - } - } + constructor(public serviceCommon: ServiceCommonService) {} ngOnInit() {} - handleSidebarNav(page: any, id: any) { - this.websiteList[page].id = id - this.router.navigate([this.router.url.split('?')[0]], { - queryParams: { - page, - id, - }, - }) - } - openMenu(item: any, index: number) { this.websiteList.forEach((data, idx) => { if (idx === index) { @@ -88,31 +34,4 @@ export default class SideComponent { }) setWebsiteList(this.websiteList) } - - onCollapse = (item: any, index: number) => { - item.collapsed = !item.collapsed - this.websiteList[this.page].nav[this.id].nav[index] = item - setWebsiteList(this.websiteList) - } - - onCollapseAll = (e: Event) => { - e?.stopPropagation() - toggleCollapseAll(this.websiteList) - } - - collapsed() { - try { - return !!websiteList[this.page].nav[this.id].collapsed - } catch (error) { - return false - } - } - - trackByItem(a: any, item: any) { - return item.title - } - - trackByItemWeb(a: any, item: any) { - return item.id - } } diff --git a/src/view/sim/index.component.html b/src/view/sim/index.component.html index 9c45b9c79c..0e5987469d 100644 --- a/src/view/sim/index.component.html +++ b/src/view/sim/index.component.html @@ -1,19 +1,23 @@
    - +

    - {{ settings.simTitle || settings.title }} + {{ serviceCommon.settings.simTitle || serviceCommon.settings.title }}

       
     
    @@ -53,17 +57,17 @@ 

    -
    @@ -75,6 +74,8 @@