shihuojian commited on
Commit
70024a5
·
1 Parent(s): 58e0fb5
ndcc/_cms/routeCode/index.js CHANGED
@@ -137,7 +137,7 @@ function App(props={}) {
137
  if(reload){
138
  params.updateFile = updateFile;
139
  }
140
- props.socket.routeCode.emit('post',params);
141
  saveHistory(value);
142
 
143
  // _.post(`/code/update?collection=${collection}`,params).then(res=>{
 
137
  if(reload){
138
  params.updateFile = updateFile;
139
  }
140
+ props.socket.routeCode.emit('db',params);
141
  saveHistory(value);
142
 
143
  // _.post(`/code/update?collection=${collection}`,params).then(res=>{
ndcc/server/plugins/socket.js CHANGED
@@ -79,12 +79,12 @@ exports.plugin = {
79
  const request = socket.auth.request
80
  request.socket = socket;
81
 
82
- //设置种方法,一种通过handler自己可以写逻辑,第二种定义post方法直接操作数据库
83
- if(typeof settings.handler === 'function'){
84
  const {req,res} = await new Basic(request,server).init();
85
  settings.handler(req,res)
86
  }else{
87
- socket.on('post',async (options)=>{
88
  const {collection,action,callback_id} = options;
89
  try{
90
  let result = await mongodb(request,collection,{},server).payload(options)[action]();
@@ -93,7 +93,16 @@ exports.plugin = {
93
  const {output} = Boom.badRequest(e.message)
94
  socket.emit(callback_id,output)
95
  }
96
- })
 
 
 
 
 
 
 
 
 
97
  }
98
  });
99
  item.settings.plugins['socket'].io = io
 
79
  const request = socket.auth.request
80
  request.socket = socket;
81
 
82
+ //设置4种方法,一种通过handler自己可以写逻辑,但是每次都需要重启服务器,第二种定义db方法直接操作数据库,三四可以直接注入get、post请求。实现无刷新
83
+ if(typeof settings.handler === 'function'){
84
  const {req,res} = await new Basic(request,server).init();
85
  settings.handler(req,res)
86
  }else{
87
+ socket.on('db',async (options)=>{
88
  const {collection,action,callback_id} = options;
89
  try{
90
  let result = await mongodb(request,collection,{},server).payload(options)[action]();
 
93
  const {output} = Boom.badRequest(e.message)
94
  socket.emit(callback_id,output)
95
  }
96
+ });
97
+ // socket.on('post',async (payload)=>{
98
+ // const result = await server.inject({url:"/socket/auth",method:"POST",
99
+ // payload,
100
+ // plugins:{
101
+ // request
102
+ // }
103
+ // });
104
+ // // console.log(result,'====')
105
+ // })
106
  }
107
  });
108
  item.settings.plugins['socket'].io = io
src/pages/web/ZhkJRJZe81m1AB-0/index.js CHANGED
@@ -1,6 +1,6 @@
1
  import Container from './style';
2
  const io = require('socket.io-client');
3
- import {post,get,useState,useEffect,decompress} from "@/components/_cms/_";
4
 
5
  export default function App(props) {
6
  const start = async () => {
@@ -13,6 +13,8 @@ export default function App(props) {
13
  console.log(value)
14
  });
15
 
 
 
16
 
17
 
18
  // async function post(url = '', data = {}) {
@@ -41,7 +43,7 @@ export default function App(props) {
41
 
42
  return (
43
  <Container>
44
- tttt
45
  </Container>
46
  )
47
  }
 
1
  import Container from './style';
2
  const io = require('socket.io-client');
3
+ import {post,get,useState,useEffect,decompress} from "ndcc/_cms/_";
4
 
5
  export default function App(props) {
6
  const start = async () => {
 
13
  console.log(value)
14
  });
15
 
16
+ // socket.emit('post',{name:'testPost'})
17
+
18
 
19
 
20
  // async function post(url = '', data = {}) {
 
43
 
44
  return (
45
  <Container>
46
+ tttt1222
47
  </Container>
48
  )
49
  }
src/pages/web/Zi9DvwHCONdkSAtP/index.js ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import style from './style.module.scss';
3
+ import Container from './style';
4
+ export default (props) =>{
5
+ return (
6
+ <Container>
7
+ <div className={style.root}>
8
+ <h1>Hello test2sss!</h1>
9
+ </div>
10
+ </Container>
11
+ )
12
+ }
src/pages/web/Zi9DvwHCONdkSAtP/style.js ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+
2
+ import { styled } from '@mui/material/styles'
3
+ export default (props)=>{
4
+ const Style = styled('div')({
5
+
6
+ });
7
+ return <Style>{props.children}</Style>
8
+ }
src/pages/web/Zi9DvwHCONdkSAtP/style.module.scss ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+
2
+ .root :global{
3
+ h1{
4
+ color: black;
5
+ }
6
+ }