diff --git a/project/java-cli/src/main/java/com/example/datacollect/view/ConsoleView.java b/project/java-cli/src/main/java/com/example/datacollect/view/ConsoleView.java deleted file mode 100644 index b9fe7be..0000000 --- a/project/java-cli/src/main/java/com/example/datacollect/view/ConsoleView.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.example.datacollect.view; - -import com.example.datacollect.model.Article; -import java.util.List; -import java.util.Scanner; - -public class ConsoleView { - private static final String ANSI_RESET = "\u001B[0m"; - private static final String ANSI_GREEN = "\u001B[32m"; - private static final String ANSI_RED = "\u001B[31m"; - private static final String ANSI_BLUE = "\u001B[94m"; - private static final String ANSI_BG_DARK = "\u001B[40m"; - private static final String ANSI_WHITE = "\u001B[97m"; - private static final boolean DARK_MODE = true; - - private final Scanner scanner = new Scanner(System.in); - - public String readLine() { - if (DARK_MODE) { - System.out.print(ANSI_BG_DARK + ANSI_WHITE + "> " + ANSI_RESET); - } else { - System.out.print("> "); - } - return scanner.nextLine(); - } - - public void printSuccess(String msg) { - if (DARK_MODE) { - System.out.println(ANSI_BG_DARK + ANSI_GREEN + msg + ANSI_RESET); - } else { - System.out.println(ANSI_GREEN + msg + ANSI_RESET); - } - } - - public void printError(String msg) { - if (DARK_MODE) { - System.out.println(ANSI_BG_DARK + ANSI_RED + msg + ANSI_RESET); - } else { - System.out.println(ANSI_RED + msg + ANSI_RESET); - } - } - - public void printInfo(String msg) { - if (DARK_MODE) { - System.out.println(ANSI_BG_DARK + ANSI_BLUE + msg + ANSI_RESET); - } else { - System.out.println(ANSI_BLUE + msg + ANSI_RESET); - } - } - - public void display(List
articles) { - if (articles.isEmpty()) { - printInfo("暂无文章,请先执行 crawl。"); - return; - } - for (int i = 0; i < articles.size(); i++) { - Article a = articles.get(i); - if (DARK_MODE) { - System.out.println(ANSI_BG_DARK + ANSI_WHITE + (i + 1) + ". " + a.getTitle() + " | " + a.getUrl() + ANSI_RESET); - } else { - System.out.println((i + 1) + ". " + a.getTitle() + " | " + a.getUrl()); - } - } - } -}