更改下载类型处理

This commit is contained in:
super
2026-04-06 16:58:58 +08:00
parent 9720453ac4
commit afffb7aad2
11 changed files with 87 additions and 18 deletions

View File

@@ -12,7 +12,7 @@ zn_username=%E8%87%AA%E5%8A%A8%E5%8C%96_Robot
client_name=ShuFuAI
java_api_base=http://127.0.0.1:18080
# java_api_base=http://8.136.19.173:18080
# java_api_base=http://127.0.0.1:18080
java_api_base=http://8.136.19.173:18080

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -154,17 +154,36 @@ class WindowAPI:
)
return result[0] if result else ''
def save_file_from_url(self, url, default_filename='download.zip'):
"""弹窗选择保存位置,从 url 下载文件并保存。用于品牌任务结果 zip 等"""
def save_file_from_url(self, url, default_filename='download.bin'):
"""弹窗选择保存位置,从 url 下载文件并保存。根据文件后缀动态设置保存类型"""
if not url or not url.strip():
return {'success': False, 'error': '下载地址为空'}
filename = str(default_filename or 'download.bin').strip() or 'download.bin'
ext = os.path.splitext(filename)[1].lower()
# 根据默认文件名后缀动态设置文件类型,避免固定为 zip 造成误导
if ext == '.zip':
file_types = ('ZIP 压缩包 (*.zip)', '所有文件 (*.*)')
elif ext in ('.xlsx', '.xls'):
file_types = ('Excel 文件 (*.xlsx;*.xls)', '所有文件 (*.*)')
elif ext == '.csv':
file_types = ('CSV 文件 (*.csv)', '所有文件 (*.*)')
elif ext == '.txt':
file_types = ('文本文件 (*.txt)', '所有文件 (*.*)')
elif ext == '.json':
file_types = ('JSON 文件 (*.json)', '所有文件 (*.*)')
else:
file_types = ('所有文件 (*.*)',)
result = self._window.create_file_dialog(
webview.SAVE_DIALOG,
save_filename=default_filename,
file_types=('ZIP 压缩包 (*.zip)', '所有文件 (*.*)')
save_filename=filename,
file_types=file_types
)
if not result:
return {'success': False, 'error': '用户取消'}
path = result[0] if isinstance(result, (list, tuple)) else result
try:
import requests

View File

@@ -5,8 +5,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>格式转换 - 数富AI</title>
<script type="module" crossorigin src="/assets/convert.js"></script>
<link rel="modulepreload" crossorigin href="/assets/pywebview-BCPdlDdb.js">
<link rel="modulepreload" crossorigin href="/assets/brand-CFZZtTv8.js">
<link rel="modulepreload" crossorigin href="/assets/pywebview-V_UIajJm.js">
<link rel="modulepreload" crossorigin href="/assets/brand-1nUVsWrm.js">
<link rel="stylesheet" crossorigin href="/assets/pywebview-Q4glvYu5.css">
<link rel="stylesheet" crossorigin href="/assets/convert-Cfr3mUjs.css">
</head>

View File

@@ -5,8 +5,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>数据去重 - 数富AI</title>
<script type="module" crossorigin src="/assets/dedupe.js"></script>
<link rel="modulepreload" crossorigin href="/assets/pywebview-BCPdlDdb.js">
<link rel="modulepreload" crossorigin href="/assets/brand-CFZZtTv8.js">
<link rel="modulepreload" crossorigin href="/assets/pywebview-V_UIajJm.js">
<link rel="modulepreload" crossorigin href="/assets/brand-1nUVsWrm.js">
<link rel="stylesheet" crossorigin href="/assets/pywebview-Q4glvYu5.css">
<link rel="stylesheet" crossorigin href="/assets/dedupe-CS18ls2z.css">
</head>

View File

@@ -5,8 +5,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>删除品牌 - 数富AI</title>
<script type="module" crossorigin src="/assets/delete-brand.js"></script>
<link rel="modulepreload" crossorigin href="/assets/pywebview-BCPdlDdb.js">
<link rel="modulepreload" crossorigin href="/assets/brand-CFZZtTv8.js">
<link rel="modulepreload" crossorigin href="/assets/pywebview-V_UIajJm.js">
<link rel="modulepreload" crossorigin href="/assets/brand-1nUVsWrm.js">
<link rel="stylesheet" crossorigin href="/assets/pywebview-Q4glvYu5.css">
<link rel="stylesheet" crossorigin href="/assets/delete-brand-_jGFWTAn.css">
</head>

View File

@@ -5,8 +5,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>数据拆分 - 数富AI</title>
<script type="module" crossorigin src="/assets/split.js"></script>
<link rel="modulepreload" crossorigin href="/assets/pywebview-BCPdlDdb.js">
<link rel="modulepreload" crossorigin href="/assets/brand-CFZZtTv8.js">
<link rel="modulepreload" crossorigin href="/assets/pywebview-V_UIajJm.js">
<link rel="modulepreload" crossorigin href="/assets/brand-1nUVsWrm.js">
<link rel="stylesheet" crossorigin href="/assets/pywebview-Q4glvYu5.css">
<link rel="stylesheet" crossorigin href="/assets/split-mwLUJT1K.css">
</head>

View File

@@ -75,6 +75,24 @@
</div>
<div v-if="countryPrefSaving" class="country-pref-status">保存中</div>
<div class="section-title">商品列表筛选</div>
<p class="hint listing-filter-hint">推送到 Python 队列一并下发 Python 区分处理场景</p>
<div class="listing-filter-row">
<el-select
v-model="productRiskListingFilter"
class="listing-filter-select"
teleported
placeholder="选择筛选类型"
>
<el-option
v-for="opt in PRODUCT_RISK_LISTING_FILTER_OPTIONS"
:key="opt.value"
:label="opt.label"
:value="opt.value"
/>
</el-select>
</div>
<div class="run-row">
<button type="button" class="btn-run" :disabled="matching" @click="runMatch">
{{ matching ? '匹配中' : '匹配店铺' }}
@@ -271,7 +289,16 @@ const COUNTRY_OPTIONS = [
{ code: 'ES', label: '西班牙' },
] as const
/** 与 Python 约定:队列 payload.data.risk_listing_filter */
const PRODUCT_RISK_LISTING_FILTER_OPTIONS = [
{ value: 'SearchSuppressed', label: '在搜索结果中禁止显示' },
{ value: 'ApprovalRequired', label: '需要批准' },
] as const
type ProductRiskListingFilter = (typeof PRODUCT_RISK_LISTING_FILTER_OPTIONS)[number]['value']
const orderedCountryCodes = ref<string[]>(['DE', 'UK', 'FR', 'IT', 'ES'])
const productRiskListingFilter = ref<ProductRiskListingFilter>('SearchSuppressed')
const dragCountryIndex = ref<number | null>(null)
const countryPrefSaving = ref(false)
/** 用户已改过顺序/勾选后,忽略晚到的 GET避免把界面打回全选 */
@@ -928,6 +955,7 @@ async function pushToPythonQueue() {
taskId: created.taskId,
items: [item],
country_codes: [...orderedCountryCodes.value],
risk_listing_filter: productRiskListingFilter.value,
},
}
queuePayloadText.value = JSON.stringify(payload, null, 2)
@@ -1112,6 +1140,28 @@ onUnmounted(() => {
margin-bottom: 10px;
}
.listing-filter-hint {
margin-top: -4px;
}
.listing-filter-row {
margin-bottom: 16px;
}
.listing-filter-select {
width: 100%;
}
.listing-filter-row :deep(.el-select__wrapper) {
background-color: #2a2a2a;
box-shadow: 0 0 0 1px #3a3a3a inset;
}
.listing-filter-row :deep(.el-select__placeholder),
.listing-filter-row :deep(.el-select__selected-item) {
color: #ccc;
}
.input-row {
display: flex;
gap: 10px;