perf: app.ts
This commit is contained in:
parent
362ab9b952
commit
14224ccd61
@ -24,7 +24,7 @@
|
||||
"zustand": "^5.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@kevisual/router": "0.0.6-alpha-4",
|
||||
"@kevisual/router": "0.0.6-alpha-5",
|
||||
"@kevisual/store": "0.0.1-alpha.9",
|
||||
"@kevisual/types": "^0.0.5",
|
||||
"@types/react": "^19.0.2",
|
||||
@ -33,6 +33,6 @@
|
||||
"@vitejs/plugin-react": "^4.3.4",
|
||||
"cross-env": "^7.0.3",
|
||||
"react": "^19.0.0",
|
||||
"vite": "^6.0.6"
|
||||
"vite": "^6.0.7"
|
||||
}
|
||||
}
|
12
src/app.ts
12
src/app.ts
@ -0,0 +1,12 @@
|
||||
import type { Page } from '@kevisual/store/page';
|
||||
import type { QueryRouterServer } from '@kevisual/router';
|
||||
export const page = useContextKey('page', () => {
|
||||
return new window.Page({
|
||||
basename: '',
|
||||
}) as unknown as Page;
|
||||
});
|
||||
|
||||
export const app = useContextKey('app', () => {
|
||||
console.error('app not found');
|
||||
return null as unknown as QueryRouterServer;
|
||||
});
|
17
src/main.ts
17
src/main.ts
@ -1,18 +1,10 @@
|
||||
import { useContextKey } from '@kevisual/store/config';
|
||||
import { Page } from '@kevisual/store/page';
|
||||
import { QueryRouterServer } from '@kevisual/router';
|
||||
import { page, app } from './app.ts';
|
||||
export const render = ({ renderRoot }) => {
|
||||
renderRoot.innerHTML = `
|
||||
<h1>Hello, World!</h1>
|
||||
`;
|
||||
};
|
||||
|
||||
const page = useContextKey('page', () => {
|
||||
return new Page({
|
||||
basename: '',
|
||||
});
|
||||
});
|
||||
|
||||
if (page) {
|
||||
page.addPage('/app-template', 'home');
|
||||
page.subscribe('home', () => {
|
||||
@ -22,10 +14,6 @@ if (page) {
|
||||
});
|
||||
}
|
||||
|
||||
const app = useContextKey('app', () => {
|
||||
console.error('app not found');
|
||||
return null as unknown as QueryRouterServer;
|
||||
});
|
||||
if (app) {
|
||||
app
|
||||
.route({
|
||||
@ -46,5 +34,6 @@ if (app) {
|
||||
render({
|
||||
renderRoot,
|
||||
});
|
||||
}).addTo(app);
|
||||
})
|
||||
.addTo(app);
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ export default defineConfig({
|
||||
'@': path.resolve(__dirname, './src'),
|
||||
},
|
||||
},
|
||||
base: isDev ? '/' : './',
|
||||
define: {
|
||||
DEV_SERVER: JSON.stringify(isDev),
|
||||
BUILD_TIME: JSON.stringify(BUILD_TIME),
|
||||
@ -40,12 +41,10 @@ export default defineConfig({
|
||||
'/api': {
|
||||
target: 'https://kevisual.xiongxiao.me',
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/api/, '/api'),
|
||||
},
|
||||
'/system': {
|
||||
'/system/lib': {
|
||||
target: 'https://kevisual.xiongxiao.me',
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/system/, '/system'),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
Reference in New Issue
Block a user