add getEmojiUrl as util function

This commit is contained in:
waltcow 2023-04-05 15:48:44 +08:00 committed by GitHub
parent 80904ac2bb
commit f4fc682fa3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 6 deletions

View File

@ -17,6 +17,7 @@ import { Message, SubmitKey, useChatStore, BOT_HELLO, ROLES } from "../store";
import { import {
copyToClipboard, copyToClipboard,
downloadAs, downloadAs,
getEmojiUrl,
isMobileScreen, isMobileScreen,
selectOrCopy, selectOrCopy,
} from "../utils"; } from "../utils";
@ -50,7 +51,7 @@ export function Avatar(props: { role: Message["role"] }) {
return ( return (
<div className={styles["user-avtar"]}> <div className={styles["user-avtar"]}>
<Emoji unified={config.avatar} size={18} /> <Emoji unified={config.avatar} size={18} getEmojiUrl={getEmojiUrl} />
</div> </div>
); );
} }

View File

@ -1,6 +1,6 @@
import { useState, useEffect, useMemo, HTMLProps } from "react"; import { useState, useEffect, useMemo, HTMLProps } from "react";
import EmojiPicker, { Theme as EmojiTheme, EmojiStyle } from "emoji-picker-react"; import EmojiPicker, { Theme as EmojiTheme } from "emoji-picker-react";
import styles from "./settings.module.scss"; import styles from "./settings.module.scss";
@ -26,7 +26,7 @@ import {
import { Avatar } from "./chat"; import { Avatar } from "./chat";
import Locale, { AllLangs, changeLang, getLang } from "../locales"; import Locale, { AllLangs, changeLang, getLang } from "../locales";
import { getCurrentVersion } from "../utils"; import { getCurrentVersion, getEmojiUrl } from "../utils";
import Link from "next/link"; import Link from "next/link";
import { UPDATE_URL } from "../constant"; import { UPDATE_URL } from "../constant";
import { SearchService, usePromptStore } from "../store/prompt"; import { SearchService, usePromptStore } from "../store/prompt";
@ -181,9 +181,7 @@ export function Settings(props: { closeSettings: () => void }) {
<EmojiPicker <EmojiPicker
lazyLoadEmojis lazyLoadEmojis
theme={EmojiTheme.AUTO} theme={EmojiTheme.AUTO}
getEmojiUrl={(unified: string, style: EmojiStyle) => { getEmojiUrl={getEmojiUrl}
return `https://cdn.staticfile.org/emoji-datasource-apple/14.0.0/img/${style}/64/${unified}.png`;
}}
onEmojiClick={(e) => { onEmojiClick={(e) => {
updateConfig((config) => (config.avatar = e.unified)); updateConfig((config) => (config.avatar = e.unified));
setShowEmojiPicker(false); setShowEmojiPicker(false);

View File

@ -1,3 +1,4 @@
import { EmojiStyle } from "emoji-picker-react";
import { showToast } from "./components/ui-lib"; import { showToast } from "./components/ui-lib";
import Locale from "./locales"; import Locale from "./locales";
@ -81,3 +82,7 @@ export function getCurrentVersion() {
return currentId; return currentId;
} }
export function getEmojiUrl(unified: string, style: EmojiStyle) {
return `https://cdn.staticfile.org/emoji-datasource-apple/14.0.0/img/${style}/64/${unified}.png`;
}