87 lines
2.9 KiB
TypeScript
87 lines
2.9 KiB
TypeScript
import { MaybeRefOrGetter, MaybeRef, ComputedRef, App, Ref } from 'vue';
|
|
import { WatermarkOptions as WatermarkOptions$1 } from 'watermark-js-plus';
|
|
import { PageFrontmatter } from 'vuepress/shared';
|
|
|
|
type WatermarkOptions = Partial<WatermarkOptions$1>;
|
|
/**
|
|
* Define additional watermark configurations in the client-side.
|
|
*
|
|
* In most cases, the majority of options should be defined in Node,
|
|
* but there are some special situations. For example,
|
|
* it may be necessary to control different watermark opacities, font colors,
|
|
* etc., in dark/light mode, or to pass in callbacks such as `onSuccess`, `extraDrawFunc`, and so on.
|
|
*
|
|
* 在客户端中定义额外的水印配置。
|
|
*
|
|
* 通常来说,大部分选项应该在 Node 中定义,但存在一些特殊情况。
|
|
* 比如需要在 深色/浅色 模式下控制不同的 水印 透明度、字体颜色等,
|
|
* 或者需要传入如 `onSuccess`、`extraDrawFunc` 等回调函数。
|
|
*
|
|
* @param userConfig - Watermark options / 水印选项
|
|
*
|
|
* @example
|
|
* ```ts
|
|
* import { useDarkMode } from '@vuepress/helper/client'
|
|
* import { computed } from 'vue'
|
|
*
|
|
* const isDark = useDarkMode()
|
|
*
|
|
* const watermarkConfig = computed(() => ({
|
|
* fontColor: isDark.value ? '#fff' : '#000',
|
|
* onSuccess: () => {
|
|
* console.log('success')
|
|
* },
|
|
* }))
|
|
*
|
|
* defineWatermarkConfig(watermarkConfig)
|
|
* ```
|
|
*/
|
|
declare const defineWatermarkConfig: (userConfig: MaybeRefOrGetter<WatermarkOptions>) => void;
|
|
/**
|
|
* Get watermark options from multiple sources
|
|
*
|
|
* 从多个来源获取水印选项
|
|
*
|
|
* @param options - Base watermark options / 基础水印选项
|
|
*
|
|
* @returns Computed watermark options / 计算后的水印选项
|
|
*/
|
|
declare const useWatermarkOptions: (options: MaybeRef<WatermarkOptions>) => ComputedRef<WatermarkOptions>;
|
|
/**
|
|
* Inject watermark configuration into Vue application
|
|
*
|
|
* 向 Vue 应用注入水印配置
|
|
*
|
|
* @param app - Vue application instance / Vue 应用实例
|
|
*/
|
|
declare const injectWatermarkConfig: (app: App) => void;
|
|
|
|
/**
|
|
* Setup watermark functionality
|
|
*
|
|
* 设置水印功能
|
|
*
|
|
* @param options - Watermark options / 水印选项
|
|
* @param enabled - Whether watermark is enabled / 是否启用水印
|
|
*/
|
|
declare const setupWatermark: (options: MaybeRef<WatermarkOptions>, enabled: Ref<boolean>) => void;
|
|
|
|
type WatermarkPureOptions = Omit<Partial<WatermarkOptions$1>, 'extraDrawFunc' | 'onBeforeDestroy' | 'onDestroyed' | 'onObserveError' | 'onSuccess' | 'parent'> & {
|
|
/**
|
|
* Watermark parent selector
|
|
*
|
|
* 水印父元素选择器
|
|
*
|
|
* @default 'body'
|
|
*/
|
|
parent?: 'body' | (string & {
|
|
__z_ignore?: never;
|
|
});
|
|
};
|
|
interface WatermarkPluginFrontmatter extends PageFrontmatter {
|
|
watermark?: WatermarkPureOptions | boolean;
|
|
}
|
|
|
|
export { defineWatermarkConfig, injectWatermarkConfig, setupWatermark, useWatermarkOptions };
|
|
export type { WatermarkOptions, WatermarkPluginFrontmatter, WatermarkPureOptions };
|