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