feat: 添加query WS的功能

This commit is contained in:
2024-09-28 18:35:50 +08:00
parent 632d164087
commit ed178ee4c6
11 changed files with 239 additions and 13 deletions

View File

@@ -16,9 +16,12 @@
}
},
"..": {
"name": "@abearxiong/query",
"version": "0.0.1",
"name": "@kevisual/query",
"version": "0.0.2-alpha.0",
"license": "ISC",
"dependencies": {
"zustand": "^4.5.5"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-typescript": "^11.1.6",

View File

@@ -3,7 +3,7 @@
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"dev": "vite"
},
"keywords": [],
"author": "",

View File

@@ -1,5 +1,6 @@
// console.log('Hello World');
import { adapter, Query } from '@abearxiong/query';
import { QueryWs } from '@abearxiong/query/ws';
window.onload = async () => {
// const res = await adapter({
@@ -27,4 +28,13 @@ window.onload = async () => {
},
);
console.log(res);
const queryWs = new QueryWs({ url: '/api/router' });
// queryWs.conn
queryWs.listenConnect(() => {
console.log('Connected');
});
queryWs.listenConnect(() => {
console.log('Connected2');
});
};

View File

@@ -9,10 +9,17 @@ export default defineConfig({
port: 6102,
// host: '::',
proxy: {
'/api/router': {
target: 'http://127.0.0.1:3003',
'/api': {
target: 'http://127.0.0.1:4000',
changeOrigin: true,
},
'/api/router': {
target: 'ws://localhost:4000',
changeOrigin: true,
ws: true,
rewriteWsOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '/api'),
},
},
},
// define: {