diff --git a/scripts/setup.py b/scripts/setup.py index 37a853f..ccb0127 100644 --- a/scripts/setup.py +++ b/scripts/setup.py @@ -1,12 +1,6 @@ from fastapi import FastAPI from scripts.api import baidu_netdisk_api, send_img_path, AutoUpload from modules import script_callbacks, generation_parameters_copypaste as send, extras -from scripts.bin import ( - bin_file_name, - get_matched_summary, - check_bin_exists, - download_bin_file, -) from scripts.tool import cwd, debounce from PIL import Image from scripts.logger import logger @@ -16,28 +10,12 @@ from scripts.logger import logger api函数声明和启动分离方便另外一边被外部调用 """ -not_exists_msg = ( - f"找不到{bin_file_name},尝试手动从 {get_matched_summary()[1]} 或者 {get_matched_summary()[2]} 下载,下载后放到 {cwd} 文件夹下,重启界面" -) def on_ui_tabs(): import gradio as gr - - exists = check_bin_exists() - if not exists: - try: - print("缺少必要的二进制文件,开始下载") - download_bin_file() - print("done") - except Exception as e: - print("下载二进制文件时出错:", str(e)) - exists = check_bin_exists() - if not exists: - print(f"\033[31m{not_exists_msg}\033[0m") with gr.Blocks(analytics_enabled=False) as baidu_netdisk: - gr.Textbox(not_exists_msg, visible=not exists) - with gr.Row(visible=bool(exists)): + with gr.Row(): with gr.Column(): gr.HTML( "如果你看到这个那说明此项那说明出现了问题", elem_id="baidu_netdisk_container_wrapper" diff --git a/vue/components.d.ts b/vue/components.d.ts index f70d5dd..e996dee 100644 --- a/vue/components.d.ts +++ b/vue/components.d.ts @@ -18,6 +18,7 @@ declare module '@vue/runtime-core' { AFormItem: typeof import('ant-design-vue/es')['FormItem'] AImage: typeof import('ant-design-vue/es')['Image'] AInput: typeof import('ant-design-vue/es')['Input'] + AInputNumber: typeof import('ant-design-vue/es')['InputNumber'] AMenu: typeof import('ant-design-vue/es')['Menu'] AMenuItem: typeof import('ant-design-vue/es')['MenuItem'] AModal: typeof import('ant-design-vue/es')['Modal'] @@ -26,6 +27,7 @@ declare module '@vue/runtime-core' { ASelect: typeof import('ant-design-vue/es')['Select'] ASkeleton: typeof import('ant-design-vue/es')['Skeleton'] AStatistic: typeof import('ant-design-vue/es')['Statistic'] + ASwitch: typeof import('ant-design-vue/es')['Switch'] ATabPane: typeof import('ant-design-vue/es')['TabPane'] ATabs: typeof import('ant-design-vue/es')['Tabs'] ATag: typeof import('ant-design-vue/es')['Tag'] diff --git a/vue/src/App.vue b/vue/src/App.vue index ef4051c..edf1b60 100644 --- a/vue/src/App.vue +++ b/vue/src/App.vue @@ -1,123 +1,32 @@ \ No newline at end of file diff --git a/vue/src/SplitViewTab/SplitViewTab.vue b/vue/src/SplitViewTab/SplitViewTab.vue index d3eccee..0b6ad0c 100644 --- a/vue/src/SplitViewTab/SplitViewTab.vue +++ b/vue/src/SplitViewTab/SplitViewTab.vue @@ -15,7 +15,8 @@ const compMap: Record> netdisk: defineAsyncComponent(() => import('@/fileTransfer/stackView.vue')), "task-record": defineAsyncComponent(() => import('@/taskRecord/taskRecord.vue')), empty: defineAsyncComponent(() => import('./emptyStartup.vue')), - "log-detail": defineAsyncComponent(() => import('@/taskRecord/logDetail.vue')) + "log-detail": defineAsyncComponent(() => import('@/taskRecord/logDetail.vue')), + "global-setting": defineAsyncComponent(() => import('@/page/globalSetting.vue')) } const onEdit = (idx: number, targetKey: any, action: string) => { const tab = global.tabList[idx] diff --git a/vue/src/SplitViewTab/emptyStartup.vue b/vue/src/SplitViewTab/emptyStartup.vue index 4f10a3a..1eac718 100644 --- a/vue/src/SplitViewTab/emptyStartup.vue +++ b/vue/src/SplitViewTab/emptyStartup.vue @@ -12,7 +12,8 @@ const compCnMap: Partial> = { "auto-upload": '自动上传', local: '本地文件', netdisk: '百度云', - "task-record": '任务记录' + "task-record": '任务记录', + 'global-setting': '全局设置' } const openInCurrentTab = (type: TabPane['type'], path?: string, walkMode = false) => { let pane: TabPane @@ -23,6 +24,7 @@ const openInCurrentTab = (type: TabPane['type'], path?: string, walkMode = false case 'auto-upload': case 'task-record': case 'log-detail': + case 'global-setting': case 'empty': pane = { type, name: compCnMap[type]!, key: Date.now() + uniqueId() } break @@ -182,4 +184,7 @@ const openInNewWindow = () => window.parent.open('/baidu_netdisk') flex: 1; font-size: 16px; } +.quick-start__icon { + margin-right: 8px; +} \ No newline at end of file diff --git a/vue/src/fileTransfer/hook.ts b/vue/src/fileTransfer/hook.ts index 4063878..179a230 100644 --- a/vue/src/fileTransfer/hook.ts +++ b/vue/src/fileTransfer/hook.ts @@ -17,6 +17,7 @@ import NProgress from 'multi-nprogress' import { Modal, message } from 'ant-design-vue' import type { MenuInfo } from 'ant-design-vue/lib/menu/src/interface' import { nextTick } from 'vue' +import { loginByBduss } from '@/api/user' const global = useGlobalStore() export const toRawFileUrl = (file: FileNodeInfo, download = false) => `/baidu_netdisk/file?filename=${encodeURIComponent(file.fullpath)}${download ? `&disposition=${encodeURIComponent(file.name)}` : ''}` @@ -87,6 +88,8 @@ export type ViewMode = 'line' | 'grid' | 'large-size-grid' export const useBaiduyun = () => { const taskListStore = useTaskListStore() + + const bduss = ref('') const installedBaiduyun = computedAsync(taskListStore.checkBaiduyunInstalled, false) const baiduyunLoading = ref(false) const failedHint = ref('') @@ -105,11 +108,29 @@ export const useBaiduyun = () => { baiduyunLoading.value = false } } + + const onLoginBtnClick = async () => { + if (baiduyunLoading.value) { + return + } + try { + baiduyunLoading.value = true + global.user = await loginByBduss(bduss.value) + } catch (error) { + console.error(error) + message.error(isAxiosError(error) ? error.response?.data?.detail ?? '未知错误' : '未知错误') + } finally { + baiduyunLoading.value = false + } + } + return { installBaiduyunBin, installedBaiduyun, failedHint, - baiduyunLoading + baiduyunLoading, + bduss, + onLoginBtnClick } } @@ -218,7 +239,7 @@ export function useLocation (props: Props) { watch(() => stack.value.length, debounce((v, lv) => { if (v !== lv) { - scroller.value!.scrollToItem(0) + scroller.value?.scrollToItem(0) } }, 300)) @@ -251,7 +272,7 @@ export function useLocation (props: Props) { /** * 登录后重新获取 */ - watch(() => props.target === 'netdisk' && installedBaiduyun.value, async (v, last) => { + watch(() => props.target === 'netdisk' && installedBaiduyun.value && global.user, async (v, last) => { if (v && !last) { const resp = await getTargetFolderFiles(props.target, '/') stack.value = [{ diff --git a/vue/src/fileTransfer/stackView.vue b/vue/src/fileTransfer/stackView.vue index 713516b..16dbe8d 100644 --- a/vue/src/fileTransfer/stackView.vue +++ b/vue/src/fileTransfer/stackView.vue @@ -22,7 +22,9 @@ const props = defineProps<{ path?: string, walkMode?: boolean }>() -const { installBaiduyunBin, installedBaiduyun, failedHint, baiduyunLoading, scroller, stackViewEl, props: _props } = useHookShareState().toRefs() +const { installBaiduyunBin, installedBaiduyun, failedHint, baiduyunLoading, + scroller, stackViewEl, props: _props, bduss, onLoginBtnClick +} = useHookShareState().toRefs() watch(() => props, () => { _props.value = props }, { immediate: true }) @@ -41,18 +43,36 @@ const { previewIdx, onPreviewVisibleChange, previewing, previewImgMove, canPrevi