فهرست منبع

feat:项目初始化,完成基础的窗口搭建

yang yi 11 ماه پیش
کامیت
30e135bae3
3فایلهای تغییر یافته به همراه243 افزوده شده و 0 حذف شده
  1. 31 0
      .gitignore
  2. 28 0
      pom.xml
  3. 184 0
      src/main/java/space/anyi/amountVerification/App.java

+ 31 - 0
.gitignore

@@ -0,0 +1,31 @@
+# created by virtualenv automatically
+
+
+**/.idea
+**/node_modules
+**/.gradle
+**/.mvn
+**/*.iml
+**/*.log
+**/*.rar
+**/*.png
+**/*.jpg
+**/*.xls
+**/*.xlsx
+**/*.zip
+**/*.o
+**/*.exe
+**/out/**
+**/target/**
+**/build/**
+/*
+
+!/**/**.java
+!/**/**.vue
+!/**/**.yaml
+!/**/**.yml
+!/**/**.properties
+!/**/**/pom.xml
+
+!/src
+!.gitignore

+ 28 - 0
pom.xml

@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>space.anyi</groupId>
+    <artifactId>amount-verification</artifactId>
+    <version>0.0.1</version>
+    <dependencies>
+        <dependency>
+            <groupId>org.openjfx</groupId>
+            <artifactId>javafx-controls</artifactId>
+            <version>17.0.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.openjfx</groupId>
+            <artifactId>javafx-fxml</artifactId>
+            <version>17.0.2</version>
+        </dependency>
+    </dependencies>
+
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+    </properties>
+
+</project>

+ 184 - 0
src/main/java/space/anyi/amountVerification/App.java

@@ -0,0 +1,184 @@
+package space.anyi.amountVerification;
+
+import javafx.application.Application;
+import javafx.geometry.Insets;
+import javafx.geometry.Pos;
+import javafx.scene.Scene;
+import javafx.scene.control.Alert;
+import javafx.scene.control.Button;
+import javafx.scene.control.ButtonType;
+import javafx.scene.control.Label;
+import javafx.scene.control.Menu;
+import javafx.scene.control.MenuBar;
+import javafx.scene.control.MenuItem;
+import javafx.scene.control.TextField;
+import javafx.scene.layout.BorderPane;
+import javafx.scene.layout.GridPane;
+import javafx.scene.layout.VBox;
+import javafx.stage.DirectoryChooser;
+import javafx.stage.FileChooser;
+import javafx.stage.Stage;
+import java.io.File;
+import java.util.Optional;
+
+/**
+ * @ProjectName: amount-verification
+ * @FileName: Application
+ * @Author: 杨逸
+ * @Data:2025/11/27 18:33
+ * @Description:
+ */
+public class App extends Application {
+    private TextField fileField;
+    private TextField folderField;
+
+    public static void main(String[] args) {
+        Application.launch(App.class, args);
+    }
+
+    @Override
+    public void start(Stage primaryStage) throws Exception {
+        primaryStage.setTitle("金额验证工具");
+        primaryStage.setResizable(false);
+        // 设置窗口关闭事件处理
+        primaryStage.setOnCloseRequest(event -> {
+            event.consume(); // 阻止默认关闭行为
+            showCloseConfirmation(primaryStage);
+        });
+
+        // 创建主布局
+        BorderPane mainLayout = new BorderPane();
+
+        // 创建菜单栏
+        MenuBar menuBar = createMenuBar();
+        mainLayout.setTop(menuBar);
+
+        // 创建内容区域
+        VBox contentLayout = new VBox(20);
+        contentLayout.setPadding(new Insets(20));
+        contentLayout.setAlignment(Pos.CENTER);
+
+        // 创建网格布局用于表单
+        GridPane gridPane = new GridPane();
+        gridPane.setHgap(10);
+        gridPane.setVgap(10);
+        gridPane.setAlignment(Pos.CENTER);
+
+        // 文件选择组件
+        Label fileLabel = new Label("选择文件:");
+        fileField = new TextField();
+        fileField.setPromptText("请选择文件...");
+        fileField.setPrefWidth(300);
+        Button fileButton = new Button("浏览");
+
+        // 文件夹选择组件
+        Label folderLabel = new Label("选择文件夹:");
+        folderField = new TextField();
+        folderField.setPromptText("请选择文件夹...");
+        folderField.setPrefWidth(300);
+        Button folderButton = new Button("浏览");
+
+        // 开始按钮
+        Button startButton = new Button("开始验证");
+        startButton.setPrefWidth(150);
+        startButton.setPrefHeight(40);
+
+        // 设置按钮事件
+        fileButton.setOnAction(e -> chooseFile());
+        folderButton.setOnAction(e -> chooseFolder());
+        startButton.setOnAction(e -> startVerification());
+
+        // 添加到网格布局
+        gridPane.add(fileLabel, 0, 0);
+        gridPane.add(fileField, 1, 0);
+        gridPane.add(fileButton, 2, 0);
+
+        gridPane.add(folderLabel, 0, 1);
+        gridPane.add(folderField, 1, 1);
+        gridPane.add(folderButton, 2, 1);
+
+        // 添加到内容布局
+        contentLayout.getChildren().addAll(gridPane, startButton);
+        mainLayout.setCenter(contentLayout);
+
+        // 创建场景并显示
+        Scene scene = new Scene(mainLayout, 500, 350);
+        primaryStage.setScene(scene);
+        primaryStage.show();
+    }
+
+    private MenuBar createMenuBar() {
+        MenuBar menuBar = new MenuBar();
+
+        // 创建帮助菜单
+        Menu helpMenu = new Menu("帮助");
+
+        // 创建关于菜单项
+        MenuItem aboutMenuItem = new MenuItem("关于");
+        aboutMenuItem.setOnAction(e -> showAboutDialog());
+
+        helpMenu.getItems().add(aboutMenuItem);
+        menuBar.getMenus().add(helpMenu);
+
+        return menuBar;
+    }
+
+    private void showAboutDialog() {
+        Alert alert = new Alert(Alert.AlertType.INFORMATION);
+        alert.setTitle("关于");
+        alert.setHeaderText("金额验证工具");
+        alert.setContentText("作者: 杨逸\n" +
+                           "联系方式: huanglve2004@163.com\n\n" +
+                           "版本: 1.0.0\n" +
+                           "描述: 用于金额验证的桌面应用程序");
+
+        alert.showAndWait();
+    }
+
+    private void showCloseConfirmation(Stage stage) {
+        Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
+        alert.setTitle("确认关闭");
+        alert.setHeaderText("您确定要关闭应用程序吗?");
+        alert.setContentText("如果正在执行验证操作,关闭将中断该过程。");
+
+        Optional<ButtonType> result = alert.showAndWait();
+        if (result.isPresent() && result.get() == ButtonType.OK) {
+            stage.close();
+        }
+    }
+
+    private void chooseFile() {
+        FileChooser fileChooser = new FileChooser();
+        fileChooser.setTitle("选择文件");
+        File selectedFile = fileChooser.showOpenDialog(null);
+        if (selectedFile != null) {
+            fileField.setText(selectedFile.getAbsolutePath());
+        }
+    }
+
+    private void chooseFolder() {
+        DirectoryChooser directoryChooser = new DirectoryChooser();
+        directoryChooser.setTitle("选择文件夹");
+        File selectedFolder = directoryChooser.showDialog(null);
+        if (selectedFolder != null) {
+            folderField.setText(selectedFolder.getAbsolutePath());
+        }
+    }
+
+    private void startVerification() {
+        String filePath = fileField.getText();
+        String folderPath = folderField.getText();
+
+        if (filePath.isEmpty() && folderPath.isEmpty()) {
+            System.out.println("请至少选择文件或文件夹");
+            return;
+        }
+
+        System.out.println("开始验证...");
+        System.out.println("文件路径: " + filePath);
+        System.out.println("文件夹路径: " + folderPath);
+
+        // 这里可以添加实际的验证逻辑
+        // 例如:读取文件内容、处理文件夹中的文件等
+    }
+}