client: 更新鉴权请求头等
This commit is contained in:
@@ -1,6 +1,15 @@
|
|||||||
# v-chat
|
# v-chat
|
||||||
微信多客户端方案。服务器通过Web版微信接口提供收发微信消息的能力,并允许多个客户端同时连接。
|
微信多客户端方案。服务器通过Web版微信接口提供收发微信消息的能力,并允许多个客户端同时连接。
|
||||||
|
|
||||||
|
## 使用
|
||||||
|
### 服务端
|
||||||
|
`cd packages/server`
|
||||||
|
`node ./ -c CONFIG_FILE`
|
||||||
|
|
||||||
|
### 客户端
|
||||||
|
`cd packages/web`
|
||||||
|
参考`.env.example`文件,编辑`.env`文件配置环境变量,然后编译:`npm run build`。
|
||||||
|
|
||||||
## 鸣谢
|
## 鸣谢
|
||||||
前端程序参考自[fiora](https://github.com/yinxin630/fiora)web聊天室。
|
前端程序参考自[fiora](https://github.com/yinxin630/fiora)web聊天室。
|
||||||
服务端程序使用了[wechat4u](https://github.com/nodeWechat/wechat4u)。
|
服务端程序使用了[wechat4u](https://github.com/nodeWechat/wechat4u)。
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
APP_NAME=dubug
|
||||||
|
APP_CODE=dubug
|
||||||
|
SERVER=http://localhost:8094
|
||||||
|
API_BASE=http://localhost:8094/
|
||||||
|
SOCKET_PATH=/socket.io
|
||||||
@@ -5,8 +5,7 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "cross-env NODE_ENV=development webpack serve --config build/webpack.dev.js",
|
"start": "cross-env NODE_ENV=development webpack serve --config build/webpack.dev.js",
|
||||||
"build": "rm -rf dist && cross-env NODE_ENV=production webpack --config build/webpack.prod.js",
|
"build": "rm -rf dist && cross-env NODE_ENV=production webpack --config build/webpack.prod.js"
|
||||||
"build-relative": "rm -rf dist && cross-env NODE_ENV=production PublicPath=./ webpack --config build/webpack.prod.js"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@loadable/component": "^5.15.0",
|
"@loadable/component": "^5.15.0",
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
import { MB } from '../utils/const';
|
import { MB } from '../utils/const';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
app_name: 'mattuy-laptop',
|
app_name: process.env.APP_NAME || 'debug',
|
||||||
app_code: 'iasdjfkwe3ds-qw3rjkwjfda8',
|
app_code: process.env.APP_CODE || 'debug',
|
||||||
server:
|
server:
|
||||||
process.env.Server ||
|
process.env.SERVER ||
|
||||||
(process.env.NODE_ENV === 'development' ? '//localhost:9200/' : '/bg/'),
|
(process.env.NODE_ENV === 'development' ? '//localhost:8094' : '/'),
|
||||||
|
socketPath: process.env.SOCKET_PATH || '/socket.io',
|
||||||
|
apiBase: process.env.API_BASE || '/',
|
||||||
maxImageSize: process.env.MaxImageSize
|
maxImageSize: process.env.MaxImageSize
|
||||||
? parseInt(process.env.MaxImageSize, 10)
|
? parseInt(process.env.MaxImageSize, 10)
|
||||||
: MB * 5,
|
: MB * 5,
|
||||||
@@ -24,16 +25,4 @@ export default {
|
|||||||
defaultTheme: process.env.DefaultTheme || 'cool',
|
defaultTheme: process.env.DefaultTheme || 'cool',
|
||||||
sound: process.env.Sound || 'default',
|
sound: process.env.Sound || 'default',
|
||||||
tagColorMode: process.env.TagColorMode || 'fixedColor',
|
tagColorMode: process.env.TagColorMode || 'fixedColor',
|
||||||
|
|
||||||
/**
|
|
||||||
* 前端监控: https://yueying.effirst.com/index
|
|
||||||
* 值为监控应用id, 为空则不启用监控
|
|
||||||
*/
|
|
||||||
frontendMonitorAppId: process.env.FrontendMonitorAppId || '',
|
|
||||||
|
|
||||||
// 禁止用户撤回消息, 不包括管理员, 管理员始终能撤回任何消息
|
|
||||||
// 默认是禁止的
|
|
||||||
disableDeleteMessage: process.env.DisableDeleteMessage
|
|
||||||
? process.env.DisableDeleteMessage === 'true'
|
|
||||||
: false,
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -22,8 +22,10 @@ window.onblur = () => {
|
|||||||
windowStatus = 'blur';
|
windowStatus = 'blur';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 只能通过path参数指定socket url,即使uri参数包含路径也会被忽略
|
||||||
const socket = IO(config.server, {
|
const socket = IO(config.server, {
|
||||||
autoConnect: false,
|
autoConnect: false,
|
||||||
|
path: config.socketPath,
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('connect', async () => {
|
socket.on('connect', async () => {
|
||||||
|
|||||||
@@ -2,10 +2,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>fiora</title>
|
<title>vchat</title>
|
||||||
<meta name=keywords content="fiora,碎碎酱,聊天室,node.js聊天室,网页聊天室,web聊天室,fiora聊天室,开源聊天室">
|
|
||||||
<meta name=description content="fiora聊天室是基于node.js和react由碎碎酱独自开发的开源网页聊天室,使用socket.io模块WebSocket协议通讯,支持Service Worker和PWA.功能丰富,并且简单易上手,很适合作为学习node.js的参考项目,node.js初学者的福音">
|
|
||||||
<meta name=author content=碎碎酱>
|
|
||||||
<meta name=viewport content="viewport-fit=cover,width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no">
|
<meta name=viewport content="viewport-fit=cover,width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no">
|
||||||
<link rel="shortcut icon" href="/favicon-192.png">
|
<link rel="shortcut icon" href="/favicon-192.png">
|
||||||
<% if (process.env.NODE_ENV === 'production') { %>
|
<% if (process.env.NODE_ENV === 'production') { %>
|
||||||
@@ -14,7 +11,7 @@
|
|||||||
<!-- Add to home screen for Safari on iOS -->
|
<!-- Add to home screen for Safari on iOS -->
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||||
<meta name="apple-mobile-web-app-title" content="fiora">
|
<meta name="apple-mobile-web-app-title" content="vchat">
|
||||||
<link rel="apple-touch-icon" href="/favicon-192.png">
|
<link rel="apple-touch-icon" href="/favicon-192.png">
|
||||||
<!-- Windows -->
|
<!-- Windows -->
|
||||||
<meta name="msapplication-TileImage" content="/favicon-192.png">
|
<meta name="msapplication-TileImage" content="/favicon-192.png">
|
||||||
|
|||||||
@@ -9,10 +9,11 @@ import { sessionID } from '../socket';
|
|||||||
export default async function uploadFile(blob: Blob): Promise<string> {
|
export default async function uploadFile(blob: Blob): Promise<string> {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('file', blob);
|
formData.append('file', blob);
|
||||||
const resp = await fetch(config.server + 'upload_file', {
|
const url =
|
||||||
headers: {
|
config.apiBase +
|
||||||
session_id: sessionID,
|
(config.apiBase.endsWith('/') ? 'upload_file' : '/upload_file');
|
||||||
},
|
const resp = await fetch(url, {
|
||||||
|
headers: { 'sid': sessionID },
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: formData,
|
body: formData,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
cd "$(dirname "$0")" && cd ../packages/web || exit 1
|
|
||||||
if ! npm run-script build; then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [[ $(ssh master@home.mattuy.top -e /data/share/www-root/vchat) ]]; then
|
|
||||||
echo "远程目录已存在,跳过复制"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
echo 复制编译结果到远程目录...
|
|
||||||
scp -r ./dist/fiora master@home.mattuy.top:/data/share/www-root/vchat
|
|
||||||
Reference in New Issue
Block a user