Compare commits

...

10 Commits

3 changed files with 177 additions and 55 deletions

132
.gitignore vendored
View File

@@ -1,63 +1,113 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# how to include another gitignore?
# https://stackoverflow.com/questions/7005142/can-i-include-other-gitignore-file-in-a-gitignore-file-like-include-in-c-li
# https://github.com/github/gitignore
# https://github.com/SlideWave/gitignore-include?tab=readme-ov-file#examples
# https://gitignore.io
node_modules/ ### .gitignore.global.txt ###
/test/unit/coverage/
/test/e2e/reports/ # Self defined pattern to ignore
?*.gitignore
?*.gitignore/
?*.gitignore.*
?*.gitignore.*/
*.gitomit
*.gitomit.*
*.gitomit/
*.gitomit.*/
*.nogit
*.nogit.*
*.nogit/
*.nogit.*/
# 保留
!.gitignore
!.gitignore.*
!.gitkeep
# 通用
.svn/ .svn/
.deploy_git/
.idea/ .idea/
.sass-cache/ .sass-cache/
.deploy_git/ .wrangler
/test/unit/coverage/
/test/e2e/reports/
node_modules/
*.aab
*.apk
*.ipa
*.min.js
*.min.css
*.min.html
*.iml
*.njsproj
*.ntvs*
*.sw*
*.sln
*.suo
.gitattributes .gitattributes
_desktop.ini
.DS_Store
.thumbnails
Thumbs.db
thumbs.db
.umi .umi
.umi-production .umi-production
npm-debug.log* npm-debug.log*
yarn-debug.log* yarn-debug.log*
yarn-error.log* yarn-error.log*
yarn.lock
selenium-debug.log selenium-debug.log
package-lock.json Thumbs.db
*.iml thumbs.db
*.njsproj _desktop.ini
*.ntvs*
*.sln
*.suo
._*
.$*
~$*
.bashrc_custom # vue-cli 项目
/dist/
# 来自 vue-cli 创建项目的 .gitignore
.project
# hexo # hexo
db.json /public/
# 客户端 uniapp 项目 # Hardhat
/unpackage/dist /artifacts/
/unpackage/release /cache/
/unpackage/cache
# seafile 临时文件
._*
.$*
# office 暂存文件
~$*
# 用户shell配置脚本
.bashrc_custom
# 苹果系统临时文件
.DS_Store
# 安卓缓存文件夹
.thumbnails
# local env files
.env.local
.env.*.local
# hexo
/db.json
# wo
# 服务端
/_archive/* /_archive/*
/_datastore/* /_datastore/*
/_logstore/*
/_filestore/* /_filestore/*
/_logstore/*
/_webroot/* /_webroot/*
/dist/ /_ssl/*
*.apk # uniapp 客户端
*.min.js /unpackage/*
*.min.css !/unpackage/res/
*.min.html package-lock.json
/pages4loader.json5 pages4loader.json5
envar-web-custom.js
envar-deploy-secret.js
# hexo 项目 ### .gitignore.local.txt ###
public/
# 服务端(server or uniapp-uniCloud)项目
envar-base-custom.js
envar-base-dynamic.js
envar-base-secret.js
!.gitkeep

View File

@@ -14,14 +14,14 @@ const DAD = (module.exports = class RpcSocket extends ws {
ws.sid = randomBytes(16).toString('hex') ws.sid = randomBytes(16).toString('hex')
ws.onmessage = async ({ data }) => { ws.onmessage = async ({ data }) => {
// console.log('[onmessage] 被调用在 data =', data) // console.log({ _at: new Date().toJSON(), about:'[onmessage] 被调用在 data =', data}, '\n,')
try { try {
let { rpcType, rpcHow, rpcWhat, randomEvent, rpcResult } = JSON.parse(data) let { rpcType, rpcHow, rpcWhat, randomEvent, rpcResult } = JSON.parse(data)
// console.log('message data parsed to ', {rpcType, rpcHow, rpcWhat, randomEvent, rpcResult}) // console.log({ _at: new Date().toJSON(), about:'message data parsed', rpcType, rpcHow, rpcWhat, randomEvent, rpcResult}, '\n,')
switch (rpcType) { switch (rpcType) {
case 'SEND_REQUEST': case 'SEND_REQUEST':
// 接收到异步的远程调用 // 接收到异步的远程调用
// console.log(`被调方 收到 SEND_REQUEST: rpcHow=${rpcHow}, rpcWhat=${JSON.stringify(rpcWhat)}`) // console.log({ _at: new Date().toJSON(), about:'被调方 收到 SEND_REQUEST', rpcHow, rpcWhat}, '\n,')
if (ws.hasOwnProperty(rpcHow)) rpcResult = await ws[rpcHow](rpcWhat) if (ws.hasOwnProperty(rpcHow)) rpcResult = await ws[rpcHow](rpcWhat)
else rpcResult = { _state: 'ERROR', _stateMsg: `unknown rpcHow=${rpcHow}` } else rpcResult = { _state: 'ERROR', _stateMsg: `unknown rpcHow=${rpcHow}` }
if (randomEvent) { if (randomEvent) {
@@ -30,20 +30,20 @@ const DAD = (module.exports = class RpcSocket extends ws {
break break
case 'SEND_RESULT': case 'SEND_RESULT':
// 接收到远程返回的结果 // 接收到远程返回的结果
// console.log('主调方 收到 SEND_RESULT: rpcResult=', rpcResult) // console.log({ _at: new Date().toJSON(),about:'主调方 收到 SEND_RESULT', rpcResult}, '\n,')
ws.emit(randomEvent, rpcResult) ws.emit(randomEvent, rpcResult)
break break
case 'SEND_NOTIFY': case 'SEND_NOTIFY':
default: default:
// 接收到同步的远程调用 或者 标准ws的send(...) // 接收到同步的远程调用 或者 标准ws的send(...)
// console.log(`被调方 收到 SEND_NOFITY: rpcHow=${rpcHow}, rpcWhat=${JSON.stringify(rpcWhat)}`) // console.log({ _at: new Date().toJSON(),about:'被调方 收到 SEND_NOFITY', rpcHow, rpcWhat})
if (ws.hasOwnProperty(rpcHow)) ws[rpcHow](rpcWhat) if (ws.hasOwnProperty(rpcHow)) ws[rpcHow](rpcWhat)
else if (ws.eventNames().indexOf(rpcHow) >= 0) ws.emit(rpcHow, rpcWhat) else if (ws.eventNames().indexOf(rpcHow) >= 0) ws.emit(rpcHow, rpcWhat)
else console.error('[onmessage] unknown rpc: ', rpcHow, rpcWhat) else console.error({ _at: new Date().toJSON(), about: '[onmessage] unknown rpc', rpcHow, rpcWhat }, '\n,')
break break
} }
} catch (exception) { } catch (exception) {
console.error('[onmessage] invalid rpc data: ', data, exception) console.error({ _at: new Date().toJSON(), about: '[onmessage] invalid rpc data', data, exception }, '\n,')
return return
} }
} }
@@ -78,11 +78,11 @@ const DAD = (module.exports = class RpcSocket extends ws {
sendRequest ({ rpcHow, rpcWhat, rpcCallback, timeout = 5000 } = {}) { sendRequest ({ rpcHow, rpcWhat, rpcCallback, timeout = 5000 } = {}) {
// 发起异步的远程调用 // 发起异步的远程调用
let randomEvent = randomBytes(16).toString('hex') let randomEvent = randomBytes(16).toString('hex')
// console.log('randomEvent is randomized: ', randomEvent) // console.log({ _at: new Date().toJSON(),about:'randomEvent is randomized', randomEvent})
if (typeof rpcCallback === 'function') { if (typeof rpcCallback === 'function') {
// 有回调 // 有回调
this.send(JSON.stringify({ rpcType: 'SEND_REQUEST', rpcHow, rpcWhat, randomEvent }), () => { this.send(JSON.stringify({ rpcType: 'SEND_REQUEST', rpcHow, rpcWhat, randomEvent }), () => {
// console.log('in callback, randomEvent=', randomEvent) // console.log({ _at: new Date().toJSON(),about:'in callback', randomEvent})
this.once(randomEvent, rpcCallback) this.once(randomEvent, rpcCallback)
setTimeout(() => { setTimeout(() => {
if (this.eventNames().indexOf(randomEvent) >= 0) { if (this.eventNames().indexOf(randomEvent) >= 0) {

72
seafile-ignore.txt Normal file
View File

@@ -0,0 +1,72 @@
# https://help.seafile.com/syncing_client/excluding_files/
# 注释。通配符:* 匹配0到若干个字符包括代表目录的/。? 匹配1个字符包括/。
# seafile-ignore.txt 只能控制在客户端需要忽略哪些文件。你依然可以在 seahub 的 web 界面创建这些被客户端忽略的文件。
# 在这种情况下,
# 这些文件会被同步到客户端,但是用户在客户端对这些文件的后续修改会被忽略,不会被同步回服务器。
# 文件在服务器端的后续更改会被同步到客户端,如果客户端也同时修改了这些文件,系统会生成冲突文件。
# seafile-ignore.txt 只能忽略还没有被同步的文件。对于已经被同步的文件,如果后来把它添加到 seafile-ignore.txt 中,系统只会忽略后续更改,已经上传的版本不会受影响。
### seafile-ignore.global.txt ###
# 自定义的后缀名,凡有 sfignore 后缀的都不进行同步
*.sfignore
*.sfignore/
*.sfignore.*
*.sfignore.*/
*.sfomit
*.sfomit.*
*.sfomit/
*.sfomit.*/
*.nosf
*.nosf.*
*.nosf/
*.nosf.*/
.DS_Store
*/.DS_Store
.thumbnails
*/.thumbnails
Thumbs.db
*/Thumbs.db
thumbs.db
*/thumbs.db
_desktop.ini
*/_desktop.ini
._*
*/._*
.$*
*/.$*
~$*
*/~$*
node_modules/
*/node_modules/
package-lock.json
pages4loader.json5
.deploy_git/
*/.deploy_git/
# HBuilder 目录
unpackage/
*/unpackage/
Icon
OneDrive/Icon
# wrangler project
.dev.vars*
*/.dev.vars*
.wrangler/
*/.wrangler/
### seafile-ignore.local.txt ###