update app-template
This commit is contained in:
parent
11ac3a22ab
commit
0297d69cdb
@ -3,6 +3,7 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>AI Apps</title>
|
<title>AI Apps</title>
|
||||||
|
<link rel="stylesheet" href="./src/assets/index.css">
|
||||||
<style>
|
<style>
|
||||||
html,
|
html,
|
||||||
body {
|
body {
|
||||||
@ -23,6 +24,7 @@
|
|||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="ai-root"></div>
|
<div id="ai-root"></div>
|
||||||
|
<div id="ai-bot-root"></div>
|
||||||
</body>
|
</body>
|
||||||
<script src="./src/main.ts" type="module"></script>
|
<script src="./src/main.ts" type="module"></script>
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
|
"basename": "/me/app/",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"dev:web": "cross-env WEB_DEV=true vite --mode web",
|
"dev:web": "cross-env WEB_DEV=true vite --mode web",
|
||||||
@ -33,6 +34,7 @@
|
|||||||
"@kevisual/router": "0.0.6-alpha-5",
|
"@kevisual/router": "0.0.6-alpha-5",
|
||||||
"@kevisual/store": "0.0.1-alpha.10",
|
"@kevisual/store": "0.0.1-alpha.10",
|
||||||
"@kevisual/types": "^0.0.6",
|
"@kevisual/types": "^0.0.6",
|
||||||
|
"@tailwindcss/vite": "^4.0.9",
|
||||||
"@types/react": "^19.0.8",
|
"@types/react": "^19.0.8",
|
||||||
"@types/react-dom": "^19.0.3",
|
"@types/react-dom": "^19.0.3",
|
||||||
"@vitejs/plugin-basic-ssl": "^1.2.0",
|
"@vitejs/plugin-basic-ssl": "^1.2.0",
|
||||||
@ -40,6 +42,7 @@
|
|||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"esbuild": "^0.25.0",
|
"esbuild": "^0.25.0",
|
||||||
"react": "^19.0.0",
|
"react": "^19.0.0",
|
||||||
|
"tailwindcss": "^4.0.9",
|
||||||
"vite": "^6.1.0"
|
"vite": "^6.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
770
pnpm-lock.yaml
generated
770
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -1,11 +1,11 @@
|
|||||||
import type { Page } from '@kevisual/store/page';
|
import type { Page } from '@kevisual/store/page';
|
||||||
import type { QueryRouterServer } from '@kevisual/router';
|
import type { QueryRouterServer } from '@kevisual/router';
|
||||||
|
import { basename } from './modules/basename';
|
||||||
export const page = useContextKey('page', () => {
|
export const page = useContextKey('page', () => {
|
||||||
return new window.Page({
|
return new window.Page({
|
||||||
basename: '',
|
basename,
|
||||||
}) as unknown as Page;
|
}) as unknown as Page;
|
||||||
});
|
});
|
||||||
|
|
||||||
export const app = useContextKey('app', () => {
|
export const app = useContextKey('app', () => {
|
||||||
console.error('app not found');
|
console.error('app not found');
|
||||||
return null as unknown as QueryRouterServer;
|
return null as unknown as QueryRouterServer;
|
||||||
|
10
src/assets/index.css
Normal file
10
src/assets/index.css
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
@import 'tailwindcss';
|
||||||
|
@config "../../tailwind.config.js";
|
||||||
|
#ai-bot-root {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: -100px;
|
||||||
|
z-index: 9999;
|
||||||
|
}
|
@ -1,9 +1,11 @@
|
|||||||
import { page, app } from './app.ts';
|
import { page, app } from './app.ts';
|
||||||
|
import { basename } from './modules/basename.ts';
|
||||||
export const render = ({ renderRoot }) => {
|
export const render = ({ renderRoot }) => {
|
||||||
renderRoot.innerHTML = `
|
renderRoot.innerHTML = `
|
||||||
<h1>Hello, World!</h1>
|
<h1>Hello, World!</h1>
|
||||||
`;
|
`;
|
||||||
};
|
};
|
||||||
|
console.log('basename', basename, page, app);
|
||||||
|
|
||||||
if (page) {
|
if (page) {
|
||||||
page.addPage('/app-template', 'home');
|
page.addPage('/app-template', 'home');
|
||||||
@ -12,6 +14,13 @@ if (page) {
|
|||||||
renderRoot: document.getElementById('ai-root'),
|
renderRoot: document.getElementById('ai-root'),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
page.addPage('', 'index');
|
||||||
|
page.subscribe('index', () => {
|
||||||
|
const root = document.getElementById('ai-root') as HTMLElement;
|
||||||
|
root.innerHTML = `
|
||||||
|
<h1>Hello, World!</h1>
|
||||||
|
`;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (app) {
|
if (app) {
|
||||||
|
2
src/modules/basename.ts
Normal file
2
src/modules/basename.ts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
// @ts-ignore
|
||||||
|
export const basename = DEV_SERVER ? '/' : BASE_NAME;
|
3
tailwind.config.js
Normal file
3
tailwind.config.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
module.exports = {
|
||||||
|
root: '#ai-root',
|
||||||
|
};
|
@ -3,11 +3,14 @@ import basicSsl from '@vitejs/plugin-basic-ssl';
|
|||||||
// import react from '@vitejs/plugin-react';
|
// import react from '@vitejs/plugin-react';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
import tailwindcss from '@tailwindcss/vite'
|
||||||
|
import pkgs from './package.json' with { type: 'json' };
|
||||||
|
|
||||||
const isDev = process.env.NODE_ENV === 'development';
|
const isDev = process.env.NODE_ENV === 'development';
|
||||||
const isWebDev = process.env.WEB_DEV === 'true';
|
const isWebDev = process.env.WEB_DEV === 'true';
|
||||||
const BUILD_TIME = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
const BUILD_TIME = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
||||||
let plugins = [];
|
const basename = pkgs.basename;
|
||||||
|
let plugins = [tailwindcss(),];
|
||||||
|
|
||||||
if (!isWebDev) {
|
if (!isWebDev) {
|
||||||
// 在bolt的web开发环境下不需要ssl
|
// 在bolt的web开发环境下不需要ssl
|
||||||
@ -22,10 +25,11 @@ export default defineConfig({
|
|||||||
'@': path.resolve(__dirname, './src'),
|
'@': path.resolve(__dirname, './src'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
base: isDev ? '/' : './',
|
base: isDev ? '/' : basename,
|
||||||
define: {
|
define: {
|
||||||
DEV_SERVER: JSON.stringify(isDev),
|
DEV_SERVER: JSON.stringify(isDev),
|
||||||
BUILD_TIME: JSON.stringify(BUILD_TIME),
|
BUILD_TIME: JSON.stringify(BUILD_TIME),
|
||||||
|
BASE_NAME: JSON.stringify(basename),
|
||||||
},
|
},
|
||||||
optimizeDeps: {
|
optimizeDeps: {
|
||||||
exclude: ['react'], // 排除 react 和 react-dom 以避免打包
|
exclude: ['react'], // 排除 react 和 react-dom 以避免打包
|
||||||
|
Reference in New Issue
Block a user