Skip to main content

helper-plugin 迁移参考

🌐 helper-plugin migration reference

本文件旨在帮助开发者将他们的 Strapi 插件和应用迁移,以便不使用 helper-plugin 包。 它列出了 helper-plugin 包中存在的每一个导出,按字母顺序并按字段分组。

🌐 This document has been written to help developers migrate their Strapi plugins and applications to not use the helper-plugin package. It lists every export that existed in the helper-plugin package, in alphabetical order and grouped by domain.

组件

🌐 Components


AnErrorOccurred

此组件已被移除,并重构为 @strapi/strapi/admin 导出的 Page 组件的一部分。你应该从那里使用 Page 组件:

🌐 This component has been removed and refactored to be part of the Page component exported from @strapi/strapi/admin. You should use the Page component from there:

// Before
import { AnErrorOccurred } from '@strapi/helper-plugin';

const MyPage = () => {
// ...

if (error) {
return <AnErrorOccurred />;
}

// ...
};

// After
import { Page } from '@strapi/strapi/admin';

const MyPage = () => {
// ...

if (error) {
return <Page.Error />;
}

// ...
};

CheckPermissions

此组件已被移除且未替换。如果你觉得需要此组件,请在 Strapi 仓库中打开一个问题以讨论你的使用情况。

🌐 This component has been removed and not replaced. If you feel like you need this component, please open an issue on the Strapi repository to discuss your usecase.

我们建议使用来自 @strapi/strapi/adminPage.Protect 组件(参见 CheckPagePermissions 获取示例)。如果你需要检查更底层组件的权限,可以使用 useRBAC Hook

🌐 We recommend using the Page.Protect component from @strapi/strapi/admin instead (see CheckPagePermissions for an example). If you need to check permissions for a lower level component you can use the useRBAC hook.

CheckPagePermissions

此组件已被移除,并重构为 @strapi/strapi/admin 导出的 Page 组件的一部分。你应该从那里使用 Page 组件:

🌐 This component has been removed and refactored to be part of the Page component exported from @strapi/strapi/admin. You should use the Page component from there:

// Before
import { CheckPagePermissions } from '@strapi/helper-plugin';

const MyProtectedPage = () => {
return (
<CheckPagePermissions
permissions={[action: 'plugin::my-plugin.read']}
>
<MyPag />
</CheckPagePermissions>
);
};

// After
import { Page } from '@strapi/strapi/admin';

const MyProtectedPage = () => {
<Page.Protect permissions={[action: 'plugin::my-plugin.read']}>
return (
</Page.Protect>
<MyPage />
);
};

行为略有改变,以前没有权限会将你重定向到页面的根,现在它将渲染 NoPermissions 组件。

🌐 The behaviour has slightly changed, where previously no permissions would redirect you to the root of the page, now it will render the NoPermissions component.

ConfirmDialog

这个组件已经被移动和重构。它可以从 @strapi/strapi/admin 包中导入:

🌐 This component has been moved and refactored. It can be imported from the @strapi/strapi/admin package:

// Before
import { ConfirmDialog } from '@strapi/helper-plugin';

// After
import { ConfirmDialog } from '@strapi/strapi/admin';

请参阅贡献者 `ConfirmDialog` 组件的文档 以获取更多信息。

🌐 Please see the contributors documentation for the `ConfirmDialog` component for more information.

ContentBox

此组件已被移除且未替换。如果你觉得需要此组件,请在 Strapi 仓库中打开一个问题以讨论你的使用情况。

🌐 This component has been removed and not replaced. If you feel like you need this component, please open an issue on the Strapi repository to discuss your usecase.

DateTimePicker

这是对设计系统进行了别名处理。你应该从那里导入组件:

🌐 This was aliasing the design-system. You should import the component from there:

// Before
import { DateTimePicker } from '@strapi/helper-plugin';

// After
import { DateTimePicker } from '@strapi/design-system';

DynamicTable

此组件以前已被弃用,现在已被移除。与弃用通知类似,我们建议使用来自 @strapi/strapi/adminTable 组件。

🌐 This component was previously deprecated and has now been removed. Similar to the deprecation notice, we recommend using the Table component from @strapi/strapi/admin.

请参阅贡献者 `Table` 组件的文档 以获取更多信息。

🌐 Please see the contributors documentation for the `Table` component for more information.

EmptyBodyTable

此组件已被移除,并已成为 Table 组件的一部分。

🌐 This component has been removed and is part of the Table component.

请参阅贡献者 `Table` 组件的文档 以获取更多信息。

🌐 Please see the contributors documentation for the `Table` component for more information.

EmptyStateLayout

这个组件已被移除且未被替代。你应该使用来自 @strapi/design-systemEmptyStateLayout

🌐 This component has been removed and not replaced. You should use EmptyStateLayout from @strapi/design-system:

// Before
import { EmptyStateLayout } from '@strapi/helper-plugin';

// After
import { EmptyStateLayout } from '@strapi/design-system';
Note

这些属性将会不同。请参考 Strapi 设计系统 `EmptyStateLayout` 组件文档

🌐 The props will be different. Please refer to the Strapi Design System documentation for the `EmptyStateLayout` component.

筛选列表URL查询

🌐 FilterListURLQuery

此组件已移至 admin 包,现在可以通过 @strapi/strapi 包作为复合组件 Filters 的一部分进行导入:

🌐 This component was moved to the admin package and can now be imported via the @strapi/strapi package as part of the composite component Filters:

// Before
import { FilterListURLQuery } from '@strapi/helper-plugin';

const MyComponent = () => {
return (
<FilterListURLQuery
filtersSchema={[
{
name: 'name',
metadatas: { label: 'Name' },
fieldSchema: { type: 'string' },
},
]}
/>
);
};

// After
import { Filters } from '@strapi/strapi/admin';

const MyComponent = () => {
return (
<Filters.Root>
<Filters.List />
</Filters.Root>
);
};

FilterPopoverURLQueryProps

此组件已移至 admin 包,现在可以通过 @strapi/strapi 包作为复合组件 Filters 的一部分进行导入:

🌐 This component was moved to the admin package and can now be imported via the @strapi/strapi package as part of the composite component Filters:

// Before
import { FilterPopoverURLQueryProps } from '@strapi/helper-plugin';

// After
import { Filters } from '@strapi/strapi/admin';

const MyComponent = () => {
return (
<Filters.Root>
<Filters.Trigger />
<Filters.Popover />
</Filters.Root>
);
};

表格

🌐 Form

这个组件别名为 Formik,我们正在努力移除它。应改为使用 Form 组件及其来自 @strapi/strapi/admin 的兄弟导出组件:

🌐 This component aliased Formik, something we're working towards removing. The Form component and its sibling exports from @strapi/strapi/admin should be used instead:

// Before
import { Form } from '@strapi/helper-plugin';

// After
import { Form } from '@strapi/strapi/admin';

用户应注意,Formik 库的任何使用将不再有效,取而代之的应查看贡献者 `Form` 组件文档

🌐 Users should note that any use of the Formik library will no longer work and instead should look at the contributors documentation for the `Form` component.

GenericInput

此组件已被移除并重构为从 @strapi/strapi/admin 导出的 InputRenderer 组件。你应该从那里使用 InputRenderer 组件:

🌐 This component has been removed and refactored to become the InputRenderer component exported from @strapi/strapi/admin. You should use the InputRenderer component from there:

// Before
import { GenericInput } from '@strapi/helper-plugin';

const MyComponent = () => {
return (
<GenericInput
type={'type'}
hint={'hint'}
label={'label'}
name={'name'}
onChange={onMetaChange}
value={'value'}
/>
);
};

// After
import { InputRenderer } from '@strapi/strapi/admin';

请注意,InputRenderer 组件有不同的 API,你应参考 `InputRenderer` 组件的文档

🌐 Note, that the InputRenderer component has a different API, and you should refer to the documentation for the `InputRenderer` component.

InjectionZone

此组件已被移除且未替换。然而,你可以通过使用 useStrapiApp 钩子在自己的项目中轻松复制此功能:

🌐 This component has been removed and not replaced. However, you can easily replicate this in your own project by using the useStrapiApp hook:

// Before

import { InjectionZone } from '@strapi/helper-plugin';
<InjectionZone area={`injection.zone.area`} />;

// After

const MyComponent = ({ area, ...compProps }) => {
const getPlugin = useStrapiApp('MyComponent', (state) => state.getPlugin);

const [pluginName, page, position] = area.split('.');

const plugin = getPlugin(pluginName);
const components = plugin?.getInjectedComponents(page, position);

if (!plugin || !components) {
return null;
}

return components.map(({ name, Component }) => (
<Component key={name} {...props} />
));
};

🌐 Link

这是在对 design-system 使用别名,并将 as 属性与 react-router-dom 一起使用。你应该从那里导入组件:

🌐 This was aliasing the design-system and using the as prop with react-router-dom. You should import the component from there:

// Before
import { Link } from '@strapi/helper-plugin';

// After
import { Link } from '@strapi/design-system/v2';
import { NavLink } from 'react-router-dom';

const MyLink = () => {
return (
<Link as={NavLink} to="/my-link">
My Link
</Link>
);
};

LinkButton

这是在对 design-system 使用别名,并将 as 属性与 react-router-dom 一起使用。你应该从那里导入组件:

🌐 This was aliasing the design-system and using the as prop with react-router-dom. You should import the component from there:

// Before
import { LinkButton } from '@strapi/helper-plugin';

// After
import { LinkButton } from '@strapi/design-system/v2';
import { NavLink } from 'react-router-dom';

const MyLink = () => {
return (
<LinkButton as={NavLink} to="/my-link">
My Link
</LinkButton>
);
};

LoadingIndicatorPage

此组件已被移除,并重构为 @strapi/strapi/admin 导出的 Page 组件的一部分。你应该从那里使用 Page 组件:

🌐 This component has been removed and refactored to be part of the Page component exported from @strapi/strapi/admin. You should use the Page component from there:

// Before
import { LoadingIndicatorPage } from '@strapi/helper-plugin';

const MyPage = () => {
// ...

if (isLoading) {
return <LoadingIndicatorPage />;
}

// ...
};

// After
import { Page } from '@strapi/strapi/admin';

const MyPage = () => {
// ...

if (isLoading) {
return <Page.Loading />;
}

// ...
};

NoContent

此组件已被移除且未被替代,你应使用来自 @strapi/design-systemEmptyStateLayout 组件。

🌐 This component has been removed and not replaced, you should use the EmptyStateLayout component from @strapi/design-system.

// Before
import { NoContent } from '@strapi/helper-plugin';

<NoContent
content={{
id: 'translation_id',
defaultMessage: 'Message',
}}
/>;

// After
import { EmptyStateLayout } from '@strapi/design-system';

<EmptyStateLayout
content={{
id: 'translation_id',
defaultMessage: 'Message',
}}
/>;

NoMedia

此组件已被移除且未替换。如果你觉得需要此组件,请在 Strapi 仓库中打开一个问题以讨论你的使用情况。

🌐 This component has been removed and not replaced. If you feel like you need this component, please open an issue on the Strapi repository to discuss your usecase.

NoPermissions

此组件已被移除,并重构为 @strapi/strapi/admin 导出的 Page 组件的一部分。你应该从那里使用 Page 组件:

🌐 This component has been removed and refactored to be part of the Page component exported from @strapi/strapi/admin. You should use the Page component from there:

// Before
import { NoPermissions } from '@strapi/helper-plugin';

const MyPage = () => {
// ...

if (!canRead) {
return <NoPermissions />;
}

// ...
};

// After
import { Page } from '@strapi/strapi/admin';

const MyPage = () => {
// ...

if (!canRead) {
return <Page.NoPermissions />;
}

// ...
};

NotAllowedInput

此组件已被移除,且未被替代。如果你觉得自己需要此组件,请在 Strapi 仓库中打开一个问题来讨论你的使用案例。你可以通过在自己的项目中使用来自 @strapi/design-systemTextInput 来轻松复制此功能:

🌐 This component has been removed and not replaced. If you feel like you need this component, please open an issue on the Strapi repository to discuss your usecase. You can easily replicate this in your own project by using the TextInput from @strapi/design-system:

import { TextInput } from '@strapi/design-system';

const MyComponent = (props) => {
return (
<TextInput
disabled
placeholder="No permissions to see this field"
type="text"
{...props}
/>
);
};

页面大小URL查询

🌐 PageSizeURLQuery

此组件已移至 admin 包,现在可以通过 @strapi/strapi 包作为复合组件 Pagination 的一部分进行导入:

🌐 This component was moved to the admin package and can now be imported via the @strapi/strapi package as part of the composite component Pagination:

// Before
import { PageSizeURLQuery } from '@strapi/helper-plugin';

const MyComponent = () => {
return (
<PageSizeURLQuery options={['12', '24', '50', '100']} defaultValue="24" />
);
};

// After
import { Pagination } from '@strapi/strapi/admin';

const MyComponent = () => {
return (
<Pagination.Root>
<Pagination.PageSize />
</Pagination.Root>
);
};

注意,行为上有一些轻微的变化,即如果最低的 PageSize 是 10 但你只有 9 个条目,PageSize 将不会渲染。由于重构,一些属性可能已经移动或更改,请查看贡献者 documentation for the Pagination component 了解更多信息。

分页URL查询属性

🌐 PaginationURLQueryProps

此组件已移至 admin 包,现在可以通过 @strapi/strapi 包作为复合组件 Pagination 的一部分进行导入:

🌐 This component was moved to the admin package and can now be imported via the @strapi/strapi package as part of the composite component Pagination:

// Before
import { PaginationURLQueryProps } from '@strapi/helper-plugin';

// After
import { Pagination } from '@strapi/strapi/admin';

const MyComponent = () => {
return (
<Pagination.Root pageCount={2}>
<Pagination.Links />
</Pagination.Root>
);
};

注意,有一些轻微的行为变化,例如:如果页面少于2页,链接将不会显示。由于重构,一些属性会被移动和改变,请查看 documentation for the Pagination component 以获取更多信息。

ReactSelect

此组件已被移除且未替换。如果你觉得需要此组件,请在 Strapi 仓库中打开一个问题以讨论你的使用情况。

🌐 This component has been removed and not replaced. If you feel like you need this component, please open an issue on the Strapi repository to discuss your usecase.

RelativeTime

此组件已被移除且未替换。如果你觉得需要此组件,请在 Strapi 仓库中打开一个问题以讨论你的使用情况。

🌐 This component has been removed and not replaced. If you feel like you need this component, please open an issue on the Strapi repository to discuss your usecase.

搜索URL查询

🌐 SearchURLQuery

此组件已被移除并重命名为 SearchInput,现在可以通过 @strapi/strapi 包导入:

🌐 This component was removed and renamed to SearchInput and can now be imported by the @strapi/strapi package:

// Before
import { SearchURLQuery } from '@strapi/helper-plugin';

// After
import { SearchInput } from '@strapi/strapi/admin';

SettingsPageTitle

此组件已被移除且未替换。如果你觉得需要此组件,请在 Strapi 仓库中打开一个问题以讨论你的使用情况。

🌐 This component has been removed and not replaced. If you feel like you need this component, please open an issue on the Strapi repository to discuss your usecase.

状态

🌐 Status

该组件应从 @strapi/design-system 包中导入:

🌐 This component should be imported from the @strapi/design-system package:

// Before
import { Status } from '@strapi/helper-plugin';

const MyComponent = () => {
return (
<Status variant={statusColor} showBullet={false} size="S">
<Typography fontWeight="bold" textColor={`${statusColor}700`}>
{stateMessage[status]}
</Typography>
</Status>
);
};

// After
import { Status } from '@strapi/design-system';

表格

🌐 Table

这个组件应从 @strapi/strapi/admin 包中导入:

🌐 This component should be imported from the @strapi/strapi/admin package:

// Before
import { Table } from '@strapi/helper-plugin';

const MyComponent = () => {
return (
<Table colCount={2} rowCount={2}>
<Thead>
<Tr>
<Th>
<Typography variant="sigma" textColor="neutral600">
{`Name`}
</Typography>
</Th>
<Th>
<Typography variant="sigma" textColor="neutral600">
{`Description`}
</Typography>
</Th>
</Tr>
</Thead>
<Tbody>
{data?.map(({ name, description }) => {
return (
<Tr key={name}>
<Td>
<Typography
textColor="neutral800"
variant="omega"
fontWeight="bold"
>
{name}
</Typography>
</Td>
<Td>
<Typography textColor="neutral800">{description}</Typography>
</Td>
</Tr>
);
})}
</Tbody>
</Table>
);
};

// After
import { Table } from '@strapi/strapi/admin';
Note

某些属性已更改,请参阅贡献者 关于 `Table` 组件的文档

🌐 Some of the props have changed, please refer to the contributors documentation for the `Table` component.

内容经理

🌐 Content Manager

contentManagementUtilRemoveFieldsFromData

此功能已被移除且未被替代。如果你觉得需要此功能,请在 Strapi 仓库中提交问题以讨论你的使用案例。

🌐 This function has been removed and not replaced. If you feel like you need this function, please open an issue on the Strapi repository to discuss your usecase.

formatContentTypeData

此功能已被移除且未被替代。如果你觉得需要此功能,请在 Strapi 仓库中提交问题以讨论你的使用案例。

🌐 This function has been removed and not replaced. If you feel like you need this function, please open an issue on the Strapi repository to discuss your usecase.

useCMEditViewDataManager

许多内部结构已经被重新设计和拆分。我们正在公开一个主要的实验性钩子,以替代名为 useContentManagerContext 的钩子,而其余的逻辑则分布在几个钩子中。

🌐 A lot of the internals have been reworked and split. We are exposing a main experimental hook to replace this one named useContentManagerContext while the rest of the logic is in several hooks.

// Before
import { useCMEditViewDataManager } from '@strapi/helper-plugin';

// After
import { unstable_useContentManagerContext as useContentManagerContext } from '@strapi/strapi/admin';

下面列出了一些常见的用例:

🌐 Some common use cases are listed below:

// Before
const { slug, isSingleType, isCreatingEntry, hasDraftAndPublished } =
useCMEditViewDataManager();

// After
const {
model,
collectionType,
id,
slug,
isCreatingEntry,
isSingleType,
hasDraftAndPublish,
} = useContentManagerContext();
// Before

// 'allLayoutData' has been removed. It contained 'components' and 'contentType' which can be extracted from the 'useContentManagerContext' hook as seen below.
const { allLayoutData } = useCMEditViewDataManager();

// After
const { components, contentType } = useContentManagerContext();
// Before
const { layout } = useCMEditViewDataManager();

// After
const { layout } = useContentManagerContext();

const {
edit: { layout, components },
list: { layout },
} = layout;
// Before
const { initialData, modifiedData, onChange } = useCMEditViewDataManager();

// After
const { form } = useContentManagerContext();

// Here 'initialData' and 'modifiedData' correspond to 'initialValues' and 'values'.
const { initialValues, values, onChange } = form;
// Before
const { onPublish, onUnpublish } = useCMEditViewDataManager();

// After
const { publish, unpublish } = useDocumentActions();

特性

🌐 Features


AppInfo

此功能已被移至 @strapi/admin,现在仅导出钩子 useStrapiApp

🌐 This feature has been moved to @strapi/admin and only the hook useStrapiApp is now exported.

AutoReloadOverlayBlocker

此功能已被移除且未被替代。如果你觉得需要此功能,请在 Strapi 仓库中提交问题以讨论你的使用案例。

🌐 This feature has been removed and not replaced. If you feel like you need this feature, please open an issue on the Strapi repository to discuss your usecase.

CustomFields

此功能已被移除,并且是 useStrapiApp 钩子的一部分。

🌐 This feature has been removed and is part of the useStrapiApp hook.

GuidedTour

此功能已被移至 @strapi/admin,现在仅导出钩子 useGuidedTour

🌐 This feature has been moved to @strapi/admin and only the hook useGuidedTour is now exported.

🌐 Library

此功能已被移除,并且是 useStrapiApp 钩子的一部分。

🌐 This feature has been removed and is part of the useStrapiApp hook.

通知

🌐 Notifications

此功能已移动到 @strapi/admin 包中,并且只导出了 useNotifications 钩子。message 属性不再可以是 TranslationMessage,而只能是字符串。如果你之前使用的是 warning 类型,则应改为使用 danger 类型;如果你使用的是 softWarning 类型,则应使用 warning。最后,返回类型现在是一个对象。

🌐 This feature has been moved to the @strapi/admin package and only the useNotifications hook is exported. The message property can no longer be a TranslationMessage and instead, only a string. If you were previously using the warning type you should instead use the danger type and if you were using the softWarning type you should use warning. Finally, the return type is now an object.

// Before
import { useNotification } from '@strapi/helper-plugin';

const toggleNotification = useNotification();

toggleNotification({
type: 'warning',
message: {
id: 'my.message.id',
defaultMessage: 'My message',
},
});

// After
import { useNotification } from '@strapi/strapi/admin';

const { toggleNotification } = useNotification();

toggleNotification({
type: 'danger',
message: formatMessage({
id: 'my.message.id',
defaultMessage: 'My message',
}),
});

基于角色的访问控制

🌐 RBAC

此功能已被移除且未被替代。如果你需要访问用户的权限,应该使用 useAuth 钩子。

🌐 This feature has removed and not replaced. If you need to access the user's permissions you should use the useAuth hook.

// Before
import { useRBACProvider } from '@strapi/helper-plugin';

const { allPermission, refetchPermissions } = useRBACProvider();

// After
import { useAuth } from '@strapi/strapi/admin';

const permissions = useAuth('COMPONENT_NAME', (state) => state.permissions);
const refetchPermission = useAuth(
'COMPONENT_NAME',
(state) => state.refetchPermission
);

OverlayBlocker

此功能已被移除且未被替代。如果你觉得需要此功能,请在 Strapi 仓库中提交问题以讨论你的使用案例。

🌐 This feature has been removed and not replaced. If you feel like you need this feature, please open an issue on the Strapi repository to discuss your usecase.

StrapiApp

此功能已被移至 @strapi/admin,现在仅导出钩子 useStrapiApp

🌐 This feature has been moved to @strapi/admin and only the hook useStrapiApp is now exported.

跟踪

🌐 Tracking

此功能已移至 @strapi/admin 包,并且仅导出 useTracking 钩子。

🌐 This feature has been moved to the @strapi/admin package and only the useTracking hook is exported.

钩子

🌐 Hooks


useAPIErrorHandler

此钩子已被移除。你应该从 @strapi/strapi/admin 包中导入它:

🌐 This hook has been removed. You should import it from the @strapi/strapi/admin package:

// Before
import { useAPIErrorHandler } from '@strapi/helper-plugin';

// After
import { useAPIErrorHandler } from '@strapi/strapi/admin';

useCallbackRef

此钩子已被移除。你应该从 @strapi/design-system 包中导入它:

🌐 This hook has been removed. You should import it from the @strapi/design-system package:

// Before
import { useCallbackRef } from '@strapi/helper-plugin';

// After
import { useCallbackRef } from '@strapi/design-system';

useClipboard

这个钩子已被移除,且未被替代。如果你觉得需要这个钩子,请在 Strapi 仓库中打开一个问题来讨论你的使用场景。

🌐 This hook has been removed and not replaced. If you feel like you need this hook, please open an issue on the Strapi repository to discuss your usecase.

useCollator

此钩子已被移除。你应该从 @strapi/design-system 包中导入它:

🌐 This hook has been removed. You should import it from the @strapi/design-system package:

// Before
import { useCollator } from '@strapi/helper-plugin';

// After
import { useCollator } from '@strapi/design-system';

useFetchClient

此钩子已被移除。你应该从 @strapi/strapi/admin 包中导入它:

🌐 This hook has been removed. You should import it from the @strapi/strapi/admin package:

// Before
import { useFetchClient } from '@strapi/helper-plugin';

// After
import { useFetchClient } from '@strapi/strapi/admin';

useFieldHint

这个钩子已被移除,且未被替代。如果你觉得需要这个钩子,请在 Strapi 仓库中打开一个问题来讨论你的使用场景。

🌐 This hook has been removed and not replaced. If you feel like you need this hook, please open an issue on the Strapi repository to discuss your usecase.

useFilter

此钩子已被移除。你应该从 @strapi/design-system 包中导入它:

🌐 This hook has been removed. You should import it from the @strapi/design-system package:

// Before
import { useFilter } from '@strapi/helper-plugin';

// After
import { useFilter } from '@strapi/design-system';

useFocusInputField

这个钩子已被移除,且未被替代。如果你觉得需要这个钩子,请在 Strapi 仓库中打开一个问题来讨论你的使用场景。

🌐 This hook has been removed and not replaced. If you feel like you need this hook, please open an issue on the Strapi repository to discuss your usecase.

useFocusWhenNavigate

这个钩子已被移除,且未被替代。如果你觉得需要这个钩子,请在 Strapi 仓库中打开一个问题来讨论你的使用场景。

🌐 This hook has been removed and not replaced. If you feel like you need this hook, please open an issue on the Strapi repository to discuss your usecase.

useFormattedMessage

这个钩子已被移除,且未被替代。如果你觉得需要这个钩子,请在 Strapi 仓库中打开一个问题来讨论你的使用场景。

🌐 This hook has been removed and not replaced. If you feel like you need this hook, please open an issue on the Strapi repository to discuss your usecase.

useLockScroll

这个钩子已被移除,且未被替代。如果你觉得需要这个钩子,请在 Strapi 仓库中打开一个问题来讨论你的使用场景。

🌐 This hook has been removed and not replaced. If you feel like you need this hook, please open an issue on the Strapi repository to discuss your usecase.

useQuery

这个钩子已被移除,且未被替代。如果你觉得需要这个钩子,请在 Strapi 仓库中打开一个问题来讨论你的使用场景。

🌐 This hook has been removed and not replaced. If you feel like you need this hook, please open an issue on the Strapi repository to discuss your usecase.

useQueryParams

此钩子已被移动。你应该从 @strapi/strapi/admin 包中导入它:

🌐 This hook has been moved. You should import it from the @strapi/strapi/admin package:

// Before
import { useQueryParams } from '@strapi/helper-plugin';

// After
import { useQueryParams } from '@strapi/strapi/admin';

useRBAC

此钩子已被移动。你应该从 @strapi/strapi/admin 包中导入它:

🌐 This hook has been moved. You should import it from the @strapi/strapi/admin package:

// Before
import { useRBAC } from '@strapi/helper-plugin';

// After
import { useRBAC } from '@strapi/strapi/admin';

useSelectionState

这个钩子已被移除,且未被替代。如果你觉得需要这个钩子,请在 Strapi 仓库中打开一个问题来讨论你的使用场景。

🌐 This hook has been removed and not replaced. If you feel like you need this hook, please open an issue on the Strapi repository to discuss your usecase.

图标

🌐 Icons


SortIcon

此组件已被移除且未替换。如果你觉得需要此功能,请在 Strapi 仓库中提交一个问题以讨论你的使用案例。

🌐 This component has been removed and not replaced. If you feel like you need this function, please open an issue on the Strapi repository to discuss your usecase.

RemoveRoundedButton

此组件已被移除且未替换。如果你觉得需要此功能,请在 Strapi 仓库中提交一个问题以讨论你的使用案例。

🌐 This component has been removed and not replaced. If you feel like you need this function, please open an issue on the Strapi repository to discuss your usecase.

工具

🌐 Utils


awaitToJs

此工具已被移除且未替代,请改用 async / await 搭配 try / catch。如果你觉得仍然需要此工具,请在 Strapi 仓库中打开一个 issue 讨论你的使用场景。

🌐 This util has been removed and not replaced, use async / await with try / catch instead. If you feel like you need this util, please open an issue on the Strapi repository to discuss your usecase.

difference

此工具已被移除且未替代。如果你觉得需要此工具,请在 Strapi 仓库中打开一个问题以讨论你的使用情况。

🌐 This util has been removed and not replaced. If you feel like you need this util, please open an issue on the Strapi repository to discuss your usecase.

findMatchingPermissions

此工具已被移除且未替代。你应该自己过滤权限。如果你觉得需要此工具,请在 Strapi 仓库中打开一个问题讨论你的使用案例。

🌐 This util has been removed and not replaced. You should filter the permissions yourself. If you feel like you need this util, please open an issue on the Strapi repository to discuss your usecase.

formatPermissionsForRequest

此工具已被移除且未替代。你应该自己格式化权限。如果你认为需要此工具,请在 Strapi 仓库中打开一个 issue 讨论你的使用场景。

🌐 This util has been removed and not replaced. You should format the permissions yourself. If you feel like you need this util, please open an issue on the Strapi repository to discuss your usecase.

getAPIInnerErrors

此工具已被移除且未替代,请改用 async / await 搭配 try / catch。如果你觉得仍然需要此工具,请在 Strapi 仓库中打开一个 issue 讨论你的使用场景。

🌐 This util has been removed and not replaced, use async / await with try / catch instead. If you feel like you need this util, please open an issue on the Strapi repository to discuss your usecase.

getFetchClient

此工具已被移除。你应该从 @strapi/strapi/admin 包中导入它:

🌐 This util has been removed. You should import it from the @strapi/strapi/admin package:

// Before
import { getFetchClient } from '@strapi/helper-plugin';

// After
import { getFetchClient } from '@strapi/strapi/admin';

getFileExtension

此工具已被移除且未替代。如果你觉得需要此工具,请在 Strapi 仓库中打开一个问题以讨论你的使用情况。

🌐 This util has been removed and not replaced. If you feel like you need this util, please open an issue on the Strapi repository to discuss your usecase.

getYupInnerErrors

此工具已被移除且未替代。如果你觉得需要此工具,请在 Strapi 仓库中打开一个问题以讨论你的使用情况。

🌐 This util has been removed and not replaced. If you feel like you need this util, please open an issue on the Strapi repository to discuss your usecase.

auth

此工具已被移除且没有替代。如果你尝试与令牌或当前用户交互,应改为使用 useAuth 钩子。 如果你通常是与 localStorage 交互,则可以直接访问,例如 localStorage.getItem('myKey')

🌐 This util has been removed and not replaced. If you're trying to interact with the token or current user you use should use the useAuth hook instead. If you're generally interacting with localStorage, then access this directly e.g. localStorage.getItem('myKey').

hasPermissions

此工具已被移除。如果你需要使用它,你应该使用 useAuth 钩子中的 checkUserHasPermissions 函数。

🌐 This util has been removed. If you need to use it, you should use the checkUserHasPermissions function from the useAuth hook.

// Before
import { hasPermissions } from '@strapi/helper-plugin';

const permissions = await Promise.all(
generalSectionRawLinks.map(({ permissions }) =>
hasPermissions(userPermissions, permissions)
)
);

// After
import { useAuth } from '@strapi/strapi/admin';

const { checkUserHasPermissions } = useAuth(
'COMPONENT_NAME',
(state) => state.checkUserHasPermissions
);

normalizeAPIError

此工具已被移除且未替代。如果你觉得需要此工具,请在 Strapi 仓库中打开一个问题以讨论你的使用情况。

🌐 This util has been removed and not replaced. If you feel like you need this util, please open an issue on the Strapi repository to discuss your usecase.

prefixFileUrlWithBackendUrl

此工具已被移除,且未被替代。如果需要,请使用 strapi backendUrl 来为相对 URL 添加前缀。如果你觉得需要此工具,请在 Strapi 仓库中打开一个问题以讨论你的使用场景。

🌐 This util has been removed and not replaced. Use the strapi backendUrl to prefix the relative url if you need. If you feel like you need this util, please open an issue on the Strapi repository to discuss your usecase.

prefixPluginTranslations

此工具已被移除且没有替代。如果需要,你的插件应自行定义此工具,其实现可如下所示:

🌐 This util has been removed and not replaced. Your plugin should define this util itself if needed, with an implementation like this:

type TradOptions = Record<string, string>;

const prefixPluginTranslations = (
trad: TradOptions,
pluginId: string
): TradOptions => {
if (!pluginId) {
throw new TypeError("pluginId can't be empty");
}
return Object.keys(trad).reduce((acc, current) => {
acc[`${pluginId}.${current}`] = trad[current];
return acc;
}, {} as TradOptions);
};

如果你觉得需要这个实用程序,请在 Strapi 存储库上打开一个问题来讨论你的用例。

🌐 If you feel like you need this util, please open an issue on the Strapi repository to discuss your usecase.

pxToRem

此工具已被移除且未被替代。你应该直接使用这段代码来替代 pxToRem:

🌐 This util has been removed and not replaced. You should use directly this code in place of the pxToRem:

// Before
pxToRem(
32
) // After
`${32 / 16}rem`;
// or
('2rem');

如果你觉得需要这个实用程序,请在 Strapi 存储库上打开一个问题来讨论你的用例。

🌐 If you feel like you need this util, please open an issue on the Strapi repository to discuss your usecase.

request

这个工具已被移除且未被替代。 你可以从 @strapi/strapi/admin 使用 useFetchClient

🌐 This util has been removed and not replaced. You can use useFetchClient from @strapi/strapi/admin.

// Before
import { request } from '@strapi/helper-plugin';

request(`/${pluginId}/settings/config`, { method: 'GET' });

// After
import { useFetchClient } from '@strapi/strapi/admin';

const { get } = useFetchClient();
get(`/${pluginId}/settings/config`);

你可以这样使用它

🌐 And you can use it like this

const { get } = useFetchClient();

const { data } = await get(requestURL);

如果你觉得需要这个实用程序,请在 Strapi 存储库上打开一个问题来讨论你的用例。

🌐 If you feel like you need this util, please open an issue on the Strapi repository to discuss your usecase.

setHexOpacity

此工具已被移除且未替代,请改用原生 CSS 不透明度属性。如果你觉得仍需要此工具,请在 Strapi 仓库中提交一个问题以讨论你的使用情况。

🌐 This util has been removed and not replaced, use the native CSS opacity property instead. If you feel like you need this util, please open an issue on the Strapi repository to discuss your usecase.

stopPropagation

此工具已被移除且未替代。如果你觉得需要此工具,请在 Strapi 仓库中打开一个问题以讨论你的使用情况。

🌐 This util has been removed and not replaced. If you feel like you need this util, please open an issue on the Strapi repository to discuss your usecase.

shouldCheckPermissions

此工具已被移除且未替代。如果你觉得需要此工具,请在 Strapi 仓库中打开一个问题以讨论你的使用情况。

🌐 This util has been removed and not replaced. If you feel like you need this util, please open an issue on the Strapi repository to discuss your usecase.

translatedErrors

此工具已被移除。你应该从 @strapi/strapi/admin 包中导入它:

🌐 This utils has been removed. You should import it from the @strapi/strapi/admin package:

// Before
import { translatedErrors } from '@strapi/helper-plugin';

// After
import { translatedErrors } from '@strapi/strapi/admin';

如果你觉得需要这个实用程序,请在 Strapi 存储库上打开一个问题来讨论你的用例。

🌐 If you feel like you need this util, please open an issue on the Strapi repository to discuss your usecase.

wrapAxiosInstance

此工具已被移除且未替代。如果你觉得需要此工具,请在 Strapi 仓库中打开一个问题以讨论你的使用情况。

🌐 This util has been removed and not replaced. If you feel like you need this util, please open an issue on the Strapi repository to discuss your usecase.