Update various configuration files, components, and assets; enhance notification system and API endpoints; improve documentation and styles across the application.
This commit is contained in:
42
server/api/devtool/content/code/file-code.js
Normal file
42
server/api/devtool/content/code/file-code.js
Normal file
@@ -0,0 +1,42 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const query = await getQuery(event);
|
||||
|
||||
let code = "";
|
||||
// console.log(query.path);
|
||||
|
||||
try {
|
||||
// Get vue code from path in query
|
||||
const filePath = path.join(process.cwd() + "/pages/", query.path + ".vue");
|
||||
try {
|
||||
code = fs.readFileSync(filePath, "utf8");
|
||||
return {
|
||||
statusCode: 200,
|
||||
message: "Code successfully loaded",
|
||||
data: code,
|
||||
};
|
||||
} catch (error) {}
|
||||
|
||||
// Check if there is path with index.vue
|
||||
const filePathIndex = path.join(
|
||||
process.cwd() + "/pages/",
|
||||
query.path + "/index.vue"
|
||||
);
|
||||
|
||||
code = fs.readFileSync(filePathIndex, "utf8");
|
||||
|
||||
return {
|
||||
statusCode: 200,
|
||||
message: "Code successfully loaded",
|
||||
data: code,
|
||||
mode: "index",
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
statusCode: 500,
|
||||
message: "File not found",
|
||||
};
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user