返回提交历史
Added
src/controllers/custom/getConfigDataController.ts
+8
-0
Added
src/controllers/custom/updateConfigDataController.ts
+16
-0
Modified
src/routes/custom.ts
+6
-1
Modified
src/routes/webui.ts
+3
-0
Modified
static/webui/index.html
+74
-4
Modified
static/webui/script.js
+45
-0
XFEstudio/SpaceNinjaServer
feat(webui): change server config through UI (#294)
1c6412a6
代码差异
6 个文件
+152
-5
@@ -0,0 +1,8 @@
1
import { RequestHandler } from "express";
2
import configFile from "@/config.json";
3
4
const getConfigDataController: RequestHandler = (_req, res) => {
5
res.json(configFile);
6
};
7
8
export { getConfigDataController };
@@ -0,0 +1,16 @@
1
import { RequestHandler } from "express";
2
import path from "path";
3
import fs from "fs";
4
const rootDir = path.join(__dirname, "../../..");
5
6
const updateConfigDataController: RequestHandler = (req) => {
7
const updateSettingsData = req.body;
8
9
fs.writeFile(path.join(rootDir, "config.json"), updateSettingsData, function(err:any) {
10
if(err) {
11
return console.log(err);
12
}
13
});
14
};
15
16
export { updateConfigDataController };
@@ -2,6 +2,8 @@ import express from "express";
2
2
import { getItemListsController } from "@/src/controllers/custom/getItemListsController";
3
3
import { createAccountController } from "@/src/controllers/custom/createAccountController";
4
4
import { addItemController } from "@/src/controllers/custom/addItemController";
5
import { getConfigDataController } from "@/src/controllers/custom/getConfigDataController";
6
import { updateConfigDataController } from "@/src/controllers/custom/updateConfigDataController";
5
7
6
8
const customRouter = express.Router();
7
9
@@ -10,4 +12,7 @@ customRouter.get("/getItemLists", getItemListsController);
10
12
customRouter.post("/createAccount", createAccountController);
11
13
customRouter.post("/addItem", addItemController);
12
14
13
export { customRouter };
15
customRouter.get("/config", getConfigDataController);
16
customRouter.post("/config", updateConfigDataController);
17
18
export { customRouter };
@@ -19,6 +19,9 @@ webuiRouter.use("/webui", (req, res, next) => {
19
19
});
20
20
21
21
// Serve virtual routes
22
webuiRouter.get("/webui/settings", (_req, res) => {
23
res.sendFile(path.join(rootDir, "static/webui/index.html"));
24
});
22
25
webuiRouter.get("/webui/inventory", (_req, res) => {
23
26
res.sendFile(path.join(rootDir, "static/webui/index.html"));
24
27
});
@@ -67,15 +67,21 @@
67
67
Mods
68
68
</a>
69
69
</li>
70
<li class="nav-item">
71
<a
72
class="nav-link"
73
href="/webui/settings"
74
data-bs-dismiss="offcanvas"
75
data-bs-target="#sidebar"
76
>
77
Settings
78
</a>
79
</li>
70
80
</ul>
71
81
</div>
72
82
</div>
73
83
</div>
74
84
<div>
75
<p id="refresh-note" class="mb-4">
76
Note: Changes made here will only be reflected in-game when the game re-downloads your inventory.
77
Visiting the navigation should be the easiest way to trigger that.
78
</p>
79
85
<div data-route="/webui/" data-title="Login | OpenWF WebUI">
80
86
<p>Login using your OpenWF account credentials.</p>
81
87
<form onsubmit="doLogin();return false;">
@@ -89,6 +95,10 @@
89
95
</form>
90
96
</div>
91
97
<div data-route="/webui/inventory" data-title="Inventory | OpenWF WebUI">
98
<p id="refresh-note" class="mb-4">
99
Note: Changes made here will only be reflected in-game when the game re-downloads your inventory.
100
Visiting the navigation should be the easiest way to trigger that.
101
</p>
92
102
<div class="card mb-4">
93
103
<h5 class="card-header">Add Items</h5>
94
104
<form class="card-body input-group" onsubmit="doAcquireMiscItems();return false;">
@@ -133,6 +143,10 @@
133
143
</div>
134
144
</div>
135
145
<div data-route="/webui/mods" data-title="Mods | OpenWF WebUI">
146
<p id="refresh-note" class="mb-4">
147
Note: Changes made here will only be reflected in-game when the game re-downloads your inventory.
148
Visiting the navigation should be the easiest way to trigger that.
149
</p>
136
150
<div class="row">
137
151
<div class="col-xxl-6">
138
152
<div class="card mb-4">
@@ -189,6 +203,62 @@
189
203
</div>
190
204
</div>
191
205
</div>
206
<div data-route="/webui/settings" data-title="Settings | OpenWF WebUI">
207
<div class="card mb-4">
208
<h5 class="card-header">Change Settings</h5>
209
<form class="card-body" onsubmit="doChangeSettings();return false;">
210
<div class="form-check">
211
<input class="form-check-input" type="checkbox" value="" id="skipStoryModeChoice" />
212
<label label class="form-check-label" for="skipStoryModeChoice">Skip Story Mode Choice?</label>
213
</div>
214
<div class="form-check">
215
<input class="form-check-input" type="checkbox" value="" id="skipTutorial" />
216
<label label class="form-check-label" for="skipTutorial">Skip Tutorial?</label>
217
</div>
218
<div class="form-check">
219
<input class="form-check-input" type="checkbox" value="" id="unlockAllScans" />
220
<label label class="form-check-label" for="unlockAllScans">Unlock All Scans?</label>
221
</div>
222
<div class="form-check">
223
<input class="form-check-input" type="checkbox" value="" id="unlockAllMissions" />
224
<label label class="form-check-label" for="unlockAllMissions">Unlock All Missions?</label>
225
</div>
226
<div class="form-check">
227
<input class="form-check-input" type="checkbox" value="" id="unlockAllQuests" />
228
<label label class="form-check-label" for="unlockAllQuests">Unlock All Quests?</label>
229
</div>
230
<div class="form-check">
231
<input class="form-check-input" type="checkbox" value="" id="completeAllQuests" />
232
<label label class="form-check-label" for="completeAllQuests">Complete All Quests?</label>
233
</div>
234
<div class="form-check">
235
<input class="form-check-input" type="checkbox" value="" id="infiniteResources" />
236
<label label class="form-check-label" for="infiniteResources">Infinite Credits and Platinum?</label>
237
</div>
238
<div class="form-check">
239
<input class="form-check-input" type="checkbox" value="" id="unlockallShipFeatures" />
240
<label label class="form-check-label" for="unlockallShipFeatures">Unlock All Ship Features?</label>
241
</div>
242
<div class="form-check">
243
<input class="form-check-input" type="checkbox" value="" id="unlockAllShipDecorations" />
244
<label label class="form-check-label" for="unlockAllShipDecorations">Unlock All Ship Decorations?</label>
245
</div>
246
<div class="form-check">
247
<input class="form-check-input" type="checkbox" value="" id="unlockAllFlavourItems" />
248
<label label class="form-check-label" for="unlockAllFlavourItems">Unlock All Accessories?</label>
249
</div>
250
<div class="form-check">
251
<input class="form-check-input" type="checkbox" value="" id="unlockAllSkins" />
252
<label label class="form-check-label" for="unlockAllSkins">Unlock All Skins?</label>
253
</div>
254
<div class="form-check">
255
<label label class="form-check-label" for="spoofMasteryRank">Spoofed Mastery Rank (-1 to disable)</label>
256
<input class="form-control" id="spoofMasteryRank" type="number" min="-1" value="" />
257
</div>
258
<button class="btn btn-primary" type="submit">Save Settings</button>
259
</form>
260
</div>
261
</div>
192
262
</div>
193
263
</div>
194
264
<datalist id="datalist-warframes"></datalist>
@@ -15,6 +15,7 @@ function loginFromLocalStorage() {
15
15
window.accountId = data.id;
16
16
window.authz = "accountId=" + data.id + "&nonce=" + data.Nonce;
17
17
updateInventory();
18
fetchSettings();
18
19
},
19
20
() => {
20
21
logout();
@@ -618,3 +619,47 @@ function doAcquireMod() {
618
619
$("#mod-to-acquire").on("input", () => {
619
620
$("#mod-to-acquire").removeClass("is-invalid");
620
621
});
622
623
function fetchSettings() {
624
fetch('/custom/config')
625
.then((response) => response.json())
626
.then((json) => Object.entries(json).forEach((entry) => {
627
const [key, value] = entry;
628
var x = document.getElementById(`${key}`);
629
if (x!=null) {
630
if (x.type == "checkbox") {
631
if (value === true) {
632
x.setAttribute("checked", "checked")
633
}
634
} else if (x.type == "number") {
635
x.setAttribute("value", `${value}`)
636
}
637
}
638
}));
639
}
640
641
function doChangeSettings() {
642
fetch('/custom/config')
643
.then((response) => response.json())
644
.then((json) => {
645
for(var i in json) {
646
var x = document.getElementById(`${i}`);
647
if (x!=null) {
648
if (x.type == "checkbox") {
649
if (x.checked === true) {
650
json[i]=true;
651
} else {
652
json[i]=false;
653
}
654
} else if (x.type == "number") {
655
json[i]=parseInt(x.value);
656
}
657
}
658
}
659
$.post({
660
url: "/custom/config",
661
contentType: "text/plain",
662
data: JSON.stringify(json, null, 2)
663
})
664
})
665
}