diff --git a/resources/assets/src/components/Alert.tsx b/resources/assets/src/components/Alert.tsx index c580b150..e05b914b 100644 --- a/resources/assets/src/components/Alert.tsx +++ b/resources/assets/src/components/Alert.tsx @@ -1,4 +1,3 @@ -import type React from 'react'; type AlertType = 'success' | 'info' | 'warning' | 'danger'; diff --git a/resources/assets/src/components/ButtonEdit.tsx b/resources/assets/src/components/ButtonEdit.tsx index fe497ae9..076134e7 100644 --- a/resources/assets/src/components/ButtonEdit.tsx +++ b/resources/assets/src/components/ButtonEdit.tsx @@ -1,4 +1,3 @@ -import type React from 'react'; type Properties = { readonly title?: string; diff --git a/resources/assets/src/components/DarkModeButton.tsx b/resources/assets/src/components/DarkModeButton.tsx index 942c4bc0..a8313b24 100644 --- a/resources/assets/src/components/DarkModeButton.tsx +++ b/resources/assets/src/components/DarkModeButton.tsx @@ -1,4 +1,4 @@ -import React, {useState} from 'react'; +import {useState} from 'react'; import * as fetch from '@/scripts/net'; type Properties = { diff --git a/resources/assets/src/components/EmailSuggestion.tsx b/resources/assets/src/components/EmailSuggestion.tsx index d6d1f1c8..72f16c89 100644 --- a/resources/assets/src/components/EmailSuggestion.tsx +++ b/resources/assets/src/components/EmailSuggestion.tsx @@ -1,5 +1,5 @@ /** @jsxImportSource @emotion/react */ -import type React from 'react'; + import {useState, useEffect} from 'react'; import Autosuggest from 'react-autosuggest'; import {css} from '@emotion/react'; diff --git a/resources/assets/src/components/Modal.tsx b/resources/assets/src/components/Modal.tsx index 36775721..4ac8427f 100644 --- a/resources/assets/src/components/Modal.tsx +++ b/resources/assets/src/components/Modal.tsx @@ -1,4 +1,4 @@ -import React, {useState, useEffect, useRef} from 'react'; +import {useState, useEffect, useRef} from 'react'; import $ from 'jquery'; import 'bootstrap'; import {t} from '../scripts/i18n'; diff --git a/resources/assets/src/components/ModalBody.tsx b/resources/assets/src/components/ModalBody.tsx index 03aff67d..18358ded 100644 --- a/resources/assets/src/components/ModalBody.tsx +++ b/resources/assets/src/components/ModalBody.tsx @@ -1,4 +1,4 @@ -import type React from 'react'; + import ModalContent, {type Props as ContentProperties} from './ModalContent'; import ModalInput, { type diff --git a/resources/assets/src/components/ModalContent.tsx b/resources/assets/src/components/ModalContent.tsx index 87cac9f8..4b0eb2e9 100644 --- a/resources/assets/src/components/ModalContent.tsx +++ b/resources/assets/src/components/ModalContent.tsx @@ -1,4 +1,3 @@ -import type React from 'react'; export type Props = { readonly text?: string; diff --git a/resources/assets/src/components/ModalFooter.tsx b/resources/assets/src/components/ModalFooter.tsx index 118266ba..a2f4d3d3 100644 --- a/resources/assets/src/components/ModalFooter.tsx +++ b/resources/assets/src/components/ModalFooter.tsx @@ -1,4 +1,3 @@ -import type React from 'react'; export type Props = { readonly flexFooter?: boolean; diff --git a/resources/assets/src/components/ModalHeader.tsx b/resources/assets/src/components/ModalHeader.tsx index 69d76618..ac4e5e0c 100644 --- a/resources/assets/src/components/ModalHeader.tsx +++ b/resources/assets/src/components/ModalHeader.tsx @@ -1,4 +1,3 @@ -import type React from 'react'; export type Props = { readonly title?: string; diff --git a/resources/assets/src/components/ModalInput.tsx b/resources/assets/src/components/ModalInput.tsx index 75483857..b5dba7dc 100644 --- a/resources/assets/src/components/ModalInput.tsx +++ b/resources/assets/src/components/ModalInput.tsx @@ -1,4 +1,3 @@ -import type React from 'react'; export type Props = { readonly inputType?: string; diff --git a/resources/assets/src/components/Pagination.tsx b/resources/assets/src/components/Pagination.tsx index 8c8bf951..eb92dc57 100644 --- a/resources/assets/src/components/Pagination.tsx +++ b/resources/assets/src/components/Pagination.tsx @@ -1,4 +1,4 @@ -import type React from 'react'; + import PaginationItem from './PaginationItem'; import {t} from '@/scripts/i18n'; diff --git a/resources/assets/src/components/PaginationItem.tsx b/resources/assets/src/components/PaginationItem.tsx index 905c26d8..6bf43253 100644 --- a/resources/assets/src/components/PaginationItem.tsx +++ b/resources/assets/src/components/PaginationItem.tsx @@ -1,4 +1,3 @@ -import type React from 'react'; type Properties = { readonly disabled?: boolean; diff --git a/resources/assets/src/components/Toast.tsx b/resources/assets/src/components/Toast.tsx index 279ce90f..f70f070f 100644 --- a/resources/assets/src/components/Toast.tsx +++ b/resources/assets/src/components/Toast.tsx @@ -1,5 +1,5 @@ /** @jsxImportSource @emotion/react */ -import type React from 'react'; + import {useState, useEffect} from 'react'; import {css} from '@emotion/react'; diff --git a/resources/assets/src/components/Viewer.tsx b/resources/assets/src/components/Viewer.tsx index cc01d19d..46cf409b 100644 --- a/resources/assets/src/components/Viewer.tsx +++ b/resources/assets/src/components/Viewer.tsx @@ -1,5 +1,5 @@ /** @jsxImportSource @emotion/react */ -import type React from 'react'; + import {useState, useEffect, useRef} from 'react'; import {useMeasure} from 'react-use'; import {css} from '@emotion/react'; diff --git a/resources/assets/src/scripts/cli.tsx b/resources/assets/src/scripts/cli.tsx index 4777a755..8151020a 100644 --- a/resources/assets/src/scripts/cli.tsx +++ b/resources/assets/src/scripts/cli.tsx @@ -1,4 +1,4 @@ -import React, {useEffect, useRef} from 'react'; +import {useEffect, useRef} from 'react'; import ReactDOM from 'react-dom'; import styled from '@emotion/styled'; import {Terminal} from 'xterm'; diff --git a/resources/assets/src/views/admin/PlayersManagement/Card.tsx b/resources/assets/src/views/admin/PlayersManagement/Card.tsx index 821142bf..ea84b05f 100644 --- a/resources/assets/src/views/admin/PlayersManagement/Card.tsx +++ b/resources/assets/src/views/admin/PlayersManagement/Card.tsx @@ -1,4 +1,4 @@ -import type React from 'react'; + import clsx from 'clsx'; import {Box} from './styles'; import {t} from '@/scripts/i18n'; diff --git a/resources/assets/src/views/admin/PlayersManagement/ModalUpdateTexture.tsx b/resources/assets/src/views/admin/PlayersManagement/ModalUpdateTexture.tsx index 2927d008..47925913 100644 --- a/resources/assets/src/views/admin/PlayersManagement/ModalUpdateTexture.tsx +++ b/resources/assets/src/views/admin/PlayersManagement/ModalUpdateTexture.tsx @@ -1,4 +1,4 @@ -import React, {useState} from 'react'; +import {useState} from 'react'; import {t} from '@/scripts/i18n'; import {TextureType} from '@/scripts/types'; import Modal from '@/components/Modal'; diff --git a/resources/assets/src/views/admin/PlayersManagement/Row.tsx b/resources/assets/src/views/admin/PlayersManagement/Row.tsx index 236ea374..6c493ffe 100644 --- a/resources/assets/src/views/admin/PlayersManagement/Row.tsx +++ b/resources/assets/src/views/admin/PlayersManagement/Row.tsx @@ -1,4 +1,4 @@ -import type React from 'react'; + import {t} from '@/scripts/i18n'; import type {Player} from '@/scripts/types'; import ButtonEdit from '@/components/ButtonEdit'; diff --git a/resources/assets/src/views/admin/PlayersManagement/index.tsx b/resources/assets/src/views/admin/PlayersManagement/index.tsx index 0f65b900..0d183e43 100644 --- a/resources/assets/src/views/admin/PlayersManagement/index.tsx +++ b/resources/assets/src/views/admin/PlayersManagement/index.tsx @@ -1,4 +1,4 @@ -import React, {useState, useEffect, useLayoutEffect} from 'react'; +import {useState, useEffect, useLayoutEffect} from 'react'; import {useImmer} from 'use-immer'; import Header from '../UsersManagement/Header'; import Card from './Card'; diff --git a/resources/assets/src/views/admin/PluginsManagement/InfoBox.tsx b/resources/assets/src/views/admin/PluginsManagement/InfoBox.tsx index 4db30d7c..ebb03d27 100644 --- a/resources/assets/src/views/admin/PluginsManagement/InfoBox.tsx +++ b/resources/assets/src/views/admin/PluginsManagement/InfoBox.tsx @@ -1,4 +1,4 @@ -import type React from 'react'; + import styled from '@emotion/styled'; import clsx from 'clsx'; import type {Plugin} from './types'; diff --git a/resources/assets/src/views/admin/PluginsManagement/index.tsx b/resources/assets/src/views/admin/PluginsManagement/index.tsx index d7381773..b480cd1b 100644 --- a/resources/assets/src/views/admin/PluginsManagement/index.tsx +++ b/resources/assets/src/views/admin/PluginsManagement/index.tsx @@ -1,4 +1,4 @@ -import React, {useState, useEffect} from 'react'; +import {useState, useEffect} from 'react'; import {useImmer} from 'use-immer'; import InfoBox from './InfoBox'; import type {Plugin} from './types'; diff --git a/resources/assets/src/views/admin/PluginsMarket/Row.tsx b/resources/assets/src/views/admin/PluginsMarket/Row.tsx index 6561f4b8..b0417003 100644 --- a/resources/assets/src/views/admin/PluginsMarket/Row.tsx +++ b/resources/assets/src/views/admin/PluginsMarket/Row.tsx @@ -1,4 +1,4 @@ -import type React from 'react'; + import type {Plugin} from './types'; import {t} from '@/scripts/i18n'; diff --git a/resources/assets/src/views/admin/ReportsManagement/ImageBox.tsx b/resources/assets/src/views/admin/ReportsManagement/ImageBox.tsx index c2b676f1..ca17a53c 100644 --- a/resources/assets/src/views/admin/ReportsManagement/ImageBox.tsx +++ b/resources/assets/src/views/admin/ReportsManagement/ImageBox.tsx @@ -1,4 +1,4 @@ -import type React from 'react'; + import styled from '@emotion/styled'; import {type Report, Status} from './types'; import {t} from '@/scripts/i18n'; diff --git a/resources/assets/src/views/admin/Translations/Row.tsx b/resources/assets/src/views/admin/Translations/Row.tsx index 0cd88f04..ab3b02d8 100644 --- a/resources/assets/src/views/admin/Translations/Row.tsx +++ b/resources/assets/src/views/admin/Translations/Row.tsx @@ -1,5 +1,4 @@ import styled from '@emotion/styled'; -import type React from 'react'; import type {Line} from './types'; import {t} from '@/scripts/i18n'; diff --git a/resources/assets/src/views/admin/UsersManagement/Card.tsx b/resources/assets/src/views/admin/UsersManagement/Card.tsx index 1de2b1b9..f80bd688 100644 --- a/resources/assets/src/views/admin/UsersManagement/Card.tsx +++ b/resources/assets/src/views/admin/UsersManagement/Card.tsx @@ -1,4 +1,4 @@ -import type React from 'react'; + import clsx from 'clsx'; import {Box, Icon, InfoTable} from './styles'; import { diff --git a/resources/assets/src/views/admin/UsersManagement/Row.tsx b/resources/assets/src/views/admin/UsersManagement/Row.tsx index 745450c8..ea09bd33 100644 --- a/resources/assets/src/views/admin/UsersManagement/Row.tsx +++ b/resources/assets/src/views/admin/UsersManagement/Row.tsx @@ -1,4 +1,4 @@ -import type React from 'react'; + import { humanizePermission, verificationStatusText, diff --git a/resources/assets/src/views/admin/UsersManagement/index.tsx b/resources/assets/src/views/admin/UsersManagement/index.tsx index 93491078..c1a91d1f 100644 --- a/resources/assets/src/views/admin/UsersManagement/index.tsx +++ b/resources/assets/src/views/admin/UsersManagement/index.tsx @@ -1,4 +1,4 @@ -import React, {useState, useEffect, useLayoutEffect} from 'react'; +import {useState, useEffect, useLayoutEffect} from 'react'; import {useImmer} from 'use-immer'; import Header from './Header'; import Card from './Card'; diff --git a/resources/assets/src/views/auth/Login.tsx b/resources/assets/src/views/auth/Login.tsx index a4e7a8d5..9a2fe2e7 100644 --- a/resources/assets/src/views/auth/Login.tsx +++ b/resources/assets/src/views/auth/Login.tsx @@ -1,4 +1,4 @@ -import React, {useState, useRef, useEffect} from 'react'; +import {useState, useRef, useEffect} from 'react'; import useBlessingExtra from '@/scripts/hooks/useBlessingExtra'; import useEmitMounted from '@/scripts/hooks/useEmitMounted'; import {t} from '@/scripts/i18n'; diff --git a/resources/assets/src/views/skinlib/Show/index.tsx b/resources/assets/src/views/skinlib/Show/index.tsx index 6acafc74..931f585f 100644 --- a/resources/assets/src/views/skinlib/Show/index.tsx +++ b/resources/assets/src/views/skinlib/Show/index.tsx @@ -23,7 +23,7 @@ export type Badge = { const Previewer = React.lazy(async () => import('@/components/Viewer')); -function Show() { +export default function Show() { const [texture, setTexture] = useState({} as Texture); const [isLoading, setIsLoading] = useState(true); const [showModalApply, setShowModalApply] = useState(false); @@ -50,14 +50,14 @@ function Show() { setIsLoading(false); }; - fetchInfo(); + void fetchInfo(); }, []); useEffect(() => { setLiked(blessing.extra.inCloset as boolean); }, []); - const handleEditName = async () => { + async function handleEditName() { let name: string; try { const {value} = await showModal({ @@ -85,9 +85,9 @@ function Show() { } else { toast.error(message); } - }; + } - const handleSwitchType = async () => { + async function handleSwitchType() { let type: TextureType; try { const {value} = await showModal({ @@ -116,34 +116,27 @@ function Show() { } else { toast.error(message); } - }; + } - const handleAddItemClick = async () => { + async function handleAddItemClick() { const ok = await addClosetItem(texture); if (ok) { setTexture(texture => ({...texture, likes: texture.likes + 1})); setLiked(true); } - }; + } - const handleRemoveItemClick = async () => { + async function handleRemoveItemClick() { const ok = await removeClosetItem(texture.tid); if (ok) { setTexture(texture => ({...texture, likes: texture.likes - 1})); setLiked(false); } - }; + } const handleSetAsAvatar = async () => setAsAvatar(texture.tid); - const handleDownloadClick = () => { - const a = document.createElement('a'); - a.href = `${blessing.base_url}/raw/${texture.tid}`; - a.download = `${texture.name}.png`; - a.click(); - }; - - const handleReport = async () => { + async function handleReport() { const prompt = (() => { if (reportScore > 0) { return t('skinlib.report.positive', {score: reportScore.toString()}); @@ -181,9 +174,9 @@ function Show() { } else { toast.error(message); } - }; + } - const handlePrivacyClick = async () => { + async function handlePrivacyClick() { try { await showModal({ text: texture.public @@ -194,35 +187,34 @@ function Show() { return; } - type Ok = {code: 0; message: string}; - type Error_ = {code: 1; message: string}; - type Duplicated = {code: 2; message: string; data: {tid: number}}; + type OkResp = {code: 0; message: string}; + type ErrorResp = {code: 1; message: string}; + type DuplicatedResp = {code: 2; message: string; data: {tid: number}}; - const resp = await fetch.put( - urls.texture.privacy(texture.tid), - ); - const {code, message} = resp; - if (code === 0) { - toast.success(message); - setTexture(texture => ({...texture, public: !texture.public})); - } else if (resp.code === 2) { - try { - await showModal({ - mode: 'confirm', - text: message, - okButtonText: t('user.viewInSkinlib'), - }); - window.location.href - = blessing.base_url + urls.skinlib.show(resp.data.tid); - } catch { - // - } - } else { - toast.error(message); - } - }; + const resp = await fetch.put( + urls.texture.privacy(texture.tid), + ); + const {code, message} = resp; + if (code === 0) { + toast.success(message); + setTexture(texture => ({...texture, public: !texture.public})); + } else if (resp.code === 2) { + try { + await showModal({ + mode: 'confirm', + text: message, + okButtonText: t('user.viewInSkinlib'), + }); + window.location.href = blessing.base_url + urls.skinlib.show(resp.data.tid); + } catch { + void 0; + } + } else { + toast.error(message); + } + } - const handleDeleteTextureClick = async () => { + async function handleDeleteTextureClick() { try { await showModal({ text: t('skinlib.deleteNotice'), @@ -243,7 +235,7 @@ function Show() { } else { toast.error(message); } - }; + } const handleOpenModalApply = () => { setShowModalApply(true); @@ -272,86 +264,94 @@ function Show() { return ( <> {container - && createPortal( - }> - - {currentUid === 0 ? ( - - ) : ( -
-
- {liked && ( - - )} - {liked ? ( - - ) : ( - - )} - {texture.type !== TextureType.Cape && ( - - )} - {canBeDownloaded && ( - - )} - -
-
- - {texture.likes} -
-
- )} -
-
, - container, - )} + && createPortal( + }> + + {currentUid === 0 ? ( + + ) : ( +
+
+ {liked && ( + + )} + {liked ? ( + + ) : ( + + )} + {texture.type !== TextureType.Cape && ( + + )} + {canBeDownloaded && ( + + {t('skinlib.show.download')} + + )} + +
+
+ + {texture.likes} +
+
+ )} +
+
, + container, + )}

{t('skinlib.show.detail')}

@@ -466,12 +466,13 @@ function Show() {
-