-
-
Notifications
You must be signed in to change notification settings - Fork 329
fix: 修复 IMSS 文本框中 emoji 无法正常显示的问题 #896
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,5 +1,5 @@ | ||||||||||||||||||
| import styles from './textbox.module.scss'; | ||||||||||||||||||
| import { useEffect } from 'react'; | ||||||||||||||||||
| import { useEffect, useMemo } from 'react'; | ||||||||||||||||||
| import { WebGAL } from '@/Core/WebGAL'; | ||||||||||||||||||
| import { ITextboxProps } from './types'; | ||||||||||||||||||
| import useApplyStyle from '@/hooks/useApplyStyle'; | ||||||||||||||||||
|
|
@@ -8,6 +8,11 @@ import { textSize } from '@/store/userDataInterface'; | |||||||||||||||||
| import { useSelector } from 'react-redux'; | ||||||||||||||||||
| import { RootState } from '@/store/store'; | ||||||||||||||||||
|
|
||||||||||||||||||
| const hasEmoji = (text: any): boolean => { | ||||||||||||||||||
| if (typeof text !== 'string') return false; | ||||||||||||||||||
| return /\p{Emoji}/u.test(text); | ||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The new Useful? React with 👍 / 👎. |
||||||||||||||||||
| }; | ||||||||||||||||||
|
Comment on lines
+11
to
+14
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
|
|
||||||||||||||||||
| export default function IMSSTextbox(props: ITextboxProps) { | ||||||||||||||||||
| const { | ||||||||||||||||||
| textArray, | ||||||||||||||||||
|
|
@@ -72,24 +77,18 @@ export default function IMSSTextbox(props: ITextboxProps) { | |||||||||||||||||
| } | ||||||||||||||||||
| const styleClassName = ' ' + css(style, { label: 'showname' }); | ||||||||||||||||||
| const styleAllText = ' ' + css(style_alltext, { label: 'showname' }); | ||||||||||||||||||
| if (isEnhanced) { | ||||||||||||||||||
| return ( | ||||||||||||||||||
| <span key={index} style={{ position: 'relative' }}> | ||||||||||||||||||
| const skipEffect = hasEmoji(e); | ||||||||||||||||||
| return ( | ||||||||||||||||||
| <span key={index} style={{ position: 'relative' }}> | ||||||||||||||||||
| {skipEffect ? ( | ||||||||||||||||||
| <span className={styleClassName + styleAllText}>{e}</span> | ||||||||||||||||||
| ) : ( | ||||||||||||||||||
| <span className={styles.zhanwei + styleAllText}> | ||||||||||||||||||
| {e} | ||||||||||||||||||
| <span className={applyStyle('outerName', styles.outerName) + styleClassName + styleAllText}>{e}</span> | ||||||||||||||||||
| {isUseStroke && <span className={applyStyle('innerName', styles.innerName) + styleAllText}>{e}</span>} | ||||||||||||||||||
| </span> | ||||||||||||||||||
| </span> | ||||||||||||||||||
| ); | ||||||||||||||||||
| } | ||||||||||||||||||
| return ( | ||||||||||||||||||
| <span key={index} style={{ position: 'relative' }}> | ||||||||||||||||||
| <span className={styles.zhanwei + styleAllText}> | ||||||||||||||||||
| {e} | ||||||||||||||||||
| <span className={applyStyle('outerName', styles.outerName) + styleClassName + styleAllText}>{e}</span> | ||||||||||||||||||
| {isUseStroke && <span className={applyStyle('innerName', styles.innerName) + styleAllText}>{e}</span>} | ||||||||||||||||||
| </span> | ||||||||||||||||||
| )} | ||||||||||||||||||
| </span> | ||||||||||||||||||
| ); | ||||||||||||||||||
| }); | ||||||||||||||||||
|
|
@@ -140,36 +139,44 @@ export default function IMSSTextbox(props: ITextboxProps) { | |||||||||||||||||
| } | ||||||||||||||||||
| const styleClassName = ' ' + css(style); | ||||||||||||||||||
| const styleAllText = ' ' + css(style_alltext); | ||||||||||||||||||
| const skipEffect = hasEmoji(e); | ||||||||||||||||||
|
|
||||||||||||||||||
| if (allTextIndex < prevLength) { | ||||||||||||||||||
| return ( | ||||||||||||||||||
| <span | ||||||||||||||||||
| // data-text={e} | ||||||||||||||||||
| id={`${delay}`} | ||||||||||||||||||
| className={applyStyle('TextBox_textElement_Settled', styles.TextBox_textElement_Settled)} | ||||||||||||||||||
| key={currentDialogKey + index} | ||||||||||||||||||
| style={{ animationDelay: `${delay}ms`, animationDuration: `${textDuration}ms` }} | ||||||||||||||||||
| > | ||||||||||||||||||
| <span className={styles.zhanwei + styleAllText}> | ||||||||||||||||||
| {e} | ||||||||||||||||||
| <span className={applyStyle('outer', styles.outer) + styleClassName + styleAllText}>{e}</span> | ||||||||||||||||||
| {isUseStroke && <span className={applyStyle('inner', styles.inner) + styleAllText}>{e}</span>} | ||||||||||||||||||
| </span> | ||||||||||||||||||
| {skipEffect ? ( | ||||||||||||||||||
| <span className={styleClassName + styleAllText}>{e}</span> | ||||||||||||||||||
| ) : ( | ||||||||||||||||||
| <span className={styles.zhanwei + styleAllText}> | ||||||||||||||||||
| {e} | ||||||||||||||||||
| <span className={applyStyle('outer', styles.outer) + styleClassName + styleAllText}>{e}</span> | ||||||||||||||||||
| {isUseStroke && <span className={applyStyle('inner', styles.inner) + styleAllText}>{e}</span>} | ||||||||||||||||||
| </span> | ||||||||||||||||||
| )} | ||||||||||||||||||
| </span> | ||||||||||||||||||
| ); | ||||||||||||||||||
| } | ||||||||||||||||||
| return ( | ||||||||||||||||||
| <span | ||||||||||||||||||
| // data-text={e} | ||||||||||||||||||
| id={`${delay}`} | ||||||||||||||||||
| className={`${applyStyle('TextBox_textElement_start', styles.TextBox_textElement_start)} Textelement_start`} | ||||||||||||||||||
| key={currentDialogKey + index} | ||||||||||||||||||
| style={{ animationDelay: `${delay}ms`, position: 'relative' }} | ||||||||||||||||||
| > | ||||||||||||||||||
| <span className={styles.zhanwei + styleAllText}> | ||||||||||||||||||
| {e} | ||||||||||||||||||
| <span className={applyStyle('outer', styles.outer) + styleClassName + styleAllText}>{e}</span> | ||||||||||||||||||
| {isUseStroke && <span className={applyStyle('inner', styles.inner) + styleAllText}>{e}</span>} | ||||||||||||||||||
| </span> | ||||||||||||||||||
| {skipEffect ? ( | ||||||||||||||||||
| <span className={styleClassName + styleAllText}>{e}</span> | ||||||||||||||||||
| ) : ( | ||||||||||||||||||
| <span className={styles.zhanwei + styleAllText}> | ||||||||||||||||||
| {e} | ||||||||||||||||||
| <span className={applyStyle('outer', styles.outer) + styleClassName + styleAllText}>{e}</span> | ||||||||||||||||||
| {isUseStroke && <span className={applyStyle('inner', styles.inner) + styleAllText}>{e}</span>} | ||||||||||||||||||
| </span> | ||||||||||||||||||
| )} | ||||||||||||||||||
| </span> | ||||||||||||||||||
| ); | ||||||||||||||||||
|
Comment on lines
144
to
181
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 在 |
||||||||||||||||||
| }); | ||||||||||||||||||
|
|
||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useMemo被导入了,但在这个文件中并未使用。为了保持代码整洁,建议移除未使用的导入。