@@ -11,6 +11,7 @@ import { bus, fsArchiveDecompress, handleRespWithNotifySuccess } from "~/utils"
1111import { batch , createSignal , onCleanup } from "solid-js"
1212import { ModalFolderChoose } from "~/components"
1313import { selectedObjs } from "~/store"
14+ import { CreateFolderButton } from "./CopyMove"
1415
1516export const Decompress = ( ) => {
1617 const t = useT ( )
@@ -23,9 +24,14 @@ export const Decompress = () => {
2324 const [ cacheFull , setCacheFull ] = createSignal ( true )
2425 const [ putIntoNewDir , setPutIntoNewDir ] = createSignal ( false )
2526 const [ overwrite , setOverwrite ] = createSignal ( false )
27+ const [ srcPath , setSrcPath ] = createSignal ( "" )
28+ const [ srcName , setSrcName ] = createSignal < string [ ] > ( )
2629 const handler = ( name : string ) => {
2730 if ( name === "decompress" ) {
31+ const path = pathname ( )
2832 batch ( ( ) => {
33+ setSrcPath ( path )
34+ setSrcName ( selectedObjs ( ) . map ( ( o ) => o . name ) )
2935 setCacheFull ( true )
3036 setInnerPath ( "/" )
3137 setArchivePass ( "" )
@@ -35,7 +41,11 @@ export const Decompress = () => {
3541 }
3642 const extractHandler = ( args : string ) => {
3743 const { inner, pass } = JSON . parse ( args )
44+ const path = pathname ( )
45+ const idx = path . lastIndexOf ( "/" )
3846 batch ( ( ) => {
47+ setSrcPath ( path . slice ( 0 , idx ) )
48+ setSrcName ( [ path . slice ( idx + 1 ) ] )
3949 setCacheFull ( false )
4050 setInnerPath ( inner )
4151 setArchivePass ( pass )
@@ -54,21 +64,14 @@ export const Decompress = () => {
5464 }
5565 return t ( "home.toolbar.archive.extract_header" , { path : innerPath ( ) } )
5666 }
57- const getPathAndName = ( ) => {
58- let path = pathname ( )
59- if ( innerPath ( ) === "/" ) {
60- return { path : path , name : selectedObjs ( ) . map ( ( o ) => o . name ) }
61- } else {
62- let idx = path . lastIndexOf ( "/" )
63- return { path : path . slice ( 0 , idx ) , name : [ path . slice ( idx + 1 ) ] }
64- }
65- }
6667 return (
6768 < ModalFolderChoose
6869 header = { header ( ) }
6970 opened = { isOpen ( ) }
7071 onClose = { onClose }
7172 loading = { loading ( ) }
73+ defaultValue = { srcPath }
74+ headerSlot = { ( handler ) => < CreateFolderButton handler = { handler } /> }
7275 footerSlot = {
7376 < VStack w = "$full" spacing = "$2" >
7477 < Checkbox
@@ -81,11 +84,10 @@ export const Decompress = () => {
8184 </ VStack >
8285 }
8386 onSubmit = { async ( dst ) => {
84- const { path, name } = getPathAndName ( )
8587 const resp = await ok (
86- path ,
88+ srcPath ( ) ,
8789 dst ,
88- name ,
90+ srcName ( ) ,
8991 archivePass ( ) ,
9092 innerPath ( ) ,
9193 cacheFull ( ) ,
0 commit comments