提交 668da058 编写于 作者: X xjh22222228

refactor(nav.config): Remove searchEngineList

上级 10d0d680
[
{
"name": "站内",
"icon": "https://raw.sevencdn.com/xjh22222228/nav/image/logo.png",
"placeholder": "站内搜索",
"blocked": false
},
{
"name": "百度",
"url": "https://www.baidu.com/s?wd=",
"icon": "https://raw.sevencdn.com/xjh22222228/nav/image/baidu.svg",
"placeholder": "百度一下",
"blocked": false
},
{
"name": "Google",
"url": "https://www.google.com/search?q=",
"icon": "https://raw.sevencdn.com/xjh22222228/nav/image/google.svg",
"blocked": false
},
{
"name": "必应",
"url": "https://cn.bing.com/search?q=",
"icon": "https://raw.sevencdn.com/xjh22222228/nav/image/bing.svg",
"blocked": false
},
{
"name": "GitHub",
"url": "https://github.com/search?q=",
"icon": "https://raw.sevencdn.com/xjh22222228/nav/image/github.svg",
"placeholder": "Search GitHub",
"blocked": false
},
{
"name": "知乎",
"url": "https://www.zhihu.com/search?type=content&q=",
"icon": "https://raw.sevencdn.com/xjh22222228/nav/image/zhihu.svg",
"blocked": false
},
{
"name": "豆瓣",
"url": "https://search.douban.com/book/subject_search?search_text=",
"icon": "https://raw.sevencdn.com/xjh22222228/nav/image/douban.svg",
"placeholder": "书名、作者、ISBN",
"blocked": false
}
]
\ No newline at end of file
......@@ -25,48 +25,6 @@ const c: IConfig = {
// 默认主题: Light | Sim | Side | App
theme: 'Light',
// 搜索引擎列表, 为空时不显示搜索引擎
searchEngineList: [
{
name: '站内',
icon: 'https://raw.sevencdn.com/xjh22222228/nav/image/logo.png',
placeholder: '站内搜索'
},
{
name: '百度',
url: 'https://www.baidu.com/s?wd=',
icon: 'https://raw.sevencdn.com/xjh22222228/nav/image/baidu.svg',
placeholder: '百度一下'
},
{
name: 'Google',
url: 'https://www.google.com/search?q=',
icon: 'https://raw.sevencdn.com/xjh22222228/nav/image/google.svg',
},
{
name: '必应',
url: 'https://cn.bing.com/search?q=',
icon: 'https://raw.sevencdn.com/xjh22222228/nav/image/bing.svg',
},
{
name: 'GitHub',
url: 'https://github.com/search?q=',
icon: 'https://raw.sevencdn.com/xjh22222228/nav/image/github.svg',
placeholder: 'Search GitHub'
},
{
name: '知乎',
url: 'https://www.zhihu.com/search?type=content&q=',
icon: 'https://raw.sevencdn.com/xjh22222228/nav/image/zhihu.svg',
},
{
name: '豆瓣',
url: 'https://search.douban.com/book/subject_search?search_text=',
icon: 'https://raw.sevencdn.com/xjh22222228/nav/image/douban.svg',
placeholder: '书名、作者、ISBN'
}
],
// 网站底部内容, 版权信息、备案号, 可以是 HTML
footerContent: `
<div style="font-weight: bold;">共收录\${total}个网站</div>
......
// Copyright @ 2018-2021 xiejiahe. All rights reserved. MIT license.
import hotkeys from 'hotkeys-js'
import config from '../../../nav.config'
import { Component } from '@angular/core'
import { getDefaultSearchEngine, setDefaultSearchEngine, queryString } from '../../utils'
import { Router } from '@angular/router'
import * as searchEngineList from '../../../data/search.json'
@Component({
selector: 'app-search-engine',
......@@ -12,7 +12,7 @@ import { Router } from '@angular/router'
styleUrls: ['./search-engine.component.scss']
})
export class SearchEngineComponent {
searchEngineList = config.searchEngineList
searchEngineList = (searchEngineList as any).default
currentEngine = getDefaultSearchEngine()
showEngine = false
keyword = queryString().q
......@@ -54,7 +54,7 @@ export class SearchEngineComponent {
}
clickEngineItem(index) {
this.currentEngine = config.searchEngineList[index]
this.currentEngine = this.searchEngineList[index]
this.toggleEngine()
this.inputFocus()
setDefaultSearchEngine(this.currentEngine)
......
......@@ -56,6 +56,7 @@ export interface ISearchEngineProps {
url?: string
icon: string | null
placeholder?: string
blocked: boolean
}
export interface IConfig {
......@@ -66,7 +67,6 @@ export interface IConfig {
description: string
keywords: string
theme: ThemeType
searchEngineList: ISearchEngineProps[]
footerContent?: string|null
baiduStatisticsUrl?: string
cnzzStatisticsUrl?: string
......
......@@ -6,12 +6,14 @@ import config from '../../nav.config'
import Clipboard from 'clipboard'
import { INavFourProp, INavProps, ISearchEngineProps } from '../types'
import * as db from '../../data/db.json'
import * as s from '../../data/search.json'
export const websiteList = getWebsiteList()
let total = 0
const { lightThemeConfig, searchEngineList } = config
const { lightThemeConfig } = config
const { backgroundLinear } = lightThemeConfig
const searchEngineList: ISearchEngineProps[] = (s as any).default
export function randomInt(max: number) {
return Math.floor(Math.random() * max)
......
......@@ -4,7 +4,7 @@
import config from '../../../../nav.config'
import { Component } from '@angular/core'
import { Router, ActivatedRoute } from '@angular/router'
import { INavProps, INavThreeProp } from '../../../types'
import { INavProps, INavThreeProp, ISearchEngineProps } from '../../../types'
import {
fuzzySearch,
queryString,
......@@ -13,6 +13,9 @@ import {
} from '../../../utils'
import { websiteList } from '../../../store'
import { LOGO_CDN } from '../../../constants'
import * as s from '../../../../data/search.json'
const searchEngineList: ISearchEngineProps[] = (s as any).default
@Component({
selector: 'app-home',
......@@ -28,7 +31,7 @@ export default class HomeComponent {
title: string = config.title.trim().split(/\s/)[0]
openIndex = queryString().page
contentEl: HTMLElement
searchEngineList = config.searchEngineList
searchEngineList = searchEngineList
constructor (private router: Router, private activatedRoute: ActivatedRoute) {}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册