keep profile name

This commit is contained in:
pompurin404 2024-08-06 16:14:31 +08:00
parent 3a7d123af9
commit 30e3aa2316
No known key found for this signature in database
2 changed files with 3 additions and 5 deletions

View File

@ -104,7 +104,7 @@ export async function createProfile(item: Partial<IProfileItem>): Promise<IProfi
const id = item.id || new Date().getTime().toString(16) const id = item.id || new Date().getTime().toString(16)
const newItem = { const newItem = {
id, id,
name: item.name || 'Local File', name: item.name || item.type === 'remote' ? 'Remote File' : 'Local File',
type: item.type || 'local', type: item.type || 'local',
url: item.url, url: item.url,
interval: item.interval || 0, interval: item.interval || 0,
@ -134,7 +134,7 @@ export async function createProfile(item: Partial<IProfileItem>): Promise<IProfi
}) })
const data = res.data const data = res.data
const headers = res.headers const headers = res.headers
if (headers['content-disposition']) { if (headers['content-disposition'] && newItem.name === 'Remote File') {
newItem.name = parseFilename(headers['content-disposition']) newItem.name = parseFilename(headers['content-disposition'])
} }
if (headers['profile-web-page-url']) { if (headers['profile-web-page-url']) {

View File

@ -21,9 +21,7 @@ const Profiles: React.FC = () => {
const handleImport = async (): Promise<void> => { const handleImport = async (): Promise<void> => {
setImporting(true) setImporting(true)
try { try {
await addProfileItem({ name: 'Remote File', type: 'remote', url }) await addProfileItem({ name: '', type: 'remote', url })
} catch (e) {
console.error(e)
} finally { } finally {
setImporting(false) setImporting(false)
} }