mirror of
https://github.com/putyy/res-downloader.git
synced 2026-01-12 06:04:55 +08:00
Compare commits
3 Commits
86378b9fba
...
b562f76c69
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b562f76c69 | ||
|
|
8aaf95fd36 | ||
|
|
983d72d65a |
@@ -66,7 +66,7 @@ func initConfig() *Config {
|
||||
TaskNumber: runtime.NumCPU() * 2,
|
||||
DownNumber: 3,
|
||||
UserAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36",
|
||||
UseHeaders: "User-Agent,Referer,Authorization,Cookie",
|
||||
UseHeaders: "default",
|
||||
InsertTail: true,
|
||||
MimeMap: getDefaultMimeMap(),
|
||||
Rule: "*",
|
||||
|
||||
@@ -82,8 +82,41 @@ func (fd *FileDownloader) buildClient() *http.Client {
|
||||
}
|
||||
}
|
||||
|
||||
var forbiddenDownloadHeaders = map[string]struct{}{
|
||||
"accept-encoding": {},
|
||||
"content-length": {},
|
||||
"host": {},
|
||||
"connection": {},
|
||||
"keep-alive": {},
|
||||
"proxy-connection": {},
|
||||
"transfer-encoding": {},
|
||||
|
||||
"sec-fetch-site": {},
|
||||
"sec-fetch-mode": {},
|
||||
"sec-fetch-dest": {},
|
||||
"sec-fetch-user": {},
|
||||
"sec-ch-ua": {},
|
||||
"sec-ch-ua-mobile": {},
|
||||
"sec-ch-ua-platform": {},
|
||||
|
||||
"if-none-match": {},
|
||||
"if-modified-since": {},
|
||||
|
||||
"x-forwarded-for": {},
|
||||
"x-real-ip": {},
|
||||
}
|
||||
|
||||
func (fd *FileDownloader) setHeaders(request *http.Request) {
|
||||
for key, value := range fd.Headers {
|
||||
if globalConfig.UseHeaders == "default" {
|
||||
lk := strings.ToLower(key)
|
||||
if _, forbidden := forbiddenDownloadHeaders[lk]; forbidden {
|
||||
continue
|
||||
}
|
||||
request.Header.Set(key, value)
|
||||
continue
|
||||
}
|
||||
|
||||
if strings.Contains(globalConfig.UseHeaders, key) {
|
||||
request.Header.Set(key, value)
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
</NIcon>
|
||||
</template>
|
||||
<div class="flex flex-col">
|
||||
<div class="flex items-center justify-start p-1.5 cursor-pointer" v-if="row.Status === 'running'" @click="action('cancel')">
|
||||
<div class="flex items-center justify-start p-1.5 cursor-pointer" v-if="row.Status === 'running' || row.Status === 'pending'" @click="action('cancel')">
|
||||
<n-icon
|
||||
size="28"
|
||||
class="text-red-500 dark:text-red-300 bg-red-500/20 dark:bg-red-500/30 rounded-full flex items-center justify-center p-1.5 cursor-pointer hover:bg-red-500/40 transition-colors"
|
||||
|
||||
@@ -120,7 +120,7 @@
|
||||
"connections_tip": "Keep default if unsure, usually CPU cores * 2, for faster downloads",
|
||||
"down_number": "Download Number",
|
||||
"down_number_tip": "Number of downloads executed simultaneously",
|
||||
"use_headers_tip": "Define headers for downloads, comma separated",
|
||||
"use_headers_tip": "Default system filtering, Define headers for downloads, comma separated",
|
||||
"mime_map": "Intercept Rules",
|
||||
"mime_map_tip": "JSON format, keep default if unsure, please restart software after modification",
|
||||
"domain_rule": "Domain Rule",
|
||||
|
||||
@@ -120,7 +120,7 @@
|
||||
"connections_tip": "如不清楚请保持默认,通常CPU核心数*2,用于加速下载",
|
||||
"down_number": "下载数",
|
||||
"down_number_tip": "同时进行的下载数量",
|
||||
"use_headers_tip": "定义下载时可使用的header参数,逗号分割",
|
||||
"use_headers_tip": "默认系统过滤,定义下载时可使用的header参数,逗号分割",
|
||||
"mime_map": "拦截规则",
|
||||
"mime_map_tip": "json格式,如果不清楚保持默认就行,修改后请重启软件",
|
||||
"domain_rule": "域名规则",
|
||||
|
||||
@@ -189,6 +189,10 @@ const filteredData = computed(() => {
|
||||
result = result.filter(item => item.Description?.toLowerCase().includes(descriptionSearchValue.value.toLowerCase()))
|
||||
}
|
||||
|
||||
if (urlSearchValue.value) {
|
||||
result = result.filter(item => item.Url?.toLowerCase().includes(urlSearchValue.value.toLowerCase()))
|
||||
}
|
||||
|
||||
return result
|
||||
})
|
||||
|
||||
@@ -232,6 +236,7 @@ const classify = ref([
|
||||
])
|
||||
|
||||
const descriptionSearchValue = ref("")
|
||||
const urlSearchValue = ref("")
|
||||
const rememberChoice = ref(false)
|
||||
const rememberChoiceTmp = ref(false)
|
||||
|
||||
@@ -240,11 +245,49 @@ const columns = ref<any[]>([
|
||||
type: "selection",
|
||||
},
|
||||
{
|
||||
title: computed(() => {
|
||||
return checkedRowKeysValue.value.length > 0 ? h(NGradientText, {type: "success"}, t("index.choice") + `(${checkedRowKeysValue.value.length})`) : t("index.domain")
|
||||
}),
|
||||
title: () => {
|
||||
if (checkedRowKeysValue.value.length > 0) {
|
||||
return h(NGradientText, {type: "success"}, t("index.choice") + `(${checkedRowKeysValue.value.length})`)
|
||||
}
|
||||
return h('div', {class: 'flex items-center'}, [
|
||||
t('index.domain'),
|
||||
h(NPopover, {
|
||||
style: "--wails-draggable:no-drag",
|
||||
trigger: 'click',
|
||||
placement: 'bottom',
|
||||
showArrow: true,
|
||||
}, {
|
||||
trigger: () => h(NIcon, {
|
||||
size: "18",
|
||||
class: `ml-1 cursor-pointer ${urlSearchValue.value ? "text-green-600": "text-gray-500"}`,
|
||||
onClick: (e: MouseEvent) => e.stopPropagation()
|
||||
}, h(SearchOutline)),
|
||||
default: () => h('div', {class: 'p-2 w-64'}, [
|
||||
h(NInput, {
|
||||
value: urlSearchValue.value,
|
||||
'onUpdate:value': (val: string) => urlSearchValue.value = val,
|
||||
placeholder: t('index.search_description'),
|
||||
clearable: true
|
||||
}, {
|
||||
prefix: () => h(NIcon, {component: SearchOutline})
|
||||
})
|
||||
])
|
||||
})
|
||||
])
|
||||
},
|
||||
key: "Domain",
|
||||
width: 90,
|
||||
render: (row: appType.MediaInfo) => {
|
||||
return h(NTooltip, {
|
||||
trigger: 'hover',
|
||||
placement: 'top'
|
||||
}, {
|
||||
trigger: () => h('span', {
|
||||
class: 'cursor-default'
|
||||
}, row.Domain),
|
||||
default: () => row.Url
|
||||
})
|
||||
}
|
||||
},
|
||||
{
|
||||
title: computed(() => t("index.type")),
|
||||
@@ -590,7 +633,17 @@ const dataAction = (row: appType.MediaInfo, index: number, type: string) => {
|
||||
download(row, index)
|
||||
break
|
||||
case "cancel":
|
||||
if (row.Status === "running") {
|
||||
if (row.Status === "pending") {
|
||||
const queueIndex = downloadQueue.value.findIndex(item => item.Id === row.Id)
|
||||
if (queueIndex !== -1) {
|
||||
downloadQueue.value.splice(queueIndex, 1)
|
||||
}
|
||||
updateItem(row.Id, item => {
|
||||
item.Status = 'ready'
|
||||
item.SavePath = ''
|
||||
})
|
||||
cacheData()
|
||||
} else if (row.Status === "running") {
|
||||
appApi.cancel({id: row.Id}).then((res) => {
|
||||
updateItem(row.Id, item => {
|
||||
item.Status = 'ready'
|
||||
@@ -696,7 +749,21 @@ const batchCancel = async () => {
|
||||
loading.value = true
|
||||
const cancelTasks: Promise<any>[] = []
|
||||
data.value.forEach((item, index) => {
|
||||
if (checkedRowKeysValue.value.includes(item.Id) && item.Status === "running") {
|
||||
if (!checkedRowKeysValue.value.includes(item.Id)) {
|
||||
return
|
||||
}
|
||||
|
||||
if (item.Status === "pending") {
|
||||
const queueIndex = downloadQueue.value.findIndex(qItem => qItem.Id === item.Id)
|
||||
if (queueIndex !== -1) {
|
||||
downloadQueue.value.splice(queueIndex, 1)
|
||||
}
|
||||
item.Status = 'ready'
|
||||
item.SavePath = ''
|
||||
return
|
||||
}
|
||||
|
||||
if (item.Status === "running") {
|
||||
if (activeDownloads > 0) {
|
||||
activeDownloads--
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
"info": {
|
||||
"companyName": "res-downloader",
|
||||
"productName": "res-downloader",
|
||||
"productVersion": "3.1.2",
|
||||
"productVersion": "3.1.3",
|
||||
"copyright": "Copyright © 2023",
|
||||
"comments": "This is a high-value high-performance and diverse resource downloader called res-downloader."
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user