diff --git a/desktop/src/features/download/GridDownloadView.vue b/desktop/src/features/download/GridDownloadView.vue
index 539a98c..b48cb35 100644
--- a/desktop/src/features/download/GridDownloadView.vue
+++ b/desktop/src/features/download/GridDownloadView.vue
@@ -15,12 +15,14 @@ import { HelpCircleOutline } from "@vicons/ionicons5";
import { ApiError, chooseDirectory } from "../../shared/http";
import { createJob, loadMeta, type Meta } from "./api";
+const props = defineProps<{ cityName?: string }>();
const emit = defineEmits<{ started: [id: string] }>();
const message = useMessage();
+const FORM_KEY = "nqi.download.form";
const meta = ref(null);
const network = ref("NR");
-const cityCode = ref("JM");
+const cityCode = ref("");
const month = ref(previousMonth());
const concurrency = ref(8);
const groups = ref([]);
@@ -39,6 +41,56 @@ const networkOptions = [
{ label: "4G", value: "LTE" },
];
+function readForm() {
+ try {
+ const raw = localStorage.getItem(FORM_KEY);
+ if (!raw) return null;
+ const data = JSON.parse(raw) as {
+ network?: unknown;
+ gridSize?: unknown;
+ concurrency?: unknown;
+ outputDir?: unknown;
+ };
+ return data && typeof data === "object" ? data : null;
+ } catch {
+ return null;
+ }
+}
+
+function applyForm() {
+ const saved = readForm();
+ if (!saved) return;
+ if (saved.network === "NR" || saved.network === "LTE") network.value = saved.network;
+ if (saved.gridSize === "GRID20" || saved.gridSize === "GRID50") gridSize.value = saved.gridSize;
+ if (typeof saved.concurrency === "number" && saved.concurrency >= 1 && saved.concurrency <= 32) {
+ concurrency.value = Math.round(saved.concurrency);
+ }
+ if (typeof saved.outputDir === "string") outputDir.value = saved.outputDir;
+}
+
+function rememberForm() {
+ localStorage.setItem(
+ FORM_KEY,
+ JSON.stringify({
+ network: network.value,
+ gridSize: gridSize.value,
+ concurrency: concurrency.value,
+ outputDir: outputDir.value,
+ }),
+ );
+}
+
+function matchCity(cities: { name: string; code: string }[], cityName: string) {
+ const normalized = cityName.replace(/\s+/g, "");
+ if (!cities.length) return "";
+ if (!normalized) return cities[0].code;
+ const matches = cities.filter((city) => normalized === city.name || normalized === `${city.name}市` || normalized.includes(city.name));
+ matches.sort((left, right) => right.name.length - left.name.length);
+ return matches[0]?.code ?? cities[0].code;
+}
+
+applyForm();
+
function previousMonth() {
const date = new Date();
date.setDate(1);
@@ -49,6 +101,7 @@ function previousMonth() {
onMounted(async () => {
try {
meta.value = await loadMeta();
+ cityCode.value = matchCity(meta.value.cities || [], props.cityName || "");
syncGroups();
} catch (error) {
message.error(error instanceof ApiError ? error.message : "读取下载项目失败");
@@ -56,6 +109,7 @@ onMounted(async () => {
});
watch(network, syncGroups);
+watch([network, gridSize, concurrency, outputDir], rememberForm);
function syncGroups() {
const items = meta.value?.groups[network.value] || [];
diff --git a/desktop/src/shell/Shell.vue b/desktop/src/shell/Shell.vue
index 6ce4773..922d5c5 100644
--- a/desktop/src/shell/Shell.vue
+++ b/desktop/src/shell/Shell.vue
@@ -93,7 +93,7 @@ async function signOut() {
-
+