环境搭建配置
This commit is contained in:
@@ -1,149 +1,24 @@
|
||||
export interface SplitExcelPayload {
|
||||
paths: string[]
|
||||
selected_columns: string[]
|
||||
split_mode: 'rows_per_file' | 'parts'
|
||||
rows_per_file?: number
|
||||
parts?: number
|
||||
output_dir?: string
|
||||
}
|
||||
|
||||
export interface SplitExcelResultItem {
|
||||
result_id?: number
|
||||
source_path: string
|
||||
output_path?: string
|
||||
success: boolean
|
||||
error?: string
|
||||
row_count?: number
|
||||
}
|
||||
|
||||
export interface SplitExcelSummary {
|
||||
total: number
|
||||
success_count: number
|
||||
failed_count: number
|
||||
output_dir?: string
|
||||
}
|
||||
|
||||
export interface SplitExcelResponse {
|
||||
success: boolean
|
||||
summary?: SplitExcelSummary
|
||||
items?: SplitExcelResultItem[]
|
||||
error?: string
|
||||
}
|
||||
|
||||
export interface ExcelInfoResponse {
|
||||
success: boolean
|
||||
headers?: string[]
|
||||
total_rows?: number
|
||||
error?: string
|
||||
}
|
||||
|
||||
export interface CleanExcelPayload {
|
||||
paths: string[]
|
||||
selected_columns: string[]
|
||||
keep_integer_ids?: boolean
|
||||
keep_underscore_ids?: boolean
|
||||
output_dir?: string
|
||||
}
|
||||
|
||||
export interface CleanExcelResultItem {
|
||||
result_id?: number
|
||||
source_path: string
|
||||
output_path?: string
|
||||
success: boolean
|
||||
error?: string
|
||||
}
|
||||
|
||||
export interface ConvertTxtPayload {
|
||||
paths: string[]
|
||||
output_dir?: string
|
||||
template_id: string
|
||||
}
|
||||
|
||||
export interface ConvertTxtTemplateItem {
|
||||
id: string
|
||||
label: string
|
||||
output_filename: string
|
||||
is_default?: boolean
|
||||
built_in?: boolean
|
||||
}
|
||||
|
||||
export interface ConvertTxtResultItem {
|
||||
result_id?: number
|
||||
source_path: string
|
||||
output_path?: string
|
||||
success: boolean
|
||||
error?: string
|
||||
}
|
||||
|
||||
export interface ConvertTxtSummary {
|
||||
total: number
|
||||
success_count: number
|
||||
failed_count: number
|
||||
output_dir?: string
|
||||
}
|
||||
|
||||
export interface ConvertTxtResponse {
|
||||
success: boolean
|
||||
summary?: ConvertTxtSummary
|
||||
items?: ConvertTxtResultItem[]
|
||||
error?: string
|
||||
}
|
||||
|
||||
export interface CleanExcelSummary {
|
||||
total: number
|
||||
success_count: number
|
||||
failed_count: number
|
||||
output_dir?: string
|
||||
}
|
||||
|
||||
export interface CleanExcelResponse {
|
||||
success: boolean
|
||||
summary?: CleanExcelSummary
|
||||
items?: CleanExcelResultItem[]
|
||||
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 UploadedJavaFile {
|
||||
fileKey: string
|
||||
originalFilename: string
|
||||
localPath: string
|
||||
size: number
|
||||
}
|
||||
|
||||
export interface PywebviewApi {
|
||||
select_brand_xlsx_files?: () => Promise<string[]>
|
||||
select_clean_xlsx_files?: () => Promise<string[]>
|
||||
select_brand_folder?: () => Promise<string | null>
|
||||
select_clean_folder?: () => Promise<string | null>
|
||||
close?: () => Promise<void>
|
||||
minimize?: () => Promise<void>
|
||||
maximize?: () => Promise<void>
|
||||
toggle_maximize?: () => Promise<void>
|
||||
save_image?: (urlOrData: string, filename?: string) => Promise<{ success: boolean; path?: string; error?: string }>
|
||||
save_image_to_folder?: (urlOrData: string, dirPath: string, filename?: string) => Promise<{ success: boolean; path?: string; error?: string }>
|
||||
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 }>
|
||||
select_brand_xlsx_files?: () => Promise<string[]>
|
||||
select_brand_folder?: () => Promise<string | null>
|
||||
upload_file_to_java?: (filePath: string) => Promise<{ success: boolean; message?: string; data?: UploadedJavaFile; error?: string }>
|
||||
save_file_from_url?: (url: string, filename: string) => Promise<{ success: boolean; path?: string; error?: string }>
|
||||
save_template_xlsx?: () => Promise<{ success: boolean; path?: string; error?: string }>
|
||||
save_template_zip?: () => Promise<{ success: boolean; path?: string; error?: string }>
|
||||
save_file_from_url?: (url: string, filename: string) => Promise<{ success: boolean; path?: string; error?: string }>
|
||||
}
|
||||
|
||||
declare global {
|
||||
@@ -154,8 +29,26 @@ declare global {
|
||||
}
|
||||
}
|
||||
|
||||
let cachedPywebviewApi: PywebviewApi | undefined
|
||||
let pywebviewReadyBound = false
|
||||
|
||||
function syncPywebviewApi() {
|
||||
cachedPywebviewApi = window.pywebview?.api
|
||||
return cachedPywebviewApi
|
||||
}
|
||||
|
||||
function bindPywebviewReady() {
|
||||
if (pywebviewReadyBound || typeof window === 'undefined' || !window.addEventListener) return
|
||||
pywebviewReadyBound = true
|
||||
window.addEventListener('pywebviewready', () => {
|
||||
syncPywebviewApi()
|
||||
})
|
||||
}
|
||||
|
||||
bindPywebviewReady()
|
||||
|
||||
export function getPywebviewApi() {
|
||||
return window.pywebview?.api
|
||||
return syncPywebviewApi() || cachedPywebviewApi
|
||||
}
|
||||
|
||||
export function hasPywebview() {
|
||||
|
||||
Reference in New Issue
Block a user