fix: add file existence checks before backup and fix CSS typo

This commit is contained in:
xmk23333 2025-12-14 22:15:38 +08:00
parent d811f76bb4
commit 041a81cfd4
2 changed files with 28 additions and 10 deletions

View File

@ -59,15 +59,33 @@ export async function webdavBackup(): Promise<boolean> {
const { client, webdavDir, webdavMaxBackups } = await getWebDAVClient() const { client, webdavDir, webdavMaxBackups } = await getWebDAVClient()
const zip = new AdmZip() const zip = new AdmZip()
zip.addLocalFile(appConfigPath()) if (existsSync(appConfigPath())) {
zip.addLocalFile(controledMihomoConfigPath()) zip.addLocalFile(appConfigPath())
zip.addLocalFile(profileConfigPath()) }
zip.addLocalFile(overrideConfigPath()) if (existsSync(controledMihomoConfigPath())) {
zip.addLocalFolder(themesDir(), 'themes') zip.addLocalFile(controledMihomoConfigPath())
zip.addLocalFolder(profilesDir(), 'profiles') }
zip.addLocalFolder(overrideDir(), 'override') if (existsSync(profileConfigPath())) {
zip.addLocalFolder(rulesDir(), 'rules') zip.addLocalFile(profileConfigPath())
zip.addLocalFolder(subStoreDir(), 'substore') }
if (existsSync(overrideConfigPath())) {
zip.addLocalFile(overrideConfigPath())
}
if (existsSync(themesDir())) {
zip.addLocalFolder(themesDir(), 'themes')
}
if (existsSync(profilesDir())) {
zip.addLocalFolder(profilesDir(), 'profiles')
}
if (existsSync(overrideDir())) {
zip.addLocalFolder(overrideDir(), 'override')
}
if (existsSync(rulesDir())) {
zip.addLocalFolder(rulesDir(), 'rules')
}
if (existsSync(subStoreDir())) {
zip.addLocalFolder(subStoreDir(), 'substore')
}
const date = new Date() const date = new Date()
const zipFileName = `${process.platform}_${dayjs(date).format('YYYY-MM-DD_HH-mm-ss')}.zip` const zipFileName = `${process.platform}_${dayjs(date).format('YYYY-MM-DD_HH-mm-ss')}.zip`

View File

@ -200,7 +200,7 @@ const WebdavConfig: React.FC = () => {
/> />
</div> </div>
</SettingItem> </SettingItem>
<div className="flex justify0between"> <div className="flex justify-between">
<Button isLoading={backuping} fullWidth size="sm" className="mr-1" onPress={handleBackup}> <Button isLoading={backuping} fullWidth size="sm" className="mr-1" onPress={handleBackup}>
{t('webdav.backup')} {t('webdav.backup')}
</Button> </Button>