Skip to content

Commit 027f72e

Browse files
committed
fix: acode javascript console issue
1 parent 15fe73a commit 027f72e

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

src/lib/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ export default {
2323
// API_BASE: 'https://192.168.0.102:3001/api', // test api
2424
SKU_LIST: ["basic", "bronze", "silver", "gold", "platinum"],
2525
LOG_FILE_NAME: "Acode.log",
26+
CONSOLE_BUILD_PATH: "/js/build/console.build.js",
2627
};

src/lib/run.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import ajax from "@deadlyjack/ajax";
12
import tutorial from "components/tutorial";
23
import alert from "dialogs/alert";
34
import box from "dialogs/box";
@@ -133,7 +134,7 @@ async function run(
133134

134135
//this extra www is incorrect because asset_directory itself has www
135136
//but keeping it in case something depends on it
136-
pathName = `${ASSETS_DIRECTORY}www/`;
137+
pathName = "/";
137138
port = constants.CONSOLE_PORT;
138139

139140
start();
@@ -191,9 +192,9 @@ async function run(
191192
isConsole ||
192193
appSettings.value.console === appSettings.CONSOLE_LEGACY
193194
) {
194-
url = `${ASSETS_DIRECTORY}/js/build/console.build.js`;
195+
url = constants.CONSOLE_BUILD_PATH;
195196
} else {
196-
url = `${DATA_STORAGE}/eruda.js`;
197+
url = `${DATA_STORAGE}eruda.js`;
197198
}
198199
sendFileContent(url, reqId, "application/javascript");
199200
break;
@@ -478,14 +479,22 @@ async function run(
478479
* @returns
479480
*/
480481
async function sendFileContent(url, id, mime, processText) {
481-
const fs = fsOperation(url);
482+
let text;
483+
if (url.includes(constants.CONSOLE_BUILD_PATH)) {
484+
text = await ajax.get(url, {
485+
responseType: "text",
486+
});
487+
} else {
488+
const fs = fsOperation(url);
482489

483-
if (!(await fs.exists())) {
484-
error(id);
485-
return;
490+
if (!(await fs.exists())) {
491+
error(id);
492+
return;
493+
}
494+
495+
text = await fs.readFile(appSettings.value.defaultFileEncoding);
486496
}
487497

488-
let text = await fs.readFile(appSettings.value.defaultFileEncoding);
489498
text = processText ? processText(text) : text;
490499
if (mime === MIMETYPE_HTML) {
491500
sendHTML(text, id);

0 commit comments

Comments
 (0)