Update Electron

This commit is contained in:
Kenta420 2024-03-15 14:10:24 +07:00
parent cae6d582ac
commit c84ee948f5
22 changed files with 763 additions and 152 deletions

View file

@ -18,18 +18,18 @@ const LoginPage: React.FC = () => {
import.meta.env.TAOBIN_RECIPE_MANAGER_SERVER_URL + '/auth/google?redirect_to=' + redirectUrl + '&kind=electron'
)
window.ipcRenderer.on('loginSuccess', (_event, data) => {
window.ipcRenderer.on('loginSuccess', async (_event, data) => {
console.log(data)
const { accessToken, maxAge, refreshToken } = data
const { accessToken, refreshToken } = data
window.ipcRenderer.send('set-keyChain', {
await window.ipcRenderer.invoke('set-keyChain', {
serviceName: import.meta.env.TAOBIN_RECIPE_MANAGER_KEY_CHAIN_SERVICE_NAME,
account: import.meta.env.TAOBIN_RECIPE_MANAGER_KEY_CHAIN_ACCOUNT_ACCESS_TOKEN,
password: accessToken + ';' + maxAge
password: accessToken
})
window.ipcRenderer.send('set-keyChain', {
await window.ipcRenderer.invoke('set-keyChain', {
serviceName: import.meta.env.TAOBIN_RECIPE_MANAGER_KEY_CHAIN_SERVICE_NAME,
account: import.meta.env.TAOBIN_RECIPE_MANAGER_KEY_CHAIN_ACCOUNT_REFRESH_TOKEN,
password: refreshToken

View file

@ -11,6 +11,7 @@ import DataTableRowActions from './filemanager-table/data-table-row-actions'
import { Checkbox } from '@/components/ui/checkbox'
import { type AndroidFile } from '@/models/android/schema'
import { File, Folder } from 'lucide-react'
import useAdb from '@/hooks/useAdb'
export const FileManagerTab: React.FC = () => {
const { currentPath, pushPath, scanPath } = useFileManager(
@ -23,6 +24,8 @@ export const FileManagerTab: React.FC = () => {
}))
)
const adb = useAdb(state => state.adb)
useEffect(() => {
console.log('scanning path', currentPath)
scanPath(currentPath).then(files => {
@ -30,7 +33,7 @@ export const FileManagerTab: React.FC = () => {
setFiles(files)
setIsLoading(false)
})
}, [currentPath])
}, [currentPath, adb])
const [files, setFiles] = useState<AndroidFile[] | undefined>(undefined)
const [isLoading, setIsLoading] = useState(true)

View file

@ -1,9 +0,0 @@
const RecipeForm: React.FC = () => {
return (
<div>
<h1>Recipe Form</h1>
</div>
)
}
export default RecipeForm

View file

@ -1,9 +1,11 @@
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion'
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
import { Button } from '@/components/ui/button'
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '@/components/ui/dropdown-menu'
import { Label } from '@/components/ui/label'
import { Separator } from '@/components/ui/separator'
import { Switch } from '@/components/ui/switch'
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table'
import { Textarea } from '@/components/ui/textarea'
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
import useRecipeDashboard from '@/hooks/recipe-dashboard'
@ -36,7 +38,7 @@ const RecipeDisplay: React.FC<RecipeDisplayProps> = ({ recipes }) => {
}
return (
<div className="flex h-full flex-col">
<div className="flex h-full flex-col overflow-y-auto">
<div className="flex items-center p-2">
<div className="flex items-center gap-2">
<Tooltip>
@ -159,16 +161,54 @@ const RecipeDisplay: React.FC<RecipeDisplayProps> = ({ recipes }) => {
<span className="font-semibold">Other Description:</span> {recipe.otherDescription}
</div>
<div>
{
// list all recipes
recipe.recipes
.filter(r => r.isUse)
.map((recipe, index) => (
<div key={index}>
<span className="font-semibold">Recipe {index + 1}:</span> {recipe.materialPathId}
</div>
))
}
<Accordion type="single" collapsible>
{
// list all recipes
recipe.recipes
.filter(r => r.isUse)
.map((recipe, index) => (
<AccordionItem key={index} value={'item-' + index}>
<AccordionTrigger>{recipe.materialPathId}</AccordionTrigger>
<AccordionContent>
<Table>
<TableHeader>
<TableRow>
<TableHead>Is Use</TableHead>
<TableHead>Powder Gram</TableHead>
<TableHead>Powder Time</TableHead>
<TableHead>Syrup Gram</TableHead>
<TableHead>Syrup Time</TableHead>
<TableHead>Hot Water</TableHead>
<TableHead>Cold Water</TableHead>
<TableHead>Mix Order</TableHead>
<TableHead>String Param</TableHead>
<TableHead>Stir Time</TableHead>
<TableHead>Feed param</TableHead>
<TableHead>Feed pattern</TableHead>
</TableRow>
</TableHeader>
<TableBody>
<TableRow>
<TableCell className="font-medium">{JSON.stringify(recipe.isUse)}</TableCell>
<TableCell>{recipe.powderGram}</TableCell>
<TableCell>{recipe.powderTime}</TableCell>
<TableCell>{recipe.syrupGram}</TableCell>
<TableCell>{recipe.syrupTime}</TableCell>
<TableCell>{recipe.waterYield}</TableCell>
<TableCell>{recipe.waterCold}</TableCell>
<TableCell>{recipe.MixOrder}</TableCell>
<TableCell>{recipe.StringParam}</TableCell>
<TableCell>{recipe.stirTime}</TableCell>
<TableCell>{recipe.FeedParameter}</TableCell>
<TableCell>{recipe.FeedPattern}</TableCell>
</TableRow>
</TableBody>
</Table>
</AccordionContent>
</AccordionItem>
))
}
</Accordion>
</div>
</div>
)}

View file

@ -202,7 +202,7 @@ export const RecipeEditor: React.FC<RecipeEditorProps> = ({
onLayout={(sizes: number[]) => {
document.cookie = `react-resizable-panels:layout=${JSON.stringify(sizes)}`
}}
className="h-full max-h-[900px] items-stretch"
className="h-full max-h-screen items-stretch"
>
<ResizablePanel
defaultSize={defaultLayout[0]}