From e48e650f1e76dec137920a014d0ff6245006f93e Mon Sep 17 00:00:00 2001 From: Wang Guan Date: Wed, 6 Nov 2024 02:37:40 +0900 Subject: [PATCH 01/10] revise ui labels --- src/components/ProjectEditForm.tsx | 2 +- src/components/TeamSettingBase.tsx | 1 + src/locales/en.json | 4 ++-- src/locales/messages.yaml | 4 ++-- src/pages/ProjectSetting.tsx | 1 - 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/ProjectEditForm.tsx b/src/components/ProjectEditForm.tsx index 74cb66b..b7e0ba5 100644 --- a/src/components/ProjectEditForm.tsx +++ b/src/components/ProjectEditForm.tsx @@ -107,7 +107,7 @@ export const ProjectEditForm: FC = ({ className }) => {
{currentProject.targetCount} - 前往设置 + {formatMessage({id: 'project.targetLanguages'})}
= ({ className }) => { {permissionsVisible && (
+ {/* FIXME: this should be presented in a table */} {currentTeam.role.permissions.map((x) => { return ( Date: Wed, 6 Nov 2024 02:54:38 +0900 Subject: [PATCH 02/10] move project/ project-set/ components --- src/components/index.ts | 8 ------- .../{ => project-set}/ProjectCreateForm.tsx | 22 +++++++++---------- .../{ => project-set}/ProjectImportForm.tsx | 19 +++++----------- .../{ => project}/ProjectEditForm.tsx | 22 ++++++++++--------- .../{ => project}/ProjectFinishedTip.tsx | 4 ++-- .../ProjectImportFromLabelplusStatus.tsx | 10 ++++----- .../{ => project}/ProjectSettingBase.tsx | 20 ++++++++--------- .../{ => project}/ProjectSettingTarget.tsx | 14 ++++++------ .../{ => project}/ProjectTargetList.tsx | 12 +++++----- src/pages/Project.tsx | 8 +++---- src/pages/ProjectFiles.tsx | 22 ++++++++----------- src/pages/ProjectPreview.tsx | 16 +++++++------- src/pages/ProjectSet.tsx | 16 +++++++------- src/pages/ProjectSetting.tsx | 18 +++++++-------- 14 files changed, 97 insertions(+), 114 deletions(-) rename src/components/{ => project-set}/ProjectCreateForm.tsx (95%) rename src/components/{ => project-set}/ProjectImportForm.tsx (93%) rename src/components/{ => project}/ProjectEditForm.tsx (91%) rename src/components/{ => project}/ProjectFinishedTip.tsx (85%) rename src/components/{ => project}/ProjectImportFromLabelplusStatus.tsx (89%) rename src/components/{ => project}/ProjectSettingBase.tsx (96%) rename src/components/{ => project}/ProjectSettingTarget.tsx (95%) rename src/components/{ => project}/ProjectTargetList.tsx (93%) diff --git a/src/components/index.ts b/src/components/index.ts index 202c955..5f365b0 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -57,19 +57,12 @@ export { NavTab } from './NavTab'; export { NavTabs } from './NavTabs'; export { Output } from './Output'; export { OutputList } from './OutputList'; -export { ProjectCreateForm } from './ProjectCreateForm'; -export { ProjectEditForm } from './ProjectEditForm'; -export { ProjectFinishedTip } from './ProjectFinishedTip'; -export { ProjectImportFromLabelplusStatus } from './ProjectImportFromLabelplusStatus'; export { ProjectItem } from './ProjectItem'; export { ProjectList } from './ProjectList'; export { ProjectSetCreateForm } from './ProjectSetCreateForm'; export { ProjectSetEditForm } from './ProjectSetEditForm'; export { ProjectSetList } from './ProjectSetList'; export { ProjectSetSettingBase } from './ProjectSetSettingBase'; -export { ProjectSettingBase } from './ProjectSettingBase'; -export { ProjectSettingTarget } from './ProjectSettingTarget'; -export { ProjectTargetList } from './ProjectTargetList'; export { RoleRadioGroup } from './RoleRadioGroup'; export { RoleSelect } from './RoleSelect'; export { Spin } from './Spin'; @@ -90,4 +83,3 @@ export { UserEmailEditForm } from './UserEmailEditForm'; export { UserInvitationList } from './UserInvitationList'; export { UserPasswordEditForm } from './UserPasswordEditForm'; export { VCodeInput } from './VCodeInput'; -export { ProjectImportForm } from './ProjectImportForm'; diff --git a/src/components/ProjectCreateForm.tsx b/src/components/project-set/ProjectCreateForm.tsx similarity index 95% rename from src/components/ProjectCreateForm.tsx rename to src/components/project-set/ProjectCreateForm.tsx index b470589..45cac2e 100644 --- a/src/components/ProjectCreateForm.tsx +++ b/src/components/project-set/ProjectCreateForm.tsx @@ -1,6 +1,6 @@ import { css } from '@emotion/core'; import { Button, Form as AntdForm, Input, message, Modal, Upload } from 'antd'; -import React, { useState } from 'react'; +import { useState } from 'react'; import { useIntl } from 'react-intl'; import { Form, @@ -8,18 +8,18 @@ import { RoleRadioGroup, TypeRadioGroup, LanguageSelect, -} from '.'; -import api from '../apis'; -import { FC, UserProjectSet, UserTeam } from '../interfaces'; +} from '..'; +import api from '@/apis'; +import { FC, UserProjectSet, UserTeam } from '@/interfaces'; import { useDispatch, useSelector } from 'react-redux'; -import { createProject, resetProjectsState } from '../store/project/slice'; +import { createProject, resetProjectsState } from '@/store/project/slice'; import { useHistory } from 'react-router-dom'; -import { AppState } from '../store'; -import { toLowerCamelCase } from '../utils'; -import { GROUP_ALLOW_APPLY_TYPE } from '../constants'; -import { configs } from '../configs'; -import style from '../style'; -import { resetFilesState } from '../store/file/slice'; +import { AppState } from '@/store'; +import { toLowerCamelCase } from '@/utils'; +import { GROUP_ALLOW_APPLY_TYPE } from '@/constants'; +import { configs } from '@/configs'; +import style from '../../style'; +import { resetFilesState } from '@/store/file/slice'; /** 创建项目表单的属性接口 */ interface ProjectCreateFormProps { diff --git a/src/components/ProjectImportForm.tsx b/src/components/project-set/ProjectImportForm.tsx similarity index 93% rename from src/components/ProjectImportForm.tsx rename to src/components/project-set/ProjectImportForm.tsx index cd436fd..8285b7b 100644 --- a/src/components/ProjectImportForm.tsx +++ b/src/components/project-set/ProjectImportForm.tsx @@ -2,21 +2,14 @@ import { css } from '@emotion/core'; import { Button, Form as AntdForm, Input, message, Modal, Upload } from 'antd'; import React, { useState } from 'react'; import { useIntl } from 'react-intl'; -import { - Form, - FormItem, - RoleRadioGroup, - TypeRadioGroup, - LanguageSelect, -} from '.'; -import api from '../apis'; -import { FC, UserProjectSet, UserTeam } from '../interfaces'; +import api from '../../apis'; +import { FC, UserProjectSet, UserTeam } from '@/interfaces'; import { useDispatch, useSelector } from 'react-redux'; -import { createProject, resetProjectsState } from '../store/project/slice'; +import { createProject, resetProjectsState } from '@/store/project/slice'; import { useHistory } from 'react-router-dom'; -import { AppState } from '../store'; -import { toLowerCamelCase } from '../utils'; -import { resetFilesState } from '../store/file/slice'; +import { AppState } from '@/store'; +import { toLowerCamelCase } from '@/utils'; +import { resetFilesState } from '@/store/file/slice'; import * as zip from '@zip.js/zip.js'; import { RcFile } from 'antd/lib/upload'; import produce from 'immer'; diff --git a/src/components/ProjectEditForm.tsx b/src/components/project/ProjectEditForm.tsx similarity index 91% rename from src/components/ProjectEditForm.tsx rename to src/components/project/ProjectEditForm.tsx index b7e0ba5..462319d 100644 --- a/src/components/ProjectEditForm.tsx +++ b/src/components/project/ProjectEditForm.tsx @@ -1,17 +1,17 @@ import { css } from '@emotion/core'; import { Button, Form as AntdForm, Input, message } from 'antd'; -import React, { useEffect, useState } from 'react'; +import { useEffect, useState } from 'react'; import { useIntl } from 'react-intl'; import { useDispatch, useSelector } from 'react-redux'; import { NavLink } from 'react-router-dom'; -import { Form, FormItem, RoleRadioGroup, TypeRadioGroup } from '.'; -import api from '../apis'; -import { GROUP_ALLOW_APPLY_TYPE, PROJECT_PERMISSION } from '../constants'; -import { FC, Project } from '../interfaces'; -import { AppState } from '../store'; -import { editProject, setCurrentProject } from '../store/project/slice'; -import { toLowerCamelCase } from '../utils'; -import { can } from '../utils/user'; +import { Form, FormItem, RoleRadioGroup, TypeRadioGroup } from '..'; +import api from '../../apis'; +import { GROUP_ALLOW_APPLY_TYPE, PROJECT_PERMISSION } from '@/constants'; +import { FC, Project } from '@/interfaces'; +import { AppState } from '@/store'; +import { editProject, setCurrentProject } from '@/store/project/slice'; +import { toLowerCamelCase } from '@/utils'; +import { can } from '@/utils/user'; /** 修改项目表单的属性接口 */ interface ProjectEditFormProps { @@ -107,7 +107,9 @@ export const ProjectEditForm: FC = ({ className }) => {
{currentProject.targetCount} - {formatMessage({id: 'project.targetLanguages'})} + + {formatMessage({ id: 'project.targetLanguages' })} +
Date: Wed, 6 Nov 2024 03:45:55 +0900 Subject: [PATCH 03/10] fix language selector --- src/apis/language.ts | 20 ++++++++++++++++---- src/components/LanguageSelect.tsx | 8 +++----- src/locales/index.ts | 4 +++- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/apis/language.ts b/src/apis/language.ts index 9fc3b5c..1f07f8f 100644 --- a/src/apis/language.ts +++ b/src/apis/language.ts @@ -3,6 +3,8 @@ */ import { request } from '.'; import { AxiosRequestConfig } from 'axios'; +import { getIntl } from '@/locales'; +import { toLowerCamelCase } from '@/utils'; export interface APILanguage { id: string; @@ -20,14 +22,24 @@ export interface APILanguage { interface GetLanguagesData { configs?: AxiosRequestConfig; } -/** 获取系统角色 */ -const getLanguages = ({ configs = {} } = {} as GetLanguagesData) => { - return request({ + +/** Get global lang list */ +async function getLanguages({ configs = {} } = {} as GetLanguagesData) { + const res = await request({ method: 'GET', url: `/v1/languages`, ...configs, }); -}; + res.data = res.data.map((item) => toLowerCamelCase(item)); + const intl = getIntl(); + if (intl.locale === 'en') { + res.data.forEach((item) => { + // workaround server's corrupted data + item.i18nName = item.enName; + }); + } + return res; +} export default { getLanguages, diff --git a/src/components/LanguageSelect.tsx b/src/components/LanguageSelect.tsx index 62d99bd..e555258 100644 --- a/src/components/LanguageSelect.tsx +++ b/src/components/LanguageSelect.tsx @@ -3,9 +3,8 @@ import { Select } from 'antd'; import { SelectProps } from 'antd/lib/select'; import classNames from 'classnames'; import React, { useEffect, useState } from 'react'; -import apis from '../apis'; -import { FC } from '../interfaces'; -import { toLowerCamelCase } from '../utils'; +import { api } from '@/apis'; +import { FC } from '@/interfaces'; interface SelectOption { label: string; @@ -30,9 +29,8 @@ export const LanguageSelect: FC = ({ useEffect(() => { setLoading(true); - apis.getLanguages().then((result) => { + api.language.getLanguages().then((result) => { const options = result.data.map((item) => { - item = toLowerCamelCase(item); const option: SelectOption = { label: item.i18nName, value: item.code, diff --git a/src/locales/index.ts b/src/locales/index.ts index 5d5e5eb..795520b 100644 --- a/src/locales/index.ts +++ b/src/locales/index.ts @@ -7,7 +7,7 @@ import dayjs from 'dayjs'; import relativeTime from 'dayjs/plugin/relativeTime'; import utc from 'dayjs/plugin/utc'; import localizedFormat from 'dayjs/plugin/localizedFormat'; -import { setRequestLanguage } from '../apis'; +import { setRequestLanguage } from '@/apis'; dayjs.extend(localizedFormat); dayjs.extend(relativeTime); @@ -217,6 +217,8 @@ export function setLocale(l: string) { if (l in availableLocales) { localStorage.setItem(_STORAGE_KEY_LOCALE, l); location.reload(); + } else { + throw new Error(`unsupported locale: ${l}`); } } From f8662fe91dc2e04484a6762a5e3d3ee94dba87f3 Mon Sep 17 00:00:00 2001 From: Wang Guan Date: Sat, 30 Nov 2024 02:11:38 +0900 Subject: [PATCH 04/10] update translation --- src/locales/en.json | 22 +++++++++++----------- src/locales/messages.yaml | 24 ++++++++++++------------ 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/locales/en.json b/src/locales/en.json index 12cca8f..87032c1 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -96,7 +96,7 @@ "team.alreadyJoinedTipTitle": "You are already in the team", "team.alreadyJoinedTip": "You have already joined the team", "site.allowApplyTypeLabel": "Who can request to join", - "site.applicationCheckTypeLabel": "How to Handle Join Requests", + "site.applicationCheckTypeLabel": "How to handle join Requests", "site.defaultRoleLabel": "Default Role After Joining", "site.baseSetting": "Basic settings", "site.memberSetting": "Members", @@ -117,10 +117,10 @@ "site.deny": "Reject", "team.leave": "Leave Team", "team.leaveConfirm": "Are you sure you want to leave the team?", - "site.applicationSetting": "Application Management", - "site.invitationSetting": "Invite Management", + "site.applicationSetting": "Applications", + "site.invitationSetting": "Invitations", "invitation.emptySearchTip": "No users with names containing \"{word}\". Please try a different search term.", - "invitation.emptyTip": "No ongoing invitations, invite users now!", + "invitation.emptyTip": "No pending invitations. Try inviting someone!", "invitation.inviteUser": "Invite User", "invitation.inviteTip": "Please enter a username to search for users.", "invitation.inviteAsRole": "Invite as \"{role}\"", @@ -131,9 +131,9 @@ "invitation.allow": "Agree", "invitation.allowed": "Agreed", "application.operator": "Operator:", - "application.emptyTip": "No users have requested to join yet.", + "application.emptyTip": "No pending join requests yet.", "application.denied": "Rejected", - "application.allowed": "Allowed", + "application.allowed": "Approved", "application.emptyMessage": "No memo", "me.invitation.emptyTip": "No invitations received yet.", "me.invitation.new": "New Invitation", @@ -165,7 +165,7 @@ "project.finishTipTitle": "Are you sure you want to mark this project as complete?", "project.finish": "Mark Project as complete", "project.name": "Project Name", - "project.intro": "Project Introduction", + "project.intro": "Project Description", "site.createProject": "Create Project", "site.importProject": "Import Project", "project.startImport": "Start Import", @@ -269,14 +269,14 @@ "hotKeyRecorder.tip": "Press the button", "hotKeyRecorder.null": "None", "hotKeyRecorder.unbind": "Delete", - "hotKey.function": "Feature", + "hotKey.function": "Operation", "hotKey.mainHotKey": "Primary Shortcut Key", "hotKey.subHotKey": "Secondary Shortcut Key", "hotKey.focusNextSource": "Next Tab", "hotKey.focusPrevSource": "Previous Tab", "hotKey.goPrevPage": "Previous Page", "hotKey.goNextPage": "Next Page", - "mouse.function": "Feature", + "mouse.function": "Operation", "mouse.key": "Mouse Button", "mouse.addInLabel": "New Inline Label", "mouse.addOutLabel": "Create Out-of-Box Label", @@ -323,7 +323,7 @@ "site.selectPageInverse": "Deselect This Page", "site.selectCancel": "Deselect", "site.selectFile": "Select File", - "imageTranslator.translatorMode": "Translation Mode", + "imageTranslator.translatorMode": "Translations", "imageTranslator.godMode": "All-in-One Mode", "debounceStatus.debouncing": "Typing...", "debounceStatus.saving": "Saving...", @@ -348,7 +348,7 @@ "site.projectName": "Project Name", "site.member": "Member", "team.userInsight": "Member Statistics", - "imageTranslator.proofreaderMode": "Proofreading Mode", + "imageTranslator.proofreaderMode": "Proofreading", "imageTranslator.copyTranslationContent": "Copy Translated Content", "imageTranslator.checkAllTranslation": "Confirm all of the above translations", "imageTranslator.checkAllTranslationTip": "Multiple translations prioritize the first one", diff --git a/src/locales/messages.yaml b/src/locales/messages.yaml index 963a958..4a0e405 100644 --- a/src/locales/messages.yaml +++ b/src/locales/messages.yaml @@ -298,7 +298,7 @@ site.allowApplyTypeLabel: en: Who can request to join site.applicationCheckTypeLabel: zhCn: 如何处理加入申请 - en: How to Handle Join Requests + en: How to handle join Requests site.defaultRoleLabel: zhCn: 加入后默认角色 en: Default Role After Joining @@ -361,16 +361,16 @@ team.leaveConfirm: en: Are you sure you want to leave the team? site.applicationSetting: zhCn: 申请管理 - en: Application Management + en: Applications site.invitationSetting: zhCn: 邀请管理 - en: Invite Management + en: Invitations invitation.emptySearchTip: zhCn: 没有名称含有 “{word}” 的用户,请换个搜索词试试。 en: No users with names containing "{word}". Please try a different search term. invitation.emptyTip: zhCn: 还没有进行中的邀请,快去邀请用户吧! - en: No ongoing invitations, invite users now! + en: No pending invitations. Try inviting someone! invitation.inviteUser: zhCn: 邀请用户 en: Invite User @@ -403,13 +403,13 @@ application.operator: en: 'Operator:' application.emptyTip: zhCn: 还没有用户申请加入。 - en: No users have requested to join yet. + en: No pending join requests yet. application.denied: zhCn: 已拒绝 en: Rejected application.allowed: zhCn: 已允许 - en: Allowed + en: Approved application.emptyMessage: zhCn: 未附言 en: No memo @@ -505,7 +505,7 @@ project.name: en: Project Name project.intro: zhCn: 项目介绍 - en: Project Introduction + en: Project Description site.createProject: zhCn: 创建项目 en: Create Project @@ -647,7 +647,7 @@ project.changeTarget: en: Switch Target Language project.onlyOneTargetTip: zhCn: 仅有一个目标语言 - en: "Only one target language" + en: Only one target language imageTranslator.translationPlaceholder: zhCn: 请输入翻译 en: Please enter translation @@ -826,7 +826,7 @@ hotKeyRecorder.unbind: en: Delete hotKey.function: zhCn: 功能 - en: Feature + en: Operation hotKey.mainHotKey: zhCn: 主快捷键 en: Primary Shortcut Key @@ -847,7 +847,7 @@ hotKey.goNextPage: en: Next Page mouse.function: zhCn: 功能 - en: Feature + en: Operation mouse.key: zhCn: 鼠标按键 en: Mouse Button @@ -988,7 +988,7 @@ site.selectFile: en: Select File imageTranslator.translatorMode: zhCn: 翻译模式 - en: Translation Mode + en: Translations imageTranslator.godMode: zhCn: 全能模式 en: All-in-One Mode @@ -1063,7 +1063,7 @@ team.userInsight: en: Member Statistics imageTranslator.proofreaderMode: zhCn: 校对模式 - en: Proofreading Mode + en: Proofreading imageTranslator.copyTranslationContent: zhCn: 复制翻译内容 en: Copy Translated Content From 67145ea09e780833ddb775f326a598e2b835f91b Mon Sep 17 00:00:00 2001 From: Wang Guan Date: Sat, 30 Nov 2024 02:22:49 +0900 Subject: [PATCH 05/10] move ImageViewer and subcomponents --- src/components/FileItem.tsx | 6 +++--- src/components/ImageSourceViewer.tsx | 6 +++--- src/components/index.ts | 9 +-------- .../{ => project-file}/ImageViewer.tsx | 20 +++++++++---------- .../ImageViewerLabelTextExample.tsx | 2 +- .../ImageViewerPagingPanel.tsx | 12 +++++------ .../ImageViewerSettingPanel.tsx | 9 ++++----- .../ImageViewerZoomPanel.tsx | 11 +++++----- .../MovableAreaColorBackground.tsx | 2 +- .../MovableAreaImageBackground.tsx | 2 +- .../{ => project-file}/MovableItemBars.tsx | 4 ++-- .../{ => project-file}/MovableLabel.tsx | 16 +++++++-------- src/interfaces/source.ts | 2 +- 13 files changed, 45 insertions(+), 56 deletions(-) rename src/components/{ => project-file}/ImageViewer.tsx (97%) rename src/components/{ => project-file}/ImageViewerLabelTextExample.tsx (98%) rename src/components/{ => project-file}/ImageViewerPagingPanel.tsx (95%) rename src/components/{ => project-file}/ImageViewerSettingPanel.tsx (92%) rename src/components/{ => project-file}/ImageViewerZoomPanel.tsx (97%) rename src/components/{ => project-file}/MovableAreaColorBackground.tsx (93%) rename src/components/{ => project-file}/MovableAreaImageBackground.tsx (97%) rename src/components/{ => project-file}/MovableItemBars.tsx (89%) rename src/components/{ => project-file}/MovableLabel.tsx (89%) diff --git a/src/components/FileItem.tsx b/src/components/FileItem.tsx index cc65cbb..8719b92 100644 --- a/src/components/FileItem.tsx +++ b/src/components/FileItem.tsx @@ -13,10 +13,10 @@ import { FILE_NOT_EXIST_REASON, FILE_SAFE_STATUS, IMAGE_COVER, -} from '../constants'; -import { FC, File } from '../interfaces'; +} from '@/constants'; +import { FC, File } from '@/interfaces'; import style from '../style'; -import { cardClickEffect, clickEffect } from '../utils/style'; +import { cardClickEffect, clickEffect } from '@/utils/style'; /** 文件条目的属性接口 */ interface FileItemProps { diff --git a/src/components/ImageSourceViewer.tsx b/src/components/ImageSourceViewer.tsx index 08443e5..b0e1aaa 100644 --- a/src/components/ImageSourceViewer.tsx +++ b/src/components/ImageSourceViewer.tsx @@ -8,9 +8,9 @@ import { ImageSourceViewerTranslator, TranslationSaveFailed, } from '.'; -import { FC, File } from '../interfaces'; -import { Source as ISource } from '../interfaces/source'; -import { AppState } from '../store'; +import { FC, File } from '@/interfaces'; +import { Source as ISource } from '@/interfaces/source'; +import { AppState } from '@/store'; /** 原文列表的属性接口 */ interface ImageSourceViewerProps { diff --git a/src/components/index.ts b/src/components/index.ts index 5f365b0..eff9687 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -34,10 +34,7 @@ export { ImageSourceViewerProofreader } from './ImageSourceViewerProofreader'; export { ImageSourceViewerTranslator } from './ImageSourceViewerTranslator'; export { ImageTranslatorSettingHotKey } from './ImageTranslatorSettingHotKey'; export { ImageTranslatorSettingMouse } from './ImageTranslatorSettingMouse'; -export { ImageViewer } from './ImageViewer'; -export { ImageViewerLabelTextExample } from './ImageViewerLabelTextExample'; -export { ImageViewerSettingPanel } from './ImageViewerSettingPanel'; -export { ImageViewerZoomPanel } from './ImageViewerZoomPanel'; +export { ImageViewer } from './project-file/ImageViewer'; export { InvitationList } from './InvitationList'; export { InviteUser } from './InviteUser'; export { Label } from './Label'; @@ -49,10 +46,6 @@ export { ListSkeletonItem } from './ListSkeletonItem'; export { LoadingIcon } from './LoadingIcon'; export { MemberList } from './MemberList'; export { MovableArea, MovableItem } from './Movable'; -export { MovableAreaColorBackground } from './MovableAreaColorBackground'; -export { MovableAreaImageBackground } from './MovableAreaImageBackground'; -export { MovableItemBars } from './MovableItemBars'; -export { MovableLabel } from './MovableLabel'; export { NavTab } from './NavTab'; export { NavTabs } from './NavTabs'; export { Output } from './Output'; diff --git a/src/components/ImageViewer.tsx b/src/components/project-file/ImageViewer.tsx similarity index 97% rename from src/components/ImageViewer.tsx rename to src/components/project-file/ImageViewer.tsx index 2164258..0190d38 100644 --- a/src/components/ImageViewer.tsx +++ b/src/components/project-file/ImageViewer.tsx @@ -18,21 +18,21 @@ import { OnZoomEnd, OnZooming, OnZoomStart, -} from './Movable'; -import { SOURCE_POSITION_TYPE } from '../constants/source'; -import { FC, File, Source } from '../interfaces'; -import { AppState } from '../store'; -import { createSourceSaga, focusSource } from '../store/source/slice'; -import style from '../style'; -import { getBestTranslation } from '../utils/source'; -import { clickEffect } from '../utils/style'; +} from '@/components/Movable'; +import { SOURCE_POSITION_TYPE } from '@/constants/source'; +import { FC, File, Source } from '@/interfaces'; +import { AppState } from '@/store'; +import { createSourceSaga, focusSource } from '@/store/source/slice'; +import style from '@/style'; +import { getBestTranslation } from '@/utils/source'; +import { clickEffect } from '@/utils/style'; import { ImageViewerPagingPanel } from './ImageViewerPagingPanel'; import { ImageViewerSettingPanel } from './ImageViewerSettingPanel'; import { ImageViewerZoomPanel } from './ImageViewerZoomPanel'; import { MovableAreaColorBackground } from './MovableAreaColorBackground'; import { MovableAreaImageBackground } from './MovableAreaImageBackground'; import { MovableLabel } from './MovableLabel'; -import { Tooltip } from './Tooltip'; +import { Tooltip } from '@/components/Tooltip'; /** * 🖥浏览器识别 @@ -71,8 +71,6 @@ interface ImageViewerProps { } /** * 图片翻译标记器 - * @param width 宽 - * @param height 高 */ export const ImageViewer: FC = ({ file, diff --git a/src/components/ImageViewerLabelTextExample.tsx b/src/components/project-file/ImageViewerLabelTextExample.tsx similarity index 98% rename from src/components/ImageViewerLabelTextExample.tsx rename to src/components/project-file/ImageViewerLabelTextExample.tsx index 7ed572a..0ce2d3c 100644 --- a/src/components/ImageViewerLabelTextExample.tsx +++ b/src/components/project-file/ImageViewerLabelTextExample.tsx @@ -1,7 +1,7 @@ import { css } from '@emotion/core'; import classNames from 'classnames'; import React from 'react'; -import { Direction, FC, WritingMode } from '../interfaces'; +import { Direction, FC, WritingMode } from '@/interfaces'; /** 标记相对文本位置示例的属性接口 */ interface ImageViewerLabelTextExampleProps { diff --git a/src/components/ImageViewerPagingPanel.tsx b/src/components/project-file/ImageViewerPagingPanel.tsx similarity index 95% rename from src/components/ImageViewerPagingPanel.tsx rename to src/components/project-file/ImageViewerPagingPanel.tsx index 4651721..7f19aca 100644 --- a/src/components/ImageViewerPagingPanel.tsx +++ b/src/components/project-file/ImageViewerPagingPanel.tsx @@ -1,14 +1,14 @@ import { css } from '@emotion/core'; -import { Icon, ImageSelect, useHotKey } from '.'; +import { Icon, ImageSelect, useHotKey } from '@/components'; import React from 'react'; import { useIntl } from 'react-intl'; import { useHistory } from 'react-router-dom'; -import { Tooltip } from '../components'; -import { FC } from '../interfaces'; -import style from '../style'; +import { Tooltip } from '@/components'; +import { FC } from '@/interfaces'; +import style from '@/style'; import classNames from 'classnames'; -import { clearClickEffect, clickEffect } from '../utils/style'; -import { AppState } from '../store'; +import { clearClickEffect, clickEffect } from '@/utils/style'; +import { AppState } from '@/store'; import { useSelector } from 'react-redux'; /** 图片浏览器设置面板的属性接口 */ diff --git a/src/components/ImageViewerSettingPanel.tsx b/src/components/project-file/ImageViewerSettingPanel.tsx similarity index 92% rename from src/components/ImageViewerSettingPanel.tsx rename to src/components/project-file/ImageViewerSettingPanel.tsx index 0f9f510..c9b231d 100644 --- a/src/components/ImageViewerSettingPanel.tsx +++ b/src/components/project-file/ImageViewerSettingPanel.tsx @@ -2,11 +2,10 @@ import { css } from '@emotion/core'; import classNames from 'classnames'; import React from 'react'; import { useIntl } from 'react-intl'; -import { Icon } from '.'; -import { Tooltip } from '../components'; -import { FC } from '../interfaces'; -import style from '../style'; -import { clickEffect } from '../utils/style'; +import { Icon, Tooltip } from '@/components'; +import { FC } from '@/interfaces'; +import style from '@/style'; +import { clickEffect } from '@/utils/style'; /** 图片浏览器设置面板的属性接口 */ interface ImageViewerSettingPanelProps { diff --git a/src/components/ImageViewerZoomPanel.tsx b/src/components/project-file/ImageViewerZoomPanel.tsx similarity index 97% rename from src/components/ImageViewerZoomPanel.tsx rename to src/components/project-file/ImageViewerZoomPanel.tsx index e127926..8c6a649 100644 --- a/src/components/ImageViewerZoomPanel.tsx +++ b/src/components/project-file/ImageViewerZoomPanel.tsx @@ -1,16 +1,15 @@ import { css } from '@emotion/core'; -import { Icon } from './icon'; +import { Icon, Tooltip } from '@/components'; import { Slider } from 'antd'; import { debounce } from 'lodash-es'; import React from 'react'; import { useIntl } from 'react-intl'; import { useSelector } from 'react-redux'; -import { Tooltip } from './Tooltip'; -import { AppState } from '../store'; -import style from '../style'; -import { FC } from '../interfaces'; +import { AppState } from '@/store'; +import style from '@/style'; +import { FC } from '@/interfaces'; import { MovableItemBars } from './MovableItemBars'; -import { clickEffect } from '../utils/style'; +import { clickEffect } from '@/utils/style'; /** 图片浏览器缩放控制面板的属性接口 */ interface ImageViewerZoomPanelProps { diff --git a/src/components/MovableAreaColorBackground.tsx b/src/components/project-file/MovableAreaColorBackground.tsx similarity index 93% rename from src/components/MovableAreaColorBackground.tsx rename to src/components/project-file/MovableAreaColorBackground.tsx index dfbed73..c1dcdd7 100644 --- a/src/components/MovableAreaColorBackground.tsx +++ b/src/components/project-file/MovableAreaColorBackground.tsx @@ -1,6 +1,6 @@ import { css } from '@emotion/core'; import React from 'react'; -import { FC } from '../interfaces'; +import { FC } from '@/interfaces'; /** * 可移动区域纯色背景属性接口 diff --git a/src/components/MovableAreaImageBackground.tsx b/src/components/project-file/MovableAreaImageBackground.tsx similarity index 97% rename from src/components/MovableAreaImageBackground.tsx rename to src/components/project-file/MovableAreaImageBackground.tsx index 3d8e0c0..bc2a18b 100644 --- a/src/components/MovableAreaImageBackground.tsx +++ b/src/components/project-file/MovableAreaImageBackground.tsx @@ -1,6 +1,6 @@ import { css } from '@emotion/core'; import React, { useRef } from 'react'; -import { FC } from '../interfaces'; +import { FC } from '@/interfaces'; /** 可移动区域图片背景的属性接口 */ interface MovableAreaImageBackgroundProps { diff --git a/src/components/MovableItemBars.tsx b/src/components/project-file/MovableItemBars.tsx similarity index 89% rename from src/components/MovableItemBars.tsx rename to src/components/project-file/MovableItemBars.tsx index 663c2fa..edd78db 100644 --- a/src/components/MovableItemBars.tsx +++ b/src/components/project-file/MovableItemBars.tsx @@ -1,7 +1,7 @@ import { css } from '@emotion/core'; -import { Icon } from '.'; +import { Icon } from '@/components'; import React from 'react'; -import { FC } from '../interfaces'; +import { FC } from '@/interfaces'; /** 用于拖动元素的三条线样的把手的属性接口 */ interface MovableItemBarsProps { diff --git a/src/components/MovableLabel.tsx b/src/components/project-file/MovableLabel.tsx similarity index 89% rename from src/components/MovableLabel.tsx rename to src/components/project-file/MovableLabel.tsx index 8671b81..be41825 100644 --- a/src/components/MovableLabel.tsx +++ b/src/components/project-file/MovableLabel.tsx @@ -1,19 +1,19 @@ import React, { useContext, useMemo } from 'react'; import { useDispatch, useSelector } from 'react-redux'; -import { PROJECT_PERMISSION } from '../constants'; -import { SOURCE_POSITION_TYPE } from '../constants/source'; -import { FC, labelSavingStatuses } from '../interfaces'; -import { AppState } from '../store'; -import { deleteSourceSaga, editSourceSaga } from '../store/source/slice'; -import { can } from '../utils/user'; -import { Label, LabelProps } from './Label'; +import { PROJECT_PERMISSION } from '@/constants'; +import { SOURCE_POSITION_TYPE } from '@/constants/source'; +import { FC, labelSavingStatuses } from '@/interfaces'; +import { AppState } from '@/store'; +import { deleteSourceSaga, editSourceSaga } from '@/store/source/slice'; +import { can } from '@/utils/user'; +import { Label, LabelProps } from '@/components/Label'; import { MovableInfoContext, MovableItem, OnLongPress, OnMoveEnd, OnTap, -} from './Movable'; +} from '@/components/Movable'; /** * 标签(使用 Context,进行自动缩放/激活) diff --git a/src/interfaces/source.ts b/src/interfaces/source.ts index 17bc819..f7cf632 100644 --- a/src/interfaces/source.ts +++ b/src/interfaces/source.ts @@ -1,4 +1,4 @@ -import { APISource } from '../apis/source'; +import { APISource } from '@/apis/source'; export const labelSavingStatuses = ['creating', 'saving', 'deleting']; From 64dcc7b4b99fec8cab1396fe5cc635a0e5d5327a Mon Sep 17 00:00:00 2001 From: Wang Guan Date: Sat, 30 Nov 2024 02:52:31 +0900 Subject: [PATCH 06/10] move files --- src/components/TranslationSaveFailed.tsx | 6 +- src/components/index.ts | 11 +--- .../{ => project-file}/ImageSelect.tsx | 12 ++-- .../{ => project-file}/ImageSourceViewer.tsx | 10 ++- .../ImageSourceViewerGod/Source.tsx | 20 +++--- .../ImageSourceViewerGod/Translation.tsx | 18 +++--- .../ImageSourceViewerGod/TranslationList.tsx | 17 +++-- .../ImageSourceViewerGod/index.tsx | 6 +- .../ImageSourceViewerModeControl.tsx | 14 ++--- .../ImageSourceViewerProofreader/Source.tsx | 18 +++--- .../ImageSourceViewerProofreader/index.tsx | 28 +++------ .../ImageSourceViewerTranslator.tsx | 21 ++++--- .../ImageTranslatorSettingHotKey.tsx | 14 ++--- .../ImageTranslatorSettingMouse.tsx | 2 +- .../project-file/ImageViewerPagingPanel.tsx | 3 +- src/components/project-file/index.ts | 13 ++++ src/pages/ImageTranslator.tsx | 63 ++++++++++--------- 17 files changed, 135 insertions(+), 141 deletions(-) rename src/components/{ => project-file}/ImageSelect.tsx (96%) rename src/components/{ => project-file}/ImageSourceViewer.tsx (89%) rename src/components/{ => project-file}/ImageSourceViewerGod/Source.tsx (92%) rename src/components/{ => project-file}/ImageSourceViewerGod/Translation.tsx (97%) rename src/components/{ => project-file}/ImageSourceViewerGod/TranslationList.tsx (89%) rename src/components/{ => project-file}/ImageSourceViewerGod/index.tsx (89%) rename src/components/{ => project-file}/ImageSourceViewerModeControl.tsx (89%) rename src/components/{ => project-file}/ImageSourceViewerProofreader/Source.tsx (96%) rename src/components/{ => project-file}/ImageSourceViewerProofreader/index.tsx (97%) rename src/components/{ => project-file}/ImageSourceViewerTranslator.tsx (95%) rename src/components/{ => project-file}/ImageTranslatorSettingHotKey.tsx (94%) rename src/components/{ => project-file}/ImageTranslatorSettingMouse.tsx (98%) create mode 100644 src/components/project-file/index.ts diff --git a/src/components/TranslationSaveFailed.tsx b/src/components/TranslationSaveFailed.tsx index d4d5c91..f630b6c 100644 --- a/src/components/TranslationSaveFailed.tsx +++ b/src/components/TranslationSaveFailed.tsx @@ -1,7 +1,7 @@ import { css } from '@emotion/core'; import React, { useEffect } from 'react'; import { useIntl } from 'react-intl'; -import { FC, labelSavingStatuses, Source } from '../interfaces'; +import { FC, labelSavingStatuses, Source } from '@/interfaces'; import classNames from 'classnames'; import { Button } from 'antd'; import { @@ -11,9 +11,9 @@ import { EditProofreadSagaAction, SavingStatus, setSavingStatus, -} from '../store/source/slice'; +} from '@/store/source/slice'; import { useDispatch } from 'react-redux'; -import style from '../style'; +import style from '@/style'; /** 翻译/校对保存出错提示的属性接口 */ interface TranslationSaveFailedProps { diff --git a/src/components/index.ts b/src/components/index.ts index eff9687..c7d1c69 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -24,16 +24,8 @@ export { Form } from './Form'; export { FormItem } from './FormItem'; export { GroupJoinForm } from './GroupJoinForm'; export { Header } from './Header'; -export { HotKeyRecorder, useHotKey } from './HotKey'; +export { useHotKey } from './HotKey'; export { ImageOCRProgress } from './ImageOCRProgress'; -export { ImageSelect } from './ImageSelect'; -export { ImageSourceViewer } from './ImageSourceViewer'; -export { ImageSourceViewerGod } from './ImageSourceViewerGod'; -export { ImageSourceViewerModeControl } from './ImageSourceViewerModeControl'; -export { ImageSourceViewerProofreader } from './ImageSourceViewerProofreader'; -export { ImageSourceViewerTranslator } from './ImageSourceViewerTranslator'; -export { ImageTranslatorSettingHotKey } from './ImageTranslatorSettingHotKey'; -export { ImageTranslatorSettingMouse } from './ImageTranslatorSettingMouse'; export { ImageViewer } from './project-file/ImageViewer'; export { InvitationList } from './InvitationList'; export { InviteUser } from './InviteUser'; @@ -69,7 +61,6 @@ export { TeamSearchList } from './TeamSearchList'; export { TeamSettingBase } from './TeamSettingBase'; export { Tooltip } from './Tooltip'; export { TranslationProgress } from './TranslationProgress'; -export { TranslationSaveFailed } from './TranslationSaveFailed'; export { TranslationUser } from './TranslationUser'; export { TypeRadioGroup } from './TypeRadioGroup'; export { UserEmailEditForm } from './UserEmailEditForm'; diff --git a/src/components/ImageSelect.tsx b/src/components/project-file/ImageSelect.tsx similarity index 96% rename from src/components/ImageSelect.tsx rename to src/components/project-file/ImageSelect.tsx index 514a4b7..6af7126 100644 --- a/src/components/ImageSelect.tsx +++ b/src/components/project-file/ImageSelect.tsx @@ -5,12 +5,12 @@ import React, { useEffect, useRef, useState } from 'react'; import { useIntl } from 'react-intl'; import { useSelector } from 'react-redux'; import { useClickAway } from 'react-use'; -import apis from '../apis'; -import { FC, File } from '../interfaces'; -import { AppState } from '../store'; -import style from '../style'; -import { toLowerCamelCase } from '../utils'; -import { clickEffect } from '../utils/style'; +import apis from '@/apis'; +import { FC, File } from '@/interfaces'; +import { AppState } from '@/store'; +import style from '@/style'; +import { toLowerCamelCase } from '@/utils'; +import { clickEffect } from '@/utils/style'; /** 图片文件选择下拉框的属性接口 */ interface ImageSelectProps { diff --git a/src/components/ImageSourceViewer.tsx b/src/components/project-file/ImageSourceViewer.tsx similarity index 89% rename from src/components/ImageSourceViewer.tsx rename to src/components/project-file/ImageSourceViewer.tsx index b0e1aaa..259d48e 100644 --- a/src/components/ImageSourceViewer.tsx +++ b/src/components/project-file/ImageSourceViewer.tsx @@ -2,15 +2,13 @@ import { css } from '@emotion/core'; import classNames from 'classnames'; import React from 'react'; import { useSelector } from 'react-redux'; -import { - ImageSourceViewerGod, - ImageSourceViewerProofreader, - ImageSourceViewerTranslator, - TranslationSaveFailed, -} from '.'; import { FC, File } from '@/interfaces'; import { Source as ISource } from '@/interfaces/source'; import { AppState } from '@/store'; +import { TranslationSaveFailed } from '@/components/TranslationSaveFailed'; +import { ImageSourceViewerGod } from './ImageSourceViewerGod'; +import { ImageSourceViewerTranslator } from '@/components/project-file/ImageSourceViewerTranslator'; +import { ImageSourceViewerProofreader } from './ImageSourceViewerProofreader'; /** 原文列表的属性接口 */ interface ImageSourceViewerProps { diff --git a/src/components/ImageSourceViewerGod/Source.tsx b/src/components/project-file/ImageSourceViewerGod/Source.tsx similarity index 92% rename from src/components/ImageSourceViewerGod/Source.tsx rename to src/components/project-file/ImageSourceViewerGod/Source.tsx index f6702d3..31f3164 100644 --- a/src/components/ImageSourceViewerGod/Source.tsx +++ b/src/components/project-file/ImageSourceViewerGod/Source.tsx @@ -4,16 +4,16 @@ import classNames from 'classnames'; import React from 'react'; import { useIntl } from 'react-intl'; import { useDispatch, useSelector } from 'react-redux'; -import { Icon } from '..'; -import { PROJECT_PERMISSION } from '../../constants'; -import { SOURCE_POSITION_TYPE } from '../../constants/source'; -import { FC } from '../../interfaces'; -import { Source as ISource } from '../../interfaces/source'; -import { AppState } from '../../store'; -import { editSourceSaga, focusSource } from '../../store/source/slice'; -import style from '../../style'; -import { checkTranslationState } from '../../utils/source'; -import { can } from '../../utils/user'; +import { Icon } from '@/components'; +import { PROJECT_PERMISSION } from '@/constants'; +import { SOURCE_POSITION_TYPE } from '@/constants/source'; +import { FC } from '@/interfaces'; +import { Source as ISource } from '@/interfaces/source'; +import { AppState } from '@/store'; +import { editSourceSaga, focusSource } from '@/store/source/slice'; +import style from '@/style'; +import { checkTranslationState } from '@/utils/source'; +import { can } from '@/utils/user'; import { TranslationList } from './TranslationList'; /** 原文的属性接口 */ diff --git a/src/components/ImageSourceViewerGod/Translation.tsx b/src/components/project-file/ImageSourceViewerGod/Translation.tsx similarity index 97% rename from src/components/ImageSourceViewerGod/Translation.tsx rename to src/components/project-file/ImageSourceViewerGod/Translation.tsx index a1222fd..6e6c935 100644 --- a/src/components/ImageSourceViewerGod/Translation.tsx +++ b/src/components/project-file/ImageSourceViewerGod/Translation.tsx @@ -6,19 +6,19 @@ import { lighten } from 'polished'; import React, { useEffect, useState } from 'react'; import { useIntl } from 'react-intl'; import { useDispatch, useSelector } from 'react-redux'; -import { DebounceStatus, Icon, Tooltip, TranslationUser } from '..'; -import { PROJECT_PERMISSION } from '../../constants'; -import { FC, Source } from '../../interfaces'; -import { Translation as ITranslation } from '../../interfaces/translation'; -import { AppState } from '../../store'; +import { DebounceStatus, Icon, Tooltip, TranslationUser } from '@/components'; +import { PROJECT_PERMISSION } from '@/constants'; +import { FC, Source } from '@/interfaces'; +import { Translation as ITranslation } from '@/interfaces/translation'; +import { AppState } from '@/store'; import { editMyTranslationSaga, editProofreadSaga, selectTranslationSaga, -} from '../../store/source/slice'; -import style from '../../style'; -import { clearClickEffect, clickEffect } from '../../utils/style'; -import { can } from '../../utils/user'; +} from '@/store/source/slice'; +import style from '@/style'; +import { clearClickEffect, clickEffect } from '@/utils/style'; +import { can } from '@/utils/user'; export interface OnTextAreaChange { (event: React.ChangeEvent): void; diff --git a/src/components/ImageSourceViewerGod/TranslationList.tsx b/src/components/project-file/ImageSourceViewerGod/TranslationList.tsx similarity index 89% rename from src/components/ImageSourceViewerGod/TranslationList.tsx rename to src/components/project-file/ImageSourceViewerGod/TranslationList.tsx index 736b337..68c09c9 100644 --- a/src/components/ImageSourceViewerGod/TranslationList.tsx +++ b/src/components/project-file/ImageSourceViewerGod/TranslationList.tsx @@ -4,16 +4,13 @@ import classNames from 'classnames'; import React, { useEffect, useRef } from 'react'; import { useSelector } from 'react-redux'; import { Translation } from './Translation'; -import { PROJECT_PERMISSION } from '../../constants'; -import { FC, Source } from '../../interfaces'; -import { Translation as ITranslation } from '../../interfaces/translation'; -import { AppState } from '../../store'; -import style from '../../style'; -import { - filterValidTranslations, - isValidTranslation, -} from '../../utils/source'; -import { can } from '../../utils/user'; +import { PROJECT_PERMISSION } from '@/constants'; +import { FC, Source } from '@/interfaces'; +import { Translation as ITranslation } from '@/interfaces/translation'; +import { AppState } from '@/store'; +import style from '@/style'; +import { filterValidTranslations, isValidTranslation } from '@/utils/source'; +import { can } from '@/utils/user'; /** 翻译列表的属性接口 */ interface TranslationListProps { diff --git a/src/components/ImageSourceViewerGod/index.tsx b/src/components/project-file/ImageSourceViewerGod/index.tsx similarity index 89% rename from src/components/ImageSourceViewerGod/index.tsx rename to src/components/project-file/ImageSourceViewerGod/index.tsx index df160d3..4e8e7a7 100644 --- a/src/components/ImageSourceViewerGod/index.tsx +++ b/src/components/project-file/ImageSourceViewerGod/index.tsx @@ -1,9 +1,9 @@ import { css } from '@emotion/core'; import classNames from 'classnames'; import React from 'react'; -import { ImageSourceViewerModeControl } from '..'; -import { FC, Source as ISource } from '../../interfaces'; -import style from '../../style'; +import { ImageSourceViewerModeControl } from '../ImageSourceViewerModeControl'; +import { FC, Source as ISource } from '@/interfaces'; +import style from '@/style'; import { Source } from './Source'; /** 全能模式的属性接口 */ diff --git a/src/components/ImageSourceViewerModeControl.tsx b/src/components/project-file/ImageSourceViewerModeControl.tsx similarity index 89% rename from src/components/ImageSourceViewerModeControl.tsx rename to src/components/project-file/ImageSourceViewerModeControl.tsx index 686aaa1..f1ece6f 100644 --- a/src/components/ImageSourceViewerModeControl.tsx +++ b/src/components/project-file/ImageSourceViewerModeControl.tsx @@ -3,13 +3,13 @@ import classNames from 'classnames'; import React from 'react'; import { useIntl } from 'react-intl'; import { useDispatch, useSelector } from 'react-redux'; -import { PROJECT_PERMISSION } from '../constants'; -import { FC } from '../interfaces'; -import { AppState } from '../store'; -import { setImageTranslatorMode } from '../store/imageTranslator/slice'; -import style from '../style'; -import { clearClickEffect, clickEffect } from '../utils/style'; -import { can } from '../utils/user'; +import { PROJECT_PERMISSION } from '@/constants'; +import { FC } from '@/interfaces'; +import { AppState } from '@/store'; +import { setImageTranslatorMode } from '@/store/imageTranslator/slice'; +import style from '@/style'; +import { clearClickEffect, clickEffect } from '@/utils/style'; +import { can } from '@/utils/user'; /** 模板的属性接口 */ interface ImageSourceViewerModeControlProps { diff --git a/src/components/ImageSourceViewerProofreader/Source.tsx b/src/components/project-file/ImageSourceViewerProofreader/Source.tsx similarity index 96% rename from src/components/ImageSourceViewerProofreader/Source.tsx rename to src/components/project-file/ImageSourceViewerProofreader/Source.tsx index 3dcf1f1..69fbb49 100644 --- a/src/components/ImageSourceViewerProofreader/Source.tsx +++ b/src/components/project-file/ImageSourceViewerProofreader/Source.tsx @@ -5,15 +5,15 @@ import { clearFix, darken } from 'polished'; import React, { useEffect } from 'react'; import { useIntl } from 'react-intl'; import { useDispatch, useSelector } from 'react-redux'; -import { DebounceStatus, Icon, Tooltip } from '..'; -import { APITranslation } from '../../apis/translation'; -import { Source as ISource } from '../../interfaces'; -import { AppState } from '../../store'; -import { focusSource, selectTranslationSaga } from '../../store/source/slice'; -import { focusTranslation } from '../../store/translation/slice'; -import style from '../../style'; -import { getSortedTranslations } from '../../utils/source'; -import { clickEffect, hover } from '../../utils/style'; +import { DebounceStatus, Icon, Tooltip } from '@/components'; +import { APITranslation } from '@/apis/translation'; +import { Source as ISource } from '@/interfaces'; +import { AppState } from '@/store'; +import { focusSource, selectTranslationSaga } from '@/store/source/slice'; +import { focusTranslation } from '@/store/translation/slice'; +import style from '@/style'; +import { getSortedTranslations } from '@/utils/source'; +import { clickEffect, hover } from '@/utils/style'; /** 原文的属性接口 */ interface SourceProps { diff --git a/src/components/ImageSourceViewerProofreader/index.tsx b/src/components/project-file/ImageSourceViewerProofreader/index.tsx similarity index 97% rename from src/components/ImageSourceViewerProofreader/index.tsx rename to src/components/project-file/ImageSourceViewerProofreader/index.tsx index 74de271..cfe5d5b 100644 --- a/src/components/ImageSourceViewerProofreader/index.tsx +++ b/src/components/project-file/ImageSourceViewerProofreader/index.tsx @@ -5,29 +5,21 @@ import classNames from 'classnames'; import React, { useEffect, useRef } from 'react'; import { useIntl } from 'react-intl'; import { useDispatch, useSelector } from 'react-redux'; -import { - DebounceStatus, - ImageSourceViewerModeControl, - TranslationUser, -} from '..'; -import { APITranslation } from '../../apis/translation'; -import { - FC, - File, - InputDebounceStatus, - Source as ISource, -} from '../../interfaces'; -import { AppState } from '../../store'; +import { DebounceStatus, TranslationUser } from '@/components'; +import { APITranslation } from '@/apis/translation'; +import { FC, File, InputDebounceStatus, Source as ISource } from '@/interfaces'; +import { AppState } from '@/store'; import { batchSelectTranslationSaga, editMyTranslationSaga, editProofreadSaga, -} from '../../store/source/slice'; -import { focusTranslation } from '../../store/translation/slice'; -import style from '../../style'; -import { getBestTranslation } from '../../utils/source'; -import { hover } from '../../utils/style'; +} from '@/store/source/slice'; +import { focusTranslation } from '@/store/translation/slice'; +import style from '@/style'; +import { getBestTranslation } from '@/utils/source'; +import { hover } from '@/utils/style'; import { Source } from './Source'; +import { ImageSourceViewerModeControl } from '../ImageSourceViewerModeControl'; /** 校对模式的属性接口 */ interface ImageSourceViewerProofreaderProps { diff --git a/src/components/ImageSourceViewerTranslator.tsx b/src/components/project-file/ImageSourceViewerTranslator.tsx similarity index 95% rename from src/components/ImageSourceViewerTranslator.tsx rename to src/components/project-file/ImageSourceViewerTranslator.tsx index 9736cd3..479f1ac 100644 --- a/src/components/ImageSourceViewerTranslator.tsx +++ b/src/components/project-file/ImageSourceViewerTranslator.tsx @@ -5,16 +5,17 @@ import { darken } from 'polished'; import React, { useEffect, useRef } from 'react'; import { useIntl } from 'react-intl'; import { useDispatch, useSelector } from 'react-redux'; -import { DebounceStatus, Icon, ImageSourceViewerModeControl, Tooltip } from '.'; -import { APITranslation } from '../apis/translation'; -import { PROJECT_PERMISSION } from '../constants'; -import { FC, Source as ISource } from '../interfaces'; -import { AppState } from '../store'; -import { editMyTranslationSaga, focusSource } from '../store/source/slice'; -import style from '../style'; -import { getBestTranslation } from '../utils/source'; -import { clickEffect, hover } from '../utils/style'; -import { can } from '../utils/user'; +import { DebounceStatus, Icon, Tooltip } from '@/components'; +import { APITranslation } from '@/apis/translation'; +import { PROJECT_PERMISSION } from '@/constants'; +import { FC, Source as ISource } from '@/interfaces'; +import { AppState } from '@/store'; +import { editMyTranslationSaga, focusSource } from '@/store/source/slice'; +import style from '@/style'; +import { getBestTranslation } from '@/utils/source'; +import { clickEffect, hover } from '@/utils/style'; +import { can } from '@/utils/user'; +import { ImageSourceViewerModeControl } from './ImageSourceViewerModeControl'; /** 翻译模式的属性接口 */ interface ImageSourceViewerTranslatorProps { diff --git a/src/components/ImageTranslatorSettingHotKey.tsx b/src/components/project-file/ImageTranslatorSettingHotKey.tsx similarity index 94% rename from src/components/ImageTranslatorSettingHotKey.tsx rename to src/components/project-file/ImageTranslatorSettingHotKey.tsx index 34605b4..0a7cedc 100644 --- a/src/components/ImageTranslatorSettingHotKey.tsx +++ b/src/components/project-file/ImageTranslatorSettingHotKey.tsx @@ -3,17 +3,17 @@ import classNames from 'classnames'; import React from 'react'; import { useIntl } from 'react-intl'; import { useDispatch, useSelector } from 'react-redux'; -import { FC } from '../interfaces'; -import { AppState } from '../store'; -import { HotKeyState, setHotKey } from '../store/hotKey/slice'; -import { saveHotKey } from '../utils/storage'; -import { HotKeyRecorder } from './HotKey'; +import { FC } from '@/interfaces'; +import { AppState } from '@/store'; +import { HotKeyState, setHotKey } from '@/store/hotKey/slice'; +import { saveHotKey } from '@/utils/storage'; +import { HotKeyRecorder } from '@/components/HotKey'; import { ARROW_KEY_EVENT_CODES, MAIN_KEY_EVENT_CODES, SPACE_KEY_EVENT_CODES, -} from './HotKey/constants'; -import { HotKeyEvent } from './HotKey/interfaces'; +} from '@/components/HotKey/constants'; +import { HotKeyEvent } from '@/components/HotKey/interfaces'; /** 快捷键设置的属性接口 */ interface ImageTranslatorSettingHotKeyProps { diff --git a/src/components/ImageTranslatorSettingMouse.tsx b/src/components/project-file/ImageTranslatorSettingMouse.tsx similarity index 98% rename from src/components/ImageTranslatorSettingMouse.tsx rename to src/components/project-file/ImageTranslatorSettingMouse.tsx index cda8a7e..55b523e 100644 --- a/src/components/ImageTranslatorSettingMouse.tsx +++ b/src/components/project-file/ImageTranslatorSettingMouse.tsx @@ -1,7 +1,7 @@ import { css } from '@emotion/core'; import React from 'react'; import { useIntl } from 'react-intl'; -import { FC } from '../interfaces'; +import { FC } from '@/interfaces'; import classNames from 'classnames'; /** 模板的属性接口 */ diff --git a/src/components/project-file/ImageViewerPagingPanel.tsx b/src/components/project-file/ImageViewerPagingPanel.tsx index 7f19aca..f6858f4 100644 --- a/src/components/project-file/ImageViewerPagingPanel.tsx +++ b/src/components/project-file/ImageViewerPagingPanel.tsx @@ -1,5 +1,5 @@ import { css } from '@emotion/core'; -import { Icon, ImageSelect, useHotKey } from '@/components'; +import { Icon, useHotKey } from '@/components'; import React from 'react'; import { useIntl } from 'react-intl'; import { useHistory } from 'react-router-dom'; @@ -10,6 +10,7 @@ import classNames from 'classnames'; import { clearClickEffect, clickEffect } from '@/utils/style'; import { AppState } from '@/store'; import { useSelector } from 'react-redux'; +import { ImageSelect } from './ImageSelect'; /** 图片浏览器设置面板的属性接口 */ interface ImageViewerPagingPanelProps { diff --git a/src/components/project-file/index.ts b/src/components/project-file/index.ts new file mode 100644 index 0000000..653d371 --- /dev/null +++ b/src/components/project-file/index.ts @@ -0,0 +1,13 @@ +import { lazy } from 'react'; + +export const ImageViewer = lazy(() => + import('./ImageViewer').then((module) => ({ default: module.ImageViewer })), +); + +export const ImageSourceViewer = lazy(() => + import('./ImageSourceViewer').then((module) => ({ + default: module.ImageSourceViewer, + })), +); +export { ImageTranslatorSettingMouse } from './ImageTranslatorSettingMouse'; +export { ImageTranslatorSettingHotKey } from './ImageTranslatorSettingHotKey'; diff --git a/src/pages/ImageTranslator.tsx b/src/pages/ImageTranslator.tsx index 3d41c71..8a6f36a 100644 --- a/src/pages/ImageTranslator.tsx +++ b/src/pages/ImageTranslator.tsx @@ -1,25 +1,22 @@ import { css, Global } from '@emotion/core'; import { Modal } from 'antd'; -import React, { useEffect, useState } from 'react'; +import React, { useEffect, useState, Suspense } from 'react'; import { useIntl } from 'react-intl'; import { useDispatch, useSelector } from 'react-redux'; import { useParams } from 'react-router-dom'; import api from '../apis'; -import { - ImageTranslatorSettingHotKey, - ImageTranslatorSettingMouse, - ImageViewer, - ImageSourceViewer, - useHotKey, -} from '../components'; -import { FC, File } from '../interfaces'; -import { AppState } from '../store'; -import { setCurrentProjectSaga } from '../store/project/slice'; -import { fetchSourcesSaga, focusSource } from '../store/source/slice'; +import { useHotKey } from '@/components'; +import { ImageViewer, ImageSourceViewer } from '@/components/project-file'; +import { FC, File } from '@/interfaces'; +import { AppState } from '@/store'; +import { setCurrentProjectSaga } from '@/store/project/slice'; +import { fetchSourcesSaga, focusSource } from '@/store/source/slice'; import style from '../style'; -import { toLowerCamelCase } from '../utils'; -import { getCancelToken } from '../utils/api'; -import { useTitle } from '../hooks'; +import { toLowerCamelCase } from '@/utils'; +import { getCancelToken } from '@/utils/api'; +import { useTitle } from '@/hooks'; +import { ImageTranslatorSettingMouse } from '@/components/project-file/ImageTranslatorSettingMouse'; +import { ImageTranslatorSettingHotKey } from '@/components/project-file/ImageTranslatorSettingHotKey'; /** * 全屏显示的图片翻译器 @@ -284,26 +281,30 @@ const ImageTranslator: FC = () => { `} /> {file && ( - + { + setSettingModalVisible(true); + }} + /> + + )} + + { - setSettingModalVisible(true); - }} /> - )} - + Date: Sat, 30 Nov 2024 03:00:00 +0900 Subject: [PATCH 07/10] move files --- src/components/index.ts | 1 - .../project-file/ImageSourceViewerGod/Translation.tsx | 3 ++- .../project-file/ImageSourceViewerProofreader/index.tsx | 3 ++- src/components/{ => project-file}/TranslationUser.tsx | 6 +++--- 4 files changed, 7 insertions(+), 6 deletions(-) rename src/components/{ => project-file}/TranslationUser.tsx (93%) diff --git a/src/components/index.ts b/src/components/index.ts index c7d1c69..ebaa062 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -61,7 +61,6 @@ export { TeamSearchList } from './TeamSearchList'; export { TeamSettingBase } from './TeamSettingBase'; export { Tooltip } from './Tooltip'; export { TranslationProgress } from './TranslationProgress'; -export { TranslationUser } from './TranslationUser'; export { TypeRadioGroup } from './TypeRadioGroup'; export { UserEmailEditForm } from './UserEmailEditForm'; export { UserInvitationList } from './UserInvitationList'; diff --git a/src/components/project-file/ImageSourceViewerGod/Translation.tsx b/src/components/project-file/ImageSourceViewerGod/Translation.tsx index 6e6c935..fece963 100644 --- a/src/components/project-file/ImageSourceViewerGod/Translation.tsx +++ b/src/components/project-file/ImageSourceViewerGod/Translation.tsx @@ -6,7 +6,7 @@ import { lighten } from 'polished'; import React, { useEffect, useState } from 'react'; import { useIntl } from 'react-intl'; import { useDispatch, useSelector } from 'react-redux'; -import { DebounceStatus, Icon, Tooltip, TranslationUser } from '@/components'; +import { DebounceStatus, Icon, Tooltip } from '@/components'; import { PROJECT_PERMISSION } from '@/constants'; import { FC, Source } from '@/interfaces'; import { Translation as ITranslation } from '@/interfaces/translation'; @@ -19,6 +19,7 @@ import { import style from '@/style'; import { clearClickEffect, clickEffect } from '@/utils/style'; import { can } from '@/utils/user'; +import { TranslationUser } from '../TranslationUser'; export interface OnTextAreaChange { (event: React.ChangeEvent): void; diff --git a/src/components/project-file/ImageSourceViewerProofreader/index.tsx b/src/components/project-file/ImageSourceViewerProofreader/index.tsx index cfe5d5b..08ab1b7 100644 --- a/src/components/project-file/ImageSourceViewerProofreader/index.tsx +++ b/src/components/project-file/ImageSourceViewerProofreader/index.tsx @@ -5,7 +5,8 @@ import classNames from 'classnames'; import React, { useEffect, useRef } from 'react'; import { useIntl } from 'react-intl'; import { useDispatch, useSelector } from 'react-redux'; -import { DebounceStatus, TranslationUser } from '@/components'; +import { DebounceStatus } from '@/components'; +import { TranslationUser } from '../TranslationUser'; import { APITranslation } from '@/apis/translation'; import { FC, File, InputDebounceStatus, Source as ISource } from '@/interfaces'; import { AppState } from '@/store'; diff --git a/src/components/TranslationUser.tsx b/src/components/project-file/TranslationUser.tsx similarity index 93% rename from src/components/TranslationUser.tsx rename to src/components/project-file/TranslationUser.tsx index 4e99b0b..de25630 100644 --- a/src/components/TranslationUser.tsx +++ b/src/components/project-file/TranslationUser.tsx @@ -1,9 +1,9 @@ import { css } from '@emotion/core'; import classNames from 'classnames'; import React from 'react'; -import { Avatar, Icon, Tooltip } from '.'; -import { FC } from '../interfaces'; -import style from '../style'; +import { Avatar, Icon, Tooltip } from '@/components'; +import { FC } from '@/interfaces'; +import style from '@/style'; /** 翻译用户显示的属性接口 */ interface TranslationUserProps { From 6ab7ff1d11625acbe076150aaa13b6f90a7cb9cf Mon Sep 17 00:00:00 2001 From: Wang Guan Date: Sat, 30 Nov 2024 03:43:15 +0900 Subject: [PATCH 08/10] tune chunks --- .../MitPreprocess/TranslateCompanion.tsx | 11 ++---- src/components/index.ts | 1 - vite.config.mts | 34 ++++++++++++++++--- 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/src/components/MitPreprocess/TranslateCompanion.tsx b/src/components/MitPreprocess/TranslateCompanion.tsx index 9c4651a..919bd47 100644 --- a/src/components/MitPreprocess/TranslateCompanion.tsx +++ b/src/components/MitPreprocess/TranslateCompanion.tsx @@ -1,18 +1,13 @@ -import { FC } from '../../interfaces'; +import { FC } from '@/interfaces'; import { RefObject, useRef, useState } from 'react'; import { FilePond } from 'react-filepond'; import { css } from '@emotion/core'; import { Button } from '../Button'; import { createMoeflowProjectZip, LPFile } from './moeflow-packager'; -import { FailureResults } from '../../apis'; +import { FailureResults } from '@/apis'; import { measureImgSize } from '@jokester/ts-commonutil/lib/frontend/measure-img'; import { clamp } from 'lodash-es'; -import { - BBox, - CoordPair, - mitPreprocess, - TextQuad, -} from '../../apis/mit_preprocess'; +import { BBox, mitPreprocess, TextQuad } from '@/apis/mit_preprocess'; import { ResourcePool } from '@jokester/ts-commonutil/lib/concurrency/resource-pool'; const MAX_FILE_COUNT = 30; diff --git a/src/components/index.ts b/src/components/index.ts index ebaa062..bff7626 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -26,7 +26,6 @@ export { GroupJoinForm } from './GroupJoinForm'; export { Header } from './Header'; export { useHotKey } from './HotKey'; export { ImageOCRProgress } from './ImageOCRProgress'; -export { ImageViewer } from './project-file/ImageViewer'; export { InvitationList } from './InvitationList'; export { InviteUser } from './InviteUser'; export { Label } from './Label'; diff --git a/vite.config.mts b/vite.config.mts index 5f3dd05..b05c907 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -1,4 +1,4 @@ -import { defineConfig, ProxyOptions, splitVendorChunkPlugin } from 'vite'; +import { defineConfig, ProxyOptions } from 'vite'; import react from '@vitejs/plugin-react'; import path from 'node:path'; import { antdLessVars, antdLessVarsM } from './src/style'; @@ -45,11 +45,28 @@ export default defineConfig({ // external: ['lodash', 'lodash/default'], output: { manualChunks(id, meta) { + // console.debug('manualChunks', id, meta); if (id.includes(componentsDir)) { return 'moeflow-components'; - } else if (id.includes('antd')) { - return 'vendor-antd'; } + + for (const [key, value] of Object.entries({ + antd: 'antd', + 'antd-mobile': 'antd', + react: 'base', + 'react-dom': 'base', + 'react-router': 'base', + i18next: 'base', + })) { + if (id.includes(`node_modules/${key}/`)) { + return `vendor-${value}`; + } + } + + if (id.includes('node_modules/')) { + return `vendor-${hashModuleId(id)}`; + } + return null; }, }, @@ -91,7 +108,7 @@ export default defineConfig({ jsxImportSource: '@emotion/core', }), visualizer({}), - splitVendorChunkPlugin(), + // splitVendorChunkPlugin(), ], css: { preprocessorOptions: { @@ -114,3 +131,12 @@ export default defineConfig({ }, }, }); + +function hashModuleId(id: string): string { + const palette = '01234567'; + let s = 0; + for (let i = 0; i < id.length; i++) { + s += id.charCodeAt(i); + } + return palette[s % palette.length]; +} From 07320272c7523c873f7469e18348bf9c6e2ed23f Mon Sep 17 00:00:00 2001 From: Wang Guan Date: Sat, 30 Nov 2024 03:45:16 +0900 Subject: [PATCH 09/10] move file --- src/components/project-file/ImageSourceViewer.tsx | 4 ++-- src/components/{ => project-file}/TranslationSaveFailed.tsx | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename src/components/{ => project-file}/TranslationSaveFailed.tsx (100%) diff --git a/src/components/project-file/ImageSourceViewer.tsx b/src/components/project-file/ImageSourceViewer.tsx index 259d48e..4f0bc45 100644 --- a/src/components/project-file/ImageSourceViewer.tsx +++ b/src/components/project-file/ImageSourceViewer.tsx @@ -5,9 +5,9 @@ import { useSelector } from 'react-redux'; import { FC, File } from '@/interfaces'; import { Source as ISource } from '@/interfaces/source'; import { AppState } from '@/store'; -import { TranslationSaveFailed } from '@/components/TranslationSaveFailed'; +import { TranslationSaveFailed } from './TranslationSaveFailed'; import { ImageSourceViewerGod } from './ImageSourceViewerGod'; -import { ImageSourceViewerTranslator } from '@/components/project-file/ImageSourceViewerTranslator'; +import { ImageSourceViewerTranslator } from './ImageSourceViewerTranslator'; import { ImageSourceViewerProofreader } from './ImageSourceViewerProofreader'; /** 原文列表的属性接口 */ diff --git a/src/components/TranslationSaveFailed.tsx b/src/components/project-file/TranslationSaveFailed.tsx similarity index 100% rename from src/components/TranslationSaveFailed.tsx rename to src/components/project-file/TranslationSaveFailed.tsx From a54a24ad1b0f48bf0cd667a72e79c5f6a164ed7b Mon Sep 17 00:00:00 2001 From: Wang Guan Date: Sat, 30 Nov 2024 03:48:23 +0900 Subject: [PATCH 10/10] fix translation --- src/locales/en.json | 2 +- src/locales/messages.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/locales/en.json b/src/locales/en.json index 87032c1..31bde98 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -96,7 +96,7 @@ "team.alreadyJoinedTipTitle": "You are already in the team", "team.alreadyJoinedTip": "You have already joined the team", "site.allowApplyTypeLabel": "Who can request to join", - "site.applicationCheckTypeLabel": "How to handle join Requests", + "site.applicationCheckTypeLabel": "How to handle join requests", "site.defaultRoleLabel": "Default Role After Joining", "site.baseSetting": "Basic settings", "site.memberSetting": "Members", diff --git a/src/locales/messages.yaml b/src/locales/messages.yaml index 4a0e405..68b15d1 100644 --- a/src/locales/messages.yaml +++ b/src/locales/messages.yaml @@ -298,7 +298,7 @@ site.allowApplyTypeLabel: en: Who can request to join site.applicationCheckTypeLabel: zhCn: 如何处理加入申请 - en: How to handle join Requests + en: How to handle join requests site.defaultRoleLabel: zhCn: 加入后默认角色 en: Default Role After Joining