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/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/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/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/TeamSettingBase.tsx b/src/components/TeamSettingBase.tsx index d4284ac..146be2d 100644 --- a/src/components/TeamSettingBase.tsx +++ b/src/components/TeamSettingBase.tsx @@ -160,6 +160,7 @@ export const TeamSettingBase: FC = ({ className }) => { {permissionsVisible && (
+ {/* FIXME: this should be presented in a table */} {currentTeam.role.permissions.map((x) => { return ( ): 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 96% rename from src/components/ImageSourceViewerProofreader/index.tsx rename to src/components/project-file/ImageSourceViewerProofreader/index.tsx index 74de271..08ab1b7 100644 --- a/src/components/ImageSourceViewerProofreader/index.tsx +++ b/src/components/project-file/ImageSourceViewerProofreader/index.tsx @@ -5,29 +5,22 @@ 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 } from '@/components'; +import { TranslationUser } from '../TranslationUser'; +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/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..f6858f4 100644 --- a/src/components/ImageViewerPagingPanel.tsx +++ b/src/components/project-file/ImageViewerPagingPanel.tsx @@ -1,15 +1,16 @@ import { css } from '@emotion/core'; -import { Icon, ImageSelect, useHotKey } from '.'; +import { Icon, 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'; +import { ImageSelect } from './ImageSelect'; /** 图片浏览器设置面板的属性接口 */ interface ImageViewerPagingPanelProps { 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/components/TranslationSaveFailed.tsx b/src/components/project-file/TranslationSaveFailed.tsx similarity index 97% rename from src/components/TranslationSaveFailed.tsx rename to src/components/project-file/TranslationSaveFailed.tsx index d4d5c91..f630b6c 100644 --- a/src/components/TranslationSaveFailed.tsx +++ b/src/components/project-file/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/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 { 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/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 74cb66b..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' })} +
{ `} /> {file && ( - + { + setSettingModalVisible(true); + }} + /> + + )} + + { - setSettingModalVisible(true); - }} /> - )} - +