From 955f537d59f0952dd68787e5836fd9ab0fb37583 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E6=B5=B7?= Date: Sun, 17 May 2020 00:07:20 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0Service=20Worker=20?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E7=BD=91=E7=AB=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- angular.json | 10 +++++-- ngsw-config.json | 29 ++++++++++++++++++++ package-lock.json | 5 ++++ package.json | 1 + src/app/app.module.ts | 5 +++- src/index.html | 3 ++ src/manifest.webmanifest | 59 ++++++++++++++++++++++++++++++++++++++++ 7 files changed, 108 insertions(+), 4 deletions(-) create mode 100644 ngsw-config.json create mode 100644 src/manifest.webmanifest diff --git a/angular.json b/angular.json index 586539f..94596a3 100644 --- a/angular.json +++ b/angular.json @@ -30,7 +30,8 @@ "glob": "**/*", "input": "./node_modules/@ant-design/icons-angular/src/inline-svg/", "output": "/assets/" - } + }, + "src/manifest.webmanifest" ], "styles": [ "src/assets/editor/css/editormd.css", @@ -75,7 +76,9 @@ "maximumWarning": "6kb", "maximumError": "10kb" } - ] + ], + "serviceWorker": true, + "ngswConfigPath": "ngsw-config.json" } } }, @@ -105,7 +108,8 @@ "karmaConfig": "karma.conf.js", "assets": [ "src/favicon.ico", - "src/assets" + "src/assets", + "src/manifest.webmanifest" ], "styles": [ "./node_modules/ng-zorro-antd/ng-zorro-antd.min.css", diff --git a/ngsw-config.json b/ngsw-config.json new file mode 100644 index 0000000..4ddf1a7 --- /dev/null +++ b/ngsw-config.json @@ -0,0 +1,29 @@ +{ + "$schema": "./node_modules/@angular/service-worker/config/schema.json", + "index": "/index.html", + "assetGroups": [ + { + "name": "app", + "installMode": "prefetch", + "resources": { + "files": [ + "/favicon.ico", + "/index.html", + "/manifest.webmanifest", + "/*.css", + "/*.js" + ] + } + }, { + "name": "assets", + "installMode": "lazy", + "updateMode": "prefetch", + "resources": { + "files": [ + "/assets/**", + "/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)" + ] + } + } + ] +} diff --git a/package-lock.json b/package-lock.json index afa7d41..00e2c2c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -575,6 +575,11 @@ "resolved": "https://registry.npm.taobao.org/@angular/router/download/@angular/router-9.1.2.tgz?cache=0&sync_timestamp=1586994046502&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40angular%2Frouter%2Fdownload%2F%40angular%2Frouter-9.1.2.tgz", "integrity": "sha1-8juhkcRAfEvOC36n98pe3UetoBA=" }, + "@angular/service-worker": { + "version": "9.1.7", + "resolved": "https://registry.npm.taobao.org/@angular/service-worker/download/@angular/service-worker-9.1.7.tgz", + "integrity": "sha1-PrJI6D2XeKN6v/kIvFCDmQQIETw=" + }, "@ant-design/colors": { "version": "3.2.2", "resolved": "https://registry.npm.taobao.org/@ant-design/colors/download/@ant-design/colors-3.2.2.tgz?cache=0&sync_timestamp=1577271695621&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40ant-design%2Fcolors%2Fdownload%2F%40ant-design%2Fcolors-3.2.2.tgz", diff --git a/package.json b/package.json index 05587b5..b887301 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "@angular/platform-browser": "^9.1.2", "@angular/platform-browser-dynamic": "^9.1.2", "@angular/router": "^9.1.2", + "@angular/service-worker": "^9.1.2", "jquery": "^3.5.0", "ng-zorro-antd": "^9.0.1", "nrm": "^1.2.1", diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 8827d4f..0e762e0 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -12,6 +12,8 @@ import {FooterComponent} from './components/footer/footer.component'; import {AppRoutingModule} from './app-routing.module'; import {LoginRegistrationModule} from './view/login-registration/login-registration.module'; import {AdminModule} from './view/admin/admin.module'; +import { ServiceWorkerModule } from '@angular/service-worker'; +import { environment } from '../environments/environment'; registerLocaleData(zh); @@ -30,7 +32,8 @@ registerLocaleData(zh); HttpClientModule, BrowserAnimationsModule, LoginRegistrationModule, - AdminModule + AdminModule, + ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production }) ], providers: [{provide: NZ_I18N, useValue: zh_CN}], exports: [], diff --git a/src/index.html b/src/index.html index fcddea3..82ec4b0 100644 --- a/src/index.html +++ b/src/index.html @@ -8,8 +8,11 @@ + + + diff --git a/src/manifest.webmanifest b/src/manifest.webmanifest new file mode 100644 index 0000000..45a3486 --- /dev/null +++ b/src/manifest.webmanifest @@ -0,0 +1,59 @@ +{ + "name": "index", + "short_name": "index", + "theme_color": "#1976d2", + "background_color": "#fafafa", + "display": "standalone", + "scope": "./", + "start_url": "./", + "icons": [ + { + "src": "assets/icons/icon-72x72.png", + "sizes": "72x72", + "type": "image/png", + "purpose": "maskable any" + }, + { + "src": "assets/icons/icon-96x96.png", + "sizes": "96x96", + "type": "image/png", + "purpose": "maskable any" + }, + { + "src": "assets/icons/icon-128x128.png", + "sizes": "128x128", + "type": "image/png", + "purpose": "maskable any" + }, + { + "src": "assets/icons/icon-144x144.png", + "sizes": "144x144", + "type": "image/png", + "purpose": "maskable any" + }, + { + "src": "assets/icons/icon-152x152.png", + "sizes": "152x152", + "type": "image/png", + "purpose": "maskable any" + }, + { + "src": "assets/icons/icon-192x192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable any" + }, + { + "src": "assets/icons/icon-384x384.png", + "sizes": "384x384", + "type": "image/png", + "purpose": "maskable any" + }, + { + "src": "assets/icons/icon-512x512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable any" + } + ] +} From e3dc949245b61306496b8a02b86616b6d7361ff0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E6=B5=B7?= Date: Sun, 17 May 2020 00:11:10 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E6=9E=84=E5=BB=BA=E7=9A=84ci?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/buildTest.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/buildTest.yml diff --git a/.github/workflows/buildTest.yml b/.github/workflows/buildTest.yml new file mode 100644 index 0000000..f92d8f5 --- /dev/null +++ b/.github/workflows/buildTest.yml @@ -0,0 +1,20 @@ +name: BuildTest + +on: + push + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js 12.x + uses: actions/setup-node@v1 + with: + node-version: '12.x' + - run: npm install -g @angular/cli + - run: bash build.sh From 7987da4d4aaeac41bb3a61494cac10aa8221c749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A6=BE=E5=87=A0=E6=B5=B7?= <34731503+xiaohai2271@users.noreply.github.com> Date: Sun, 17 May 2020 00:13:59 +0800 Subject: [PATCH 3/4] Update buildTest.yml --- .github/workflows/buildTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/buildTest.yml b/.github/workflows/buildTest.yml index f92d8f5..032a98a 100644 --- a/.github/workflows/buildTest.yml +++ b/.github/workflows/buildTest.yml @@ -1,7 +1,7 @@ name: BuildTest on: - push + push: pull_request: branches: [ master ] From d3a122065e879bc19b3d4248cffe8f82c5eec365 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E6=B5=B7?= Date: Sun, 17 May 2020 00:20:09 +0800 Subject: [PATCH 4/4] . --- .github/workflows/nodejs.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 48040e9..d54c30d 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -6,8 +6,6 @@ name: BuildProject on: push: branches: [ master ] - pull_request: - branches: [ master ] jobs: build: