enhance(ui):调整授权码部分功能。
This commit is contained in:
parent
33dadb0d1b
commit
618a44fdd0
|
@ -3,4 +3,7 @@
|
|||
}
|
||||
.license-code-area {
|
||||
flex-grow: 1;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import { ActionIcon, Flex, Group, Paper, Textarea, Title, Tooltip } from "@mantine/core";
|
||||
import { useLicenseCode } from "@/hooks/use-license-code";
|
||||
import { ActionIcon, Box, Flex, Group, Paper, Title, Tooltip } from "@mantine/core";
|
||||
import { IconCopy } from "@tabler/icons-react";
|
||||
import classes from "./LicenseCode.module.css";
|
||||
|
||||
export function LicenseCode() {
|
||||
const [licenseCode] = useLicenseCode();
|
||||
return (
|
||||
<Paper shadow="md" p="lg" className={classes["container"]}>
|
||||
<Flex direction="column" justify="flex-start" align="stretch" gap="md">
|
||||
|
@ -14,7 +16,9 @@ export function LicenseCode() {
|
|||
</ActionIcon>
|
||||
</Tooltip>
|
||||
</Group>
|
||||
<Textarea autosize minRows={9} maxRows={12} readOnly variant="transparent" />
|
||||
<Box className={classes["license-code-area"]} c="green">
|
||||
{licenseCode}
|
||||
</Box>
|
||||
</Flex>
|
||||
</Paper>
|
||||
);
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
.conatiner {
|
||||
flex-grow: 1;
|
||||
}
|
||||
.title {
|
||||
flex-grow: 5;
|
||||
}
|
||||
.title-search {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,21 @@
|
|||
import { Flex, Paper, Title } from "@mantine/core";
|
||||
import { Flex, Paper, TextInput, Title } from "@mantine/core";
|
||||
import { IconSearch } from "@tabler/icons-react";
|
||||
import classes from "./ProductList.module.css";
|
||||
|
||||
export function ProductList() {
|
||||
return (
|
||||
<Paper shadow="md" p="lg" h="100%">
|
||||
<Flex direction="column" justify="flex-start" align="stretch" gap="md">
|
||||
<Title order={4}>产品列表</Title>
|
||||
<Flex direction="row" justify={"space-between"} align={"center"} gap="sm">
|
||||
<Title order={4} className={classes["title"]}>
|
||||
产品列表
|
||||
</Title>
|
||||
<TextInput
|
||||
placeholder="输入关键词检索产品"
|
||||
className={classes["title-search"]}
|
||||
leftSection={<IconSearch size={16} />}
|
||||
/>
|
||||
</Flex>
|
||||
</Flex>
|
||||
</Paper>
|
||||
);
|
||||
|
|
6
license_ui/src/hooks/use-license-code.ts
Normal file
6
license_ui/src/hooks/use-license-code.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
import { useState } from "react";
|
||||
|
||||
export function useLicenseCode(): [string, (licenseCode: string) => void] {
|
||||
const [licenseCode, setLicenseCode] = useState<string>("");
|
||||
return [licenseCode, setLicenseCode];
|
||||
}
|
24
license_ui/src/hooks/use-products.ts
Normal file
24
license_ui/src/hooks/use-products.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
import { useEffect, useState } from "react";
|
||||
|
||||
type ProductSearchKeyword = string | undefined | null;
|
||||
|
||||
interface Product {
|
||||
id: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export function useProducts(keyword: ProductSearchKeyword): Product[] {
|
||||
const [products, setProducts] = useState<Product[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
async function fetchProducts() {
|
||||
const response = await fetch(`/api/products?keyword=${keyword}`);
|
||||
const data = await response.json();
|
||||
setProducts(data);
|
||||
}
|
||||
|
||||
fetchProducts();
|
||||
}, [keyword]);
|
||||
|
||||
return products;
|
||||
}
|
Loading…
Reference in New Issue
Block a user