tachybase_todo/packages/plugins/@tachybase/plugin-multi-app-manager/src/client/AppManager.tsx
bai.zixv 236c308d23 refactor: @hera/plugin-core, departments-plugin ()
Reviewed-on: 
Co-authored-by: bai.zixv <bai.zixv@foxmail.com>
Co-committed-by: bai.zixv <bai.zixv@foxmail.com>
2024-05-28 10:43:58 +08:00

35 lines
798 B
TypeScript

import React from 'react';
import { SchemaComponent, useApp, useRecord } from '@tachybase/client';
import { Card } from 'antd';
import { schema } from './settings/schemas/applications';
import { usePluginUtils } from './utils';
const useLink = () => {
const record = useRecord();
const app = useApp();
if (record.cname) {
return `//${record.cname}`;
}
return app.getRouteUrl(`/apps/${record.name}/admin/`);
};
const AppVisitor = () => {
const { t } = usePluginUtils();
const link = useLink();
return (
<a href={link} target={'_blank'} rel="noreferrer">
{t('View', { ns: 'client' })}
</a>
);
};
export const AppManager = () => {
return (
<Card bordered={false}>
<SchemaComponent schema={schema} components={{ AppVisitor }} />
</Card>
);
};