提交 55da1cf5 编写于 作者: X xjh22222228

style: adjustment.

上级 a2ce5cce
# Editor configuration, see https://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
max_line_length = off
trim_trailing_whitespace = false
......@@ -38,11 +38,11 @@
- [Sim 在线预览](https://nav3.cn/#/sim)
- [Light 在线预览](https://nav3.cn/#/light)
![Preview](media/1.png)
![Preview](media/2.png)
![Preview](media/3.png)
![Preview](media/4.png)
![Preview](media/5.png)
![Preview](https://raw.githubusercontent.com/xjh22222228/public/gh-pages/nav/1.png)
![Preview](https://raw.githubusercontent.com/xjh22222228/public/gh-pages/nav/2.png)
![Preview](https://raw.githubusercontent.com/xjh22222228/public/gh-pages/nav/3.png)
![Preview](https://raw.githubusercontent.com/xjh22222228/public/gh-pages/nav/4.png)
![Preview](https://raw.githubusercontent.com/xjh22222228/public/gh-pages/nav/5.png)
......@@ -70,15 +70,17 @@
1、Fork 当前项目。
2、[https://github.com/settings/tokens](https://github.com/settings/tokens) 申请 token, 勾选相应的权限, 如果不懂就全部选中。
2、修改项目配置文件 [nav.config.ts](nav.config.ts)
3、到 https://github.com/用户名/nav/settings/secrets/new 添加刚刚申请的token, name填写 `TOKEN` 大写
3、[https://github.com/settings/tokens](https://github.com/settings/tokens) 申请 token, 勾选相应的权限, 如果不懂就全部选中
4、打开 https://github.com/用户名/nav/actions 点击 `绿色按钮`
4、到 https://github.com/用户名/nav/settings/secrets/new 添加刚刚申请的token, name填写 `TOKEN` 大写。
5、往仓库推送一条Commit (非常重要)。
5、打开 https://github.com/用户名/nav/actions 点击 `绿色按钮`
6、5分钟后打开 https://用户名.github.io/nav 就能看到一个非常强大的导航网站了。
6、往仓库推送一条Commit (非常重要)。
7、5分钟后打开 https://用户名.github.io/nav 就能看到一个非常强大的导航网站了。
注:如果想部署到自己的域名,那么以上教程同样适合,因为它提供了自动化部署, 之后可以通过 `CNAME``反向代理` 实现:
......
......@@ -33,7 +33,6 @@
}
],
"styles": [
"src/theme.less",
"src/styles.scss"
],
"scripts": []
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, './coverage/nav'),
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
restartOnFileChange: true
});
};
import { IConfig } from './src/types'
// 网站 LOGO 替换根目录下的 logo.png, 务必为 png 后缀
const c: IConfig = {
// [必填], 请填写您的仓库地址
gitRepoUrl: 'https://github.com/xjh22222228/nav',
......@@ -18,7 +19,9 @@ const c: IConfig = {
// 海报图, 只支持 Sim 主题
// 请不要放在项目里头, 填写Url
posterImageUrl: 'assets/img/wallpaper.jpg',
posterImageUrls: [
'assets/img/wallpaper.jpg'
],
// 搜索引擎列表, 为空时不显示搜索引擎
// 自定义引擎 icon 请使用网络图标
......@@ -63,13 +66,17 @@ const c: IConfig = {
}
],
// 网站底部描述, 可以是 HTML
// 可以是版权信息,备案号
footerCopyright: '',
// 网站底部内容, 版权信息、备案号, 可以是 HTML
footerContent: '',
// 百度统计
// 百度统计地址
// https://tongji.baidu.com/web/welcome/login
baiduStatisticsUrl: 'https://hm.baidu.com/hm.js?4582be7af7e7c95ef75351e07c6c32ba',
// CNZZ 统计地址
// https://www.cnzz.com/o_index.php?
cnzzStatisticsUrl: '',
// 只支持 Light 主题
// https://www.nav3.cn/#/light?q=grabient
backgroundLinear: [
......
此差异已折叠。
......@@ -13,7 +13,8 @@
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "tsc nav.config.ts && ts-node build.mjs && ng build --prod --base-href ./",
"setup": "tsc nav.config.ts && ts-node ./scripts/build.mjs",
"build": "npm run setup && ng build --prod --base-href ./",
"lint": "eslint --cache --ext .js,.ts ./src"
},
"private": true,
......@@ -28,7 +29,7 @@
"@angular/router": "~11.0.5",
"axios": "^0.21.1",
"js-base64": "^3.6.0",
"ng-zorro-antd": "^11.0.1",
"ng-zorro-antd": "^11.0.2",
"qs": "^6.9.4",
"rough-notation": "^0.5.1",
"rxjs": "~6.6.0",
......@@ -39,17 +40,9 @@
"@angular-devkit/build-angular": "~0.1100.5",
"@angular/cli": "~11.0.5",
"@angular/compiler-cli": "~11.0.5",
"@types/jasmine": "~3.6.0",
"@types/node": "^12.11.1",
"codelyzer": "^6.0.0",
"eslint": "^7.17.0",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~5.1.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
......
// Copyright @ 2018-2021 xiejiahe. All rights reserved. MIT license.
import fs from 'fs'
import config from './nav.config.js'
import config from '../nav.config.js'
import path from 'path'
function addZero(num) {
......@@ -11,14 +11,22 @@ function addZero(num) {
const now = new Date()
const date = `${now.getFullYear()}${addZero(now.getMonth() + 1)}${addZero(now.getDate())}${addZero(now.getHours())}:${addZero(now.getMinutes())}`
const { description, title, keywords, baiduStatisticsUrl } = config.default
const {
description,
title,
keywords,
baiduStatisticsUrl,
cnzzStatisticsUrl
} = config.default
const htmlTemplate = `
<title>${title}</title>
<meta name="description" content="${description}">
<meta name="keywords" content="${keywords}">
`.trim()
const scriptTemplate = `
const cnzzScript = !cnzzStatisticsUrl ? '' : `<script src="${cnzzStatisticsUrl}"></script>`
const baiduScript = !baiduStatisticsUrl ? '' : `
<script>
var _hmt = _hmt || [];
var hm = document.createElement('script');
......@@ -27,10 +35,20 @@ hm.src = '${baiduStatisticsUrl}';
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
</script>
`
let scriptTemplate = `
${baiduScript}
${cnzzScript}
<span data-date="${date}" id="BUILD-DATE-NAV"></span>
`.trim()
try {
fs.copyFileSync(
path.join('.', 'logo.png'),
path.join('.', 'src', 'assets', 'logo.png')
)
const htmlPath = path.join('.', 'src', 'index.html')
const readHtml = fs.readFileSync(htmlPath).toString()
let t = readHtml.replace('<!-- nav.config -->', htmlTemplate)
......
import { NgModule } from '@angular/core'
import { Routes, RouterModule } from '@angular/router'
const routes: Routes = []
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
<footer class="footer dark-text" [class]="className" >
<div class="total" [ngStyle]="{marginBottom: !footerCopyright && '5px'}">
<div class="total" [ngStyle]="{marginBottom: !footerContent && '5px'}">
共收录 {{ totalWeb }} 个网站
</div>
<div class="copyright" *ngIf="footerCopyright" [innerHTML]="footerCopyright"></div>
<div class="copyright" *ngIf="footerContent" [innerHTML]="footerContent"></div>
</footer>
......@@ -10,7 +10,7 @@ import { totalWeb } from '../../utils'
styleUrls: ['./footer.component.scss']
})
export class FooterComponent {
footerCopyright: string = config.footerCopyright;
footerContent: string = config.footerContent;
totalWeb: number = totalWeb()
@Input() className: string
......
......@@ -25,7 +25,6 @@
<html>
<head>
<meta charset="utf-8">
<title>发现导航 - 精选实用导航网站</title>
<base href="/">
<meta name="author" content="https://github.com/xjh22222228">
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
......@@ -33,8 +32,8 @@
<meta name="renderer" content="webkit">
<link rel="icon" href="assets/logo.png">
<link rel ="apple-touch-icon" href="assets/logo.png">
<link rel="stylesheet" href="//at.alicdn.com/t/font_2267418_40eo6u8a0ak.css">
<!-- nav.config -->
<link rel="stylesheet" href="//at.alicdn.com/t/font_2267418_40eo6u8a0ak.css">
</head>
<body>
......
// Copyright @ 2018-2021 xiejiahe. All rights reserved. MIT license.
@import "./dark.scss";
@import "../node_modules/ng-zorro-antd/ng-zorro-antd.css";
* {
margin: 0;
......
// Custom Theming for NG-ZORRO
// For more information: https://ng.ant.design/docs/customize-theme/en
@import "../node_modules/ng-zorro-antd/ng-zorro-antd.less";
......@@ -44,14 +44,15 @@ export interface ISearchEngineProps {
}
export interface IConfig {
gitRepoUrl: string,
title: string
description: string
keywords: string
theme: ThemeType
posterImageUrl: string
searchEngineList: ISearchEngineProps[]
gitRepoUrl: string,
footerCopyright: string|null
baiduStatisticsUrl: string
backgroundLinear: string[]
posterImageUrls: string[]
footerContent?: string|null
baiduStatisticsUrl?: string
cnzzStatisticsUrl?: string
}
<div class="sim">
<div class="wallpaper" [ngStyle]="{ 'background-image': 'url(' + posterImageUrl + ')' }">
<div *ngIf="posterImageUrls" class="wallpaper" [ngStyle]="{ 'background-image': 'url(' + posterImageUrls + ')' }">
<h1 class="title dark-title">{{ title }}</h1>
<h2 class="description dark-text-active">这里收录多达 <b>{{ totalWeb }}</b> 个优质网站, 助您工作、学习和生活</h2>
<app-search-engine></app-search-engine>
......
......@@ -14,7 +14,7 @@ import {
import { initRipple, setAnnotate } from '../../../utils/ripple'
import { websiteList } from '../../../store'
const { gitRepoUrl, title, posterImageUrl } = config
const { gitRepoUrl, title, posterImageUrls } = config
let sidebarEl: HTMLElement;
@Component({
......@@ -33,7 +33,7 @@ export default class HomeComponent {
gitRepoUrl: string = gitRepoUrl
totalWeb: number = totalWeb()
title: string = title
posterImageUrl: string = posterImageUrl
posterImageUrls?: string = posterImageUrls[0]
ngOnInit() {
const initList = () => {
......@@ -68,16 +68,19 @@ export default class HomeComponent {
})
}
onScroll() {
onScroll = () => {
const y = window.scrollY
if (!sidebarEl) {
sidebarEl = document.getElementById('sidebar')
}
if (y >= 438) {
sidebarEl.classList.add('fix')
} else {
sidebarEl.classList.remove('fix')
if (sidebarEl) {
const height = this.posterImageUrls ? 438 : 10
if (y >= height) {
sidebarEl.classList.add('fix')
} else {
sidebarEl.classList.remove('fix')
}
}
}
......@@ -85,7 +88,7 @@ export default class HomeComponent {
window.removeEventListener('scroll', this.onScroll)
}
ngAfterViewInit () {
ngAfterViewInit() {
initRipple()
setAnnotate();
......
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/spec",
"types": [
"jasmine",
"node"
]
},
"files": [
"src/test.ts",
"src/polyfills.ts"
],
"include": [
"src/**/*.spec.ts",
"src/**/*.d.ts"
]
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册