feat: save single html and update redis
This commit is contained in:
@@ -3,6 +3,11 @@ type HTMLOptions = {
|
||||
rootId: string;
|
||||
dataKey?: string;
|
||||
};
|
||||
/**
|
||||
* data list
|
||||
* @param opts
|
||||
* @returns
|
||||
*/
|
||||
export const getHTML = (opts: HTMLOptions) => {
|
||||
return `<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
@@ -45,3 +50,51 @@ export const getHTML = (opts: HTMLOptions) => {
|
||||
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>
|
||||
</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>`;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user