@ -0,0 +1,66 @@
|
||||
<?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/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.mathquiz</groupId>
|
||||
<artifactId>MathQuizApp</artifactId>
|
||||
<name>Math Quiz Application</name>
|
||||
<version>1.0.0</version>
|
||||
<description>小初高数学学习软件 - JavaFX版本</description>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.11.0</version>
|
||||
<configuration>
|
||||
<source>${maven.compiler.source}</source>
|
||||
<target>${maven.compiler.target}</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.3.1</version>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<transformers>
|
||||
<transformer>
|
||||
<mainClass>com.Test</mainClass>
|
||||
</transformer>
|
||||
<transformer />
|
||||
</transformers>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
<excludes>
|
||||
<exclude>META-INF/*.SF</exclude>
|
||||
<exclude>META-INF/*.DSA</exclude>
|
||||
<exclude>META-INF/*.RSA</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
<finalName>MathQuizApp</finalName>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<properties>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<javafx.version>21.0.2</javafx.version>
|
||||
</properties>
|
||||
</project>
|
||||
@ -0,0 +1,45 @@
|
||||
package com.util;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* 应用数据目录管理器
|
||||
* 根据不同操作系统返回合适的应用数据存储路径
|
||||
*/
|
||||
public class AppDataDirectory {
|
||||
private static final String APP_NAME = "Math-Quiz-App"; // 替换为你的应用名
|
||||
|
||||
/**
|
||||
* 获取应用数据根目录
|
||||
*/
|
||||
public static String getApplicationDataDirectory() {
|
||||
String os = System.getProperty("os.name").toLowerCase();
|
||||
String basePath;
|
||||
|
||||
if (os.contains("win")) {
|
||||
// Windows
|
||||
String appData = System.getenv("APPDATA");
|
||||
basePath = (appData != null) ? appData : System.getProperty("user.home") + "/AppData/Roaming";
|
||||
} else if (os.contains("mac")) {
|
||||
// macOS
|
||||
basePath = System.getProperty("user.home") + "/Library/Application Support";
|
||||
} else {
|
||||
// Linux/Unix
|
||||
String xdgDataHome = System.getenv("XDG_DATA_HOME");
|
||||
if (xdgDataHome == null) {
|
||||
xdgDataHome = System.getProperty("user.home") + "/.local/share";
|
||||
}
|
||||
basePath = xdgDataHome;
|
||||
}
|
||||
|
||||
return basePath + "/" + APP_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取完整的应用数据路径
|
||||
*/
|
||||
public static String getFullPath(String relativePath) {
|
||||
String appDataDir = getApplicationDataDirectory();
|
||||
return appDataDir + "/" + relativePath;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue