@dxtmisha/wiki 0.39.8 → 0.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{defineProperty-Bjg6wMoX.js → defineProperty-149Ahniv.js} +4 -4
- package/dist/library.js +1 -1
- package/dist/media/descriptions/wikiDescriptionsArea.d.ts +7 -0
- package/dist/media/descriptions/wikiDescriptionsClientOnly.d.ts +7 -0
- package/dist/media/descriptions/wikiDescriptionsContainer.d.ts +7 -0
- package/dist/media/descriptions/wikiDescriptionsHeader.d.ts +7 -0
- package/dist/media/descriptions/wikiDescriptionsPageArea.d.ts +7 -0
- package/dist/media/mdx/Area/wikiMdxArea.d.ts +7 -0
- package/dist/media/mdx/ClientOnly/wikiMdxClientOnly.d.ts +7 -0
- package/dist/media/mdx/Container/wikiMdxContainer.d.ts +7 -0
- package/dist/media/mdx/Header/wikiMdxHeader.d.ts +7 -0
- package/dist/media/mdx/PageArea/wikiMdxPageArea.d.ts +7 -0
- package/dist/media.d.ts +1 -1
- package/dist/media.js +115 -68
- package/dist/storybook.js +2707 -1841
- package/dist/{wikiDescriptions-Cv4WzSNL.js → wikiDescriptions-7XaHU3Yk.js} +182 -0
- package/package.json +1 -1
- package/src/media/functional/functional/composables/useApiAsyncRef/useApiAsyncRef.en.mdx +43 -0
- package/src/media/functional/functional/composables/useApiAsyncRef/useApiAsyncRef.ru.mdx +43 -0
- package/src/media/functional/functional/composables/useApiAsyncRef/useApiAsyncRef.vi.mdx +41 -0
- package/src/media/functional/functional/composables/useApiRef/useApiRef.en.mdx +20 -4
- package/src/media/functional/functional/composables/useApiRef/useApiRef.ru.mdx +21 -3
- package/src/media/functional/functional/composables/useApiRef/useApiRef.vi.mdx +20 -2
- package/src/media/functional/functional/functions/computedAsync/computedAsync.en.mdx +8 -0
- package/src/media/functional/functional/functions/computedAsync/computedAsync.ru.mdx +8 -0
- package/src/media/functional/functional/functions/computedAsync/computedAsync.vi.mdx +8 -0
- package/src/media/functional/functional/functions/computedEternity/computedEternity.en.mdx +8 -0
- package/src/media/functional/functional/functions/computedEternity/computedEternity.ru.mdx +8 -0
- package/src/media/functional/functional/functions/computedEternity/computedEternity.vi.mdx +8 -0
- package/src/media/functional/functional-basic/classes/Api/Api.en.mdx +3 -0
- package/src/media/functional/functional-basic/classes/Api/Api.ru.mdx +3 -0
- package/src/media/functional/functional-basic/classes/Api/Api.vi.mdx +3 -0
- package/src/media/functional/functional-basic/classes/ApiInstance/ApiInstance.en.mdx +5 -2
- package/src/media/functional/functional-basic/classes/ApiInstance/ApiInstance.ru.mdx +6 -3
- package/src/media/functional/functional-basic/classes/ApiInstance/ApiInstance.vi.mdx +5 -2
- package/src/media/functional/functional-basic/classes/ApiResponse/ApiResponse.en.mdx +9 -0
- package/src/media/functional/functional-basic/classes/ApiResponse/ApiResponse.ru.mdx +9 -0
- package/src/media/functional/functional-basic/classes/ApiResponse/ApiResponse.vi.mdx +9 -0
- package/src/media/functional/functional-basic/classes/CookieStorage/CookieStorage.en.mdx +31 -6
- package/src/media/functional/functional-basic/classes/CookieStorage/CookieStorage.ru.mdx +31 -6
- package/src/media/functional/functional-basic/classes/CookieStorage/CookieStorage.vi.mdx +31 -6
- package/src/media/functional/functional-basic/classes/Meta/Meta.en.mdx +16 -0
- package/src/media/functional/functional-basic/classes/Meta/Meta.ru.mdx +16 -0
- package/src/media/functional/functional-basic/classes/Meta/Meta.vi.mdx +17 -1
- package/src/media/functional/functional-basic/classes/MetaManager/MetaManager.en.mdx +9 -0
- package/src/media/functional/functional-basic/classes/MetaManager/MetaManager.ru.mdx +9 -0
- package/src/media/functional/functional-basic/classes/MetaManager/MetaManager.vi.mdx +9 -0
- package/src/media/functional/functional-basic/classes/MetaStatic/MetaStatic.en.mdx +2 -1
- package/src/media/functional/functional-basic/classes/MetaStatic/MetaStatic.ru.mdx +2 -1
- package/src/media/functional/functional-basic/classes/MetaStatic/MetaStatic.vi.mdx +3 -2
- package/src/media/functional/functional-basic/classes/ServerStorage/ServerStorage.en.mdx +2 -2
- package/src/media/functional/functional-basic/classes/ServerStorage/ServerStorage.ru.mdx +2 -2
- package/src/media/functional/functional-basic/classes/ServerStorage/ServerStorage.vi.mdx +2 -2
- package/src/media/functional/functional-basic/icons/icons.en.mdx +3 -0
- package/src/media/functional/functional-basic/icons/icons.ru.mdx +3 -0
- package/src/media/functional/functional-basic/icons/icons.vi.mdx +3 -0
- package/src/media/functional/nitro-basic/functions/getInject.en.mdx +27 -0
- package/src/media/functional/nitro-basic/functions/getInject.ru.mdx +27 -0
- package/src/media/functional/nitro-basic/functions/getInject.vi.mdx +20 -0
|
@@ -8,6 +8,7 @@ import { Meta } from '@storybook/addon-docs/blocks'
|
|
|
8
8
|
|
|
9
9
|
**Параметры:**
|
|
10
10
|
- `getter: () => Promise<T> | T` — Функция, которая возвращает вычисляемое значение (может быть синхронной или асинхронной).
|
|
11
|
+
- `initialState?: T` — Начальное значение результата.
|
|
11
12
|
|
|
12
13
|
**Возвращает:**
|
|
13
14
|
`CustomRef<T>` — Реактивное вычисляемое свойство с результатом выполнения геттера.
|
|
@@ -15,6 +16,13 @@ import { Meta } from '@storybook/addon-docs/blocks'
|
|
|
15
16
|
```typescript
|
|
16
17
|
import { computedEternity } from '@dxtmisha/functional'
|
|
17
18
|
|
|
19
|
+
// Начальное значение
|
|
20
|
+
const status = computedEternity(async () => {
|
|
21
|
+
await new Promise(resolve => setTimeout(resolve, 1000))
|
|
22
|
+
return 'online'
|
|
23
|
+
}, 'offline')
|
|
24
|
+
// Status.value будет 'offline' до завершения выполнения геттера
|
|
25
|
+
|
|
18
26
|
// Асинхронный геттер - будет вызван только при первом обращении к 'data.value'
|
|
19
27
|
const data = computedEternity(async () => {
|
|
20
28
|
const response = await fetch('/api/data')
|
|
@@ -8,6 +8,7 @@ Tạo một thuộc tính tính toán được tính toán theo yêu cầu và
|
|
|
8
8
|
|
|
9
9
|
**Các tham số:**
|
|
10
10
|
- `getter: () => Promise<T> | T` — Một hàm trả về giá trị cần tính toán (có thể là đồng bộ hoặc bất đồng bộ).
|
|
11
|
+
- `initialState?: T` — Giá trị ban đầu của kết quả.
|
|
11
12
|
|
|
12
13
|
**Trả về:**
|
|
13
14
|
`CustomRef<T>` — Một ref tùy chỉnh phản ứng chứa kết quả đã giải quyết của getter.
|
|
@@ -15,6 +16,13 @@ Tạo một thuộc tính tính toán được tính toán theo yêu cầu và
|
|
|
15
16
|
```typescript
|
|
16
17
|
import { computedEternity } from '@dxtmisha/functional'
|
|
17
18
|
|
|
19
|
+
// Trạng thái ban đầu
|
|
20
|
+
const status = computedEternity(async () => {
|
|
21
|
+
await new Promise(resolve => setTimeout(resolve, 1000))
|
|
22
|
+
return 'online'
|
|
23
|
+
}, 'offline')
|
|
24
|
+
// Status.value là 'offline' cho đến khi getter được giải quyết
|
|
25
|
+
|
|
18
26
|
// Getter bất đồng bộ - sẽ chỉ được gọi khi 'data.value' được truy cập lần đầu tiên
|
|
19
27
|
const data = computedEternity(async () => {
|
|
20
28
|
const response = await fetch('/api/data')
|
|
@@ -38,6 +38,7 @@ Methods for performing physical network requests.
|
|
|
38
38
|
- `setPreparation(callback): void` — Registers a hook to run before every enabled request.
|
|
39
39
|
- `setEnd(callback): void` — Registers a hook to run after every enabled response.
|
|
40
40
|
- `setTimeout(timeout: number): void` — Changes the global request timeout.
|
|
41
|
+
- `setOrigin(origin: string): void` — Changes the origin (protocol and domain) for the base URL.
|
|
41
42
|
- `setConfig(config?: ApiConfig): void` — Applies a complete configuration object.
|
|
42
43
|
|
|
43
44
|
### Auxiliary
|
|
@@ -46,6 +47,7 @@ Methods for performing physical network requests.
|
|
|
46
47
|
- `getResponse(): ApiResponse` — Accesses the response/emulation manager.
|
|
47
48
|
- `getHydration(): ApiHydration` — Accesses the hydration manager.
|
|
48
49
|
- `getHydrationScript(): string` — Returns the script block for SSR-to-client hydration.
|
|
50
|
+
- `getOrigin(): string` — Returns the base origin URL combined with the API path.
|
|
49
51
|
- `getUrl(path: string, api?: boolean): string` — Returns the fully resolved URL with `{locale}`, `{country}`, `{language}` placeholder substitution.
|
|
50
52
|
- `getBody(request, method?): string | FormData | undefined` — Prepares the request body.
|
|
51
53
|
- `getBodyForGet(request, path?, method?): string` — Prepares the query string.
|
|
@@ -56,6 +58,7 @@ Methods for performing physical network requests.
|
|
|
56
58
|
### ApiConfig
|
|
57
59
|
|
|
58
60
|
- `urlRoot: string` — the base URL for the API.
|
|
61
|
+
- `origin: string` — protocol and domain for the base URL.
|
|
59
62
|
- `headers: Record<string, string>` — default request headers.
|
|
60
63
|
- `requestDefault: Record<string, any>` — default request data.
|
|
61
64
|
- `preparation: (apiFetch: ApiFetch) => Promise<void>` — entry hook.
|
|
@@ -38,6 +38,7 @@ import {Meta} from '@storybook/addon-docs/blocks'
|
|
|
38
38
|
- `setPreparation(callback): void` — Регистрирует хук, запускаемый перед каждым включенным запросом.
|
|
39
39
|
- `setEnd(callback): void` — Регистрирует хук, запускаемый после каждого включенного ответа.
|
|
40
40
|
- `setTimeout(timeout: number): void` — Изменяет глобальный таймаут запроса.
|
|
41
|
+
- `setOrigin(origin: string): void` — Изменяет источник (протокол и домен) для базового URL.
|
|
41
42
|
- `setConfig(config?: ApiConfig): void` — Применяет полный объект конфигурации.
|
|
42
43
|
|
|
43
44
|
### Вспомогательные
|
|
@@ -46,6 +47,7 @@ import {Meta} from '@storybook/addon-docs/blocks'
|
|
|
46
47
|
- `getResponse(): ApiResponse` — Доступ к менеджеру ответов/эмуляции.
|
|
47
48
|
- `getHydration(): ApiHydration` — Доступ к менеджеру гидратации.
|
|
48
49
|
- `getHydrationScript(): string` — Возвращает блок скрипта для гидратации SSR-клиент.
|
|
50
|
+
- `getOrigin(): string` — Возвращает базовый URL источника, объединенный с путем API.
|
|
49
51
|
- `getUrl(path: string, api?: boolean): string` — Возвращает полностью разрешенный URL с подстановкой плейсхолдеров `{locale}`, `{country}`, `{language}`.
|
|
50
52
|
- `getBody(request?, method?): string | FormData | undefined` — Подготавливает тело запроса.
|
|
51
53
|
- `getBodyForGet(request, path?, method?): string` — Подготавливает строку запроса.
|
|
@@ -56,6 +58,7 @@ import {Meta} from '@storybook/addon-docs/blocks'
|
|
|
56
58
|
### ApiConfig
|
|
57
59
|
|
|
58
60
|
- `urlRoot: string` — базовый URL для API.
|
|
61
|
+
- `origin: string` — протокол и домен для формирования базового URL.
|
|
59
62
|
- `headers: Record<string, string>` — заголовки запроса по умолчанию.
|
|
60
63
|
- `requestDefault: Record<string, any>` — данные запроса по умолчанию.
|
|
61
64
|
- `preparation: (apiFetch: ApiFetch) => Promise<void>` — входной хук.
|
|
@@ -38,6 +38,7 @@ Các phương thức để thực hiện các yêu cầu mạng vật lý.
|
|
|
38
38
|
- `setPreparation(callback): void` — Đăng ký một hook để chạy trước mỗi yêu cầu được bật.
|
|
39
39
|
- `setEnd(callback): void` — Đăng ký một hook để chạy sau mỗi phản hồi được bật.
|
|
40
40
|
- `setTimeout(timeout: number): void` — Thay đổi timeout yêu cầu toàn cục.
|
|
41
|
+
- `setOrigin(origin: string): void` — Thay đổi nguồn (giao thức và tên miền) cho URL base.
|
|
41
42
|
- `setConfig(config?: ApiConfig): void` — Áp dụng một đối tượng cấu hình đầy đủ.
|
|
42
43
|
|
|
43
44
|
### Phụ trợ
|
|
@@ -46,6 +47,7 @@ Các phương thức để thực hiện các yêu cầu mạng vật lý.
|
|
|
46
47
|
- `getResponse(): ApiResponse` — Truy cập trình quản lý phản hồi/mô phỏng.
|
|
47
48
|
- `getHydration(): ApiHydration` — Truy cập trình quản lý hydration.
|
|
48
49
|
- `getHydrationScript(): string` — Trả về khối script để hydration từ SSR sang client.
|
|
50
|
+
- `getOrigin(): string` — Trả về URL base đã kết hợp với đường dẫn API.
|
|
49
51
|
- `getUrl(path: string, api?: boolean): string` — Trả về URL đã được phân giải đầy đủ với các token bản địa hóa.
|
|
50
52
|
- `getBody(request?, method?): string | FormData | undefined` — Chuẩn bị body yêu cầu.
|
|
51
53
|
- `getBodyForGet(request, path?, method?): string` — Chuẩn bị chuỗi truy vấn (query string).
|
|
@@ -56,6 +58,7 @@ Các phương thức để thực hiện các yêu cầu mạng vật lý.
|
|
|
56
58
|
### ApiConfig
|
|
57
59
|
|
|
58
60
|
- `urlRoot: string` — URL base cho API.
|
|
61
|
+
- `origin: string` — giao thức và tên miền cho URL base.
|
|
59
62
|
- `headers: Record<string, string>` — các header yêu cầu mặc định.
|
|
60
63
|
- `requestDefault: Record<string, any>` — dữ liệu yêu cầu mặc định.
|
|
61
64
|
- `preparation: (apiFetch: ApiFetch) => Promise<void>` — hook đầu vào (entry hook).
|
|
@@ -75,10 +75,12 @@ Methods to configure the API (support chaining, returning the `ApiInstance` obje
|
|
|
75
75
|
- `setUrl(url: string): this` — Overwrites generic target URL configurations prefix points.
|
|
76
76
|
- `setPreparation(callback: (apiFetch: ApiFetch) => Promise<void>): this` — Connects a custom hook function actively running just _before_ execution trigger occurs.
|
|
77
77
|
- `setEnd(callback: (query: Response, apiFetch: ApiFetch) => Promise<ApiPreparationEnd>): this` — Sets the hook triggered exactly _after_ network response returns.
|
|
78
|
+
- `setOrigin(origin: string): this` — Sets the origin (protocol and domain) for the base URL.
|
|
78
79
|
|
|
79
80
|
### Auxiliary
|
|
80
81
|
|
|
81
82
|
- `getUrl(path: string, api?: boolean): string` — Generates the full target URL referencing the script, handling `{locale}`, `{country}`, `{language}` placeholder substitution.
|
|
83
|
+
- `getOrigin(): string` — Returns the base origin URL combined with the API path.
|
|
82
84
|
- `getBody(request?: ApiFetch['request'], method?: string): string | FormData | undefined` — Creates data to be passed into the request physical body.
|
|
83
85
|
- `getBodyForGet(request: ApiFetch['request'], path?: string, method?: string): string` — Forms query parameters specifically for HTTP arguments assigned into the URL directly used when sending `GET` queries.
|
|
84
86
|
- `getHydration(): ApiHydration` — Returns the hydration manager.
|
|
@@ -107,7 +109,8 @@ Methods to configure the API (support chaining, returning the `ApiInstance` obje
|
|
|
107
109
|
- `timeout?: number` — request timeout in milliseconds. Default: `16000`ms (only used if `controller` is not provided).
|
|
108
110
|
- `controller?: AbortController` — controller for canceling the request. If provided, timeout is ignored.
|
|
109
111
|
- `retry?: number` — number of retries on failure.
|
|
110
|
-
- `retryDelay?: number` — base delay between retries in milliseconds. Default: `64`ms.
|
|
112
|
+
- `retryDelay?: number` — base delay between retries in milliseconds. Default: `64`ms. Jitter is used to prevent thundering herd problems.
|
|
113
|
+
- `endResetLimit?: number` — limit for recursive retries via `setEnd` with `reset: true`. Default: `8`.
|
|
111
114
|
|
|
112
115
|
## Response Data Structure
|
|
113
116
|
|
|
@@ -194,7 +197,7 @@ The `setEnd` method sets a callback function that is called after receiving a re
|
|
|
194
197
|
- `apiFetch: ApiFetch` — the parameters object with which the request was performed.
|
|
195
198
|
|
|
196
199
|
**Returns:** `Promise<ApiPreparationEnd>`. The result object can contain the following fields:
|
|
197
|
-
- `reset?: boolean` — if set to `true`, the library will abort the current chain and **execute the request again** (recursively) after a jittered delay (see `retryDelay`). The entire process of preparation and execution will be restarted. This is used for automatic handling of refreshed access rights.
|
|
200
|
+
- `reset?: boolean` — if set to `true`, the library will abort the current chain and **execute the request again** (recursively) after a jittered delay (see `retryDelay`). The entire process of preparation and execution will be restarted. This is used for automatic handling of refreshed access rights. This recursion is limited by `endResetLimit` (default: 8).
|
|
198
201
|
- `data?: any` — allows you to override the data returned by the API method. If this field is specified, the standard response reading mechanism (JSON/text) will be ignored.
|
|
199
202
|
|
|
200
203
|
```javascript
|
|
@@ -75,10 +75,12 @@ import {Meta} from '@storybook/addon-docs/blocks'
|
|
|
75
75
|
- `setUrl(url: string): this` — Изменяет базовый URL путь для API скриптов.
|
|
76
76
|
- `setPreparation(callback: (apiFetch: ApiFetch) => Promise<void>): this` — Устанавливает хук, выполняемый перед каждым сетевым запросом.
|
|
77
77
|
- `setEnd(callback: (query: Response, apiFetch: ApiFetch) => Promise<ApiPreparationEnd>): this` — Устанавливает хук, выполняемый после получения ответа.
|
|
78
|
+
- `setOrigin(origin: string): this` — Устанавливает источник (протокол и домен) для формирования базового URL.
|
|
78
79
|
|
|
79
80
|
### Вспомогательные
|
|
80
81
|
|
|
81
82
|
- `getUrl(path: string, api?: boolean): string` — Формирует полный адрес к скрипту запроса с подстановкой плейсхолдеров `{locale}`, `{country}`, `{language}`.
|
|
83
|
+
- `getOrigin(): string` — Возвращает базовый URL источника, объединенный с путем API.
|
|
82
84
|
- `getBody(request?: ApiFetch['request'], method?: string): string | FormData | undefined` — Формирует данные для тела запроса.
|
|
83
85
|
- `getBodyForGet(request: ApiFetch['request'], path?: string, method?: string): string` — Формирует строку query-параметров для GET-запроса.
|
|
84
86
|
- `getHydration(): ApiHydration` — Возвращает менеджер гидратации.
|
|
@@ -107,7 +109,8 @@ import {Meta} from '@storybook/addon-docs/blocks'
|
|
|
107
109
|
- `timeout?: number` — таймаут запроса в миллисекундах. По умолчанию: `16000`мс (используется только если не передан `controller`).
|
|
108
110
|
- `controller?: AbortController` — контроллер для отмены запроса. Если передан, таймаут игнорируется.
|
|
109
111
|
- `retry?: number` — количество повторов при сбое.
|
|
110
|
-
- `retryDelay?: number` — базовая задержка между повторами в миллисекундах. По умолчанию: `64`мс.
|
|
112
|
+
- `retryDelay?: number` — базовая задержка между повторами в миллисекундах. По умолчанию: `64`мс. Используется алгоритм с джиттером для предотвращения лавинообразных запросов.
|
|
113
|
+
- `endResetLimit?: number` — лимит рекурсивных повторов через `setEnd` с `reset: true`. По умолчанию: `8`.
|
|
111
114
|
|
|
112
115
|
## Структура данных ответа
|
|
113
116
|
|
|
@@ -166,7 +169,7 @@ controller.abort()
|
|
|
166
169
|
Метод `setPreparation` устанавливает callback-функцию, которая вызывается непосредственно перед отправкой запроса на сервер (до выполнения нативного `fetch`).
|
|
167
170
|
|
|
168
171
|
**Особенности работы:**
|
|
169
|
-
- **Очередность исполнения**: Если одновременно запускается несколько запросов, класс гарантирует, что хук подготовки будет выполнен **последовательно**. Все последующие запросы будут ждать завершения текущего хука в режиме ожидания (с интервалом опроса
|
|
172
|
+
- **Очередность исполнения**: Если одновременно запускается несколько запросов, класс гарантирует, что хук подготовки будет выполнен **последовательно**. Все последующие запросы будут ждать завершения текущего хука в режиме ожидания (с интервалом опроса 16мс). Это предотвращает конфликты, например, при одновременном обновлении токена несколькими запросами.
|
|
170
173
|
- **Параметры**: Получает объект `apiFetch`, содержащий все текущие настройки запроса. Вы можете изменять этот объект (например, добавляя заголовки или модифицируя тело запроса).
|
|
171
174
|
- **Возвращает**: `Promise<void>`.
|
|
172
175
|
|
|
@@ -194,7 +197,7 @@ api.setPreparation(async (apiFetch) => {
|
|
|
194
197
|
- `apiFetch: ApiFetch` — объект параметров, с которыми был выполнен запрос.
|
|
195
198
|
|
|
196
199
|
**Возвращает:** `Promise<ApiPreparationEnd>`. Объект результата может содержать следующие поля:
|
|
197
|
-
- `reset?: boolean` — если установлено в `true`, библиотека прервет текущую цепочку и **выполнит запрос заново** (рекурсивно) через рандомизированную задержку (см. `retryDelay`). Весь процесс подготовки и выполнения будет запущен повторно. Используется для автоматической обработки обновленных прав доступа.
|
|
200
|
+
- `reset?: boolean` — если установлено в `true`, библиотека прервет текущую цепочку и **выполнит запрос заново** (рекурсивно) через рандомизированную задержку (см. `retryDelay`). Весь процесс подготовки и выполнения будет запущен повторно. Используется для автоматической обработки обновленных прав доступа. Лимит таких повторов ограничен параметром `endResetLimit` (по умолчанию 8).
|
|
198
201
|
- `data?: any` — позволяет переопределить данные, которые вернет метод API. Если это поле указано, стандартный механизм чтения ответа (JSON/текст) будет проигнорирован.
|
|
199
202
|
|
|
200
203
|
```javascript
|
|
@@ -74,10 +74,12 @@ Hỗ trợ phương pháp nối chuỗi (chaining methods) trả về đối tư
|
|
|
74
74
|
- `setUrl(url: string): this` — Ghi đè định danh URL mặc định nhánh server API.
|
|
75
75
|
- `setPreparation(callback: (apiFetch: ApiFetch) => Promise<void>): this` — Thiết lập vòng lặp hook _ngay trước_ thời khắc thao tác diễn ra.
|
|
76
76
|
- `setEnd(callback: (query: Response, apiFetch: ApiFetch) => Promise<ApiPreparationEnd>): this` — Thiết lập vòng lặp hook _sau_ khi tín hiệu mạng phản hồi trả về.
|
|
77
|
+
- `setOrigin(origin: string): this` — Thiết lập nguồn (giao thức và tên miền) cho URL base.
|
|
77
78
|
|
|
78
79
|
### Phụ trợ
|
|
79
80
|
|
|
80
81
|
- `getUrl(path: string, api?: boolean): string` — Tạo ra đường dẫn API đầy đủ, tự thay thế thẻ định danh quốc gia `{locale}`, `{country}` v.v...
|
|
82
|
+
- `getOrigin(): string` — Trả về URL base đã kết hợp với đường dẫn API.
|
|
81
83
|
- `getBody(request?: ApiFetch['request'], method?: string): string | FormData | undefined` — Hoán đổi tài liệu để form nạp JSON hoặc `FormData`.
|
|
82
84
|
- `getBodyForGet(request: ApiFetch['request'], path?: string, method?: string): string` — Hoàn trả dữ liệu params cấu hình chuẩn cho thanh Search URL `GET`.
|
|
83
85
|
|
|
@@ -104,7 +106,8 @@ Hỗ trợ phương pháp nối chuỗi (chaining methods) trả về đối tư
|
|
|
104
106
|
- `timeout?: number` — thời gian chờ yêu cầu tính bằng mili giây. Mặc định: `16000`ms.
|
|
105
107
|
- `controller?: AbortController` — bộ điều khiển để hủy yêu cầu.
|
|
106
108
|
- `retry?: number` — số lần thử lại khi thất bại.
|
|
107
|
-
- `retryDelay?: number` — độ trễ cơ bản giữa các lần thử lại tính bằng mili giây. Mặc định: `64`ms.
|
|
109
|
+
- `retryDelay?: number` — độ trễ cơ bản giữa các lần thử lại tính bằng mili giây. Mặc định: `64`ms. Jitter được sử dụng để ngăn chặn vấn đề thundering herd.
|
|
110
|
+
- `endResetLimit?: number` — giới hạn đệ quy thử lại thông qua `setEnd` với `reset: true`. Mặc định: `8`.
|
|
108
111
|
|
|
109
112
|
## Cấu trúc dữ liệu phản hồi
|
|
110
113
|
|
|
@@ -191,7 +194,7 @@ Phương thức `setEnd` thiết lập một hàm callback được gọi sau kh
|
|
|
191
194
|
- `apiFetch: ApiFetch` — đối tượng tham số đã dùng để thực hiện yêu cầu.
|
|
192
195
|
|
|
193
196
|
**Trả về:** `Promise<ApiPreparationEnd>`. Đối tượng kết quả có thể chứa các trường sau:
|
|
194
|
-
- `reset?: boolean` — nếu được đặt thành `true`, thư viện sẽ hủy chuỗi hiện tại và **thực hiện lại yêu cầu** (đệ quy) sau một khoảng trễ ngẫu nhiên (xem `retryDelay`). Toàn bộ quá trình chuẩn bị và thực thi sẽ được khởi động lại. Việc này được dùng để tự động xử lý quyền truy cập đã được làm mới.
|
|
197
|
+
- `reset?: boolean` — nếu được đặt thành `true`, thư viện sẽ hủy chuỗi hiện tại và **thực hiện lại yêu cầu** (đệ quy) sau một khoảng trễ ngẫu nhiên (xem `retryDelay`). Toàn bộ quá trình chuẩn bị và thực thi sẽ được khởi động lại. Việc này được dùng để tự động xử lý quyền truy cập đã được làm mới. Quá trình đệ quy này được giới hạn bởi `endResetLimit` (mặc định: 8).
|
|
195
198
|
- `data?: any` — cho phép bạn ghi đè dữ liệu mà phương thức API trả về. Nếu trường này được chỉ định, cơ chế đọc phản hồi tiêu chuẩn (JSON/văn bản) sẽ bị bỏ qua.
|
|
196
199
|
|
|
197
200
|
```javascript
|
|
@@ -41,6 +41,15 @@ Core engine loop that validates request configurations and executes matched rout
|
|
|
41
41
|
|
|
42
42
|
**Returns:** `Promise<T | undefined>` — The emulated response data.
|
|
43
43
|
|
|
44
|
+
#### `emulatorAsync`
|
|
45
|
+
|
|
46
|
+
Synchronous version of the emulator. It returns the mock response immediately without any delay or loading state. This method only runs in DOM environments.
|
|
47
|
+
|
|
48
|
+
**Parameters:**
|
|
49
|
+
- `apiFetch: ApiFetch` — The properties of the request to emulate.
|
|
50
|
+
|
|
51
|
+
**Returns:** `T | undefined` — The emulated response data.
|
|
52
|
+
|
|
44
53
|
### Check
|
|
45
54
|
|
|
46
55
|
- `get(path: string, method: ApiMethod, request?: ApiFetch['request'], devMode?: boolean): ApiResponseItem | undefined` — Synchronously checks for a matching cached mock request.
|
|
@@ -41,6 +41,15 @@ const apiResponse = new ApiResponse(myApiDefault)
|
|
|
41
41
|
|
|
42
42
|
**Возвращает:** `Promise<T | undefined>` — Данные эмулированного ответа.
|
|
43
43
|
|
|
44
|
+
#### `emulatorAsync`
|
|
45
|
+
|
|
46
|
+
Синхронная версия эмулятора. Возвращает мок-ответ немедленно, без задержек и состояния загрузки. Этот метод работает только в среде DOM.
|
|
47
|
+
|
|
48
|
+
**Параметры:**
|
|
49
|
+
- `apiFetch: ApiFetch` — Свойства запроса для эмуляции.
|
|
50
|
+
|
|
51
|
+
**Возвращает:** `T | undefined` — Данные эмулированного ответа.
|
|
52
|
+
|
|
44
53
|
### Проверка
|
|
45
54
|
|
|
46
55
|
- `get(path: string, method: ApiMethod, request?: ApiFetch['request'], devMode?: boolean): ApiResponseItem | undefined` — Синхронно проверяет наличие подходящего мок-запроса в кэше.
|
|
@@ -41,6 +41,15 @@ Vòng lặp công cụ chính để xác thực các cấu hình yêu cầu và
|
|
|
41
41
|
|
|
42
42
|
**Trả về:** `Promise<T | undefined>` — Dữ liệu phản hồi đã giả lập.
|
|
43
43
|
|
|
44
|
+
#### `emulatorAsync`
|
|
45
|
+
|
|
46
|
+
Phiên bản đồng bộ của trình giả lập. Nó trả về phản hồi mock ngay lập tức mà không có bất kỳ độ trễ hoặc trạng thái tải nào. Phương thức này chỉ chạy trong môi trường DOM.
|
|
47
|
+
|
|
48
|
+
**Tham số:**
|
|
49
|
+
- `apiFetch: ApiFetch` — Các thuộc tính của yêu cầu cần giả lập.
|
|
50
|
+
|
|
51
|
+
**Trả về:** `T | undefined` — Dữ liệu phản hồi đã giả lập.
|
|
52
|
+
|
|
44
53
|
### Kiểm tra
|
|
45
54
|
|
|
46
55
|
- `get(path: string, method: ApiMethod, request?: ApiFetch['request'], devMode?: boolean): ApiResponseItem | undefined` — Kiểm tra đồng bộ một yêu cầu mock đã lưu khớp với các tham số.
|
|
@@ -50,7 +50,7 @@ Removes a cookie by setting an empty value and negative expiration. Equivalent t
|
|
|
50
50
|
|
|
51
51
|
### Configuration
|
|
52
52
|
|
|
53
|
-
- `init(getListener
|
|
53
|
+
- `init(getListener?, getListenerRaw?, setListener?)` — Initializes the storage with custom listeners for reading and writing data. The `setListener` takes 4 arguments: `(key, value, cookie, options)`.
|
|
54
54
|
- `reset()` — Resets the storage by clearing all in-memory items and removing listeners
|
|
55
55
|
|
|
56
56
|
### Auxiliary
|
|
@@ -63,9 +63,14 @@ Removes a cookie by setting an empty value and negative expiration. Equivalent t
|
|
|
63
63
|
|
|
64
64
|
Configuration object for cookie parameters:
|
|
65
65
|
|
|
66
|
-
- `age?: number` — lifetime in seconds (
|
|
66
|
+
- `age?: number` — lifetime in seconds (max-age attribute)
|
|
67
67
|
- `sameSite?: 'strict' | 'lax'` — SameSite policy
|
|
68
|
-
- `
|
|
68
|
+
- `path?: string` — cookie path (defaults to `/`)
|
|
69
|
+
- `domain?: string` — cookie domain
|
|
70
|
+
- `secure?: boolean` — if true, adds the Secure attribute
|
|
71
|
+
- `httpOnly?: boolean` — if true, adds the HttpOnly attribute (only for server-side listeners)
|
|
72
|
+
- `partitioned?: boolean` — if true, adds the Partitioned attribute (CHIPS)
|
|
73
|
+
- `arguments?: string[] | Record<string, any>` — additional directives for the cookie string
|
|
69
74
|
|
|
70
75
|
## Built-in Type Conversion
|
|
71
76
|
|
|
@@ -105,7 +110,23 @@ import { CookieStorage } from '@dxtmisha/functional-basic'
|
|
|
105
110
|
|
|
106
111
|
CookieStorage.init(
|
|
107
112
|
(key) => myStorage.get(key),
|
|
108
|
-
|
|
113
|
+
undefined,
|
|
114
|
+
(key, value, cookie, options) => {
|
|
115
|
+
// cookie is already formatted string like "key=value; max-age=..."
|
|
116
|
+
myStorage.set(key, value, cookie, options)
|
|
117
|
+
}
|
|
118
|
+
)
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Initialize for SSR (Raw)
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
import { CookieStorage } from '@dxtmisha/functional-basic'
|
|
125
|
+
|
|
126
|
+
// For SSR, get all cookies as a raw string
|
|
127
|
+
CookieStorage.init(
|
|
128
|
+
undefined,
|
|
129
|
+
() => request.headers.cookie
|
|
109
130
|
)
|
|
110
131
|
```
|
|
111
132
|
|
|
@@ -131,14 +152,18 @@ import { CookieStorage } from '@dxtmisha/functional-basic'
|
|
|
131
152
|
// Initialize with custom storage
|
|
132
153
|
CookieStorage.init(
|
|
133
154
|
(key) => redis.get(key),
|
|
134
|
-
|
|
155
|
+
undefined,
|
|
156
|
+
(key, value, cookie, options) => redis.set(key, value, cookie, options)
|
|
135
157
|
)
|
|
136
158
|
|
|
137
159
|
// Set value with options
|
|
138
160
|
CookieStorage.set('user', 'john', {
|
|
139
161
|
age: 3600, // 1 hour
|
|
140
162
|
sameSite: 'lax', // SameSite policy
|
|
141
|
-
|
|
163
|
+
path: '/', // Path
|
|
164
|
+
secure: true, // HTTPS only
|
|
165
|
+
httpOnly: true, // XSS protection (for SSR)
|
|
166
|
+
arguments: ['Priority=High'] // Additional directives
|
|
142
167
|
})
|
|
143
168
|
|
|
144
169
|
// Get with type conversion
|
|
@@ -50,7 +50,7 @@ import {Meta} from '@storybook/addon-docs/blocks'
|
|
|
50
50
|
|
|
51
51
|
### Конфигурация
|
|
52
52
|
|
|
53
|
-
- `init(getListener
|
|
53
|
+
- `init(getListener?, getListenerRaw?, setListener?)` — Инициализирует хранилище с пользовательскими слушателями для чтения и записи данных. Слушатель записи `setListener` принимает 4 аргумента: `(key, value, cookie, options)`.
|
|
54
54
|
- `reset()` — Сбрасывает хранилище, очищая все элементы в памяти и удаляя слушатели
|
|
55
55
|
|
|
56
56
|
### Вспомогательные
|
|
@@ -63,9 +63,14 @@ import {Meta} from '@storybook/addon-docs/blocks'
|
|
|
63
63
|
|
|
64
64
|
Объект конфигурации для параметров cookie:
|
|
65
65
|
|
|
66
|
-
- `age?: number` — время жизни в секундах (атрибут
|
|
66
|
+
- `age?: number` — время жизни в секундах (атрибут max-age)
|
|
67
67
|
- `sameSite?: 'strict' | 'lax'` — политика SameSite
|
|
68
|
-
- `
|
|
68
|
+
- `path?: string` — путь для cookie (по умолчанию `/`)
|
|
69
|
+
- `domain?: string` — домен для cookie
|
|
70
|
+
- `secure?: boolean` — если true, добавляет атрибут Secure
|
|
71
|
+
- `httpOnly?: boolean` — если true, добавляет атрибут HttpOnly (только для серверных слушателей)
|
|
72
|
+
- `partitioned?: boolean` — если true, добавляет атрибут Partitioned (CHIPS)
|
|
73
|
+
- `arguments?: string[] | Record<string, any>` — дополнительные директивы для строки cookie
|
|
69
74
|
|
|
70
75
|
## Встроенное преобразование типов
|
|
71
76
|
|
|
@@ -105,7 +110,23 @@ import { CookieStorage } from '@dxtmisha/functional-basic'
|
|
|
105
110
|
|
|
106
111
|
CookieStorage.init(
|
|
107
112
|
(key) => myStorage.get(key),
|
|
108
|
-
|
|
113
|
+
undefined,
|
|
114
|
+
(key, value, cookie, options) => {
|
|
115
|
+
// cookie - это уже отформатированная строка типа "key=value; max-age=..."
|
|
116
|
+
myStorage.set(key, value, cookie, options)
|
|
117
|
+
}
|
|
118
|
+
)
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Инициализация для SSR (Raw)
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
import { CookieStorage } from '@dxtmisha/functional-basic'
|
|
125
|
+
|
|
126
|
+
// Для SSR получаем все куки в виде сырой строки
|
|
127
|
+
CookieStorage.init(
|
|
128
|
+
undefined,
|
|
129
|
+
() => request.headers.cookie
|
|
109
130
|
)
|
|
110
131
|
```
|
|
111
132
|
|
|
@@ -131,14 +152,18 @@ import { CookieStorage } from '@dxtmisha/functional-basic'
|
|
|
131
152
|
// Инициализация с пользовательским хранилищем
|
|
132
153
|
CookieStorage.init(
|
|
133
154
|
(key) => redis.get(key),
|
|
134
|
-
|
|
155
|
+
undefined,
|
|
156
|
+
(key, value, cookie, options) => redis.set(key, value, cookie, options)
|
|
135
157
|
)
|
|
136
158
|
|
|
137
159
|
// Установка значения с параметрами
|
|
138
160
|
CookieStorage.set('user', 'john', {
|
|
139
161
|
age: 3600, // 1 час
|
|
140
162
|
sameSite: 'lax', // Политика SameSite
|
|
141
|
-
|
|
163
|
+
path: '/', // Путь
|
|
164
|
+
secure: true, // Только HTTPS
|
|
165
|
+
httpOnly: true, // Защита от XSS (для SSR)
|
|
166
|
+
arguments: ['Priority=High'] // Дополнительные директивы
|
|
142
167
|
})
|
|
143
168
|
|
|
144
169
|
// Получение значения с преобразованием типа
|
|
@@ -50,7 +50,7 @@ Xóa cookie bằng cách đặt giá trị rỗng và thời hạn hết hạn
|
|
|
50
50
|
|
|
51
51
|
### Cấu hình
|
|
52
52
|
|
|
53
|
-
- `init(getListener
|
|
53
|
+
- `init(getListener?, getListenerRaw?, setListener?)` — Khởi tạo bộ nhớ với các trình lắng nghe tùy chỉnh để đọc và ghi dữ liệu. Trình lắng nghe ghi `setListener` chấp nhận 4 đối số: `(key, value, cookie, options)`.
|
|
54
54
|
- `reset()` — Đặt lại lưu trữ bằng cách xóa tất cả phần tử trong bộ nhớ và xóa người nghe
|
|
55
55
|
|
|
56
56
|
### Hỗ trợ
|
|
@@ -63,9 +63,14 @@ Xóa cookie bằng cách đặt giá trị rỗng và thời hạn hết hạn
|
|
|
63
63
|
|
|
64
64
|
Đối tượng cấu hình cho tham số cookie:
|
|
65
65
|
|
|
66
|
-
- `age?: number` — thời gian tồn tại tính bằng giây (thuộc tính
|
|
66
|
+
- `age?: number` — thời gian tồn tại tính bằng giây (thuộc tính max-age)
|
|
67
67
|
- `sameSite?: 'strict' | 'lax'` — chính sách SameSite
|
|
68
|
-
- `
|
|
68
|
+
- `path?: string` — đường dẫn cho cookie (mặc định là `/`)
|
|
69
|
+
- `domain?: string` — tên miền cho cookie
|
|
70
|
+
- `secure?: boolean` — nếu đúng, thêm thuộc tính Secure
|
|
71
|
+
- `httpOnly?: boolean` — nếu đúng, thêm thuộc tính HttpOnly (chỉ dành cho trình lắng nghe phía máy chủ)
|
|
72
|
+
- `partitioned?: boolean` — nếu đúng, thêm thuộc tính Partitioned (CHIPS)
|
|
73
|
+
- `arguments?: string[] | Record<string, any>` — các chỉ thị bổ sung cho chuỗi cookie
|
|
69
74
|
|
|
70
75
|
## Chuyển đổi loại tích hợp
|
|
71
76
|
|
|
@@ -105,7 +110,23 @@ import { CookieStorage } from '@dxtmisha/functional-basic'
|
|
|
105
110
|
|
|
106
111
|
CookieStorage.init(
|
|
107
112
|
(key) => myStorage.get(key),
|
|
108
|
-
|
|
113
|
+
undefined,
|
|
114
|
+
(key, value, cookie, options) => {
|
|
115
|
+
// cookie là chuỗi đã được định dạng như "key=value; max-age=..."
|
|
116
|
+
myStorage.set(key, value, cookie, options)
|
|
117
|
+
}
|
|
118
|
+
)
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Khởi tạo cho SSR (Raw)
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
import { CookieStorage } from '@dxtmisha/functional-basic'
|
|
125
|
+
|
|
126
|
+
// Đối với SSR, lấy tất cả cookie dưới dạng chuỗi thô
|
|
127
|
+
CookieStorage.init(
|
|
128
|
+
undefined,
|
|
129
|
+
() => request.headers.cookie
|
|
109
130
|
)
|
|
110
131
|
```
|
|
111
132
|
|
|
@@ -131,14 +152,18 @@ import { CookieStorage } from '@dxtmisha/functional-basic'
|
|
|
131
152
|
// Khởi tạo với lưu trữ tùy chỉnh
|
|
132
153
|
CookieStorage.init(
|
|
133
154
|
(key) => redis.get(key),
|
|
134
|
-
|
|
155
|
+
undefined,
|
|
156
|
+
(key, value, cookie, options) => redis.set(key, value, cookie, options)
|
|
135
157
|
)
|
|
136
158
|
|
|
137
159
|
// Đặt giá trị với các tùy chọn
|
|
138
160
|
CookieStorage.set('user', 'john', {
|
|
139
161
|
age: 3600, // 1 giờ
|
|
140
162
|
sameSite: 'lax', // Chính sách SameSite
|
|
141
|
-
|
|
163
|
+
path: '/', // Đường dẫn
|
|
164
|
+
secure: true, // Chỉ HTTPS
|
|
165
|
+
httpOnly: true, // Bảo vệ XSS (cho SSR)
|
|
166
|
+
arguments: ['Priority=High'] // Các chỉ thị bổ sung
|
|
142
167
|
})
|
|
143
168
|
|
|
144
169
|
// Nhận giá trị với chuyển đổi loại
|
|
@@ -41,6 +41,11 @@ const meta = new Meta()
|
|
|
41
41
|
- `getOg(): MetaOg` — direct access to the `MetaOg` instance.
|
|
42
42
|
- `getTwitter(): MetaTwitter` — direct access to the `MetaTwitter` instance.
|
|
43
43
|
|
|
44
|
+
## Methods for Generating HTML
|
|
45
|
+
|
|
46
|
+
- `html(): string` — generates the full HTML string of all meta tags: standard + Open Graph + Twitter Card. Used for SSR.
|
|
47
|
+
- `htmlTitle(): string` — generates the page title.
|
|
48
|
+
|
|
44
49
|
## Setters
|
|
45
50
|
|
|
46
51
|
All setters return `this` for method chaining.
|
|
@@ -74,6 +79,17 @@ const html = meta.html()
|
|
|
74
79
|
// ...
|
|
75
80
|
```
|
|
76
81
|
|
|
82
|
+
### `htmlTitle(): string`
|
|
83
|
+
|
|
84
|
+
Generates the current title (including suffix).
|
|
85
|
+
|
|
86
|
+
```javascript
|
|
87
|
+
const meta = new Meta()
|
|
88
|
+
meta.setSuffix('My Site').setTitle('Home')
|
|
89
|
+
|
|
90
|
+
meta.htmlTitle() // "Home - My Site"
|
|
91
|
+
```
|
|
92
|
+
|
|
77
93
|
## Example
|
|
78
94
|
|
|
79
95
|
```javascript
|
|
@@ -41,6 +41,11 @@ const meta = new Meta()
|
|
|
41
41
|
- `getOg(): MetaOg` — прямой доступ к экземпляру `MetaOg`.
|
|
42
42
|
- `getTwitter(): MetaTwitter` — прямой доступ к экземпляру `MetaTwitter`.
|
|
43
43
|
|
|
44
|
+
## Методы для генерации HTML
|
|
45
|
+
|
|
46
|
+
- `html(): string` — генерирует полную HTML-строку всех мета-тегов: стандартных + Open Graph + Twitter Card. Используется для SSR.
|
|
47
|
+
- `htmlTitle(): string` — генерирует заголовок страницы.
|
|
48
|
+
|
|
44
49
|
## Сеттеры
|
|
45
50
|
|
|
46
51
|
Все сеттеры возвращают `this` для цепочки вызовов.
|
|
@@ -74,6 +79,17 @@ const html = meta.html()
|
|
|
74
79
|
// ...
|
|
75
80
|
```
|
|
76
81
|
|
|
82
|
+
### `htmlTitle(): string`
|
|
83
|
+
|
|
84
|
+
Генерирует текущий заголовок (включая суффикс).
|
|
85
|
+
|
|
86
|
+
```javascript
|
|
87
|
+
const meta = new Meta()
|
|
88
|
+
meta.setSuffix('Мой Сайт').setTitle('Главная')
|
|
89
|
+
|
|
90
|
+
meta.htmlTitle() // "Главная - Мой Сайт"
|
|
91
|
+
```
|
|
92
|
+
|
|
77
93
|
## Пример
|
|
78
94
|
|
|
79
95
|
```javascript
|
|
@@ -41,9 +41,14 @@ const meta = new Meta()
|
|
|
41
41
|
- `getOg(): MetaOg` — truy cập trực tiếp instance `MetaOg`.
|
|
42
42
|
- `getTwitter(): MetaTwitter` — truy cập trực tiếp instance `MetaTwitter`.
|
|
43
43
|
|
|
44
|
+
## Phương thức tạo HTML
|
|
45
|
+
|
|
46
|
+
- `html(): string` — tạo chuỗi HTML đầy đủ của tất cả thẻ meta: tiêu chuẩn + Open Graph + Twitter Card. Dùng cho SSR.
|
|
47
|
+
- `htmlTitle(): string` — tạo tiêu đề trang.
|
|
48
|
+
|
|
44
49
|
## Setter
|
|
45
50
|
|
|
46
|
-
|
|
51
|
+
All setter trả về `this` để chuỗi phương thức.
|
|
47
52
|
|
|
48
53
|
- `setTitle(title: string)` — đặt `document.title` (có hậu tố), `og:title` và `twitter:title` đồng thời.
|
|
49
54
|
- `setKeywords(keywords: string | string[])` — nhận chuỗi hoặc mảng; mảng tự động nối bằng dấu phẩy.
|
|
@@ -74,6 +79,17 @@ const html = meta.html()
|
|
|
74
79
|
// ...
|
|
75
80
|
```
|
|
76
81
|
|
|
82
|
+
### `htmlTitle(): string`
|
|
83
|
+
|
|
84
|
+
Tạo tiêu đề hiện tại (bao gồm cả hậu tố).
|
|
85
|
+
|
|
86
|
+
```javascript
|
|
87
|
+
const meta = new Meta()
|
|
88
|
+
meta.setSuffix('Trang web của tôi').setTitle('Trang chủ')
|
|
89
|
+
|
|
90
|
+
meta.htmlTitle() // "Trang chủ - Trang web của tôi"
|
|
91
|
+
```
|
|
92
|
+
|
|
77
93
|
## Ví dụ
|
|
78
94
|
|
|
79
95
|
```javascript
|
|
@@ -49,3 +49,12 @@ manager.set('description', 'My description').set('keywords', 'vue, typescript')
|
|
|
49
49
|
manager.html()
|
|
50
50
|
// '<meta name="description" content="My description"><meta name="keywords" content="vue, typescript">'
|
|
51
51
|
```
|
|
52
|
+
|
|
53
|
+
### `htmlTitle(title: string): string`
|
|
54
|
+
|
|
55
|
+
Converts a title string into an HTML `<title>` tag.
|
|
56
|
+
|
|
57
|
+
```javascript
|
|
58
|
+
manager.htmlTitle('My Page Title')
|
|
59
|
+
// '<title>My Page Title</title>'
|
|
60
|
+
```
|
|
@@ -49,3 +49,12 @@ manager.set('description', 'Моё описание').set('keywords', 'vue, type
|
|
|
49
49
|
manager.html()
|
|
50
50
|
// '<meta name="description" content="Моё описание"><meta name="keywords" content="vue, typescript">'
|
|
51
51
|
```
|
|
52
|
+
|
|
53
|
+
### `htmlTitle(title: string): string`
|
|
54
|
+
|
|
55
|
+
Преобразует строку заголовка в HTML-тег `<title>`.
|
|
56
|
+
|
|
57
|
+
```javascript
|
|
58
|
+
manager.htmlTitle('Заголовок страницы')
|
|
59
|
+
// '<title>Заголовок страницы</title>'
|
|
60
|
+
```
|
|
@@ -49,3 +49,12 @@ manager.set('description', 'Mô tả của tôi').set('keywords', 'vue, typescri
|
|
|
49
49
|
manager.html()
|
|
50
50
|
// '<meta name="description" content="Mô tả của tôi"><meta name="keywords" content="vue, typescript">'
|
|
51
51
|
```
|
|
52
|
+
|
|
53
|
+
### `htmlTitle(title: string): string`
|
|
54
|
+
|
|
55
|
+
Chuyển đổi chuỗi tiêu đề thành thẻ HTML `<title>`.
|
|
56
|
+
|
|
57
|
+
```javascript
|
|
58
|
+
manager.htmlTitle('Tiêu đề trang')
|
|
59
|
+
// '<title>Tiêu đề trang</title>'
|
|
60
|
+
```
|