Skip to content

Commit f085b3c

Browse files
committed
refactor(dev-app): convert to zoneless mode
1 parent caf6c33 commit f085b3c

4 files changed

Lines changed: 18 additions & 12 deletions

File tree

angular.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@
5353
"outputPath": "dist/dev-app",
5454
"index": "projects/dev-app/src/index.html",
5555
"browser": "projects/dev-app/src/main.ts",
56-
"polyfills": [
57-
"zone.js"
58-
],
5956
"tsConfig": "projects/dev-app/tsconfig.app.json",
6057
"inlineStyleLanguage": "scss",
6158
"assets": [
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1-
import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
1+
import {
2+
ApplicationConfig,
3+
provideBrowserGlobalErrorListeners,
4+
provideZonelessChangeDetection,
5+
} from '@angular/core';
26
import { provideRouter } from '@angular/router';
37

48
import { routes } from './app.routes';
59

610
export const appConfig: ApplicationConfig = {
7-
providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes)],
11+
providers: [
12+
provideBrowserGlobalErrorListeners(),
13+
provideZonelessChangeDetection(),
14+
provideRouter(routes),
15+
],
816
};

projects/dev-app/src/app/app.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<mat-toolbar>
22
<span>Watermark</span>
33

4-
@if (image) {
4+
@if (image()) {
55
<button mat-stroked-button (click)="restore()">Restore</button>
66
} @else {
77
<button mat-stroked-button (click)="decrypt()">Decrypt blind watermark</button>
@@ -29,8 +29,8 @@
2929
<main watermark [watermarkOptions]="options">
3030
<p>Add watermark to your page.</p>
3131

32-
@if (image) {
33-
<img [src]="image" alt="blind watermark decyption image" width="100%" height="100%" />
32+
@if (image()) {
33+
<img [src]="image()" alt="blind watermark decyption image" width="100%" height="100%" />
3434
}
3535
</main>
3636
</div>

projects/dev-app/src/app/app.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { GuiFields, GuiModule } from '@acrodata/gui';
22
import { Watermark, WatermarkDirective, WatermarkOptions } from '@acrodata/watermark';
3-
import { Component, OnInit } from '@angular/core';
3+
import { Component, OnInit, signal } from '@angular/core';
44
import { MatButtonModule } from '@angular/material/button';
55
import { MatToolbarModule } from '@angular/material/toolbar';
66
import html2canvas from 'html2canvas';
@@ -145,6 +145,7 @@ export class App implements OnInit {
145145
},
146146
fontColor: {
147147
type: 'fill',
148+
mode: 'solid',
148149
name: 'fontColor',
149150
default: '#000',
150151
},
@@ -183,7 +184,7 @@ export class App implements OnInit {
183184
},
184185
};
185186

186-
image = '';
187+
image = signal('');
187188

188189
ngOnInit(): void {
189190
html2canvas(document.querySelector('main')!, { useCORS: true });
@@ -200,11 +201,11 @@ export class App implements OnInit {
200201
if (ctx) {
201202
// 处理像素解密盲水印
202203
Watermark.decrypt(ctx);
203-
this.image = canvas.toDataURL();
204+
this.image.set(canvas.toDataURL());
204205
}
205206
}
206207

207208
restore() {
208-
this.image = '';
209+
this.image.set('');
209210
}
210211
}

0 commit comments

Comments
 (0)