From 063dc280dafe6cb288357f38ae54c5c500a6ec1c Mon Sep 17 00:00:00 2001 From: xjh22222228 Date: Wed, 11 Nov 2020 22:21:26 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E9=87=8D=E6=9E=84=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/index.ts | 8 +- data/node/deno.ts | 11 +- data/node/frame.ts | 11 +- data/node/module.ts | 26 ++-- src/app/app.component.html | 21 +-- src/app/app.component.scss | 20 --- src/app/app.component.ts | 83 ++++++------ src/app/app.module.ts | 16 ++- src/components/footer/footer.component.html | 7 + src/components/footer/footer.component.scss | 18 +++ src/components/footer/footer.component.ts | 18 +++ .../icon-git/icon-git.component.html | 9 ++ .../icon-git/icon-git.component.scss | 0 src/components/icon-git/icon-git.component.ts | 18 +++ src/components/loading/loading.component.html | 3 + src/components/loading/loading.component.scss | 12 ++ src/components/loading/loading.component.ts | 15 +++ src/components/no-data/no-data.component.html | 6 + src/components/no-data/no-data.component.scss | 12 ++ src/components/no-data/no-data.component.ts | 18 +++ src/index.html | 1 - src/utils/index.ts | 79 ++++++++++-- src/view/{ => app/default}/app.component.html | 0 src/view/{ => app/default}/app.component.scss | 0 src/view/{ => app/default}/app.component.ts | 6 +- src/view/index.component.html | 121 ------------------ src/view/index/default/index.component.html | 117 +++++++++++++++++ .../{ => index/default}/index.component.scss | 38 ++---- .../{ => index/default}/index.component.ts | 14 +- 29 files changed, 421 insertions(+), 287 deletions(-) create mode 100644 src/components/footer/footer.component.html create mode 100644 src/components/footer/footer.component.scss create mode 100644 src/components/footer/footer.component.ts create mode 100644 src/components/icon-git/icon-git.component.html create mode 100644 src/components/icon-git/icon-git.component.scss create mode 100644 src/components/icon-git/icon-git.component.ts create mode 100644 src/components/loading/loading.component.html create mode 100644 src/components/loading/loading.component.scss create mode 100644 src/components/loading/loading.component.ts create mode 100644 src/components/no-data/no-data.component.html create mode 100644 src/components/no-data/no-data.component.scss create mode 100644 src/components/no-data/no-data.component.ts rename src/view/{ => app/default}/app.component.html (100%) rename src/view/{ => app/default}/app.component.scss (100%) rename src/view/{ => app/default}/app.component.ts (93%) delete mode 100644 src/view/index.component.html create mode 100644 src/view/index/default/index.component.html rename src/view/{ => index/default}/index.component.scss (91%) rename src/view/{ => index/default}/index.component.ts (95%) diff --git a/config/index.ts b/config/index.ts index 2ff00e6..5b219c1 100644 --- a/config/index.ts +++ b/config/index.ts @@ -16,12 +16,16 @@ export const webpLanguage = [ 'Git' ] -// 如果没有请赋值空字符串 -export const git = 'https://github.com/xjh22222228/nav' +// Git 仓库地址, 没有填空字符串 +export const GIT_REPO_URL = 'https://github.com/xjh22222228/nav' // 网站底部描述, 可以是 HTML +// 可以是版权信息,备案号 export const FOOTER_DESC = '' +// 百度统计 +export const TONGJI_URL = 'https://hm.baidu.com/hm.js?4582be7af7e7c95ef75351e07c6c32ba' + // http://www.nav3.cn/#/index?q=grabient export const BACKGROUND_LINEAR = [ 'linear-gradient(62deg, #8EC5FC 0%, #E0C3FC 100%)', diff --git a/data/node/deno.ts b/data/node/deno.ts index b03f9db..9d4e9ef 100644 --- a/data/node/deno.ts +++ b/data/node/deno.ts @@ -1,11 +1,15 @@ + +const DEFAULT_ICON = 'https://avatars1.githubusercontent.com/u/42048915?s=200&v=4'; + export default { title: 'Deno', nav: [ { subtitle: '官方', + icon: DEFAULT_ICON, nav: [ { - icon: 'https://avatars1.githubusercontent.com/u/42048915?s=200&v=4', + icon: null, name: 'Deno', desc: '一个安全的运行时的JavaScript和TypeScript', link: 'https://deno.land/', @@ -16,7 +20,7 @@ export default { ] }, { - icon: 'https://avatars1.githubusercontent.com/u/42048915?s=200&v=4', + icon: null, name: 'Deno 标准库', desc: 'Deno 标准库', link: 'https://deno.land/std', @@ -25,9 +29,10 @@ export default { }, { subtitle: '工具', + icon: DEFAULT_ICON, nav: [ { - icon: 'https://avatars1.githubusercontent.com/u/42048915?s=200&v=4', + icon: null, name: 'Deno', desc: '适用于Deno的Visual Studio Code插件', link: 'https://marketplace.visualstudio.com/items?itemName=denoland.vscode-deno', diff --git a/data/node/frame.ts b/data/node/frame.ts index 9d9ae62..6b4fdd6 100644 --- a/data/node/frame.ts +++ b/data/node/frame.ts @@ -3,9 +3,10 @@ export default { nav: [ { subtitle: 'Electron', + icon: 'https://www.electronjs.org/images/favicon.ico', nav: [ { - icon: 'https://www.electronjs.org/images/favicon.ico', + icon: null, name: 'Electron', desc: '使用 JavaScript, HTML 和 CSS 构建跨平台的桌面应用', link: 'https://electronjs.org/', @@ -16,13 +17,13 @@ export default { ] }, { - icon: 'https://www.electronjs.org/images/favicon.ico', + icon: null, name: 'electron-packager', desc: '通过JS或CLI自定义和封装您的Electron应用程序与特定于操作系统的软件包(.app,.exe等)', link: 'https://github.com/electron-userland/electron-packager', }, { - icon: 'https://www.electronjs.org/images/favicon.ico', + icon: null, name: 'electron-installer-dmg', desc: '使用AppDMG为电子应用程序创建DMG安装程序', link: 'https://github.com/electron-userland/electron-installer-dmg', @@ -61,7 +62,7 @@ export default { ] }, { - icon: '', + icon: null, name: 'menubar', desc: 'Electron创建菜单栏桌面应用程序的高级方法。', link: 'https://github.com/maxogden/menubar', @@ -97,4 +98,4 @@ export default { ] }, ] -} \ No newline at end of file +} diff --git a/data/node/module.ts b/data/node/module.ts index 547eeda..1729feb 100644 --- a/data/node/module.ts +++ b/data/node/module.ts @@ -15,7 +15,7 @@ export default { link: 'https://github.com/request/request', }, { - icon: 'assets/icon/frontend/049.png', + icon: null, name: 'superagent', desc: '一个小型渐进式客户端HTTP请求库,Node.js模块具有相同的API,具有许多高级HTTP客户端功能', link: 'http://visionmedia.github.io/superagent/', @@ -44,7 +44,7 @@ export default { link: 'https://github.com/mikeal/bent', }, { - icon: 'assets/icon/frontend/049.png', + icon: null, name: 'superagent-proxy', desc: 'superagent代理扩展,这使您可以通过某种代理来代理HTTP请求', link: 'https://github.com/TooTallNate/superagent-proxy', @@ -282,7 +282,7 @@ export default { icon: DEFAULT_ICON, nav: [ { - icon: 'assets/icon/frontend/132.png', + icon: null, name: 'node-http-proxy', desc: '一个HTTP可编程代理库,支持websocket。它适用于实现反向代理和负载平衡器等组件', link: 'https://github.com/nodejitsu/node-http-proxy', @@ -368,25 +368,25 @@ export default { icon: DEFAULT_ICON, nav: [ { - icon: 'assets/icon/frontend/135.png', + icon: null, name: 'wechat-oauth', desc: '微信公共平台OAuth接口消息接口服务中间件与API SDK', link: 'https://github.com/node-webot/wechat-oauth', }, { - icon: 'assets/icon/frontend/135.png', + icon: null, name: 'wechat-api', desc: '微信公共平台API', link: 'https://github.com/node-webot/wechat-api', }, { - icon: 'assets/icon/frontend/135.png', + icon: null, name: 'wechat', desc: '微信公共平台消息接口服务中间件', link: 'https://github.com/node-webot/wechat', }, { - icon: 'assets/icon/frontend/135.png', + icon: null, name: 'wechaty', desc: '是适用于微信个人帐户的Bot SDK ,可以帮助您创建6行javascript的机器人', link: 'https://chatie.io/wechaty/', @@ -468,13 +468,13 @@ export default { link: 'https://github.com/npm/node-semver' }, { - icon: 'assets/icon/frontend/076.png', + icon: null, name: 'node-progress', desc: 'node.js的灵活ascii进度条', link: 'https://github.com/visionmedia/node-progress' }, { - icon: 'assets/icon/frontend/076.png', + icon: null, name: 'node-qrcode', desc: '二维码生成', link: 'https://github.com/soldair/node-qrcode' @@ -486,19 +486,19 @@ export default { link: 'https://github.com/sindresorhus/open', }, { - icon: 'assets/icon/frontend/076.png', + icon: null, name: 'ssh2', desc: '用纯JavaScript编写的SSH2客户端和服务器模块,用于node.js', link: 'https://github.com/mscdex/ssh2', }, { - icon: 'assets/icon/frontend/076.png', + icon: null, name: 'minimist', desc: '解析参数选项', link: 'https://github.com/substack/minimist', }, { - icon: 'assets/icon/frontend/076.png', + icon: null, name: 'node-clear', desc: '清空终端屏幕信息', link: 'https://github.com/bahamas10/node-clear', @@ -615,7 +615,7 @@ export default { ] }, { - icon: 'assets/icon/frontend/136.png', + icon: 'http://www.passportjs.org/images/favicon/apple-icon-57x57.png', name: 'passport', desc: 'Node.js的简单,不显眼的身份验证', link: 'http://www.passportjs.org/', diff --git a/src/app/app.component.html b/src/app/app.component.html index 9b3d529..11c20e1 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,22 +1,5 @@
- - - - + -
-
- 共收录 {{ includeTotal }} 个网站 -
- - -
+
- - diff --git a/src/app/app.component.scss b/src/app/app.component.scss index c954a2d..787f205 100644 --- a/src/app/app.component.scss +++ b/src/app/app.component.scss @@ -3,24 +3,4 @@ &.app { color: #000; } - - .footer { - text-align: center; - margin-top: 10px; - color: #fff; - - .total { - margin-left: 5px; - vertical-align: super; - font-weight: bold; - } - - .runtime { - font-weight: bold; - } - - .copyright > * { - color: #fff; - } - } } diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 818ab6f..10fb2c6 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,8 +1,8 @@ -import { Component } from '@angular/core'; -import { Router, ActivatedRoute } from '@angular/router'; -import nav from '../../data'; -import { BACKGROUND_LINEAR, git, FOOTER_DESC } from '../../config'; -import { randomInt } from '../utils'; +import nav from '../../data' +import { Component } from '@angular/core' +import { Router, ActivatedRoute } from '@angular/router' +import { BACKGROUND_LINEAR, TONGJI_URL } from '../../config' +import { randomInt } from '../utils' @Component({ selector: 'app-xiejiahe', @@ -10,65 +10,54 @@ import { randomInt } from '../utils'; styleUrls: ['./app.component.scss'] }) export class AppComponent { + nav: Array = nav constructor (private router: Router, private activatedRoute: ActivatedRoute) {} - nav: Array = nav; - includeTotal: number = 0; - git: string = git; - FOOTER_DESC: string = FOOTER_DESC; ngOnInit() { - const hash = window.location.hash; - const params = new URLSearchParams(hash.slice(hash.indexOf('?'))); - const page = params.get('page'); - const id = params.get('id'); - const q = params.get('q'); - const queryParams = { page, id, q }; - - this.goRoute(queryParams); - - this.computedTotal(); + const hash = window.location.hash + const params = new URLSearchParams(hash.slice(hash.indexOf('?'))) + const page = params.get('page') + const id = params.get('id') + const q = params.get('q') + const queryParams = { page, id, q } + + this.goRoute(queryParams) + this.appendTongji() } ngAfterViewInit() { - setInterval(this.setBackground, 10000); + setInterval(this.setBackground, 10000) } goRoute(queryParams: object) { - const screenWidth = window.innerWidth; + const screenWidth = window.innerWidth if (screenWidth < 768) { - this.router.navigate(['/app'], { queryParams }); + this.router.navigate(['/app'], { queryParams }) } else { - this.router.navigate(['/index'], { queryParams }); - } - } - - // 计算收录个数 - computedTotal() { - let total = 0; - function r(nav) { - if (!Array.isArray(nav)) return; - for (let i = 0; i < nav.length; i++) { - if (nav[i].link) { - total += 1; - } else { - r(nav[i].nav); - } - } + this.router.navigate(['/index'], { queryParams }) } - r(this.nav); - this.includeTotal = total; } setBackground() { - const randomBg = BACKGROUND_LINEAR[randomInt(BACKGROUND_LINEAR.length)]; - const el = document.getElementById('index-background'); - if (!el) return; - el.style.opacity = '.3'; + const randomBg = BACKGROUND_LINEAR[randomInt(BACKGROUND_LINEAR.length)] + const el = document.getElementById('index-background') + if (!el) return + el.style.opacity = '.3' setTimeout(() => { - el.style.backgroundImage = randomBg; - el.style.opacity = '1'; - }, 1000); + el.style.backgroundImage = randomBg + el.style.opacity = '1' + }, 1000) + } + + appendTongji() { + if (document.getElementById('tongji_url')) return + + const script = document.createElement('script') + script.src = TONGJI_URL + script.id = 'tongji_url' + script.async = true + document.documentElement.appendChild(script) } } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index bdb28c2..23c96db 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -7,9 +7,12 @@ import { FormsModule } from '@angular/forms'; import { AppComponent } from './app.component'; // views -import { HomeComponent } from '../view/index.component'; -import { WebpComponent } from '../view/app.component'; - +import HomeComponent from '../view/index/default/index.component'; +import WebpComponent from '../view/app/default/app.component'; +import { FooterComponent } from '../components/footer/footer.component'; +import { IconGitComponent } from '../components/icon-git/icon-git.component'; +import { NoDataComponent } from '../components/no-data/no-data.component'; +import { LoadingComponent } from '../components/loading/loading.component'; const appRoutes: Routes = [ { @@ -31,7 +34,11 @@ const appRoutes: Routes = [ declarations: [ AppComponent, HomeComponent, - WebpComponent + WebpComponent, + FooterComponent, + IconGitComponent, + NoDataComponent, + LoadingComponent ], imports: [ BrowserModule, @@ -49,4 +56,5 @@ const appRoutes: Routes = [ AppComponent, ], }) + export class AppModule { } diff --git a/src/components/footer/footer.component.html b/src/components/footer/footer.component.html new file mode 100644 index 0000000..e9d0fbf --- /dev/null +++ b/src/components/footer/footer.component.html @@ -0,0 +1,7 @@ +
+
+ 共收录 {{ totalWeb }} 个网站 +
+ + +
diff --git a/src/components/footer/footer.component.scss b/src/components/footer/footer.component.scss new file mode 100644 index 0000000..9f346e2 --- /dev/null +++ b/src/components/footer/footer.component.scss @@ -0,0 +1,18 @@ +.footer { + text-align: center; + margin-top: 5px; + color: #fff; + + .total { + font-weight: bold; + } + + .runtime { + font-weight: bold; + } + + .copyright { + color: #fff; + margin-bottom: 5px; + } +} diff --git a/src/components/footer/footer.component.ts b/src/components/footer/footer.component.ts new file mode 100644 index 0000000..7406e03 --- /dev/null +++ b/src/components/footer/footer.component.ts @@ -0,0 +1,18 @@ +import { Component, OnInit } from '@angular/core' +import { FOOTER_DESC } from '../../../config' +import { totalWeb } from '../../utils' + +@Component({ + selector: 'app-footer', + templateUrl: './footer.component.html', + styleUrls: ['./footer.component.scss'] +}) +export class FooterComponent implements OnInit { + FOOTER_DESC: string = FOOTER_DESC; + totalWeb: number = totalWeb() + + constructor() { } + + ngOnInit(): void { + } +} diff --git a/src/components/icon-git/icon-git.component.html b/src/components/icon-git/icon-git.component.html new file mode 100644 index 0000000..3d8c77d --- /dev/null +++ b/src/components/icon-git/icon-git.component.html @@ -0,0 +1,9 @@ + + + diff --git a/src/components/icon-git/icon-git.component.scss b/src/components/icon-git/icon-git.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/components/icon-git/icon-git.component.ts b/src/components/icon-git/icon-git.component.ts new file mode 100644 index 0000000..fbd11be --- /dev/null +++ b/src/components/icon-git/icon-git.component.ts @@ -0,0 +1,18 @@ +import { Component, OnInit } from '@angular/core'; +import { GIT_REPO_URL } from '../../../config'; + +@Component({ + selector: 'app-icon-git', + templateUrl: './icon-git.component.html', + styleUrls: ['./icon-git.component.scss'] +}) +export class IconGitComponent implements OnInit { + + GIT_REPO_URL: string = GIT_REPO_URL + + constructor() { } + + ngOnInit(): void { + } + +} diff --git a/src/components/loading/loading.component.html b/src/components/loading/loading.component.html new file mode 100644 index 0000000..9d8691d --- /dev/null +++ b/src/components/loading/loading.component.html @@ -0,0 +1,3 @@ +
+ +
diff --git a/src/components/loading/loading.component.scss b/src/components/loading/loading.component.scss new file mode 100644 index 0000000..b5d07b2 --- /dev/null +++ b/src/components/loading/loading.component.scss @@ -0,0 +1,12 @@ +.loading { + z-index: 6666; + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + background: rgb(251, 251, 251); + display: flex; + align-items: flex-start; + justify-content: center; +} diff --git a/src/components/loading/loading.component.ts b/src/components/loading/loading.component.ts new file mode 100644 index 0000000..3442afc --- /dev/null +++ b/src/components/loading/loading.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'app-loading', + templateUrl: './loading.component.html', + styleUrls: ['./loading.component.scss'] +}) +export class LoadingComponent implements OnInit { + + constructor() { } + + ngOnInit(): void { + } + +} diff --git a/src/components/no-data/no-data.component.html b/src/components/no-data/no-data.component.html new file mode 100644 index 0000000..0efbad3 --- /dev/null +++ b/src/components/no-data/no-data.component.html @@ -0,0 +1,6 @@ +
+ 对不起,没有找到您想要的结果~ +
+ Back +
+
diff --git a/src/components/no-data/no-data.component.scss b/src/components/no-data/no-data.component.scss new file mode 100644 index 0000000..d8a01a2 --- /dev/null +++ b/src/components/no-data/no-data.component.scss @@ -0,0 +1,12 @@ +.no-result { + margin-top: 80px; + text-align: center; + + .back { + margin-top: 30px; + + span { + cursor: pointer; + } + } +} diff --git a/src/components/no-data/no-data.component.ts b/src/components/no-data/no-data.component.ts new file mode 100644 index 0000000..ba25b5e --- /dev/null +++ b/src/components/no-data/no-data.component.ts @@ -0,0 +1,18 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'app-no-data', + templateUrl: './no-data.component.html', + styleUrls: ['./no-data.component.scss'] +}) +export class NoDataComponent implements OnInit { + + constructor() { } + + ngOnInit(): void { + } + + goBack = () => { + history.go(-1); + } +} diff --git a/src/index.html b/src/index.html index 19f3556..ea023bf 100644 --- a/src/index.html +++ b/src/index.html @@ -47,6 +47,5 @@ - diff --git a/src/utils/index.ts b/src/utils/index.ts index 734ed32..97fadb5 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,26 +1,83 @@ +import nav from '../../data'; export function debounce(func, wait, immediate) { - let timeout; + let timeout + return function () { - let context = this; - let args = arguments; + let context = this + let args = arguments + + if (timeout) clearTimeout(timeout) - if (timeout) clearTimeout(timeout); if (immediate) { - let callNow = !timeout; + let callNow = !timeout timeout = setTimeout(() => { - timeout = null; + timeout = null }, wait) if (callNow) func.apply(context, args) - } - else { + } else { timeout = setTimeout(() => { func.apply(context, args) - }, wait); + }, wait) } } } -export function randomInt(max) { - return Math.floor(Math.random() * max); +export function randomInt(max: number) { + return Math.floor(Math.random() * max) +} + +export function fuzzySearch(navList: any[], keyword: string) { + let searchResultList = [{ nav: [] }] + + return function f(arr?: any[]) { + arr = arr || navList + + for (let i = 0; i < arr.length; i++) { + + if (Array.isArray(arr[i].nav)) { + f(arr[i].nav) + } + + if (arr[i].name) { + const name = arr[i].name.toLowerCase() + const desc = arr[i].desc.toLowerCase() + const search = keyword.toLowerCase() + + if (~name.indexOf(search) || ~desc.indexOf(search)) { + try { + let result = Object.assign({}, arr[i]) + const regex = new RegExp(`(${keyword})`, 'i') + result.name = result.name.replace(regex, `$1`.bold()) + result.desc = result.desc.replace(regex, `$1`.bold()) + + const idx = searchResultList[0].nav.findIndex(item => item.name === result.name) + if (idx === -1) { + searchResultList[0].nav.push(result) + } + } catch (err) {} + } + } + } + + return searchResultList + } +} + +export function totalWeb(): number { + let total = 0; + function r(nav) { + if (!Array.isArray(nav)) return + + for (let i = 0; i < nav.length; i++) { + if (nav[i].link) { + total += 1 + } else { + r(nav[i].nav) + } + } + } + r(nav) + + return total } diff --git a/src/view/app.component.html b/src/view/app/default/app.component.html similarity index 100% rename from src/view/app.component.html rename to src/view/app/default/app.component.html diff --git a/src/view/app.component.scss b/src/view/app/default/app.component.scss similarity index 100% rename from src/view/app.component.scss rename to src/view/app/default/app.component.scss diff --git a/src/view/app.component.ts b/src/view/app/default/app.component.ts similarity index 93% rename from src/view/app.component.ts rename to src/view/app/default/app.component.ts index 3816c46..67d7ccf 100644 --- a/src/view/app.component.ts +++ b/src/view/app/default/app.component.ts @@ -1,14 +1,14 @@ +import nav from '../../../../data'; import { Component } from '@angular/core'; import { Router, ActivatedRoute } from '@angular/router'; -import nav from '../../data'; -import { webpLanguage } from '../../config'; +import { webpLanguage } from '../../../../config'; @Component({ selector: 'app-home', templateUrl: './app.component.html', styleUrls: ['./app.component.scss'] }) -export class WebpComponent { +export default class WebpComponent { constructor (private router: Router, private activatedRoute: ActivatedRoute) {} nav: Array = nav; diff --git a/src/view/index.component.html b/src/view/index.component.html deleted file mode 100644 index 1eee2de..0000000 --- a/src/view/index.component.html +++ /dev/null @@ -1,121 +0,0 @@ -
-
- - -
- -
- -
- -
- - - -
- 对不起,没有找到您想要的结果~ -
- Back -
-
-
-
-
diff --git a/src/view/index/default/index.component.html b/src/view/index/default/index.component.html new file mode 100644 index 0000000..57ffa23 --- /dev/null +++ b/src/view/index/default/index.component.html @@ -0,0 +1,117 @@ +
+
+
+ + +
+ +
+ + + + + +
+
+
+ + +
diff --git a/src/view/index.component.scss b/src/view/index/default/index.component.scss similarity index 91% rename from src/view/index.component.scss rename to src/view/index/default/index.component.scss index be0fe28..54f88e8 100644 --- a/src/view/index.component.scss +++ b/src/view/index/default/index.component.scss @@ -9,10 +9,16 @@ background-image: linear-gradient(19deg, #3EECAC 0%, #EE74E1 100%); } +.index-wrapper { + display: flex; + flex-direction: column; + height: 100vh; + padding-top: 15px; +} + .homepage { + flex: 1; position: relative; - margin-top: 20px; - height: calc(100vh - 76px); background: rgb(251, 251, 251); border-radius: 5px; overflow: hidden; @@ -33,32 +39,6 @@ box-shadow: 0 4px 8px 1px #ccc; } - .no-result { - margin-top: 80px; - text-align: center; - - .back { - margin-top: 30px; - - span { - cursor: pointer; - } - } - } - - .loading { - z-index: 6666; - position: absolute; - top: 0; - left: 0; - right: 0; - bottom: 0; - background: rgb(251, 251, 251); - display: flex; - align-items: flex-start; - justify-content: center; - } - .top-nav { padding: 10px; overflow: none; @@ -300,4 +280,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/view/index.component.ts b/src/view/index/default/index.component.ts similarity index 95% rename from src/view/index.component.ts rename to src/view/index/default/index.component.ts index 833d953..10617d8 100644 --- a/src/view/index.component.ts +++ b/src/view/index/default/index.component.ts @@ -1,8 +1,8 @@ -import nav from '../../data'; +import nav from '../../../../data'; import { Component } from '@angular/core'; import { Router, ActivatedRoute } from '@angular/router'; -import { debounce } from '../utils'; -import { appLanguage, git } from '../../config'; +import { debounce } from '../../../utils'; +import { appLanguage, GIT_REPO_URL } from '../../../../config'; import { annotate } from 'rough-notation'; let equeue = []; @@ -12,7 +12,7 @@ let equeue = []; templateUrl: './index.component.html', styleUrls: ['./index.component.scss'] }) -export class HomeComponent { +export default class HomeComponent { constructor (private router: Router, private activatedRoute: ActivatedRoute) {} @@ -24,7 +24,7 @@ export class HomeComponent { showInput = false; searchLoading = false; language: string[] = appLanguage; - git: string = git; + GIT_REPO_URL: string = GIT_REPO_URL; ngOnInit () { const that = this; @@ -168,10 +168,6 @@ export class HomeComponent { } catch (e) {} } - goBack = () => { - history.go(-1); - } - setAnnotate() { const elList = document.querySelectorAll('.top-nav .ripple-btn') || []; if (elList.length === 0) return; -- GitLab