Total Complexity | 0 |
Complexity/F | 0 |
Lines of Code | 58 |
Function Count | 0 |
Duplicated Lines | 0 |
Ratio | 0 % |
Coverage | 100% |
Changes | 0 |
1 | 1 | import type { Router } from 'vue-router'; |
|
2 | 1 | import type { ComponentOptions } from 'vue'; |
|
3 | 1 | ||
4 | 1 | export interface TitleOptions { |
|
5 | 1 | /** |
|
6 | 1 | * Prefix to be used in title generation |
|
7 | 1 | */ |
|
8 | 1 | prefix?: string; |
|
9 | 1 | /** |
|
10 | 1 | * Suffix to be used in title generation |
|
11 | 1 | */ |
|
12 | 1 | suffix?: string; |
|
13 | 1 | } |
|
14 | 1 | ||
15 | 1 | export type SetTitleFn = (val: string) => void; |
|
16 | 1 | export type TitleOptionFn<T = ComponentOptions> = (this: T, ctx: T) => string; |
|
17 | 1 | ||
18 | 1 | export type TitleOption = TitleOptionFn | string; |
|
19 | 1 | ||
20 | 1 | export interface SetTitleOptions extends TitleOptions { |
|
21 | 1 | /** |
|
22 | 1 | * Custom title definition |
|
23 | 1 | */ |
|
24 | 1 | setTitleMethod?: SetTitleFn; |
|
25 | 1 | } |
|
26 | 1 | ||
27 | 1 | export interface PageTitleOptions extends SetTitleOptions { |
|
28 | 1 | /** |
|
29 | 1 | * Register mixin |
|
30 | 1 | */ |
|
31 | 1 | mixin?: boolean; |
|
32 | 1 | /** |
|
33 | 1 | * Enable router integration |
|
34 | 1 | */ |
|
35 | 1 | router?: Router; |
|
36 | 1 | } |
|
37 | 1 | ||
38 | 1 | declare module '@vue/runtime-core' { |
|
39 | 1 | interface ComponentCustomProperties { |
|
40 | 1 | /** |
|
41 | 1 | * Current title |
|
42 | 1 | */ |
|
43 | 1 | $title: string; |
|
44 | 1 | /** |
|
45 | 1 | * Update current title |
|
46 | 1 | */ |
|
47 | 1 | $setPageTitle: SetTitleFn; |
|
48 | 1 | } |
|
49 | 1 | ||
50 | 1 | interface ComponentCustomOptions { |
|
51 | 1 | /** |
|
52 | 1 | * Title component option |
|
53 | 1 | * `mixin` must be true |
|
54 | 1 | */ |
|
55 | 1 | title?: TitleOption; |
|
56 | 1 | } |
|
57 | } |
||
58 |