update user invite style
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
import { MessagePlugin as TDesignMessage } from "tdesign-mobile-vue";
|
||||
import type { MessagePluginOptions } from "tdesign-mobile-vue/es/message/message";
|
||||
|
||||
/** Message 支持的调用参数。 */
|
||||
export type MessageOptions = MessagePluginOptions;
|
||||
export type MessageInput = string | MessageOptions;
|
||||
|
||||
type MessageTheme = Exclude<NonNullable<MessageOptions["theme"]>, "loading">;
|
||||
|
||||
interface TDesignMessageApi {
|
||||
info: (options: MessageOptions) => void;
|
||||
success: (options: MessageOptions) => void;
|
||||
warning: (options: MessageOptions) => void;
|
||||
error: (options: MessageOptions) => void;
|
||||
closeAll: () => void;
|
||||
}
|
||||
|
||||
const tDesignMessage = TDesignMessage as unknown as TDesignMessageApi;
|
||||
|
||||
function normalizeOptions(input: MessageInput): MessageOptions {
|
||||
return typeof input === "string" ? { content: input } : input;
|
||||
}
|
||||
|
||||
function normalizeOptionsWithDuration(input: MessageInput, duration?: number): MessageOptions {
|
||||
const options = normalizeOptions(input);
|
||||
return duration === undefined ? options : { ...options, duration };
|
||||
}
|
||||
|
||||
function showMessage(input: MessageInput, duration?: number): void {
|
||||
const options = normalizeOptionsWithDuration(input, duration);
|
||||
const theme = options.theme || "info";
|
||||
tDesignMessage[theme](options);
|
||||
}
|
||||
|
||||
function showMessageByTheme(theme: MessageTheme, input: MessageInput, duration?: number): void {
|
||||
tDesignMessage[theme]({
|
||||
offset: [10, 16],
|
||||
...normalizeOptionsWithDuration(input, duration),
|
||||
theme
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一 Message 调用方式,使其支持类似 Toast 的字符串和配置对象调用。
|
||||
*/
|
||||
export const Message = Object.assign(showMessage, {
|
||||
info: (input: MessageInput, duration?: number): void => showMessageByTheme("info", input, duration),
|
||||
success: (input: MessageInput, duration?: number): void => showMessageByTheme("success", input, duration),
|
||||
warning: (input: MessageInput, duration?: number): void => showMessageByTheme("warning", input, duration),
|
||||
error: (input: MessageInput, duration?: number): void => showMessageByTheme("error", input, duration),
|
||||
closeAll: (): void => tDesignMessage.closeAll()
|
||||
});
|
||||
+2
-2
@@ -209,7 +209,7 @@ function renderInvitePoster(options: InvitePosterOptions): HTMLCanvasElement {
|
||||
context.fillRect(0, 0, canvas.width, canvas.height);
|
||||
context.fillStyle = teal;
|
||||
context.fillRect(0, 0, canvas.width, 640);
|
||||
context.fillStyle = "#CCFBF1";
|
||||
context.fillStyle = "#6eb0a5";
|
||||
context.beginPath();
|
||||
context.arc(1140, 40, 220, 0, Math.PI * 2);
|
||||
context.fill();
|
||||
@@ -250,7 +250,7 @@ function renderInvitePoster(options: InvitePosterOptions): HTMLCanvasElement {
|
||||
context.fillText("客户档案 | 事件登记 | 积分激励 | 门店协同 | AI 分析", 600, 1645);
|
||||
context.fillStyle = "#94A3B8";
|
||||
context.font = "400 40px Microsoft YaHei, sans-serif";
|
||||
context.fillText("本邀请仅限本人使用,请勿转发", 600, 1760);
|
||||
context.fillText("本邀请码为一次性使用", 600, 1760);
|
||||
|
||||
return canvas;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user