feat: 添加web项目基础配置和依赖
添加web项目基础结构,包括vite配置、ts配置、package.json和示例代码 添加pnpm工作区配置 更新.gitignore包含pnpm-store
This commit is contained in:
15
web/.gitignore
vendored
Normal file
15
web/.gitignore
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
.env
|
||||
!.env*development
|
||||
|
||||
node_modules
|
||||
|
||||
dist
|
||||
pack-dist
|
||||
|
||||
.DS_Store
|
||||
|
||||
.pnpm-store
|
||||
|
||||
.vite
|
||||
|
||||
.astro
|
||||
15
web/index.html
Normal file
15
web/index.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Light Code</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="./src/main.ts"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
22
web/kevisual.json
Normal file
22
web/kevisual.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"metadata": {
|
||||
"name": "kevisual",
|
||||
"share": "public"
|
||||
},
|
||||
"registry": "https://kevisual.cn/root/ai/kevisual/frontend/simple-html",
|
||||
"clone": {
|
||||
".": {
|
||||
"enabled": true
|
||||
}
|
||||
},
|
||||
"syncd": [
|
||||
{
|
||||
"files": [
|
||||
"**/*"
|
||||
],
|
||||
"registry": ""
|
||||
}
|
||||
],
|
||||
"sync": {
|
||||
}
|
||||
}
|
||||
18
web/package.json
Normal file
18
web/package.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "@kevisual/simple-html",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"basename": "/root/simple-html",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"packageManager": "pnpm@10.27.0",
|
||||
"devDependencies": {
|
||||
"@kevisual/types": "^0.0.10",
|
||||
"vite": "^7.3.0"
|
||||
}
|
||||
}
|
||||
5
web/public/sw.js
Normal file
5
web/public/sw.js
Normal file
@@ -0,0 +1,5 @@
|
||||
import { main } from './sw2.js';
|
||||
self.onmessage = function (e) {
|
||||
console.log(e.data, typeof e.data);
|
||||
main(e.data);
|
||||
}
|
||||
3
web/public/sw2.js
Normal file
3
web/public/sw2.js
Normal file
@@ -0,0 +1,3 @@
|
||||
export const main = () => {
|
||||
console.log('sw2');
|
||||
};
|
||||
11
web/src/main.ts
Normal file
11
web/src/main.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
const root = document.querySelector('#root');
|
||||
root.innerHTML = '<h1>Hello World</h1>';
|
||||
|
||||
const worker = new Worker('./public/sw.js', { type: 'module' });
|
||||
|
||||
worker.onmessage = (event) => {
|
||||
console.log(event.data);
|
||||
};
|
||||
|
||||
worker.postMessage({ type: 'ping' });
|
||||
worker.postMessage({ type: 'pong' });
|
||||
20
web/tsconfig.json
Normal file
20
web/tsconfig.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"extends": "@kevisual/types/json/frontend.json",
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"strict": false,
|
||||
"paths": {
|
||||
"@/*": [
|
||||
"./src/*"
|
||||
],
|
||||
"@/agent": [
|
||||
"./src/agent"
|
||||
]
|
||||
},
|
||||
},
|
||||
"include": [
|
||||
"src/**/*",
|
||||
"agent/**/*",
|
||||
"typings.d.ts"
|
||||
],
|
||||
}
|
||||
1
web/typings.d.ts
vendored
Normal file
1
web/typings.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
declare var context: any;
|
||||
41
web/vite.config.ts
Normal file
41
web/vite.config.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import path from 'path';
|
||||
import pkgs from './package.json';
|
||||
import dotenv from 'dotenv';
|
||||
dotenv.config();
|
||||
const isDev = process.env.NODE_ENV === 'development';
|
||||
const plugins: any = [];
|
||||
|
||||
let target = process.env.VITE_API_URL || 'http://localhost:51515';
|
||||
const apiProxy = { target: target, changeOrigin: true, ws: true, rewriteWsOrigin: true, secure: false, cookieDomainRewrite: 'localhost' };
|
||||
let proxy = {
|
||||
'/root/': apiProxy,
|
||||
'/api': apiProxy,
|
||||
'/client': apiProxy,
|
||||
};
|
||||
const ENV_BASE_NAME = process.env.BASE_NAME;
|
||||
|
||||
const _basename = ENV_BASE_NAME || pkgs.basename;
|
||||
const basename = isDev ? undefined : `${_basename}`;
|
||||
/**
|
||||
* @see https://vitejs.dev/config/
|
||||
*/
|
||||
export default defineConfig({
|
||||
plugins,
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': path.resolve(__dirname, './src'),
|
||||
},
|
||||
},
|
||||
base: basename,
|
||||
define: {
|
||||
BASE_NAME: JSON.stringify(basename),
|
||||
BUILD_TIME: JSON.stringify(new Date().toISOString()),
|
||||
},
|
||||
server: {
|
||||
port: 7008,
|
||||
host: '::',
|
||||
allowedHosts: true,
|
||||
proxy,
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user