Skip to content

Commit

Permalink
feat: finish all dashboard component and schema
Browse files Browse the repository at this point in the history
  • Loading branch information
AprilNEA committed Nov 18, 2023
1 parent b624502 commit 7f48a90
Show file tree
Hide file tree
Showing 7 changed files with 399 additions and 241 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ config.yaml
prisma/client/

.env
config.json
apps/server/.env

# IDE
Expand Down
47 changes: 40 additions & 7 deletions packages/backend/src/common/config/config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,45 @@ const CONFIG_SCHEMA: ISettingSchema[] = [
items: [
{
key: 'frontend',
type: 'input',
type: 'input' as any,
label: '前端端口',
},
{
key: 'backend',
type: 'input',
type: 'input' as any,
label: '后端端口',
},
],
},
{
key: 'jwt',
label: 'JWT',
items: [
{
key: 'algorithm',
type: 'select' as any,
label: '算法',
selectOptions: ['HS256', 'RS256'],
},
{
key: 'secret',
type: 'input' as any,
label: '密钥',
},
],
},
{
key: 'email',
label: '邮箱',
items: [
{
key: 'use',
type: 'select' as any,
label: '启用',
selectOptions: ['disable', 'resend'],
},
],
},
];

@Injectable()
Expand All @@ -66,11 +95,15 @@ export class ConfigService {
: this.defaultConfig;
}

getInstallConfigItem() {
if (fs.existsSync(this.configFilePath)) {
throw new BizException(ErrorCodeEnum.ConfigExists);
}
return [];
getConfigSchema() {
// if (fs.existsSync(this.configFilePath)) {
// throw new BizException(ErrorCodeEnum.ConfigExists);
// }
return CONFIG_SCHEMA;
}

getConfigSchemaValue() {
return {};
}

get<K extends keyof ConfigType>(key: K): ConfigType[K] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ export class DashboardController {

@Public()
@Get('install')
install() {}
install() {
return this.configService.getConfigSchema();
}

@Get('config')
getAllConfig() {
Expand Down
72 changes: 22 additions & 50 deletions packages/frontend/src/app/dashboard/setting/page.tsx
Original file line number Diff line number Diff line change
@@ -1,55 +1,27 @@
import { OptionListItem, OptionListRoot } from '@/components/radix-ui-lib';
'use client';

import useSWR from 'swr';

import { Loading } from '@/components/loading';
import { OptionListRoot, OptionNode } from '@/components/radix-ui-lib';
import { useStore } from '@/store';

export default function AdminSettingPage() {
const { fetcher } = useStore();
const { data } = useSWR('/dashboard/install', (url) =>
fetcher(url)
.then((res) => res.json())
.then((res) => {
console.log(res);
return res;
}),
);
if (!data) return <Loading />;
return (
<>
<OptionListItem
schema={{
key: 'port',
label: '端口',
description: '设置端口',
items: [
{
key: 'frontend',
type: 'input',
label: '前端端口',
description: '设置前端端口',
},
{
key: 'backend',
type: 'input',
label: '后端端口',
description: '设置后端端口',
},
{
key: '1',
label: '原神人口普查',
items: [
{
key: 'frontend',
type: 'switch',
label: '你氪金了没',
description: '设置前端端口',
},
{
key: 'backend',
type: 'select',
selectOptions: ['1', '2', '3'],
label: '有几个五星',
description: '设置后端端口',
},
]
}
],
}}
/>
<OptionListItem schema={{
key: '2',
type: 'multi-input',
label: '多输入',
description: '设置多输入',
keys: ['1', '2', '3'],
}} />
</>
<OptionListRoot>
{data.map((item: any) => (
<OptionNode key={item.key} schema={item} />
))}
</OptionListRoot>
);
}
Loading

0 comments on commit 7f48a90

Please sign in to comment.