- Implemented routes for listing, retrieving, updating, and deleting containers. - Added ContainerModel with necessary fields and methods for data handling. - Created utility functions for fetching container data by ID. feat(page): enhance page management with CRUD and publish functionality - Developed routes for managing pages, including listing, updating, and deleting. - Integrated caching and zip file generation for page exports. - Added publish functionality to manage app versions and file uploads. feat(prompts): implement prompt management with CRUD operations - Created routes for listing, updating, and deleting prompts. - Added pagination and search capabilities for prompt listing. test: add common query utilities and prompt tests - Implemented common query utilities for API interactions. - Added tests for prompt listing functionality.
103 lines
2.1 KiB
TypeScript
103 lines
2.1 KiB
TypeScript
type HTMLOptions = {
|
|
title?: string;
|
|
rootId: string;
|
|
dataKey?: string;
|
|
};
|
|
/**
|
|
* data list
|
|
* @param opts
|
|
* @returns
|
|
*/
|
|
export const getHTML = (opts: HTMLOptions) => {
|
|
return `<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>${opts.title || 'Kevisual'}</title>
|
|
<style>
|
|
html,
|
|
body {
|
|
margin: 0;
|
|
padding: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
|
|
body {
|
|
font-size: 16px;
|
|
}
|
|
</style>
|
|
<script src="https://kevisual.xiongxiao.me/system/lib/app.js"></script>
|
|
</head>
|
|
|
|
<body>
|
|
<div id="root"></div>
|
|
<script type="module">
|
|
import { Container } from 'https://kevisual.xiongxiao.me/root/container/index.js'
|
|
import { data } from './${opts.dataKey || 'data'}.js'
|
|
const container = new Container({
|
|
root: 'root',
|
|
data: data
|
|
});
|
|
container.render('${opts.rootId}');
|
|
</script>
|
|
</body>
|
|
|
|
</html>`;
|
|
};
|
|
|
|
export const getDataJs = (result: any) => {
|
|
return 'export const data=' + JSON.stringify(result);
|
|
};
|
|
|
|
type OneHTMLOptions = {
|
|
title?: string;
|
|
file: string;
|
|
}
|
|
/**
|
|
* one data
|
|
* @param opts
|
|
* @returns
|
|
*/
|
|
export const getOneHTML = (opts: OneHTMLOptions) => {
|
|
return `<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<link rel="icon" href="https://envision.xiongxiao.me/resources/root/avatar.png"/>
|
|
<title>${opts.title || 'Kevisual'}</title>
|
|
<style>
|
|
html,
|
|
body {
|
|
margin: 0;
|
|
padding: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
body {
|
|
font-size: 16px;
|
|
}
|
|
</style>
|
|
<script src="https://kevisual.xiongxiao.me/system/lib/app.js"></script>
|
|
</head>
|
|
|
|
<body>
|
|
<div id="root"></div>
|
|
<script type="module">
|
|
import { ContainerOne } from 'https://kevisual.xiongxiao.me/system/lib/container.js'
|
|
import { render, unmount } from './${opts.file}.js'
|
|
const container = new ContainerOne({
|
|
root: '#root',
|
|
});
|
|
container.renderOne({
|
|
code: {render, unmount}
|
|
});
|
|
</script>
|
|
</body>
|
|
|
|
</html>`;
|
|
};
|