完成新需求

This commit is contained in:
super
2026-03-20 14:26:34 +08:00
parent 43d508f527
commit 92d3fc965b
71 changed files with 3265 additions and 540 deletions

View File

@@ -41,13 +41,23 @@
:class="{ active: convertTemplateId === template.id }"
>
<input v-model="convertTemplateId" type="radio" :value="template.id" name="convert-template" />
<div>
<span class="label">
{{ template.label }}
<span v-if="template.is_default" class="template-tag">默认</span>
<span v-else-if="template.built_in" class="template-tag muted">内置</span>
</span>
<div class="desc">输出文件{{ template.output_filename }}</div>
<div class="template-item-content">
<div>
<span class="label">
{{ template.label }}
<span v-if="template.is_default" class="template-tag">默认</span>
<span v-else-if="template.built_in" class="template-tag muted">内置</span>
</span>
<div class="desc">输出文件{{ template.output_filename }}</div>
</div>
<button
v-if="!template.built_in"
type="button"
class="template-delete-btn"
@click.stop.prevent="deleteConvertTemplate(template.id)"
>
删除
</button>
</div>
</label>
</div>
@@ -81,7 +91,7 @@
{{ convertRunning ? '转换中...' : '开始转换' }}
</button>
<span class="loading-msg">
{{ convertRunning ? '正在生成英国.txt,请稍候…' : '选择文件后即可执行格式转换' }}
{{ convertRunning ? '正在生成并上传结果,请稍候…' : '选择文件后即可执行格式转换,结果会显示在右侧供下载' }}
</span>
</div>
</aside>
@@ -108,9 +118,6 @@
<div class="result-list-wrap">
<div class="result-list-header">
<span>生成的 txt 列表</span>
<button type="button" class="download-all" :disabled="!convertOutputDir" @click="openConvertOutputDir">
打开输出目录
</button>
</div>
<div v-if="convertResultItems.length === 0" class="empty-tasks">
@@ -120,12 +127,12 @@
<ul v-else class="task-list clean-result-list">
<li
v-for="item in convertResultItems"
:key="`${item.source_path}-${item.output_path || item.error || 'convert'}`"
:key="`${item.output_path || item.source_path || item.error || 'convert'}`"
class="task-item"
>
<div class="left">
<span class="id" :title="item.source_path">{{ shorten(item.source_path, 42) }}</span>
<div v-if="item.output_path" class="files">输出文件{{ item.output_path }}</div>
<span class="id" :title="item.source_path">{{ item.source_path || '-' }}</span>
<div v-if="item.output_path" class="files">结果下载地址已生成</div>
<div v-else-if="item.error" class="files">错误信息{{ item.error }}</div>
</div>
@@ -137,9 +144,17 @@
v-if="item.success && item.output_path"
type="button"
class="download"
@click="openConvertResult(item)"
@click="downloadConvertResult(item)"
>
打开文件
下载文件
</button>
<button
v-if="item.result_id"
type="button"
class="btn-delete"
@click="deleteConvertHistory(item.result_id)"
>
删除
</button>
</div>
</li>
@@ -175,7 +190,6 @@ function shorten(value: string, maxLength: number) {
}
function resetConvertResults() {
convertResultItems.value = []
convertSummary.value = { total: 0, success_count: 0, failed_count: 0 }
convertOutputDir.value = ''
}
@@ -217,6 +231,26 @@ async function importConvertTemplate() {
ElMessage.success('模板导入成功')
}
async function deleteConvertTemplate(templateId: string) {
const api = getPywebviewApi()
if (!api?.delete_txt_template) {
ElMessage.warning('当前环境不支持删除模板')
return
}
const result = await api.delete_txt_template(templateId)
if (!result.success) {
ElMessage.error(result.error || '删除模板失败')
return
}
if (convertTemplateId.value === templateId) {
convertTemplateId.value = ''
}
await loadConvertTemplates()
ElMessage.success('模板已删除')
}
async function setConvertDefaultTemplate() {
const api = getPywebviewApi()
if (!api?.set_default_txt_template || !convertTemplateId.value) {
@@ -279,7 +313,7 @@ async function selectConvertFolder() {
async function submitConvertRun() {
const api = getPywebviewApi()
if (!api?.convert_excel_to_uk_txt || !api?.select_folder) {
if (!api?.convert_excel_to_uk_txt) {
ElMessage.warning('当前环境不支持格式转换,请在桌面端打开')
return
}
@@ -289,13 +323,9 @@ async function submitConvertRun() {
}
try {
const outputDir = await api.select_folder()
if (!outputDir) return
convertRunning.value = true
const result = await api.convert_excel_to_uk_txt({
paths: convertSelectedPaths.value,
output_dir: outputDir,
template_id: convertTemplateId.value,
})
@@ -304,13 +334,13 @@ async function submitConvertRun() {
return
}
convertOutputDir.value = result.summary?.output_dir || outputDir
convertOutputDir.value = ''
convertSummary.value = {
total: result.summary?.total || 0,
success_count: result.summary?.success_count || 0,
failed_count: result.summary?.failed_count || 0,
}
convertResultItems.value = result.items || []
await loadConvertHistory()
ElMessage.success('格式转换完成')
} catch (error) {
ElMessage.error(error instanceof Error ? error.message : '格式转换失败')
@@ -319,34 +349,68 @@ async function submitConvertRun() {
}
}
async function openConvertOutputDir() {
async function deleteConvertHistory(resultId: number) {
const api = getPywebviewApi()
if (!api?.open_path || !convertOutputDir.value) {
ElMessage.warning('当前环境不支持打开输出目录')
if (!api?.delete_history_item) {
ElMessage.warning('当前环境不支持删除历史')
return
}
const result = await api.open_path(convertOutputDir.value)
const result = await api.delete_history_item('convert', resultId)
if (!result.success) {
ElMessage.error(result.error || '打开目录失败')
ElMessage.error(result.error || '删除失败')
return
}
await loadConvertHistory()
ElMessage.success('已删除')
}
async function openConvertResult(item: ConvertTxtResultItem) {
async function downloadConvertResult(item: ConvertTxtResultItem) {
const api = getPywebviewApi()
if (!api?.open_path || !item.output_path) {
ElMessage.warning('当前环境不支持打开结果文件')
if (!item.output_path) {
ElMessage.warning('当前结果没有下载地址')
return
}
const result = await api.open_path(item.output_path)
if (!result.success) {
ElMessage.error(result.error || '打开文件失败')
const today = new Date()
const yyyy = String(today.getFullYear())
const mm = String(today.getMonth() + 1).padStart(2, '0')
const dd = String(today.getDate()).padStart(2, '0')
const filename = `${yyyy}${mm}${dd}.txt`
if (api?.save_file_from_url) {
const result = await api.save_file_from_url(item.output_path, filename)
if (result.success) {
ElMessage.success(`已保存:${result.path || filename}`)
} else if (result.error && result.error !== '用户取消') {
ElMessage.error(result.error)
}
return
}
window.open(item.output_path, '_blank')
}
async function loadConvertHistory() {
const api = getPywebviewApi()
if (!api?.get_convert_history) return
try {
const response = await api.get_convert_history()
if (!response.success || !response.items) return
convertResultItems.value = response.items
convertSummary.value = {
total: response.items.length,
success_count: response.items.filter((item) => item.success).length,
failed_count: response.items.filter((item) => !item.success).length,
}
} catch {
// ignore history load errors
}
}
onMounted(() => {
loadConvertTemplates().catch(() => undefined)
loadConvertHistory().catch(() => undefined)
})
</script>
@@ -374,7 +438,10 @@ onMounted(() => {
.template-tag { margin-left: 8px; padding: 2px 8px; border-radius: 999px; font-size: 11px; color: #8fd0ff; background: rgba(52, 152, 219, 0.14); }
.template-tag.muted { color: #b8b8b8; background: rgba(255, 255, 255, 0.08); }
.compact-row { margin-top: 4px; }
.radio-item { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; padding: 10px 12px; border-radius: 8px; background: #252525; border: 1px solid #2a2a2a; margin-bottom: 8px; transition: all 0.2s ease; }
.radio-item { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; padding: 10px 12px; border-radius: 8px; background: #252525; border: 1px solid #2a2a2a; margin-bottom: 8px; transition: all 0.2s ease; }
.template-item-content { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; }
.template-delete-btn { padding: 6px 10px; border: 1px solid #5c2f2f; border-radius: 6px; background: rgba(231, 76, 60, 0.12); color: #ff8f8f; font-size: 12px; cursor: pointer; }
.template-delete-btn:hover { background: rgba(231, 76, 60, 0.2); }
.radio-item:hover, .radio-item.active { background: #2a2a2a; border-color: #3a3a3a; }
.radio-item input { margin-top: 3px; }
.label { font-weight: 500; color: #e0e0e0; font-size: 13px; }

View File

@@ -79,7 +79,7 @@
{{ cleanRunning ? '清洗中...' : '开始清洗' }}
</button>
<span class="loading-msg">
{{ cleanRunning ? '正在处理文件,请稍候…' : '选择文件、列和 ID 规则后即可执行本地清洗' }}
{{ cleanRunning ? '正在处理文件并上传结果,请稍候…' : '选择文件、列和 ID 规则后即可执行清洗,结果会显示在右侧供下载' }}
</span>
</div>
</aside>
@@ -106,9 +106,6 @@
<div class="result-list-wrap">
<div class="result-list-header">
<span>处理后的 Excel 列表</span>
<button type="button" class="download-all" :disabled="!cleanOutputDir" @click="openCleanOutputDir">
打开输出目录
</button>
</div>
<div v-if="cleanResultItems.length === 0" class="empty-tasks">
@@ -118,8 +115,8 @@
<ul v-else class="task-list clean-result-list">
<li v-for="item in cleanResultItems" :key="`${item.source_path}-${item.output_path || item.error || 'result'}`" class="task-item">
<div class="left">
<span class="id" :title="item.source_path">{{ shorten(item.source_path, 42) }}</span>
<div v-if="item.output_path" class="files">输出文件{{ item.output_path }}</div>
<span class="id" :title="item.source_path">{{ item.source_path || '-' }}</span>
<div v-if="item.output_path" class="files">结果下载地址已生成</div>
<div v-else-if="item.error" class="files">错误信息{{ item.error }}</div>
</div>
@@ -131,9 +128,17 @@
v-if="item.success && item.output_path"
type="button"
class="download"
@click="openCleanResult(item)"
@click="downloadCleanResult(item)"
>
打开文件
下载文件
</button>
<button
v-if="item.result_id"
type="button"
class="btn-delete"
@click="deleteCleanHistory(item.result_id)"
>
删除
</button>
</div>
</li>
@@ -145,7 +150,7 @@
</template>
<script setup lang="ts">
import { computed, ref } from 'vue'
import { computed, onMounted, ref } from 'vue'
import { ElMessage } from 'element-plus'
import { expandBrandFolder } from '@/shared/api/brand'
import { type CleanExcelResultItem, getPywebviewApi, hasPywebview } from '@/shared/bridges/pywebview'
@@ -181,7 +186,6 @@ async function loadCleanHeaders(filePath: string) {
return
}
cleanResultItems.value = []
cleanSummary.value = { total: 0, success_count: 0, failed_count: 0 }
cleanOutputDir.value = ''
@@ -248,7 +252,7 @@ async function selectCleanFolder() {
async function submitCleanRun() {
const api = getPywebviewApi()
if (!api?.clean_excel_files || !api?.select_folder) {
if (!api?.clean_excel_files) {
ElMessage.warning('当前环境不支持数据去重,请在桌面端打开')
return
}
@@ -266,16 +270,12 @@ async function submitCleanRun() {
}
try {
const outputDir = await api.select_folder()
if (!outputDir) return
cleanRunning.value = true
const result = await api.clean_excel_files({
paths: cleanSelectedPaths.value,
selected_columns: cleanSelectedColumns.value,
keep_integer_ids: cleanKeepIntegerIds.value,
keep_underscore_ids: cleanKeepUnderscoreIds.value,
output_dir: outputDir,
})
if (!result.success) {
@@ -283,13 +283,13 @@ async function submitCleanRun() {
return
}
cleanOutputDir.value = result.summary?.output_dir || outputDir
cleanOutputDir.value = ''
cleanSummary.value = {
total: result.summary?.total || 0,
success_count: result.summary?.success_count || 0,
failed_count: result.summary?.failed_count || 0,
}
cleanResultItems.value = result.items || []
await loadCleanHistory()
ElMessage.success('数据去重完成')
} catch (error) {
ElMessage.error(error instanceof Error ? error.message : '去重失败')
@@ -298,30 +298,69 @@ async function submitCleanRun() {
}
}
async function openCleanOutputDir() {
onMounted(() => {
loadCleanHistory().catch(() => undefined)
})
async function loadCleanHistory() {
const api = getPywebviewApi()
if (!api?.open_path || !cleanOutputDir.value) {
ElMessage.warning('当前环境不支持打开输出目录')
if (!api?.get_dedupe_history) {
return
}
const result = await api.open_path(cleanOutputDir.value)
if (!result.success) {
ElMessage.error(result.error || '打开目录失败')
try {
const response = await api.get_dedupe_history()
if (!response.success || !response.items) return
cleanResultItems.value = response.items
cleanSummary.value = {
total: response.items.length,
success_count: response.items.filter((item) => item.success).length,
failed_count: response.items.filter((item) => !item.success).length,
}
} catch {
// ignore history load errors
}
}
async function openCleanResult(item: CleanExcelResultItem) {
async function deleteCleanHistory(resultId: number) {
const api = getPywebviewApi()
if (!api?.open_path || !item.output_path) {
ElMessage.warning('当前环境不支持打开结果文件')
if (!api?.delete_history_item) {
ElMessage.warning('当前环境不支持删除历史')
return
}
const result = await api.open_path(item.output_path)
const result = await api.delete_history_item('dedupe', resultId)
if (!result.success) {
ElMessage.error(result.error || '打开文件失败')
ElMessage.error(result.error || '删除失败')
return
}
await loadCleanHistory()
ElMessage.success('已删除')
}
async function downloadCleanResult(item: CleanExcelResultItem) {
const api = getPywebviewApi()
if (!item.output_path) {
ElMessage.warning('当前结果没有下载地址')
return
}
const today = new Date()
const yyyy = String(today.getFullYear())
const mm = String(today.getMonth() + 1).padStart(2, '0')
const dd = String(today.getDate()).padStart(2, '0')
const filename = `${yyyy}${mm}${dd}_cleaned.xlsx`
if (api?.save_file_from_url) {
const result = await api.save_file_from_url(item.output_path, filename)
if (result.success) {
ElMessage.success(`已保存:${result.path || filename}`)
} else if (result.error && result.error !== '用户取消') {
ElMessage.error(result.error)
}
return
}
window.open(item.output_path, '_blank')
}
</script>

View File

@@ -90,7 +90,7 @@
{{ splitRunning ? '拆分中...' : '开始拆分' }}
</button>
<span class="loading-msg">
{{ splitRunning ? '正在拆分文件,请稍候…' : '选择文件、保留列和拆分规则后即可执行本地拆分' }}
{{ splitRunning ? '正在拆分并上传结果,请稍候…' : '选择文件、保留列和拆分规则后即可执行拆分,结果会显示在右侧供下载' }}
</span>
</div>
</aside>
@@ -116,9 +116,6 @@
<div class="result-list-wrap">
<div class="result-list-header">
<span>拆分后的 Excel 列表</span>
<button type="button" class="download-all" :disabled="!splitOutputDir" @click="openSplitOutputDir">
打开输出目录
</button>
</div>
<div v-if="splitResultItems.length === 0" class="empty-tasks">
@@ -128,8 +125,8 @@
<ul v-else class="task-list clean-result-list">
<li v-for="item in splitResultItems" :key="`${item.output_path || item.source_path}-${item.row_count || 0}`" class="task-item">
<div class="left">
<span class="id" :title="item.source_path">{{ shorten(item.source_path, 42) }}</span>
<div v-if="item.output_path" class="files">输出文件{{ item.output_path }}</div>
<span class="id" :title="item.source_path">{{ item.source_path || '-' }}</span>
<div v-if="item.output_path" class="files">结果下载地址已生成</div>
<div v-if="item.row_count !== undefined" class="time">包含 {{ item.row_count }} 条数据</div>
<div v-else-if="item.error" class="files">错误信息{{ item.error }}</div>
</div>
@@ -142,9 +139,17 @@
v-if="item.success && item.output_path"
type="button"
class="download"
@click="openSplitResult(item)"
@click="downloadSplitResult(item)"
>
打开文件
下载文件
</button>
<button
v-if="item.result_id"
type="button"
class="btn-delete"
@click="deleteSplitHistory(item.result_id)"
>
删除
</button>
</div>
</li>
@@ -156,7 +161,7 @@
</template>
<script setup lang="ts">
import { computed, ref } from 'vue'
import { computed, onMounted, ref } from 'vue'
import { ElMessage } from 'element-plus'
import { expandBrandFolder } from '@/shared/api/brand'
import { type SplitExcelResultItem, getPywebviewApi, hasPywebview } from '@/shared/bridges/pywebview'
@@ -179,7 +184,6 @@ function shorten(value: string, maxLength: number) {
}
function resetSplitResults() {
splitResultItems.value = []
splitSummary.value = { total: 0, success_count: 0, failed_count: 0 }
splitOutputDir.value = ''
}
@@ -251,7 +255,7 @@ async function selectSplitFolder() {
async function submitSplitRun() {
const api = getPywebviewApi()
if (!api?.split_excel_files || !api?.select_folder) {
if (!api?.split_excel_files) {
ElMessage.warning('当前环境不支持数据拆分,请在桌面端打开')
return
}
@@ -273,9 +277,6 @@ async function submitSplitRun() {
}
try {
const outputDir = await api.select_folder()
if (!outputDir) return
splitRunning.value = true
const result = await api.split_excel_files({
paths: splitSelectedPaths.value,
@@ -283,7 +284,6 @@ async function submitSplitRun() {
split_mode: splitMode.value,
rows_per_file: splitRowsPerFile.value || undefined,
parts: splitParts.value || undefined,
output_dir: outputDir,
})
if (!result.success) {
@@ -291,13 +291,13 @@ async function submitSplitRun() {
return
}
splitOutputDir.value = result.summary?.output_dir || outputDir
splitOutputDir.value = ''
splitSummary.value = {
total: result.summary?.total || 0,
success_count: result.summary?.success_count || 0,
failed_count: result.summary?.failed_count || 0,
}
splitResultItems.value = result.items || []
await loadSplitHistory()
ElMessage.success('数据拆分完成')
} catch (error) {
ElMessage.error(error instanceof Error ? error.message : '数据拆分失败')
@@ -306,30 +306,67 @@ async function submitSplitRun() {
}
}
async function openSplitOutputDir() {
async function loadSplitHistory() {
const api = getPywebviewApi()
if (!api?.open_path || !splitOutputDir.value) {
ElMessage.warning('当前环境不支持打开输出目录')
return
}
if (!api?.get_split_history) return
const result = await api.open_path(splitOutputDir.value)
if (!result.success) {
ElMessage.error(result.error || '打开目录失败')
try {
const response = await api.get_split_history()
if (!response.success || !response.items) return
splitResultItems.value = response.items
splitSummary.value = {
total: response.items.length,
success_count: response.items.filter((item) => item.success).length,
failed_count: response.items.filter((item) => !item.success).length,
}
} catch {
// ignore history load errors
}
}
async function openSplitResult(item: SplitExcelResultItem) {
onMounted(() => {
loadSplitHistory().catch(() => undefined)
})
async function deleteSplitHistory(resultId: number) {
const api = getPywebviewApi()
if (!api?.open_path || !item.output_path) {
ElMessage.warning('当前环境不支持打开结果文件')
if (!api?.delete_history_item) {
ElMessage.warning('当前环境不支持删除历史')
return
}
const result = await api.open_path(item.output_path)
const result = await api.delete_history_item('split', resultId)
if (!result.success) {
ElMessage.error(result.error || '打开文件失败')
ElMessage.error(result.error || '删除失败')
return
}
await loadSplitHistory()
ElMessage.success('已删除')
}
async function downloadSplitResult(item: SplitExcelResultItem) {
const api = getPywebviewApi()
if (!item.output_path) {
ElMessage.warning('当前结果没有下载地址')
return
}
const today = new Date()
const yyyy = String(today.getFullYear())
const mm = String(today.getMonth() + 1).padStart(2, '0')
const dd = String(today.getDate()).padStart(2, '0')
const filename = `${yyyy}${mm}${dd}.xlsx`
if (api?.save_file_from_url) {
const result = await api.save_file_from_url(item.output_path, filename)
if (result.success) {
ElMessage.success(`已保存:${result.path || filename}`)
} else if (result.error && result.error !== '用户取消') {
ElMessage.error(result.error)
}
return
}
window.open(item.output_path, '_blank')
}
</script>

View File

@@ -3,42 +3,26 @@
<div class="brand-page">
<header class="top-bar">
<div class="logo-area">
<span class="app-name">南日AI-亚马逊</span>
<span class="app-name">数富AI-亚马逊</span>
<router-link to="/home" class="btn-home">返回首页</router-link>
</div>
<div class="nav-tabs">
<div class="nav-tab-group">
<button
type="button"
class="nav-tab"
:class="{ active: activeTab === 'brand' }"
@click="activeTab = 'brand'"
>
<button type="button" class="nav-tab" :class="{ active: activeTab === 'brand' }"
@click="activeTab = 'brand'">
品牌检测
</button>
<button
type="button"
class="nav-tab"
:class="{ active: activeTab === 'dedupe' }"
@click="activeTab = 'dedupe'"
>
<button type="button" class="nav-tab" :class="{ active: activeTab === 'dedupe' }"
@click="activeTab = 'dedupe'">
数据去重
</button>
<button
type="button"
class="nav-tab"
:class="{ active: activeTab === 'convert' }"
@click="activeTab = 'convert'"
>
<button type="button" class="nav-tab" :class="{ active: activeTab === 'convert' }"
@click="activeTab = 'convert'">
格式转换
</button>
<button
type="button"
class="nav-tab"
:class="{ active: activeTab === 'split' }"
@click="activeTab = 'split'"
>
<button type="button" class="nav-tab" :class="{ active: activeTab === 'split' }"
@click="activeTab = 'split'">
数据拆分
</button>
</div>
@@ -55,13 +39,8 @@
<button type="button" class="opt-btn" @click="selectFolder">选择文件夹</button>
</div>
<el-alert
v-if="!hasPywebviewSupport"
class="desktop-alert"
type="warning"
:closable="false"
title="当前环境未检测到 pywebview文件选择与本地保存能力需要在桌面端使用。"
/>
<el-alert v-if="!hasPywebviewSupport" class="desktop-alert" type="warning" :closable="false"
title="当前环境未检测到 pywebview文件选择与本地保存能力需要在桌面端使用。" />
<div class="selected-files">
<template v-if="selectedPaths.length">
@@ -117,12 +96,7 @@
{{ runMode === 'immediate' ? '立即运行' : '添加任务' }}
</button>
<span v-if="running" class="loading-msg">生成中请稍候</span>
<button
v-if="activeTaskId"
type="button"
class="btn-cancel-run"
@click="cancelActiveTask"
>
<button v-if="activeTaskId" type="button" class="btn-cancel-run" @click="cancelActiveTask">
取消生成
</button>
</div>
@@ -137,8 +111,10 @@
<button type="button" class="template-download-row" @click="downloadTemplateXlsx">
<span class="template-download-icon" aria-hidden="true">
<svg viewBox="0 0 24 24" fill="none">
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6z" stroke="rgba(255,255,255,0.92)" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" />
<path d="M14 2v6h6" stroke="rgba(255,255,255,0.92)" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" />
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6z"
stroke="rgba(255,255,255,0.92)" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" />
<path d="M14 2v6h6" stroke="rgba(255,255,255,0.92)" stroke-width="1.8" stroke-linecap="round"
stroke-linejoin="round" />
<path d="M8 13h8M8 17h5" stroke="rgba(255,255,255,0.86)" stroke-width="1.5" stroke-linecap="round" />
</svg>
</span>
@@ -151,9 +127,12 @@
<button type="button" class="template-download-row" @click="downloadTemplateZip">
<span class="template-download-icon" aria-hidden="true">
<svg viewBox="0 0 24 24" fill="none">
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6z" stroke="rgba(255,255,255,0.92)" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" />
<path d="M14 2v6h6" stroke="rgba(255,255,255,0.92)" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" />
<path d="M4 8h16M7 12h10M7 16h7" stroke="rgba(255,255,255,0.86)" stroke-width="1.5" stroke-linecap="round" />
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6z"
stroke="rgba(255,255,255,0.92)" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" />
<path d="M14 2v6h6" stroke="rgba(255,255,255,0.92)" stroke-width="1.8" stroke-linecap="round"
stroke-linejoin="round" />
<path d="M4 8h16M7 12h10M7 16h7" stroke="rgba(255,255,255,0.86)" stroke-width="1.5"
stroke-linecap="round" />
</svg>
</span>
<span class="template-download-text">
@@ -180,10 +159,7 @@
</div>
<div class="task-right">
<div
v-if="task.status === 'running' && (task.progress_total || 0) > 0"
class="inline-progress"
>
<div v-if="task.status === 'running' && (task.progress_total || 0) > 0" class="inline-progress">
<div class="progress-bar-bg small">
<div class="progress-bar-fill" :style="{ width: `${getTaskProgressPercent(task)}%` }"></div>
</div>
@@ -196,21 +172,13 @@
{{ getStatusLabel(task.status) }}
</span>
<button
v-if="task.status === 'running'"
type="button"
class="btn-cancel"
@click="cancelTask(task.id)"
>
<button v-if="task.status === 'running'" type="button" class="btn-cancel"
@click="cancelTask(task.id)">
取消
</button>
<button
v-if="task.result_paths?.zip_url"
type="button"
class="download"
@click="downloadTaskResult(task)"
>
<button v-if="task.result_paths?.zip_url" type="button" class="download"
@click="downloadTaskResult(task)">
下载结果
</button>
@@ -560,7 +528,7 @@ async function downloadTaskResult(task: BrandTaskItem) {
}
onMounted(() => {
document.title = '亚马逊 - 南日AI'
document.title = '亚马逊 - 数富AI'
loadTasks().catch(() => undefined)
taskRefreshTimer = window.setInterval(() => {
loadTasks().catch(() => undefined)

View File

@@ -2,7 +2,7 @@
<PageShell theme="light">
<div class="home-page">
<header class="home-header">
<div class="brand">南日AI</div>
<div class="brand">数富AI</div>
<div class="header-actions">
<span>{{ username }}</span>
<el-popover placement="bottom-end" :width="320" trigger="click">
@@ -14,12 +14,7 @@
<div class="update-version">当前版本: v{{ version }}</div>
<el-button type="primary" text :loading="loading" @click="check">检测更新</el-button>
<div class="update-hint">{{ hint }}</div>
<el-button
v-if="downloadVisible"
type="success"
:loading="downloadLoading"
@click="handleUpdate"
>
<el-button v-if="downloadVisible" type="success" :loading="downloadLoading" @click="handleUpdate">
立即更新
</el-button>
</div>

View File

@@ -3,7 +3,7 @@
<div class="image-page">
<header class="top-bar">
<div class="logo-area">
<span class="app-name">南日AI</span>
<span class="app-name">数富AI</span>
<router-link to="/home" class="btn-home">返回首页</router-link>
</div>
@@ -20,7 +20,7 @@
</template>
<script setup lang="ts">
document.title = '图片 - 南日AI'
document.title = '图片 - 数富AI'
</script>
<style scoped>

View File

@@ -1,32 +1,21 @@
<template>
<PageShell theme="light">
<div class="login-page">
<div class="login-header">南日AI</div>
<div class="login-header">数富AI</div>
<el-card class="login-card" shadow="never">
<template #header>
<div class="login-title">登录</div>
</template>
<el-alert
v-if="errorMessage"
:title="errorMessage"
type="error"
:closable="false"
class="login-alert"
/>
<el-alert v-if="errorMessage" :title="errorMessage" type="error" :closable="false" class="login-alert" />
<el-form label-width="72px" @submit.prevent="handleSubmit">
<el-form-item label="用户名">
<el-input v-model="form.username" placeholder="请输入用户名" autofocus />
</el-form-item>
<el-form-item label="密码">
<el-input
v-model="form.password"
type="password"
show-password
placeholder="请输入密码"
@keydown.enter="handleSubmit"
/>
<el-input v-model="form.password" type="password" show-password placeholder="请输入密码"
@keydown.enter="handleSubmit" />
</el-form-item>
<el-button type="primary" :loading="submitting" class="login-button" @click="handleSubmit">
登录

View File

@@ -8,27 +8,27 @@ const routes = [
{
path: '/login',
component: () => import('@/pages/login/index.vue'),
meta: { title: '登录 - 南日AI' },
meta: { title: '登录 - 数富AI' },
},
{
path: '/home',
component: () => import('@/pages/home/index.vue'),
meta: { title: '首页 - 南日AI' },
meta: { title: '首页 - 数富AI' },
},
{
path: '/brand',
component: () => import('@/pages/brand/index.vue'),
meta: { title: '亚马逊 - 南日AI' },
meta: { title: '亚马逊 - 数富AI' },
},
{
path: '/admin',
component: () => import('@/pages/admin/index.vue'),
meta: { title: '管理后台 - 南日AI' },
meta: { title: '管理后台 - 数富AI' },
},
{
path: '/image',
component: () => import('@/pages/image/index.vue'),
meta: { title: '图片 - 南日AI' },
meta: { title: '图片 - 数富AI' },
},
]

View File

@@ -0,0 +1,63 @@
import { requestGetJson, requestPostJson } from '@/shared/api/http'
export interface UploadFileVo {
fileKey: string
originalFilename?: string
localPath?: string
size?: number
}
export interface ConvertTemplateVo {
id: number
templateCode: string
templateName: string
outputFilename: string
isDefault?: boolean
builtIn?: boolean
}
export interface UploadedSourceFileDto {
fileKey: string
originalFilename?: string
}
export interface ConvertResultItemVo {
resultId?: number
sourceFilename?: string
outputFilename?: string
success: boolean
error?: string
downloadUrl?: string
}
export interface ConvertRunVo {
total: number
successCount: number
failedCount: number
items: ConvertResultItemVo[]
}
export interface StandardApiResponse<T> {
success: boolean
message?: string
data?: T
}
export function getConvertTemplates() {
return requestGetJson<StandardApiResponse<ConvertTemplateVo[]>>('/api/convert/templates')
}
export function uploadTempFile(file: File) {
const formData = new FormData()
formData.append('file', file)
return requestPostJson<StandardApiResponse<UploadFileVo>, FormData>('/api/files/upload', formData, {
headers: { 'Content-Type': 'multipart/form-data' },
})
}
export function runConvert(files: UploadedSourceFileDto[], templateId: number) {
return requestPostJson<StandardApiResponse<ConvertRunVo>>('/api/convert/run', {
files,
templateId,
})
}

View File

@@ -0,0 +1,22 @@
import { requestGetJson } from '@/shared/api/http'
export interface DedupeHistoryItem {
sourceFilename?: string
outputFilename?: string
downloadUrl?: string
success: boolean
}
export interface DedupeHistoryVo {
items: DedupeHistoryItem[]
}
export interface StandardApiResponse<T> {
success: boolean
message?: string
data?: T
}
export function getDedupeHistory() {
return requestGetJson<StandardApiResponse<DedupeHistoryVo>>('/api/dedupe/history')
}

View File

@@ -8,6 +8,7 @@ export interface SplitExcelPayload {
}
export interface SplitExcelResultItem {
result_id?: number
source_path: string
output_path?: string
success: boolean
@@ -37,6 +38,7 @@ export interface ExcelInfoResponse {
}
export interface CleanExcelResultItem {
result_id?: number
source_path: string
output_path?: string
success: boolean
@@ -58,6 +60,7 @@ export interface ConvertTxtTemplateItem {
}
export interface ConvertTxtResultItem {
result_id?: number
source_path: string
output_path?: string
success: boolean
@@ -92,6 +95,24 @@ export interface CleanExcelResponse {
error?: string
}
export interface ConvertTxtHistoryResponse {
success: boolean
items?: ConvertTxtResultItem[]
error?: string
}
export interface SplitExcelHistoryResponse {
success: boolean
items?: SplitExcelResultItem[]
error?: string
}
export interface CleanExcelHistoryResponse {
success: boolean
items?: CleanExcelResultItem[]
error?: string
}
export interface PywebviewApi {
select_brand_xlsx_files?: () => Promise<string[]>
select_clean_xlsx_files?: () => Promise<string[]>
@@ -99,12 +120,17 @@ export interface PywebviewApi {
select_clean_folder?: () => Promise<string | null>
select_folder?: () => Promise<string | null>
get_excel_headers?: (filePath: string) => Promise<{ success: boolean; headers?: string[]; error?: string }>
get_dedupe_history?: () => Promise<CleanExcelHistoryResponse>
get_convert_history?: () => Promise<ConvertTxtHistoryResponse>
get_split_history?: () => Promise<SplitExcelHistoryResponse>
delete_history_item?: (moduleType: string, resultId: number) => Promise<{ success: boolean; error?: string }>
get_excel_info?: (filePath: string) => Promise<ExcelInfoResponse>
clean_excel_files?: (payload: CleanExcelPayload) => Promise<CleanExcelResponse>
split_excel_files?: (payload: SplitExcelPayload) => Promise<SplitExcelResponse>
list_txt_templates?: () => Promise<ConvertTxtTemplateItem[]>
import_txt_template?: (name?: string) => Promise<{ success: boolean; template?: ConvertTxtTemplateItem; error?: string }>
set_default_txt_template?: (templateId: string) => Promise<{ success: boolean; error?: string }>
delete_txt_template?: (templateId: string) => Promise<{ success: boolean; error?: string }>
convert_excel_to_uk_txt?: (payload: ConvertTxtPayload) => Promise<ConvertTxtResponse>
open_path?: (path: string) => Promise<{ success: boolean; error?: string }>
save_template_xlsx?: () => Promise<{ success: boolean; path?: string; error?: string }>