Reviewed-on: daoyoucloud/tachybase#979 Co-authored-by: bai.zixv <bai.zixv@foxmail.com> Co-committed-by: bai.zixv <bai.zixv@foxmail.com>
35 lines
798 B
TypeScript
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>
|
|
);
|
|
};
|