Skip to content

Commit

Permalink
refactor(ui/types): add Layer interface
Browse files Browse the repository at this point in the history
  • Loading branch information
qwqcode committed Aug 31, 2024
1 parent f20454b commit 9fb1919
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
8 changes: 5 additions & 3 deletions ui/artalk/src/layer/layer.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import type { Layer as LayerApi } from '@/types/layer'

export interface LayerOptions {
onShow: () => void
onHide: () => void
}

export class Layer {
export class Layer implements LayerApi {
private allowMaskClose = true
private onAfterHide?: () => void

Expand Down Expand Up @@ -33,13 +35,13 @@ export class Layer {
this.$el.style.display = ''
}

async hide() {
hide() {
this.opts.onHide()
this.$el.style.display = 'none'
this.onAfterHide && this.onAfterHide()
}

async destroy() {
destroy() {
this.opts.onHide()
this.$el.remove()
this.onAfterHide && this.onAfterHide()
Expand Down
1 change: 1 addition & 0 deletions ui/artalk/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export type * from './editor'
export type * from './event'
export type * from './plugin'
export type * from './sidebar'
export type * from './layer'
export type { I18n, I18nKeys } from '../i18n'
9 changes: 9 additions & 0 deletions ui/artalk/src/types/layer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export interface Layer {
show: () => void
hide: () => void
destroy: () => void
setOnAfterHide(func: () => void): void
setAllowMaskClose(allow: boolean): void
getAllowMaskClose(): boolean
getEl: () => HTMLElement
}
2 changes: 1 addition & 1 deletion ui/plugin-kit/src/plugin/dts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function generateDts(
const diagnostics = [
...program.getDeclarationDiagnostics(),
...program.getSemanticDiagnostics(),
...program.getSyntacticDiagnostics()
...program.getSyntacticDiagnostics(),
]

if (diagnostics?.length) {
Expand Down

0 comments on commit 9fb1919

Please sign in to comment.