Skip to content

Commit

Permalink
refactor: transform standalone components & transform vite
Browse files Browse the repository at this point in the history
  • Loading branch information
xjh22222228 committed Nov 22, 2024
1 parent 4605f41 commit 3ba8208
Show file tree
Hide file tree
Showing 70 changed files with 3,208 additions and 3,166 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ trim_trailing_whitespace = true

[*.ts]
quote_type = single
ij_typescript_use_double_quotes = false

[*.md]
max_line_length = off
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ jobs:
- name: Build
run: |
npm run build-gh-pages
cp dist/index.html dist/404.html
cp dist/browser/index.html dist/browser/404.html
- name: Deploy
uses: JamesIves/github-pages-deploy-action@v4
with:
token: ${{ secrets.TOKEN }}
branch: gh-pages
folder: dist
folder: dist/browser
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.
# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files.

# Compiled output
/dist
/dist.zip
/tmp
/out-tsc
/bazel-out
Expand Down Expand Up @@ -42,8 +41,6 @@ testem.log
.DS_Store
Thumbs.db

.angular

# build output
src/index.html
nav.config.json
Expand Down
26 changes: 1 addition & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@

#### Netlify 推荐(免费)

作者目前使用,速度较快
作者目前使用,速度较快, 打包路径 `dist/browser`

[https://www.netlify.com/](https://www.netlify.com/)

Expand Down Expand Up @@ -164,30 +164,6 @@ git push
npm run update
```

## 更新日志

[CHANGELOG](https://github.com/xjh22222228/nav/releases)

## 开发构建

NODE: >= v20

```bash
# 下载
git clone --depth=1 https://github.com/xjh22222228/nav.git

cd nav

# 安装依赖
yarn

# 启动
yarn start

# 打包
yarn build
```

## 支持

项目于 2018 年到至今一直坚持维护和开源, 经过 N 次的迭代与优化, 如果项目能帮到您是我的荣幸。
Expand Down
37 changes: 17 additions & 20 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": 1,
"newProjectRoot": "projects",
"projects": {
"nav2": {
"nav": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
Expand All @@ -15,7 +15,7 @@
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"builder": "@angular-devkit/build-angular:application",
"options": {
"allowedCommonJsDependencies": [
"axios",
Expand All @@ -24,20 +24,20 @@
"clipboard",
"file-saver",
"localforage",
"dayjs"
"dayjs",
"lz-string"
],
"outputPath": "dist",
"index": "src/main.html",
"main": "src/main.ts",
"browser": "src/main.ts",
"polyfills": ["zone.js"],
"tsConfig": "tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": [
"src/assets",
{
"glob": "**/*",
"input": "public",
"output": "/"
"input": "public"
}
],
"styles": ["src/styles.scss"],
Expand All @@ -60,12 +60,9 @@
"outputHashing": "all"
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
"sourceMap": true
}
},
"defaultConfiguration": "production"
Expand All @@ -74,35 +71,35 @@
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"buildTarget": "nav2:build:production"
"buildTarget": "nav:build:production"
},
"development": {
"buildTarget": "nav2:build:development"
"buildTarget": "nav:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"buildTarget": "nav2:build"
}
"builder": "@angular-devkit/build-angular:extract-i18n"
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"polyfills": ["zone.js", "zone.js/testing"],
"tsConfig": "tsconfig.spec.json",
"inlineStyleLanguage": "scss",
"assets": ["src/favicon.ico", "src/assets"],
"assets": [
"src/assets",
{
"glob": "**/*",
"input": "public"
}
],
"styles": ["src/styles.scss"],
"scripts": []
}
}
}
}
},
"cli": {
"analytics": "e700bfbb-1203-4812-bab2-d4a7fa5f752e"
}
}
62 changes: 31 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,56 +15,56 @@
},
"private": true,
"dependencies": {
"@angular/animations": "^18.2.6",
"@angular/common": "^18.2.6",
"@angular/compiler": "^18.2.6",
"@angular/core": "^18.2.6",
"@angular/forms": "^18.2.6",
"@angular/platform-browser": "^18.2.6",
"@angular/platform-browser-dynamic": "^18.2.6",
"@angular/router": "^18.2.6",
"@angular/animations": "^19.0.0",
"@angular/common": "^19.0.0",
"@angular/compiler": "^19.0.0",
"@angular/core": "^19.0.0",
"@angular/forms": "^19.0.0",
"@angular/platform-browser": "^19.0.0",
"@angular/platform-browser-dynamic": "^19.0.0",
"@angular/router": "^19.0.0",
"rxjs": "~7.8.1",
"tslib": "^2.8.1",
"zone.js": "~0.15.0",
"@types/file-saver": "^2.0.7",
"@types/qs": "^6.9.16",
"@types/qs": "^6.9.17",
"axios": "^1.7.7",
"clipboard": "^2.0.11",
"dayjs": "^1.11.13",
"express": "^4.21.0",
"express": "^4.21.1",
"file-saver": "^2.0.5",
"js-base64": "^3.7.7",
"js-yaml": "^4.1.0",
"localforage": "^1.10.0",
"lz-string": "^1.5.0",
"mitt": "^3.0.1",
"ng-zorro-antd": "^18.1.1",
"nodemailer": "^6.9.15",
"ng-zorro-antd": "^18.2.1",
"nodemailer": "^6.9.16",
"nprogress": "^0.2.0",
"postcss": "^8.4.47",
"qs": "^6.13.0",
"postcss": "^8.4.49",
"qs": "^6.13.1",
"rough-notation": "^0.5.1",
"rxjs": "~7.8.1",
"tailwindcss": "^3.4.13",
"tslib": "^2.7.0",
"zone.js": "~0.15.0"
"tailwindcss": "^3.4.15"
},
"devDependencies": {
"@angular-devkit/build-angular": "^18.2.6",
"@angular/cli": "^18.2.6",
"@angular/compiler-cli": "^18.2.6",
"@angular-devkit/build-angular": "^19.0.0",
"@angular/cli": "^19.0.0",
"@angular/compiler-cli": "^19.0.0",
"@types/jasmine": "~5.1.4",
"@types/nprogress": "^0.2.3",
"body-parser": "^1.20.3",
"compression": "^1.7.4",
"connect-history-api-fallback": "^2.0.0",
"cors": "^2.8.5",
"info-web": "^0.0.33",
"jasmine-core": "~5.3.0",
"jasmine-core": "~5.4.0",
"karma": "~6.4.4",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.1",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0",
"pm2": "^5.4.2",
"ts-node": "~10.9.2",
"typescript": "~5.5.4"
"typescript": "~5.6.3",
"@types/nprogress": "^0.2.3",
"body-parser": "^1.20.3",
"compression": "^1.7.5",
"connect-history-api-fallback": "^2.0.0",
"cors": "^2.8.5",
"info-web": "^0.0.33",
"pm2": "^5.4.3",
"ts-node": "~10.9.2"
}
}
27 changes: 24 additions & 3 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
// See https://github.com/xjh22222228/nav

import { Component } from '@angular/core'
import { Router, ActivatedRoute, NavigationEnd } from '@angular/router'
import { CommonModule } from '@angular/common'
import {
Router,
ActivatedRoute,
NavigationEnd,
RouterOutlet,
} from '@angular/router'
import { queryString, setLocation, isMobile, getDefaultTheme } from '../utils'
import { en_US, NzI18nService, zh_CN } from 'ng-zorro-antd/i18n'
import { getLocale } from 'src/locale'
Expand All @@ -12,13 +18,26 @@ import { verifyToken, getContentes } 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'
import { NzSpinModule } from 'ng-zorro-antd/spin'
import { fetchWeb } from 'src/utils/web'
import { isSelfDevelop } from 'src/utils/util'
import { routes } from './app-routing.module'
import { routes } from './app.routes'
import { MoveWebComponent } from 'src/components/move-web/index.component'
import { CreateWebComponent } from 'src/components/create-web/index.component'
import { IconGitComponent } from 'src/components/icon-git/icon-git.component'
import Alert from './alert-event'
import event from 'src/utils/mitt'

@Component({
standalone: true,
imports: [
NzSpinModule,
IconGitComponent,
RouterOutlet,
CommonModule,
MoveWebComponent,
CreateWebComponent,
],
selector: 'app-xiejiahe',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
Expand Down Expand Up @@ -83,7 +102,9 @@ export class AppComponent {
// 处理默认主题
const currentRoutes = this.router.config
const defaultTheme = getDefaultTheme().toLowerCase()
const hasDefault = routes.find((item) => item.path === defaultTheme)
const hasDefault = routes.find(
(item: any) => item.path === defaultTheme
)
const isHome = this.router.url.split('?')[0] === '/'
if (hasDefault) {
this.router.resetConfig([
Expand Down
45 changes: 45 additions & 0 deletions src/app/app.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core'
import { registerLocaleData } from '@angular/common'
import zh from '@angular/common/locales/zh'
import { provideRouter } from '@angular/router'
import { provideNzIcons } from 'ng-zorro-antd/icon'
import { IconDefinition } from '@ant-design/icons-angular'
import { routes } from './app.routes'
import {
CheckOutline,
CopyOutline,
ShareAltOutline,
EllipsisOutline,
LoadingOutline,
UploadOutline,
MinusOutline,
PlusOutline,
StopOutline,
} from '@ant-design/icons-angular/icons'
import { provideAnimations } from '@angular/platform-browser/animations'
import { NZ_I18N } from 'ng-zorro-antd/i18n'
import { zh_CN } from 'ng-zorro-antd/i18n'

registerLocaleData(zh)

const icons: IconDefinition[] = [
CheckOutline,
CopyOutline,
ShareAltOutline,
EllipsisOutline,
LoadingOutline,
UploadOutline,
MinusOutline,
PlusOutline,
StopOutline,
]

export const appConfig: ApplicationConfig = {
providers: [
provideNzIcons(icons),
provideZoneChangeDetection({ eventCoalescing: true }),
provideRouter(routes),
provideAnimations(),
{ provide: NZ_I18N, useValue: zh_CN },
],
}
Loading

0 comments on commit 3ba8208

Please sign in to comment.