feat(app): add clear cache button (#1909)
This commit is contained in:
parent
5288cbb1cf
commit
d35f67d2e1
@ -45,7 +45,7 @@ const SnippetCheckboxGroup = connect((props) => {
|
||||
<Checkbox value="pm.*">{t('Allows to configure plugins')}</Checkbox>
|
||||
</div>
|
||||
<div style={{ marginTop: 8 }}>
|
||||
<Checkbox value="app">{t('Allows to reboot application')}</Checkbox>
|
||||
<Checkbox value="app">{t('Allows to clear cache, reboot application')}</Checkbox>
|
||||
</div>
|
||||
</Checkbox.Group>
|
||||
);
|
||||
|
@ -782,7 +782,8 @@ export default {
|
||||
'The application is reloading, please do not close the page.': '应用正在重新加载,请勿关闭页面。',
|
||||
'Application reloading': '应用重新加载中',
|
||||
'Reboot Application': '重启应用',
|
||||
"Allows to reboot application": "允许重启应用",
|
||||
"Allows to clear cache, reboot application": "允许清除缓存,重启应用",
|
||||
'The will interrupt service, it may take a few seconds to restart. Are you sure to continue?': '重启将会中断当前服务,这个过程可能需要一点时间,确定要继续吗?',
|
||||
'Reboot': '重启',
|
||||
'Clear cache': '清除缓存',
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ export const CurrentUser = () => {
|
||||
const [visible, setVisible] = useState(false);
|
||||
const { data } = useCurrentUserContext();
|
||||
const { allowAll, snippets } = useACLRoleContext();
|
||||
const allowReboot = allowAll || snippets?.includes('app');
|
||||
const appAllowed = allowAll || snippets?.includes('app');
|
||||
const silenceApi = useAPIClient();
|
||||
const check = async () => {
|
||||
return await new Promise((resolve) => {
|
||||
@ -71,9 +71,19 @@ export const CurrentUser = () => {
|
||||
<LanguageSettings />
|
||||
<ThemeSettings />
|
||||
<Menu.Divider />
|
||||
{allowReboot && (
|
||||
{appAllowed && (
|
||||
<>
|
||||
<Menu.Item
|
||||
key="reload"
|
||||
key="cache"
|
||||
onClick={async () => {
|
||||
await api.resource('app').clearCache();
|
||||
window.location.reload();
|
||||
}}
|
||||
>
|
||||
{t('Clear Cache')}
|
||||
</Menu.Item>
|
||||
<Menu.Item
|
||||
key="reboot"
|
||||
onClick={async () => {
|
||||
Modal.confirm({
|
||||
title: t('Reboot Application'),
|
||||
@ -94,8 +104,9 @@ export const CurrentUser = () => {
|
||||
>
|
||||
{t('Reboot Application')}
|
||||
</Menu.Item>
|
||||
)}
|
||||
<Menu.Divider />
|
||||
</>
|
||||
)}
|
||||
<Menu.Item
|
||||
key="signout"
|
||||
onClick={async () => {
|
||||
|
@ -96,7 +96,7 @@ export class ClientPlugin extends Plugin {
|
||||
this.app.acl.allow('plugins', '*', 'public');
|
||||
this.app.acl.registerSnippet({
|
||||
name: 'app',
|
||||
actions: ['app:reload', 'app:reboot'],
|
||||
actions: ['app:reboot', 'app:clearCache'],
|
||||
});
|
||||
const dialect = this.app.db.sequelize.getDialect();
|
||||
const locales = require('./locale').default;
|
||||
@ -171,8 +171,8 @@ export class ClientPlugin extends Plugin {
|
||||
.map((item) => item.name);
|
||||
await next();
|
||||
},
|
||||
async reload(ctx, next) {
|
||||
await ctx.app.reload();
|
||||
async clearCache(ctx, next) {
|
||||
await ctx.cache.reset();
|
||||
await next();
|
||||
},
|
||||
reboot(ctx) {
|
||||
|
Loading…
Reference in New Issue
Block a user