From c33f187744858c4e97e2c94c4d8b9f544f712a95 Mon Sep 17 00:00:00 2001 From: Marvin Zhang Date: Fri, 20 Dec 2024 23:31:24 +0800 Subject: [PATCH] feat: remove small size from dependency dialog buttons and enhance empty state messages for dependencies - Removed 'size="small"' from buttons in DependencyInstallDialog, DependencySetupDialog, and DependencyUninstallDialog components. - Added new empty state messages for uninstalled dependencies in English and Chinese, including prompts for Java dependencies. - Updated the dependency utility functions to handle Java and Go repository names. - Enhanced the DependencyList component to display appropriate messages and actions when no dependencies are configured or when Java is selected. --- .../dependency/DependencyInstallDialog.vue | 1 - .../core/dependency/DependencySetupDialog.vue | 1 - .../dependency/DependencyUninstallDialog.vue | 1 - src/i18n/lang/en/views/env.ts | 22 ++++ src/i18n/lang/zh/views/env.ts | 19 +++ src/interfaces/i18n/views/env.d.ts | 18 +++ src/utils/dependency.ts | 18 +++ src/views/dependency/list/DependencyList.vue | 56 +++++++-- .../dependency/list/useDependencyList.tsx | 111 +++++++++++------- 9 files changed, 194 insertions(+), 53 deletions(-) diff --git a/src/components/core/dependency/DependencyInstallDialog.vue b/src/components/core/dependency/DependencyInstallDialog.vue index c15666f50f206..63c70be381006 100644 --- a/src/components/core/dependency/DependencyInstallDialog.vue +++ b/src/components/core/dependency/DependencyInstallDialog.vue @@ -73,7 +73,6 @@ defineOptions({ name: 'ClDependencyInstallDialog' }); class="dep-name" type="primary" :label="form.name" - size="small" /> diff --git a/src/components/core/dependency/DependencySetupDialog.vue b/src/components/core/dependency/DependencySetupDialog.vue index f18f40a6104dc..8642f0bb3fcd0 100644 --- a/src/components/core/dependency/DependencySetupDialog.vue +++ b/src/components/core/dependency/DependencySetupDialog.vue @@ -76,7 +76,6 @@ defineOptions({ name: 'ClDependencySetupDialog' }); class="dep-name" type="primary" :label="config?.name" - size="small" /> diff --git a/src/i18n/lang/en/views/env.ts b/src/i18n/lang/en/views/env.ts index fc5583d46d73f..cc1366c08c576 100644 --- a/src/i18n/lang/en/views/env.ts +++ b/src/i18n/lang/en/views/env.ts @@ -42,6 +42,27 @@ const env: LViewsEnv = { }, nodes: 'Nodes', }, + empty: { + configNotSetup: { + title: 'Dependency environment not installed', + content: + 'Please install the dependency environment (or programming language) first', + action: { + label: 'Install now', + tooltip: + 'Install the dependency environment (or programming language)', + }, + }, + java: { + title: 'Global dependency not supported', + content: + 'Java (Maven) does not support installation/uninstallation of global dependencies. Please manage within spiders.', + action: { + label: 'Manage within spiders', + tooltip: 'Manage in the dependencies tab within spiders', + }, + }, + }, }, lang: { python: 'Python', @@ -82,6 +103,7 @@ const env: LViewsEnv = { execCmd: 'Execute Command', pkgCmd: 'Package Command', proxy: 'Proxy', + defaultVersion: 'Default Version', }, }, configSetup: { diff --git a/src/i18n/lang/zh/views/env.ts b/src/i18n/lang/zh/views/env.ts index 6b551acd498c5..00325e0b7a193 100644 --- a/src/i18n/lang/zh/views/env.ts +++ b/src/i18n/lang/zh/views/env.ts @@ -42,6 +42,24 @@ const env: LViewsEnv = { }, nodes: '节点', }, + empty: { + configNotSetup: { + title: '依赖环境未安装', + content: '请先安装依赖环境(或编程语言)', + action: { + label: '立即安装', + tooltip: '安装依赖环境(或编程语言)', + }, + }, + java: { + title: '不支持全局依赖', + content: 'Java(Maven)不支持全局依赖的安装/卸载。请在爬虫内管理。', + action: { + label: '在爬虫内管理', + tooltip: '在爬虫内的依赖选项卡中管理', + }, + }, + }, }, lang: { python: 'Python', @@ -82,6 +100,7 @@ const env: LViewsEnv = { execCmd: '执行命令', pkgCmd: '依赖管理命令', proxy: '代理', + defaultVersion: '默认版本', }, }, configSetup: { diff --git a/src/interfaces/i18n/views/env.d.ts b/src/interfaces/i18n/views/env.d.ts index 08e6e30b35a65..45380355d0977 100644 --- a/src/interfaces/i18n/views/env.d.ts +++ b/src/interfaces/i18n/views/env.d.ts @@ -32,6 +32,24 @@ interface LViewsEnv { }; nodes: string; }; + empty: { + configNotSetup: { + title: string; + content: string; + action: { + label: string; + tooltip: string; + }; + }; + java: { + title: string; + content: string; + action: { + label: string; + tooltip: string; + }; + }; + }; }; lang: { python: string; diff --git a/src/utils/dependency.ts b/src/utils/dependency.ts index 76f165e4f3d8c..16490582ffc1d 100644 --- a/src/utils/dependency.ts +++ b/src/utils/dependency.ts @@ -4,11 +4,29 @@ export const getRepoExternalPath = (repo: DependencyRepo) => { return `https://pypi.org/project/${repo.name}`; case 'node': return `https://www.npmjs.com/package/${repo.name}`; + case 'go': + return `https://pkg.go.dev/${repo.name}`; + case 'java': + return `https://mvnrepository.com/artifact/${getRepoName(repo)}`; default: return ''; } }; +export const getRepoName = (repo: DependencyRepo) => { + switch (repo.type) { + case 'go': + if (repo.name!.startsWith('github.com/')) { + return repo.name!.split('github.com/')[1]; + } + return repo.name; + case 'java': + return repo.name!.replaceAll(':', '/'); + default: + return repo.name; + } +}; + export const getEmptyDependency = (): Dependency => { return { version: 'N/A', diff --git a/src/views/dependency/list/DependencyList.vue b/src/views/dependency/list/DependencyList.vue index e7dfa8dec2828..65e6c10e9dc12 100644 --- a/src/views/dependency/list/DependencyList.vue +++ b/src/views/dependency/list/DependencyList.vue @@ -1,7 +1,7 @@