MCPcopy Create free account
hub / github.com/TheSmallHanCat/flow2api / saveSettings

Function saveSettings

extension/options.js:44–68  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

42}
43
44function saveSettings() {
45 const settings = normalizeSettings({
46 serverUrl: $("serverUrl").value,
47 apiKey: $("apiKey").value,
48 routeKey: $("routeKey").value,
49 clientLabel: $("clientLabel").value
50 });
51
52 if (!isValidWsUrl(settings.serverUrl)) {
53 setStatus("WebSocket URL 必须以 ws:// 或 wss:// 开头。", true);
54 return;
55 }
56 if (!settings.apiKey) {
57 setStatus("请填写 Flow2API API Key。", true);
58 return;
59 }
60
61 chrome.storage.local.set(settings, () => {
62 if (chrome.runtime.lastError) {
63 setStatus(`保存失败:${chrome.runtime.lastError.message}`, true);
64 return;
65 }
66 setStatus("已保存,后台连接会自动重连。");
67 });
68}
69
70document.addEventListener("DOMContentLoaded", () => {
71 loadSettings();

Callers

nothing calls this directly

Calls 5

normalizeSettingsFunction · 0.85
$Function · 0.85
isValidWsUrlFunction · 0.85
setStatusFunction · 0.85
setMethod · 0.80

Tested by

no test coverage detected