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:
29
server/api/devtool/content/template/get-list.js
Normal file
29
server/api/devtool/content/template/get-list.js
Normal file
@@ -0,0 +1,29 @@
|
||||
import templates from "@@/templates/index.js";
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
try {
|
||||
const query = await getQuery(event);
|
||||
const id = query.id;
|
||||
|
||||
if (!templates || templates?.data.length == 0)
|
||||
return {
|
||||
statusCode: 404,
|
||||
message: "Template data not found",
|
||||
};
|
||||
|
||||
// Search template by id
|
||||
const template = templates.data.find((item) => item.id == id);
|
||||
|
||||
return {
|
||||
statusCode: 200,
|
||||
message: "Template data successfully fetched",
|
||||
data: template,
|
||||
};
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return {
|
||||
statusCode: 500,
|
||||
message: "Internal server error",
|
||||
};
|
||||
}
|
||||
});
|
||||
57
server/api/devtool/content/template/import.js
Normal file
57
server/api/devtool/content/template/import.js
Normal file
@@ -0,0 +1,57 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
import templates from "@@/templates/index.js";
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
try {
|
||||
const query = await getQuery(event);
|
||||
const pagePath = query.path;
|
||||
const templateId = query.templateId;
|
||||
|
||||
// Get pageName path and check if it exists
|
||||
const filePath = path.join(process.cwd() + "/pages/", pagePath + ".vue");
|
||||
console.log(filePath);
|
||||
if (!fs.existsSync(filePath)) {
|
||||
return {
|
||||
statusCode: 500,
|
||||
message: "File path not found",
|
||||
};
|
||||
}
|
||||
|
||||
// Get template id from templates
|
||||
const template = templates.data.find(
|
||||
(template) => template.id === templateId
|
||||
);
|
||||
|
||||
// Get template path and check if it exists
|
||||
const templatePath = path.join(
|
||||
process.cwd() + "/templates/",
|
||||
template.filename + ".vue"
|
||||
);
|
||||
|
||||
if (!fs.existsSync(templatePath)) {
|
||||
return {
|
||||
statusCode: 500,
|
||||
message: "Template not found",
|
||||
};
|
||||
}
|
||||
|
||||
// Get template code
|
||||
const templateCode = fs.readFileSync(templatePath, "utf8");
|
||||
|
||||
// Write template code to pageName path
|
||||
fs.writeFileSync(filePath, templateCode, "utf8");
|
||||
|
||||
return {
|
||||
statusCode: 200,
|
||||
message: "Template successfully imported",
|
||||
};
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return {
|
||||
statusCode: 500,
|
||||
message: "Internal server error",
|
||||
};
|
||||
}
|
||||
});
|
||||
23
server/api/devtool/content/template/list.js
Normal file
23
server/api/devtool/content/template/list.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import templates from "@@/templates/index.js";
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
try {
|
||||
if (!templates || templates?.data.length == 0)
|
||||
return {
|
||||
statusCode: 404,
|
||||
message: "Template data not found",
|
||||
};
|
||||
|
||||
return {
|
||||
statusCode: 200,
|
||||
message: "List template data successfully fetched",
|
||||
data: templates.data,
|
||||
};
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return {
|
||||
statusCode: 500,
|
||||
message: "Internal server error",
|
||||
};
|
||||
}
|
||||
});
|
||||
23
server/api/devtool/content/template/tag.js
Normal file
23
server/api/devtool/content/template/tag.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import templates from "@@/templates/index.js";
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
try {
|
||||
if (!templates || templates?.tags.length == 0)
|
||||
return {
|
||||
statusCode: 404,
|
||||
message: "Template tags not found",
|
||||
};
|
||||
|
||||
return {
|
||||
statusCode: 200,
|
||||
message: "List template tags successfully fetched",
|
||||
data: templates.tags,
|
||||
};
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return {
|
||||
statusCode: 500,
|
||||
message: "Internal server error",
|
||||
};
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user