48 lines
958 B
TypeScript
48 lines
958 B
TypeScript
type HTMLOptions = {
|
|
title?: string;
|
|
rootId: string;
|
|
dataKey?: string;
|
|
};
|
|
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>
|
|
</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);
|
|
};
|