feat: 移除剪贴板/SSO改造/sso_id恢复bigint/HTTPS证书更新/麦克风权限修复

This commit is contained in:
liufumingren 2026-05-02 20:07:49 +08:00
parent f5095cb0ee
commit 076326e39e
78 changed files with 22555 additions and 5256 deletions

View File

@ -1,15 +1,15 @@
-----BEGIN CERTIFICATE-----
MIICVTCCAb4CCQCCDZ6FebPIqjANBgkqhkiG9w0BAQsFADBvMQswCQYDVQQGEwJV
UzENMAsGA1UECAwETWFyczETMBEGA1UEBwwKaVRyYW5zd2FycDETMBEGA1UECgwK
aVRyYW5zd2FycDETMBEGA1UECwwKaVRyYW5zd2FycDESMBAGA1UEAwwJMTI3LjAu
MC4xMB4XDTE4MDcxMDAzMTYzN1oXDTI4MDcwNzAzMTYzN1owbzELMAkGA1UEBhMC
VVMxDTALBgNVBAgMBE1hcnMxEzARBgNVBAcMCmlUcmFuc3dhcnAxEzARBgNVBAoM
CmlUcmFuc3dhcnAxEzARBgNVBAsMCmlUcmFuc3dhcnAxEjAQBgNVBAMMCTEyNy4w
LjAuMTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA1I6AQ6eNez85kcKjwy3g
/vcnXtw+EbP4Ab37fLhIIWG+XzmEBAqnCYjM3nmlDIGEfNylGReo9mD2OHg46a1D
wjd3pxTMit41pCTCiu8S9A2UJfbhSzQrfs+IZcNye4KR9/FzNEW6KoKQ0uc6X33E
0xe41hbRMQoKB3WmxvyN8PcCAwEAATANBgkqhkiG9w0BAQsFAAOBgQAd7GNDtKWA
0OpSCzMu0pbmss9Erh4/RC8D+wK4+TXgPDKyZ6hX4FYPvk+ryMvwxJf0o4jjx5cx
Yew7UjaKHlGXq+CNVRFYlltsbvO3oQTNkajuyYGWzMSuNxNsT3apOxH7SIu3qao8
COSwj5FxZ2JU7O+SBVFZoJrFXEa+KJMQzQ==
MIICqTCCAZGgAwIBAgIJAI+HEnOALzNzMA0GCSqGSIb3DQEBCwUAMBQxEjAQBgNVBAMTCWxvY2Fs
aG9zdDAeFw0yNjA1MDEwNzU2NDJaFw0zNjA1MDIwNzU2NDJaMBQxEjAQBgNVBAMTCWxvY2FsaG9z
dDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANgUKYozgRgzqLyVPEpdrewQfVyAIeB7
wrWHfRzgdzHRRDofRawD63YZY1bGZXIX5xH95gORrIOkNleK/K5HCc/j1ExV5rf1mDSR1EX3gpMi
yf0khjCpwP6OeIxC5UjgXXt4NYAflkq49hODr1A2G7Pgq2UIngAn/tfySFeypavo+KnE3FxfuXbW
nIixjsPWa/woCN0JvHXFCyUNDtmBooZ4fENcC4qYT1woPayVh5HQEs8gF690Q/QAIVcDJgMpk53L
t7pYPbi5yJ/v/fprSsnhpnonCFqLYPlXO4MOcAaoo1dk6HNY/JJjx1jzcDBSIbC6ApjJvho4pkKT
A4TgPtUCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAcRZ99+OAIcr+1Q8oE6OoGMO3Hox7P4EzHuwV
SQcuz0cEASJ2lwsHVl2c5M4Whct1U/sWaQoOGC19a8nwXYQV1OWWGy4I1mQJQyr6cyNuBNJhtw64
Mal6lFFkj+hzQddEYJ+bs0lILOZHQN0Mo9IjvAL8Ri/m6V/8upJNtee6tSjmXDYuJOSYFBDQqxXL
84SYr01GCViTrTc6aXg+h7wKCX893f26ubgOPxZSKH66afIBSJ9Ug6V9Q7qGvEvbox3CzdTxPQSQ
kM85ZUPVd06PjDWGuv51Q2OHjY+8gFCBa5fjq4u22Ik3YzRl+8SzlYKSobmJgCA8xW7fVJcn6rLc
TQ==
-----END CERTIFICATE-----

15
conf/keys/server.crt.bak Normal file
View File

@ -0,0 +1,15 @@
-----BEGIN CERTIFICATE-----
MIICVTCCAb4CCQCCDZ6FebPIqjANBgkqhkiG9w0BAQsFADBvMQswCQYDVQQGEwJV
UzENMAsGA1UECAwETWFyczETMBEGA1UEBwwKaVRyYW5zd2FycDETMBEGA1UECgwK
aVRyYW5zd2FycDETMBEGA1UECwwKaVRyYW5zd2FycDESMBAGA1UEAwwJMTI3LjAu
MC4xMB4XDTE4MDcxMDAzMTYzN1oXDTI4MDcwNzAzMTYzN1owbzELMAkGA1UEBhMC
VVMxDTALBgNVBAgMBE1hcnMxEzARBgNVBAcMCmlUcmFuc3dhcnAxEzARBgNVBAoM
CmlUcmFuc3dhcnAxEzARBgNVBAsMCmlUcmFuc3dhcnAxEjAQBgNVBAMMCTEyNy4w
LjAuMTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA1I6AQ6eNez85kcKjwy3g
/vcnXtw+EbP4Ab37fLhIIWG+XzmEBAqnCYjM3nmlDIGEfNylGReo9mD2OHg46a1D
wjd3pxTMit41pCTCiu8S9A2UJfbhSzQrfs+IZcNye4KR9/FzNEW6KoKQ0uc6X33E
0xe41hbRMQoKB3WmxvyN8PcCAwEAATANBgkqhkiG9w0BAQsFAAOBgQAd7GNDtKWA
0OpSCzMu0pbmss9Erh4/RC8D+wK4+TXgPDKyZ6hX4FYPvk+ryMvwxJf0o4jjx5cx
Yew7UjaKHlGXq+CNVRFYlltsbvO3oQTNkajuyYGWzMSuNxNsT3apOxH7SIu3qao8
COSwj5FxZ2JU7O+SBVFZoJrFXEa+KJMQzQ==
-----END CERTIFICATE-----

View File

@ -1,15 +1,24 @@
-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQDUjoBDp417PzmRwqPDLeD+9yde3D4Rs/gBvft8uEghYb5fOYQE
CqcJiMzeeaUMgYR83KUZF6j2YPY4eDjprUPCN3enFMyK3jWkJMKK7xL0DZQl9uFL
NCt+z4hlw3J7gpH38XM0RboqgpDS5zpffcTTF7jWFtExCgoHdabG/I3w9wIDAQAB
AoGAWsy1BjGhQrDzisy24D3NC53Q97jl2vIiU7wwnkqqpXf3tv3+4ysZx/zkZ3VX
iEwbqKso69srlnQ9OkpBJbGaa6lZe+z7BGzv2eJr+hKjjVjR122eDjAtXw+Tmt6c
iBUG9+ITC1GdhXLEgTXtYuPq8hbDhoAVI007E+5JuQoO8kECQQD3aR6zGfR7EOmn
byGkNMMPY/FoH894BpB4l7gIlNXH3pxBqukrEwnmVXSfak2PAkeLFO+bgCc6baIZ
+R4iOLn/AkEA2++dIndbY7nmGs7Q//sM7MkFMiFQ4h1nN38V9AEHaUonxlwo+Nks
PTAaVd78YIh6yBlfexm0Fxi1mEVQApqZCQJAFUPqyJglhGJqwuJxcMy8K1l6yWla
isV9q2/W+J3aViiTI63OBs7HHg4gTQd1DSK0BYdSJPp55LLBqRvZdDWN/wJBAMQa
M46exAL4p55xl9MWwyCB4LshD6B9vSGzlBx7qmMMNsjcNcAkzBhGwsScTYW5S1kN
nqABfB037/s0mjGoLRkCQF18j4MovyFaj8VAqY8YUmf86Ez9JmL9kHNA8yEoSjuI
xsRa6y5Nza5y83Mojt4W+PfS386riJ7txqrPdezyag4=
-----END RSA PRIVATE KEY-----
-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDYFCmKM4EYM6i8lTxKXa3sEH1c
gCHge8K1h30c4Hcx0UQ6H0WsA+t2GWNWxmVyF+cR/eYDkayDpDZXivyuRwnP49RMVea39Zg0kdRF
94KTIsn9JIYwqcD+jniMQuVI4F17eDWAH5ZKuPYTg69QNhuz4KtlCJ4AJ/7X8khXsqWr6PipxNxc
X7l21pyIsY7D1mv8KAjdCbx1xQslDQ7ZgaKGeHxDXAuKmE9cKD2slYeR0BLPIBevdEP0ACFXAyYD
KZOdy7e6WD24ucif7/36a0rJ4aZ6Jwhai2D5VzuDDnAGqKNXZOhzWPySY8dY83AwUiGwugKYyb4a
OKZCkwOE4D7VAgMBAAECggEAe865qn0uV96prTxZKkcY82zTV5/3STfAbeDvGA+pXDsKu77VXeV1
EdskJ0FQORpnBNEU7TCXx2nc1TZG59i+T4a8SuzhYMBw8JYqKdjS0VmaoNg/pzxs365kdgGSfLpJ
9gf/p6TxqWjnXnESj4QhRWTS7/YLCg3goH0rZExxTtkE8dOWTZX37JotMNp4qBDTXDwMYGv6/7O2
hV2cyD4y+oO84KM5HgDaqkU23Ns9TUY4HQ+qeQk0y2wO5ieRJBrOWOL8hl1fKVOoB6f7Waorxo0y
oUXWjY99XnY7CInALXlwLwrOhSyyCHpz9d9sFMgtShs5XKFA/CJ2WCyyKx7UVQKBgQD9foxVVwUm
C3bUrD171LimKyMl6r7RVWza3IqcM9Gui8OTLKzQmTBwl1O3EKuTMIkxzpxx1d5bVC+vUCkI/mHd
iycCwozzABOiBKLJrmZHS5MbHMUwHMQXEEMCHiwJa9l3LeS8ibDfwi/K9jrVry+YCX5TTKBfAqdo
9S7qA+rZWwKBgQDaNu+wgqmZgOOfrCJPOTKY0j5RoyWm1rK42wcx9TuZW454qs4rVGGBR/TvT2NP
Wsh9E9mSFp35je0oePHbOCuFiPo6czzFSVX5zrKlpvXH1FXwpclceAMql3h/dUEhZJtV2qFa0saq
rN88YNf9uvAWp88ij2k4D1Cz5nK0+4WPjwKBgQCiv4ihkckAcAPO7vZadmxGYxOh2GDCTTIiIc3s
E2jfw2PBLcGV+4QaBU3+DnnZeiPbEmdmvoSP5jDnQXPXDlsOvbRCFV4g9T+lmYxaJ9oKk/7SPVps
VUuf8xTSW0Syl8d6uMBOO6iPQEEm8Yc8gcjwt8ee+2dLGI0a2a9RF0rEWQKBgB6nFOhgkl5jwpXN
YkxqpnbdIa/qEQHsqtJYwhv8bNDQEaVVqPxhMAkvCHMNXc/p2rvnK+rfjnVdwHCs/JxkuYhag3vu
cBzufktHA8VNPL1DUIcrYqvAmAFFocGVwP5l2YQn3/6YGRwkiH88w1p7BfrIu8oJByi+zgFXX8mY
g1x1AoGAQV/YgYUW/CH0M3uxJfAtte6weNmYOmSgdw/J/TiRwOjy0BL32Oh8qOsxo/6lPolJ+21s
S2M5TUd5lH73QYZgtuFCO10iht5rJasv0RNqS3M728Q9bgJXuKu3a65RiqOW02PdrnTytNJQ6Q/E
Z08i5REUpJshJAaXu71HUJfslEI=
-----END PRIVATE KEY-----

15
conf/keys/server.key.bak Normal file
View File

@ -0,0 +1,15 @@
-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQDUjoBDp417PzmRwqPDLeD+9yde3D4Rs/gBvft8uEghYb5fOYQE
CqcJiMzeeaUMgYR83KUZF6j2YPY4eDjprUPCN3enFMyK3jWkJMKK7xL0DZQl9uFL
NCt+z4hlw3J7gpH38XM0RboqgpDS5zpffcTTF7jWFtExCgoHdabG/I3w9wIDAQAB
AoGAWsy1BjGhQrDzisy24D3NC53Q97jl2vIiU7wwnkqqpXf3tv3+4ysZx/zkZ3VX
iEwbqKso69srlnQ9OkpBJbGaa6lZe+z7BGzv2eJr+hKjjVjR122eDjAtXw+Tmt6c
iBUG9+ITC1GdhXLEgTXtYuPq8hbDhoAVI007E+5JuQoO8kECQQD3aR6zGfR7EOmn
byGkNMMPY/FoH894BpB4l7gIlNXH3pxBqukrEwnmVXSfak2PAkeLFO+bgCc6baIZ
+R4iOLn/AkEA2++dIndbY7nmGs7Q//sM7MkFMiFQ4h1nN38V9AEHaUonxlwo+Nks
PTAaVd78YIh6yBlfexm0Fxi1mEVQApqZCQJAFUPqyJglhGJqwuJxcMy8K1l6yWla
isV9q2/W+J3aViiTI63OBs7HHg4gTQd1DSK0BYdSJPp55LLBqRvZdDWN/wJBAMQa
M46exAL4p55xl9MWwyCB4LshD6B9vSGzlBx7qmMMNsjcNcAkzBhGwsScTYW5S1kN
nqABfB037/s0mjGoLRkCQF18j4MovyFaj8VAqY8YUmf86Ez9JmL9kHNA8yEoSjuI
xsRa6y5Nza5y83Mojt4W+PfS386riJ7txqrPdezyag4=
-----END RSA PRIVATE KEY-----

8
doc_api/api_index.json Normal file
View File

@ -0,0 +1,8 @@
{
"generatedAt": "2026-04-29T16:33:59.996Z",
"files": [
"service_overview.json",
"http_api.json",
"socket_api.json"
]
}

View File

@ -0,0 +1,409 @@
const fs = require('fs');
const path = require('path');
const projectRoot = path.resolve(__dirname, '..');
const controllerRoot = path.join(projectRoot, 'src', 'controller', 'web');
const socketRoot = path.join(projectRoot, 'src', 'socket');
function readText(filePath) {
return fs.readFileSync(filePath, 'utf8');
}
function listFiles(dirPath) {
const entries = fs.readdirSync(dirPath, { withFileTypes: true });
const files = [];
for (const entry of entries) {
const fullPath = path.join(dirPath, entry.name);
if (entry.isDirectory()) {
files.push(...listFiles(fullPath));
continue;
}
if (entry.isFile() && entry.name.endsWith('.js')) {
files.push(fullPath);
}
}
return files;
}
function toPosixPath(filePath) {
return path.relative(projectRoot, filePath).replace(/\\/g, '/');
}
function uniq(values) {
return [...new Set(values.filter(Boolean))];
}
function parseStringArray(source, variableName) {
const pattern = new RegExp(`const\\s+${variableName}\\s*=\\s*\\[([\\s\\S]*?)\\]`, 'm');
const match = source.match(pattern);
if (!match) {
return [];
}
return [...match[1].matchAll(/'([^']+)'/g)].map((item) => item[1]);
}
function extractCommentValue(comment, key) {
const pattern = new RegExp(`#${key}\\s+(.+)`);
const line = comment
.split(/\r?\n/)
.map((item) => item.replace(/^\s*\*\s?/, '').trim())
.find((item) => pattern.test(item));
if (!line) {
return '';
}
return line.replace(pattern, '$1').trim();
}
function parseObjectKeys(text) {
return uniq(
text
.split(',')
.map((item) => item.trim())
.filter(Boolean)
.map((item) => item.split(':')[0].trim())
.filter((item) => item && !item.startsWith('...'))
);
}
function getParamBlocks(routeBody) {
const blocks = [];
for (const match of routeBody.matchAll(/const\s*\{([\s\S]*?)\}\s*=\s*request\.(body|query);/g)) {
blocks.push({
source: match[2],
params: uniq(
match[1]
.split(',')
.map((item) => item.trim())
.filter(Boolean)
.map((item) => item.replace(/=.*$/, '').trim())
),
});
}
return blocks;
}
function getRequiredParams(routeBody) {
const required = [];
for (const match of routeBody.matchAll(/checkRequestParams\s*\(\s*\{([\s\S]*?)\}\s*\)/g)) {
required.push(...parseObjectKeys(match[1]));
}
return uniq(required);
}
function detectResponseCookies(routeBody) {
const cookies = [];
for (const match of routeBody.matchAll(/response\.cookie\(([^,]+),/g)) {
cookies.push(match[1].trim());
}
return uniq(cookies);
}
function detectBusinessCall(routeBody) {
const match = routeBody.match(/const\s+result\s*=\s*await\s+([\w$.]+)\s*\(/);
return match ? match[1] : '';
}
function normalizeService(fullPath) {
if (
fullPath.startsWith('/api/web/system-') ||
fullPath.includes('/system-login') ||
fullPath.includes('/system-logout')
) {
return 'super-api';
}
return 'api';
}
function parseControllers(loginAuthIgnoreApi, loginRoleIgnoreApi) {
const controllerFiles = listFiles(controllerRoot);
const endpoints = [];
for (const filePath of controllerFiles) {
const source = readText(filePath);
const routePattern = /\/\*\*([\s\S]*?)\*\/\s*router\.(get|post)\('([^']+)'\s*,\s*async function\(request, response\) \{([\s\S]*?)\n\}\)\s*;?/g;
for (const match of source.matchAll(routePattern)) {
const comment = match[1];
const method = match[2].toUpperCase();
const subPath = match[3];
const routeBody = match[4];
const annotatedPath = extractCommentValue(comment, 'controller');
const fullPath = annotatedPath ? annotatedPath.split(/\s+/).slice(1).join(' ') : subPath;
const description = extractCommentValue(comment, 'desc');
const paramBlocks = getParamBlocks(routeBody);
const requiredParams = getRequiredParams(routeBody);
const paramSource = paramBlocks.length === 1 ? paramBlocks[0].source : (paramBlocks[0]?.source || 'none');
const params = [];
const paramsByName = new Map();
for (const block of paramBlocks) {
for (const name of block.params) {
paramsByName.set(name, {
name,
source: block.source,
required: requiredParams.includes(name),
});
}
}
for (const name of requiredParams) {
if (!paramsByName.has(name)) {
paramsByName.set(name, {
name,
source: paramSource,
required: true,
});
}
}
params.push(...paramsByName.values());
endpoints.push({
controllerFile: toPosixPath(filePath),
module: path.basename(path.dirname(filePath)),
method,
path: fullPath || subPath,
subPath,
description,
service: normalizeService(fullPath || subPath),
auth: {
loginRequired: !loginAuthIgnoreApi.includes(fullPath || subPath),
roleCheckRequired: !loginRoleIgnoreApi.includes(fullPath || subPath),
tokenType: (fullPath || subPath).includes('/system-') ? 'system-cookie-or-header' : 'user-cookie-or-header',
},
request: {
paramSource,
params,
setsCookies: detectResponseCookies(routeBody),
},
response: {
envelope: {
success: 'boolean',
code: 'number',
msg: 'string',
data: 'object|array|string|number|boolean',
},
businessResult: detectBusinessCall(routeBody),
commonErrorCodes: [400, 403, 404, 500, 504],
},
});
}
}
return endpoints.sort((left, right) => left.path.localeCompare(right.path));
}
function parseRequireMap(source) {
const map = new Map();
for (const match of source.matchAll(/const\s+(\w+)\s*=\s*require\("([^"]+)"\);/g)) {
map.set(match[1], match[2]);
}
for (const match of source.matchAll(/const\s+(\w+)\s*=\s*require\('([^']+)'\);/g)) {
map.set(match[1], match[2]);
}
return map;
}
function findRequiredModule(source, alias) {
const escapedAlias = alias.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
const patterns = [
new RegExp(`const\\s+${escapedAlias}\\s*=\\s*require\\(\"([^\"]+)\"\\)`),
new RegExp(`const\\s+${escapedAlias}\\s*=\\s*require\\('([^']+)'\\)`),
];
for (const pattern of patterns) {
const match = source.match(pattern);
if (match) {
return match[1];
}
}
return '';
}
function extractHandlerFunctionInfo(handlerPath, functionName) {
const source = readText(handlerPath);
const params = [];
const dataDestructure = source.match(/const\s*\{([\s\S]*?)\}\s*=\s*data;/);
if (dataDestructure) {
params.push(...uniq(dataDestructure[1].split(',').map((item) => item.trim()).filter(Boolean).map((item) => item.replace(/=.*$/, '').trim())));
}
const emits = uniq([
...[...source.matchAll(/\.emit\(socketClientEvent\.(\w+)/g)].map((item) => item[1]),
...[...source.matchAll(/\.emit\('([^']+)'/g)].map((item) => item[1]),
...[...source.matchAll(/\.emit\("([^"]+)"/g)].map((item) => item[1]),
]);
return {
handlerFile: toPosixPath(handlerPath),
handlerFunction: functionName,
params,
emits,
};
}
function parseSocketDocs() {
const connectPath = path.join(socketRoot, 'connect.js');
const connectSource = readText(connectPath);
const inboundEvents = [];
for (const match of connectSource.matchAll(/socket\.on\(socketServerEvent\.(\w+),\s*\(data\)\s*=>\s*\{\s*(\w+)\.(\w+)\(io, socket, data\)/g)) {
const eventName = match[1];
const alias = match[2];
const functionName = match[3];
const relativeHandlerPath = findRequiredModule(connectSource, alias);
if (!relativeHandlerPath) {
inboundEvents.push({
event: eventName,
handlerFile: '',
handlerFunction: functionName,
params: [],
emits: [],
});
continue;
}
const handlerPath = path.resolve(path.dirname(connectPath), relativeHandlerPath + '.js');
inboundEvents.push({
event: eventName,
...extractHandlerFunctionInfo(handlerPath, functionName),
});
}
const serverEventPath = path.join(socketRoot, 'event', 'server_event.js');
const clientEventPath = path.join(socketRoot, 'event', 'client_event.js');
const serverSource = readText(serverEventPath);
const clientSource = readText(clientEventPath);
const parseEventEnum = (source) => {
const events = [];
let pendingDescription = '';
for (const rawLine of source.split(/\r?\n/)) {
const line = rawLine.trim();
if (line.startsWith('//')) {
pendingDescription = line.replace(/^\/\/\s*/, '').trim();
continue;
}
const match = line.match(/(\w+)\s*:\s*['"]([^'"]+)['"]/);
if (!match) {
continue;
}
events.push({
key: match[1],
event: match[2],
description: pendingDescription,
});
pendingDescription = '';
}
return events;
};
const outboundEnum = parseEventEnum(clientSource);
const inboundEnum = parseEventEnum(serverSource);
return {
transport: 'socket.io',
entryFile: toPosixPath(path.join(socketRoot, 'index.js')),
serverEventEnumFile: toPosixPath(serverEventPath),
clientEventEnumFile: toPosixPath(clientEventPath),
inboundEvents: inboundEnum.map((eventInfo) => {
const detail = inboundEvents.find((item) => item.event === eventInfo.key || item.event === eventInfo.event);
return {
event: eventInfo.event,
key: eventInfo.key,
description: eventInfo.description,
handlerFile: detail?.handlerFile || '',
handlerFunction: detail?.handlerFunction || '',
params: detail?.params || [],
emits: detail?.emits || [],
};
}),
outboundEvents: outboundEnum,
};
}
function groupHttpEndpoints(endpoints) {
const groups = {};
for (const endpoint of endpoints) {
if (!groups[endpoint.service]) {
groups[endpoint.service] = [];
}
groups[endpoint.service].push(endpoint);
}
return groups;
}
function writeJson(fileName, payload) {
const outputPath = path.join(__dirname, fileName);
fs.writeFileSync(outputPath, JSON.stringify(payload, null, 2) + '\n', 'utf8');
}
function main() {
const loginAuthSource = readText(path.join(projectRoot, 'src', 'middleware', 'loginAuth.js'));
const loginRoleSource = readText(path.join(projectRoot, 'src', 'middleware', 'loginRole.js'));
const loginAuthIgnoreApi = parseStringArray(loginAuthSource, 'loginAuthIngoreApi');
const loginRoleIgnoreApi = parseStringArray(loginRoleSource, 'loginRoleIngoreApi');
const httpEndpoints = parseControllers(loginAuthIgnoreApi, loginRoleIgnoreApi);
const socketDocs = parseSocketDocs();
const grouped = groupHttpEndpoints(httpEndpoints);
const generatedAt = new Date().toISOString();
writeJson('service_overview.json', {
generatedAt,
project: 'tl-rtc-app',
services: [
{
service: 'api',
entryFile: 'tlapi.js',
defaultPortEnv: 'tl_rtc_app_api_port',
defaultPort: 9096,
staticRoot: 'web-dist/',
routePrefix: '/api/web',
endpointCount: grouped.api ? grouped.api.length : 0,
},
{
service: 'super-api',
entryFile: 'tlsuperapi.js',
defaultPortEnv: 'tl_rtc_app_super_api_port',
defaultPort: 9098,
staticRoot: 'system-dist/',
routePrefix: '/api/web',
endpointCount: grouped['super-api'] ? grouped['super-api'].length : 0,
},
{
service: 'socket',
entryFile: 'tlsocket.js',
defaultPortEnv: 'tl_rtc_app_socket_port',
defaultPort: 9097,
transport: 'socket.io',
inboundEventCount: socketDocs.inboundEvents.length,
outboundEventCount: socketDocs.outboundEvents.length,
},
],
commonResponseEnvelope: {
success: 'boolean',
code: 'number',
msg: 'string',
data: 'object|array|string|number|boolean',
},
});
writeJson('http_api.json', {
generatedAt,
routeRoot: '/api/web',
totalEndpoints: httpEndpoints.length,
endpoints: httpEndpoints,
});
writeJson('socket_api.json', {
generatedAt,
...socketDocs,
});
writeJson('api_index.json', {
generatedAt,
files: [
'service_overview.json',
'http_api.json',
'socket_api.json',
],
});
}
main();

5551
doc_api/http_api.json Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,39 @@
{
"generatedAt": "2026-04-29T16:33:59.996Z",
"project": "tl-rtc-app",
"services": [
{
"service": "api",
"entryFile": "tlapi.js",
"defaultPortEnv": "tl_rtc_app_api_port",
"defaultPort": 9096,
"staticRoot": "web-dist/",
"routePrefix": "/api/web",
"endpointCount": 98
},
{
"service": "super-api",
"entryFile": "tlsuperapi.js",
"defaultPortEnv": "tl_rtc_app_super_api_port",
"defaultPort": 9098,
"staticRoot": "system-dist/",
"routePrefix": "/api/web",
"endpointCount": 23
},
{
"service": "socket",
"entryFile": "tlsocket.js",
"defaultPortEnv": "tl_rtc_app_socket_port",
"defaultPort": 9097,
"transport": "socket.io",
"inboundEventCount": 18,
"outboundEventCount": 17
}
],
"commonResponseEnvelope": {
"success": "boolean",
"code": "number",
"msg": "string",
"data": "object|array|string|number|boolean"
}
}

290
doc_api/socket_api.json Normal file
View File

@ -0,0 +1,290 @@
{
"generatedAt": "2026-04-29T16:33:59.996Z",
"transport": "socket.io",
"entryFile": "src/socket/index.js",
"serverEventEnumFile": "src/socket/event/server_event.js",
"clientEventEnumFile": "src/socket/event/client_event.js",
"inboundEvents": [
{
"event": "connection",
"key": "connection",
"description": "socket连接",
"handlerFile": "",
"handlerFunction": "",
"params": [],
"emits": []
},
{
"event": "disconnect",
"key": "disconnect",
"description": "socket断开连接",
"handlerFile": "src/socket/handler/disconnect.js",
"handlerFunction": "disconnect",
"params": [],
"emits": [
"exit"
]
},
{
"event": "offer",
"key": "offer",
"description": "webrtc offer",
"handlerFile": "src/socket/handler/rtc/offer.js",
"handlerFunction": "offer",
"params": [],
"emits": [
"offer"
]
},
{
"event": "answer",
"key": "answer",
"description": "webrtc answer",
"handlerFile": "src/socket/handler/rtc/answer.js",
"handlerFunction": "answer",
"params": [],
"emits": [
"answer"
]
},
{
"event": "candidate",
"key": "candidate",
"description": "webrtc candidate",
"handlerFile": "src/socket/handler/rtc/candidate.js",
"handlerFunction": "candidate",
"params": [],
"emits": [
"candidate"
]
},
{
"event": "count",
"key": "count",
"description": "在线人数",
"handlerFile": "src/socket/handler/count.js",
"handlerFunction": "count",
"params": [],
"emits": [
"count"
]
},
{
"event": "exit",
"key": "exit",
"description": "退出",
"handlerFile": "src/socket/handler/exit.js",
"handlerFunction": "exit",
"params": [],
"emits": [
"exit"
]
},
{
"event": "createAndJoin",
"key": "createAndJoin",
"description": "加入/创建房间",
"handlerFile": "",
"handlerFunction": "",
"params": [],
"emits": []
},
{
"event": "heartbeat",
"key": "heartbeat",
"description": "心跳",
"handlerFile": "src/socket/handler/heartbeat.js",
"handlerFunction": "heartbeat",
"params": [],
"emits": [
"heartbeat"
]
},
{
"event": "channelChat",
"key": "channelChat",
"description": "广播聊天消息",
"handlerFile": "src/socket/handler/channel_chat.js",
"handlerFunction": "channelChat",
"params": [],
"emits": [
"channelChat"
]
},
{
"event": "contactApply",
"key": "contactApply",
"description": "广播好友申请",
"handlerFile": "src/socket/handler/contact_apply.js",
"handlerFunction": "contactApply",
"params": [],
"emits": [
"contactApply"
]
},
{
"event": "contactApplyPass",
"key": "contactApplyPass",
"description": "通过好友申请",
"handlerFile": "src/socket/handler/contact_apply_pass.js",
"handlerFunction": "contactApplyPass",
"params": [],
"emits": [
"contactApplyPass"
]
},
{
"event": "contactApplyReject",
"key": "contactApplyReject",
"description": "拒绝好友申请",
"handlerFile": "src/socket/handler/contact_apply_reject.js",
"handlerFunction": "contactApplyReject",
"params": [],
"emits": [
"contactApplyReject"
]
},
{
"event": "groupApply",
"key": "groupApply",
"description": "广播群组申请",
"handlerFile": "src/socket/handler/group_apply.js",
"handlerFunction": "groupApply",
"params": [],
"emits": [
"groupApply"
]
},
{
"event": "groupApplyPass",
"key": "groupApplyPass",
"description": "通过群组申请",
"handlerFile": "src/socket/handler/group_apply_pass.js",
"handlerFunction": "groupApplyPass",
"params": [],
"emits": [
"groupApplyPass"
]
},
{
"event": "groupApplyReject",
"key": "groupApplyReject",
"description": "拒绝群组申请",
"handlerFile": "src/socket/handler/group_apply_reject.js",
"handlerFunction": "groupApplyReject",
"params": [],
"emits": [
"groupApplyReject"
]
},
{
"event": "channelVideoCall",
"key": "channelVideoCall",
"description": "广播视频消息",
"handlerFile": "src/socket/handler/channel_video.js",
"handlerFunction": "channelVideoCall",
"params": [],
"emits": [
"channelVideoCall"
]
},
{
"event": "channelFile",
"key": "channelFile",
"description": "文件",
"handlerFile": "src/socket/handler/channel_file.js",
"handlerFunction": "channelFile",
"params": [],
"emits": [
"channelFile"
]
}
],
"outboundEvents": [
{
"key": "created",
"event": "created",
"description": "创建房间"
},
{
"key": "joined",
"event": "joined",
"description": "加入房间"
},
{
"key": "offer",
"event": "offer",
"description": "webrtc offer"
},
{
"key": "answer",
"event": "answer",
"description": "webrtc answer"
},
{
"key": "candidate",
"event": "candidate",
"description": "webrtc candidate"
},
{
"key": "exit",
"event": "exit",
"description": "退出"
},
{
"key": "count",
"event": "count",
"description": "人数"
},
{
"key": "heartbeat",
"event": "heartbeat",
"description": "心跳"
},
{
"key": "channelChat",
"event": "channelChat",
"description": "广播聊天消息"
},
{
"key": "contactApply",
"event": "contactApply",
"description": "广播好友申请"
},
{
"key": "contactApplyPass",
"event": "contactApplyPass",
"description": "通过好友申请"
},
{
"key": "contactApplyReject",
"event": "contactApplyReject",
"description": "拒绝好友申请"
},
{
"key": "groupApply",
"event": "groupApply",
"description": "广播群组申请"
},
{
"key": "groupApplyPass",
"event": "groupApplyPass",
"description": "通过群组申请"
},
{
"key": "groupApplyReject",
"event": "groupApplyReject",
"description": "拒绝群组申请"
},
{
"key": "channelVideoCall",
"event": "channelVideoCall",
"description": "广播视频消息"
},
{
"key": "channelFile",
"event": "channelFile",
"description": "文件"
}
]
}

View File

@ -211,13 +211,6 @@ const web_module_js = () => {
'./web-res/js/module/contact/content/search_group.js',
'./web-res/js/module/contact/content.js',
//cut_paste模块
'./web-res/js/module/cut_paste/top.js',
'./web-res/js/module/cut_paste/list.js',
'./web-res/js/module/cut_paste/cut_paste.js',
// cut_paste-content模块
'./web-res/js/module/cut_paste/content.js',
//setting模块
'./web-res/js/module/setting/list.js',
'./web-res/js/module/setting/setting.js',

14083
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
const {
tlResponseArgsError, tlResponseSvrError,
tlResponseArgsError, tlResponseSvrError, tlResponseForbidden,
tlResponseNotFound, tlResponseSuccess, setBit, checkIsId
} = require('../../utils/utils')
const channelService = require('../../service/channel/tl_channel_service')
@ -15,6 +15,7 @@ const { fields: userFields } = require('../../tables/tl_user')
const { fields: userFriendFields } = require('../../tables/tl_user_friend')
const { fields: channelFields } = require('../../tables/tl_channel')
const { getAvatarOssUrl } = require('../../utils/oss/oss')
const { SUBJECT_CHANNEL_STORE_TYPE } = require('../../utils/external/subject')
const { Def: TlChannelUserDef, Type: TlChannelUserType, Flag: TlChannelUserFlag } = channelUserFields
const { Def : TlUserDef } = userFields
@ -766,12 +767,29 @@ const exitChannel = async function({channelId, loginInfo}){
userId: loginUserId
}, [
TlChannelUserDef.id,
TlChannelUserDef.roleId,
])
if(Object.keys(channelUserInfo).length == 0){
return tlResponseNotFound("退出成功")
}
const channelInfo = await channelService.getInfoById({
companyId: loginUserCompanyId,
id: channelId
}, [
TlChannelDef.id,
TlChannelDef.storeType,
])
if(
channelInfo[TlChannelDef.id]
&& !!channelInfo[TlChannelDef.storeType]
&& channelUserInfo[TlChannelUserDef.roleId] == TlRoleInner.channel.member.id
){
return tlResponseForbidden("主群成员不允许主动退出")
}
// 删除自己在频道的数据
const deleteRes = await channelUserService.deleteInfoById({
companyId: loginUserCompanyId,

View File

@ -241,6 +241,12 @@ const adminGetSystemEnvConfig = async function({
pass: conf.mail_password,
}
// 外部互通服务配置
const externalServiceConfig = {
url: conf.external_service_url,
secret: conf.external_service_secret,
}
// 配置项定义 - 从前端移到后端
const configDefinitions = {
redis: {
@ -284,6 +290,14 @@ const adminGetSystemEnvConfig = async function({
{ key: 'user', label: '邮箱账号', desc: '发送邮件的邮箱账号', type: 'text' },
{ key: 'pass', label: '邮箱密码', desc: '邮箱授权密码', type: 'text' }
]
},
externalService: {
title: '外部互通服务配置',
configKey: 'externalServiceConfig',
fields: [
{ key: 'url', label: '服务地址', desc: '外部互通服务基础地址', type: 'text' },
{ key: 'secret', label: '服务密钥', desc: '外部互通服务签名密钥', type: 'text' }
]
}
};
@ -292,6 +306,7 @@ const adminGetSystemEnvConfig = async function({
webrtcConfig,
mysqlConfig,
emailConfig,
externalServiceConfig,
configDefinitions
})
}
@ -304,6 +319,7 @@ const adminGetSystemEnvConfig = async function({
* @param {*} webrtcConfig
* @param {*} mysqlConfig
* @param {*} emailConfig
* @param {*} externalServiceConfig
* @returns
*/
const adminSetSystemEnvConfig = async function({
@ -312,6 +328,7 @@ const adminSetSystemEnvConfig = async function({
webrtcConfig = {},
mysqlConfig = {},
emailConfig = {},
externalServiceConfig = {},
}) {
const {
loginUserCompanyId, loginUserId, loginUserRoleId
@ -393,6 +410,17 @@ const adminSetSystemEnvConfig = async function({
set_env_config("mail_password", emailConfig.pass)
}
}
// 设置外部互通服务配置
if(Object.keys(externalServiceConfig).length > 0) {
if(externalServiceConfig.url !== undefined && externalServiceConfig.url !== null) {
set_env_config("external_service_url", externalServiceConfig.url)
}
if(externalServiceConfig.secret !== undefined && externalServiceConfig.secret !== null) {
set_env_config("external_service_secret", externalServiceConfig.secret)
}
}
return tlResponseSuccess("设置完成")
}

File diff suppressed because it is too large Load Diff

View File

@ -360,6 +360,111 @@ const bindEmail = async function({ token, loginInfo, email, code }) {
}
/**
* 获取按 subject 分组的用户列表
* @param {*} loginInfo
*/
const getSubjectUserList = async function({ loginInfo }){
const {
loginUserCompanyId, loginUserId, loginUserCompanyName
} = loginInfo
// 仅展示当前登录用户所属主体成员
const loginUserInfo = await userService.getInfoById({
companyId: loginUserCompanyId,
id: loginUserId,
}, [
TlUserDef.subjectId,
])
const loginUserSubjectId = loginUserInfo[TlUserDef.subjectId] || ''
if(!loginUserSubjectId){
return tlResponseSuccess("获取成功", [])
}
// 获取同公司内所有有 subject_id 的用户
const userList = await userService.getListWithSubjectByCompanyId({
companyId: loginUserCompanyId,
}, [
TlUserDef.id,
TlUserDef.name,
TlUserDef.avatarUrl,
TlUserDef.email,
TlUserDef.mobile,
TlUserDef.subjectId,
TlUserDef.subjectName,
TlUserDef.subjectType,
])
if(!userList.length){
return tlResponseSuccess("获取成功", [])
}
// 仅保留与当前用户同主体成员
const sameSubjectUserList = userList.filter(u => u[TlUserDef.subjectId] === loginUserSubjectId)
// 提取所有用户 ID(排除自己)
const memberIdList = sameSubjectUserList
.map(u => u[TlUserDef.id])
.filter(id => id !== loginUserId)
// 查询与当前用户的好友关系,获取 channelId
const friendList = memberIdList.length > 0
? await userFriendService.getListByUserIdAndFriendIdList({
companyId: loginUserCompanyId,
userId: loginUserId,
friendIdList: memberIdList
}, [
TlUserFriendDef.friendId,
TlUserFriendDef.channelId,
])
: []
const friendChannelMap = new Map()
friendList.forEach(f => {
friendChannelMap.set(f[TlUserFriendDef.friendId], f[TlUserFriendDef.channelId])
})
// 查询在线状态
const statusMap = memberIdList.length > 0
? await userSessionService.getUserLoginStatusByIdList({ userIdList: memberIdList })
: {}
// 按 subjectId 分组
const groupMap = new Map()
for(const u of sameSubjectUserList){
const uid = u[TlUserDef.id]
if(uid === loginUserId) continue
const subjectId = u[TlUserDef.subjectId]
const subjectName = u[TlUserDef.subjectName] || subjectId
const subjectType = u[TlUserDef.subjectType]
if(!groupMap.has(subjectId)){
groupMap.set(subjectId, {
subjectId,
subjectName,
subjectType,
members: []
})
}
groupMap.get(subjectId).members.push({
userId: uid,
username: u[TlUserDef.name],
userAvatar: await getAvatarOssUrl(u[TlUserDef.avatarUrl]),
userEmail: u[TlUserDef.email] || '',
userMobile: u[TlUserDef.mobile] || '',
userCompanyName: loginUserCompanyName,
loginStatus: statusMap[uid + ''] || 0,
channelId: friendChannelMap.get(uid) || null,
})
}
return tlResponseSuccess("获取成功", [...groupMap.values()])
}
/**
* 更新用户信息 - 管理员
* @param {*} id
@ -833,7 +938,7 @@ const adminAddUser = async function({
const result = await userService.addInfo({
companyId,
name,
password,
password: saltPassword,
salt,
roleId,
email: email || '',
@ -854,6 +959,7 @@ module.exports = {
updateUserAvatar,
searchUserById,
bindEmail,
getSubjectUserList,
adminUpdateUser,
adminAddUser,

View File

@ -8,6 +8,7 @@ const channelChatService = require('../../service/channel/tl_channel_chat_servic
const channelFileService = require('../../service/channel/tl_channel_file_service')
const channelMediaService = require('../../service/channel/tl_channel_media_service')
const channelUserService = require('../../service/channel/tl_channel_user_service')
const userSessionService = require('../../service/user/tl_user_session_service')
const { fields: userClearDef } = require('../../tables/tl_user_clear')
@ -307,6 +308,25 @@ const updateChannelFileClear = async function({
})
}
/**
* 清除当前用户相关缓存
* @param {*} loginInfo
* @returns
*/
const clearSelfCache = async function({ loginInfo }){
const { loginUserId } = loginInfo
if(!checkIsId(loginUserId)){
return tlResponseArgsError("请求参数错误")
}
await userSessionService.clearUserRelatedCache({
userId: loginUserId,
})
return tlResponseSuccess("清除缓存成功")
}
module.exports = {
@ -314,4 +334,5 @@ module.exports = {
updateChannelMediaClear,
updateChannelFileClear,
updateChannelMuiltClear,
clearSelfCache,
}

View File

@ -535,6 +535,86 @@ const initUserFriendForPassFriend = async function({
}
/**
* 同主体静默建立好友关系(无需申请/同意)
* 校验双方均有相同的 subject_id 后直接建立好友关系和频道
* @param {*} targetUserId 目标用户 id
* @param {*} loginInfo
*/
const silentAddSubjectFriend = async function({ targetUserId, loginInfo }){
const { loginUserCompanyId, loginUserId } = loginInfo
if(!targetUserId){
return tlResponseArgsError("请求参数错误")
}
targetUserId = parseInt(targetUserId)
if(!checkIsId(targetUserId)){
return tlResponseArgsError("请求参数错误")
}
if(targetUserId === loginUserId){
return tlResponseArgsError("不能与自己建立好友关系")
}
// 查询双方 subject_id
const userList = await userService.getListByIdList({
companyId: loginUserCompanyId,
idList: [loginUserId, targetUserId]
}, [
TlUserDef.id,
TlUserDef.name,
TlUserDef.subjectId,
])
const selfInfo = userList.find(u => u[TlUserDef.id] === loginUserId)
const targetInfo = userList.find(u => u[TlUserDef.id] === targetUserId)
if(!selfInfo || !targetInfo){
return tlResponseNotFound("用户不存在")
}
const selfSubjectId = selfInfo[TlUserDef.subjectId]
const targetSubjectId = targetInfo[TlUserDef.subjectId]
if(!selfSubjectId || !targetSubjectId || selfSubjectId !== targetSubjectId){
return tlResponseForbidden("双方不属于同一主体,无法使用快速添加")
}
// 建立频道(幂等)
const channelRes = await initChannelForPassFriend({
loginUserCompanyId,
loginUserId,
applyUserId: targetUserId
})
if(!channelRes.success){
return channelRes
}
const channelId = channelRes.data.channelId
// 建立双向好友记录(幂等)
const selfFriendRes = await initUserFriendForPassFriend({
loginUserCompanyId,
loginUserId,
loginUsername: selfInfo[TlUserDef.name],
applyUserId: targetUserId,
applyUserName: targetInfo[TlUserDef.name],
origin: '同主体快速添加',
remark: '',
channelId,
flag: 0
})
if(!selfFriendRes.success){
return selfFriendRes
}
return tlResponseSuccess("建立好友关系成功", { channelId })
}
module.exports = {
getFriendList,
deleteFriend,
@ -542,4 +622,5 @@ module.exports = {
updateRename,
initChannelForPassFriend,
initUserFriendForPassFriend,
silentAddSubjectFriend,
}

View File

@ -11,19 +11,399 @@ const {
const userService = require('../../service/user/tl_user_service')
const userSessionService = require('../../service/user/tl_user_session_service')
const companyService = require('../../service/company/tl_company_service')
const channelService = require('../../service/channel/tl_channel_service')
const channelUserService = require('../../service/channel/tl_channel_user_service')
const userFingerPrintService = require('../../service/user/tl_user_finger_print_service')
const { postExternalService } = require('../../utils/external/service')
const cache = require('../../utils/cache/cache')
const { normalizeExternalSubject } = require('../../utils/external/subject')
const { fields: companyFields } = require('../../tables/tl_company')
const { Def: TlCompanyDef } = companyFields
const { fields: userFields } = require('../../tables/tl_user')
const { Def: TlUserDef, Flag: TlUserFlag } = userFields
const { fields: channelFields } = require('../../tables/tl_channel')
const { Def: TlChannelDef, Type: TlChannelType } = channelFields
const { fields: userFingerPrintFields } = require('../../tables/tl_user_finger_print')
const { Def: TlUserFingerPrintDef } = userFingerPrintFields
const { fields: channelUserFields } = require('../../tables/tl_channel_user')
const { Def: TlChannelUserDef, Type: TlChannelUserType } = channelUserFields
const { inner: TlRoleInner } = require('../../tables/tl_role')
const SSO_DEFAULT_AVATAR_URL = '/image/default-avatar.png'
const getDefaultSsoCompany = async function(){
const companyList = await companyService.getListForPage({}, [
TlCompanyDef.id,
TlCompanyDef.name
], 1, 1)
return companyList[0] || {}
}
const buildSsoUsername = function({ ssoId, ssoName }){
const username = (ssoName || '').trim().slice(0, 20)
if(username){
return username
}
return `sso_${ssoId}`.slice(0, 20)
}
const createSsoUser = async function({ ssoId, ssoName, companyId = 0, subjectInfo = {} }){
let useCompanyId = companyId
if(!useCompanyId){
const company = await getDefaultSsoCompany()
useCompanyId = company[TlCompanyDef.id]
}
if(!useCompanyId){
return {}
}
const username = buildSsoUsername({
ssoId,
ssoName,
})
const salt = crypto.randomBytes(16).toString('hex')
const password = encryptStr({
str: `${ssoId}_${Date.now()}`,
salt,
})
return await userService.addInfo({
companyId: useCompanyId,
ssoId,
subjectType: subjectInfo.storeType != null ? String(subjectInfo.storeType) : '',
subjectId: subjectInfo.storeId ? String(subjectInfo.storeId) : '',
subjectName: subjectInfo.storeName || '',
name: username,
password,
roleId: TlRoleInner.user.normal.id,
salt,
avatarUrl: SSO_DEFAULT_AVATAR_URL,
})
}
const normalizeStoreEmployee = function(employee = {}){
const ssoIdRaw = employee.employees_id || ''
const ssoNameRaw = employee.employees_name || ''
const ssoAvatarRaw = employee.avatar || ''
const ssoId = typeof ssoIdRaw === 'number' ? String(ssoIdRaw) : String(ssoIdRaw || '').trim()
const ssoName = String(ssoNameRaw || '').trim().slice(0, 20)
const ssoAvatar = String(ssoAvatarRaw || '').trim().slice(0, 255)
return {
ssoId,
ssoName,
ssoAvatar,
}
}
const getStoreEmployeesFromExternal = async function({ subjectInfo = {} }){
if(!subjectInfo.storeId){
return []
}
const res = await postExternalService({
methodKey: 'getStoreEmployees',
data: {
store_id: subjectInfo.storeId,
}
})
if(!res || res.code !== 200){
return []
}
const rawList = Array.isArray(res.data) ? res.data : []
if(!Array.isArray(rawList)){
return []
}
const ssoIdMap = {}
const result = []
rawList.forEach(item => {
const employee = normalizeStoreEmployee(item)
if(!employee.ssoId){
return
}
if(ssoIdMap[employee.ssoId]){
return
}
ssoIdMap[employee.ssoId] = true
result.push(employee)
})
return result
}
const ensureStoreEmployeesJoinChannel = async function({ companyId, channelId, subjectInfo }){
if(!companyId || !channelId){
return
}
const employees = await getStoreEmployeesFromExternal({ subjectInfo })
if(employees.length === 0){
return
}
for(const employee of employees){
let member = await userService.getInfoBySsoIdForLogin({
ssoId: employee.ssoId,
}, [
TlUserDef.id,
TlUserDef.companyId,
TlUserDef.name,
TlUserDef.avatarUrl,
])
if(!member[TlUserDef.id]){
await createSsoUser({
ssoId: employee.ssoId,
ssoName: employee.ssoName,
companyId,
subjectInfo,
})
member = await userService.getInfoBySsoIdForLogin({
ssoId: employee.ssoId,
}, [
TlUserDef.id,
TlUserDef.companyId,
TlUserDef.name,
TlUserDef.avatarUrl,
])
}
if(!member[TlUserDef.id]){
continue
}
if(parseInt(member[TlUserDef.companyId]) !== parseInt(companyId)){
continue
}
const updateUserData = {}
if(employee.ssoName && member[TlUserDef.name] !== employee.ssoName){
updateUserData[TlUserDef.name] = employee.ssoName
}
if(employee.ssoAvatar && member[TlUserDef.avatarUrl] !== employee.ssoAvatar){
updateUserData[TlUserDef.avatarUrl] = employee.ssoAvatar
}
if(Object.keys(updateUserData).length > 0){
await userService.updateInfoById({
companyId,
id: member[TlUserDef.id],
}, updateUserData)
}
const channelUser = await channelUserService.getInfoByChannelIdAndUserId({
companyId,
channelId,
userId: member[TlUserDef.id],
})
let channelRoleId = channelUser[TlChannelUserDef.roleId]
if(!channelUser[TlChannelUserDef.id]){
await channelUserService.addInfo({
companyId,
channelId,
type: TlChannelUserType.GROUP,
userId: member[TlUserDef.id],
roleId: TlRoleInner.channel.member.id,
})
channelRoleId = TlRoleInner.channel.member.id
}
// 同步更新用户个人频道权限缓存,避免已登录成员权限缓存滞后
if(channelRoleId){
await userSessionService.updateUserChannelRoleMap({
userId: member[TlUserDef.id],
channelRoleMap: {
[channelId]: channelRoleId,
}
})
}
}
}
// 兜底:把数据库里同主体的用户补齐到主群
const ensureSubjectUsersJoinChannel = async function({ companyId, channelId, subjectInfo }){
if(!companyId || !channelId){
return
}
if(!subjectInfo.storeType || !subjectInfo.storeId){
return
}
const subjectTypeStr = String(subjectInfo.storeType)
const subjectIdStr = String(subjectInfo.storeId)
const userList = await userService.getListWithSubjectByCompanyId({
companyId,
}, [
TlUserDef.id,
TlUserDef.subjectType,
TlUserDef.subjectId,
])
for(const user of userList){
const userId = user[TlUserDef.id]
if(!userId){
continue
}
if(String(user[TlUserDef.subjectType] || '') !== subjectTypeStr){
continue
}
if(String(user[TlUserDef.subjectId] || '') !== subjectIdStr){
continue
}
const channelUser = await channelUserService.getInfoByChannelIdAndUserId({
companyId,
channelId,
userId,
}, [
TlChannelUserDef.id,
TlChannelUserDef.roleId,
])
let channelRoleId = channelUser[TlChannelUserDef.roleId]
if(!channelUser[TlChannelUserDef.id]){
await channelUserService.addInfo({
companyId,
channelId,
type: TlChannelUserType.GROUP,
userId,
roleId: TlRoleInner.channel.member.id,
})
channelRoleId = TlRoleInner.channel.member.id
}
if(channelRoleId){
await userSessionService.updateUserChannelRoleMap({
userId,
channelRoleMap: {
[channelId]: channelRoleId,
}
})
}
}
}
const ensureSubjectChannelForUser = async function({ user, subjectInfo }){
if(!user[TlUserDef.id] || !user[TlUserDef.companyId]){
return
}
if(!subjectInfo.storeType || !subjectInfo.storeId || !subjectInfo.storeName){
return
}
const companyId = user[TlUserDef.companyId]
const userId = user[TlUserDef.id]
let channelId = await cache.getSubjectChannel({
storeType: subjectInfo.storeType,
storeId: subjectInfo.storeId,
})
if(channelId){
channelId = parseInt(channelId)
}
let channelInfo = {}
if(channelId){
channelInfo = await channelService.getInfoById({
companyId,
id: channelId,
})
}
if(!channelInfo[TlChannelDef.id]){
channelInfo = await channelService.getInfoByStore({
companyId,
storeType: subjectInfo.storeType,
storeId: subjectInfo.storeId,
}, [
TlChannelDef.id,
TlChannelDef.name,
TlChannelDef.companyId,
])
}
let channelRoleId = TlRoleInner.channel.member.id
if(!channelInfo[TlChannelDef.id]){
channelInfo = await channelService.addInfo({
companyId,
name: subjectInfo.storeName,
businessName: 'main',
type: TlChannelType.GROUP,
storeType: subjectInfo.storeType,
storeId: subjectInfo.storeId,
})
if(!channelInfo[TlChannelDef.id]){
return
}
channelRoleId = TlRoleInner.channel.creator.id
}
await cache.setSubjectChannel({
storeType: subjectInfo.storeType,
storeId: subjectInfo.storeId,
channelId: channelInfo[TlChannelDef.id],
})
const channelUser = await channelUserService.getInfoByChannelIdAndUserId({
companyId,
channelId: channelInfo[TlChannelDef.id],
userId,
})
if(!channelUser[TlChannelUserDef.id]){
await channelUserService.addInfo({
companyId,
channelId: channelInfo[TlChannelDef.id],
type: TlChannelUserType.GROUP,
userId,
roleId: channelRoleId,
})
}
// 每次SSO登录都执行一次门店员工入群与个人权限缓存同步,避免缓存长期滞后
await ensureStoreEmployeesJoinChannel({
companyId,
channelId: channelInfo[TlChannelDef.id],
subjectInfo,
})
// 兜底:外部员工接口漏人的情况下,补齐同主体历史用户
await ensureSubjectUsersJoinChannel({
companyId,
channelId: channelInfo[TlChannelDef.id],
subjectInfo,
})
}
/**
* 通过帐号登录接口
@ -395,6 +775,33 @@ const setUserChannelRole = async function({userId, companyId}){
})
}
/**
* 创建用户登录态
* @param {*} user
* @param {*} companyName
* @returns
*/
const createUserLoginSession = async function({ user, companyName }){
const token = userSessionService.generateLoginToken();
const info = {
loginUserId: user[TlUserDef.id],
loginUsername: user[TlUserDef.name],
loginUserEmail: user[TlUserDef.email],
loginUserMobile: user[TlUserDef.mobile],
loginUserRoleId: user[TlUserDef.roleId],
loginUserCompanyName : companyName,
loginUserCompanyId: user[TlUserDef.companyId],
loginUserAvatar: await getAvatarOssUrl(user[TlUserDef.avatarUrl]),
loginTime: new Date().getTime(),
token
}
await userSessionService.setUserInfoByToken({token, info})
await setUserChannelRole({ userId: user[TlUserDef.id], companyId: user[TlUserDef.companyId] })
return token
}
/**
* 管理后台登录 - 支持邮箱登录
@ -489,10 +896,202 @@ const userLoginBySystem = async function({ email, password }){
return tlResponseSuccess("登录成功", token)
}
/**
* 通过SSO票据登录接口
* @param {*} token
* @returns
*/
const userLoginBySsoTicket = async function({ token }){
if(!token){
return tlResponseArgsError("SSO票据非法")
}
const isValidSsoToken = typeof token === 'string' && (
token.length === 64 || token.startsWith('test-')
)
if(!isValidSsoToken){
return tlResponseArgsError("SSO票据非法")
}
const ssoCodeRes = await postExternalService({
methodKey: 'ssoCodeToId',
data: {
code: token
}
})
if(!ssoCodeRes || ssoCodeRes.code !== 200){
return tlResponseForbidden((ssoCodeRes && ssoCodeRes.message) || 'SSO换票失败')
}
let ssoId = ''
let ssoName = ''
let ssoAvatar = ''
let subjectInfo = {}
if(typeof ssoCodeRes.data === 'string'){
ssoId = ssoCodeRes.data
}
else if(ssoCodeRes.data && typeof ssoCodeRes.data === 'object'){
ssoId = ssoCodeRes.data.sso_id || ssoCodeRes.data.ssoId || ssoCodeRes.data.id || ssoCodeRes.data.employees_id || ''
ssoName = ssoCodeRes.data.employees_name || ssoCodeRes.data.name || ''
ssoAvatar = ssoCodeRes.data.avatar || ''
tlConsole('[SSO] raw data:', JSON.stringify(ssoCodeRes.data))
subjectInfo = normalizeExternalSubject(ssoCodeRes.data.subject)
}
if(typeof ssoId === 'number'){
ssoId = ssoId.toString()
}
if(typeof ssoName === 'string'){
ssoName = ssoName.trim().slice(0, 20)
}
if(typeof ssoAvatar === 'string'){
ssoAvatar = ssoAvatar.trim().slice(0, 255)
}
if(!ssoId){
return tlResponseForbidden('SSO标识无效')
}
let user = await userService.getInfoBySsoIdForLogin({
ssoId
}, [
TlUserDef.id,
TlUserDef.companyId,
TlUserDef.subjectType,
TlUserDef.subjectId,
TlUserDef.subjectName,
TlUserDef.name,
TlUserDef.avatarUrl,
TlUserDef.roleId,
TlUserDef.email,
TlUserDef.mobile,
])
if(!user[TlUserDef.id]){
const createUserRes = await createSsoUser({
ssoId,
ssoName,
subjectInfo,
})
if(!createUserRes[TlUserDef.id]){
return tlResponseForbidden('SSO用户创建失败')
}
user = await userService.getInfoBySsoIdForLogin({
ssoId
}, [
TlUserDef.id,
TlUserDef.companyId,
TlUserDef.subjectType,
TlUserDef.subjectId,
TlUserDef.subjectName,
TlUserDef.name,
TlUserDef.avatarUrl,
TlUserDef.roleId,
TlUserDef.email,
TlUserDef.mobile,
])
if(!user[TlUserDef.id]){
return tlResponseForbidden('SSO用户创建失败')
}
}
const updateUserData = {}
if(ssoName && user[TlUserDef.name] !== ssoName){
updateUserData[TlUserDef.name] = ssoName
}
if(ssoAvatar && user[TlUserDef.avatarUrl] !== ssoAvatar){
updateUserData[TlUserDef.avatarUrl] = ssoAvatar
}
if(subjectInfo.storeType != null){
const subjectTypeStr = String(subjectInfo.storeType)
if(user[TlUserDef.subjectType] !== subjectTypeStr){
updateUserData[TlUserDef.subjectType] = subjectTypeStr
}
}
if(subjectInfo.storeId){
const subjectId = String(subjectInfo.storeId)
if(user[TlUserDef.subjectId] !== subjectId){
updateUserData[TlUserDef.subjectId] = subjectId
}
}
if(subjectInfo.storeName && user[TlUserDef.subjectName] !== subjectInfo.storeName){
updateUserData[TlUserDef.subjectName] = subjectInfo.storeName
}
if(Object.keys(updateUserData).length > 0){
await userService.updateInfoById({
companyId: user[TlUserDef.companyId],
id: user[TlUserDef.id]
}, updateUserData)
await userSessionService.clearUserLoginCache({
userId: user[TlUserDef.id]
})
if(updateUserData[TlUserDef.name]){
user[TlUserDef.name] = updateUserData[TlUserDef.name]
}
if(updateUserData[TlUserDef.avatarUrl]){
user[TlUserDef.avatarUrl] = updateUserData[TlUserDef.avatarUrl]
}
if(updateUserData[TlUserDef.subjectType]){
user[TlUserDef.subjectType] = updateUserData[TlUserDef.subjectType]
}
if(updateUserData[TlUserDef.subjectId]){
user[TlUserDef.subjectId] = updateUserData[TlUserDef.subjectId]
}
if(updateUserData[TlUserDef.subjectName]){
user[TlUserDef.subjectName] = updateUserData[TlUserDef.subjectName]
}
}
await ensureSubjectChannelForUser({
user,
subjectInfo,
})
const company = await companyService.getInfoById({
id: user[TlUserDef.companyId]
}, [
TlCompanyDef.id,
TlCompanyDef.name
])
const companyId = company[TlCompanyDef.id]
const companyName = company[TlCompanyDef.name]
if(!companyId){
return tlResponseForbidden('SSO用户企业不存在')
}
const loginToken = await createUserLoginSession({
user,
companyName,
})
return tlResponseSuccess('登录成功', loginToken)
}
module.exports = {
userLoginByAccount,
userLoginByEmail,
userLoginByFingerPrint,
userLoginBySsoTicket,
userLoginBySystem
}

View File

@ -1,308 +0,0 @@
const {
tlResponseSvrError, tlConsoleError, tlResponseArgsError, checkRequestParams,
} = require("../../../utils/utils");
const express = require('express');
const router = express.Router();
const cutPasteBiz = require('../../../biz/cut_paste/cut_paste_biz');
const {
contentFilter, objectContentFilter
} = require('../../../utils/sensitive/content')
/**
* #controller get /api/web/cut-paste/get-cut-paste-list
* #desc 获取剪切板列表
* @param {*} request
* @param {*} response
*/
router.get('/get-cut-paste-list', async function(request, response) {
try {
const loginInfo = request.ctx || {}
const result = await cutPasteBiz.getCutPasteList({
loginInfo
});
response.json(result);
} catch (error) {
tlConsoleError(error)
response.json(tlResponseSvrError());
}
});
/**
* #controller post /api/web/cut-paste/add-cut-paste
* #desc 新增剪切板
* @param {*} request
* @param {*} response
*/
router.post('/add-cut-paste', async function(request, response) {
try {
const { code, title, password } = request.body;
const loginInfo = request.ctx || {}
if (!checkRequestParams({
code, title, password
})) {
response.json(tlResponseArgsError("请求参数非法"));
return;
}
const result = await cutPasteBiz.createCutPaste({
loginInfo, code, title: contentFilter(title), password
});
response.json(result);
} catch (error) {
tlConsoleError(error)
response.json(tlResponseSvrError());
}
});
/**
* #controller post /api/web/cut-paste/update-cut-paste-title
* #desc 更新剪切板标题
* @param {*} request
* @param {*} response
*/
router.post('/update-cut-paste-title', async function(request, response) {
try {
const { cutPasteId, title } = request.body;
const loginInfo = request.ctx || {}
if (!checkRequestParams({
cutPasteId, title
})) {
response.json(tlResponseArgsError("请求参数非法"));
return;
}
const result = await cutPasteBiz.updateCutPasteTitle({
loginInfo, cutPasteId, title: contentFilter(title),
});
response.json(result);
} catch (error) {
tlConsoleError(error)
response.json(tlResponseSvrError());
}
});
/**
* #controller post /api/web/cut-paste/update-cut-paste-password
* #desc 更新剪切板密码
* @param {*} request
* @param {*} response
*/
router.post('/update-cut-paste-password', async function(request, response) {
try {
const { cutPasteId, password } = request.body;
const loginInfo = request.ctx || {}
if (!checkRequestParams({
cutPasteId, password
})) {
response.json(tlResponseArgsError("请求参数非法"));
return;
}
const result = await cutPasteBiz.updateCutPastePassword({
loginInfo, cutPasteId, password
});
response.json(result);
} catch (error) {
tlConsoleError(error)
response.json(tlResponseSvrError());
}
});
/**
* #controller post /api/web/cut-paste/close-cut-paste
* #desc 关闭剪切板
* @param {*} request
* @param {*} response
*/
router.post('/close-cut-paste', async function(request, response) {
try {
const { cutPasteId } = request.body;
const loginInfo = request.ctx || {}
if (!checkRequestParams({
cutPasteId
})) {
response.json(tlResponseArgsError("请求参数非法"));
return;
}
const result = await cutPasteBiz.closeCutPaste({
loginInfo, cutPasteId
});
response.json(result);
} catch (error) {
tlConsoleError(error)
response.json(tlResponseSvrError());
}
});
/**
* #controller post /api/web/cut-paste/open-cut-paste
* #desc 开启剪切板
* @param {*} request
* @param {*} response
*/
router.post('/open-cut-paste', async function(request, response) {
try {
const { cutPasteId } = request.body;
const loginInfo = request.ctx || {}
if (!checkRequestParams({
cutPasteId
})) {
response.json(tlResponseArgsError("请求参数非法"));
return;
}
const result = await cutPasteBiz.openCutPaste({
loginInfo, cutPasteId
});
response.json(result);
} catch (error) {
tlConsoleError(error)
response.json(tlResponseSvrError());
}
});
/**
* #controller post /api/web/cut-paste/delete-cut-paste
* #desc 删除剪切板
* @param {*} request
* @param {*} response
*/
router.post('/delete-cut-paste', async function(request, response) {
try {
const { cutPasteId } = request.body;
const loginInfo = request.ctx || {}
if (!checkRequestParams({
cutPasteId
})) {
response.json(tlResponseArgsError("请求参数非法"));
return;
}
const result = await cutPasteBiz.deleteCutPaste({
loginInfo, cutPasteId
});
response.json(result);
} catch (error) {
tlConsoleError(error)
response.json(tlResponseSvrError());
}
});
/**
* #controller post /api/web/cut-paste/delete-cut-paste-detail
* #desc 删除剪切板详情
* @param {*} request
* @param {*} response
*/
router.post('/delete-cut-paste-detail', async function(request, response) {
try {
const { cutPasteDetailId } = request.body;
const loginInfo = request.ctx || {}
if (!checkRequestParams({
cutPasteDetailId
})) {
response.json(tlResponseArgsError("请求参数非法"));
return;
}
const result = await cutPasteBiz.deleteCutPasteDetail({
loginInfo, cutPasteDetailId
});
response.json(result);
} catch (error) {
tlConsoleError(error)
response.json(tlResponseSvrError());
}
});
/**
* #controller post /api/web/cut-paste/add-cut-paste-detail
* #desc 新增剪切板详情
* @param {*} request
* @param {*} response
*/
router.post('/add-cut-paste-detail', async function(request, response) {
try {
const { cutPasteId, content } = request.body;
const loginInfo = request.ctx || {}
if (!checkRequestParams({
cutPasteId
})) {
response.json(tlResponseArgsError("请求参数非法"));
return;
}
const result = await cutPasteBiz.addCutPasteDetail({
loginInfo, cutPasteId, content: contentFilter(content),
});
response.json(result);
} catch (error) {
tlConsoleError(error)
response.json(tlResponseSvrError());
}
});
/**
* #controller post /api/web/cut-paste/get-cut-paste-detail-list
* #desc 获取剪切板详情列表
* @param {*} request
* @param {*} response
*/
router.post('/get-cut-paste-detail-list', async function(request, response) {
try {
const { cutPasteId, typeList } = request.body;
const loginInfo = request.ctx || {}
if (!checkRequestParams({
cutPasteId, typeList
})) {
response.json(tlResponseArgsError("请求参数非法"));
return;
}
const result = await cutPasteBiz.getCutPasteDetailList({
loginInfo, cutPasteId, typeList
});
response.json(result);
} catch (error) {
tlConsoleError(error)
response.json(tlResponseSvrError());
}
});
module.exports = router;

View File

@ -1,67 +0,0 @@
const {
tlConsole, tlResponseSvrError, tlConsoleError, tlResponseArgsError, checkRequestParams
} = require("../../../utils/utils");
const express = require('express');
const router = express.Router();
const cutPasteBiz = require('../../../biz/cut_paste/cut_paste_biz');
/**
* #controller post /api/web/cut-paste-share/share-get-cut-paste-list
* #desc 通过分享渠道获取剪切板列表
* @param {*} request
* @param {*} response
*/
router.post('/share-get-cut-paste-list', async function(request, response) {
try {
const { code, typeList, password } = request.body;
if (!checkRequestParams({
code, typeList, password
})) {
response.json(tlResponseArgsError("请求参数非法"));
return;
}
const result = await cutPasteBiz.getCutPasteDetailListByCode({
code, typeList, inputPassword: password
});
response.json(result);
} catch (error) {
tlConsoleError(error)
response.json(tlResponseSvrError());
}
});
/**
* #controller post /api/web/cut-paste-share/share-add-cut-paste-detail
* #desc 通过分享渠道新增剪切板详情
* @param {*} request
* @param {*} response
*/
router.post('/share-add-cut-paste-detail', async function(request, response) {
try {
const { code, content, password } = request.body;
if (!checkRequestParams({
code, password
})) {
response.json(tlResponseArgsError("请求参数非法"));
return;
}
const result = await cutPasteBiz.addCutPasteDetailByCode({
code, content, inputPassword: password
});
response.json(result);
} catch (error) {
tlConsoleError(error)
response.json(tlResponseSvrError());
}
});
module.exports = router;

View File

@ -0,0 +1,89 @@
const express = require('express')
const router = express.Router()
const {
tlResponseArgsError,
tlResponseForbidden,
tlResponseSuccess,
tlResponseSvrError,
tlConsoleError,
} = require('../../../utils/utils')
const {
genExternalServiceSign,
ExternalServiceMethod,
} = require('../../../utils/external/service')
const verifyExternalRequestSign = function({ sign = '', method = '', data = {} }){
if(!sign || !method){
return false
}
const localSign = genExternalServiceSign({
method,
data,
})
return String(localSign) === String(sign)
}
const dispatchExternalMethod = async function({ method = '', data = {} }){
switch(method){
case ExternalServiceMethod.ping:
return tlResponseSuccess('pong', {
method,
requestId: data.requestId || '',
serverTime: Date.now(),
})
default:
return tlResponseArgsError('method不支持')
}
}
const handleExternalServiceRequest = async function(request, response){
try{
const sign = request.query.sign || ''
const method = request.body.method || ''
const data = request.body.data || {}
if(!method){
return response.json(tlResponseArgsError('method不能为空'))
}
const signOk = verifyExternalRequestSign({
sign,
method,
data,
})
if(!signOk){
return response.json(tlResponseForbidden('sign校验失败'))
}
const result = await dispatchExternalMethod({
method,
data,
})
return response.json(result)
}catch(error){
tlConsoleError('external service request error', error.message || error)
return response.json(tlResponseSvrError('外部互通请求失败'))
}
}
/**
* #controller post /api/web/external-service
* #desc 外部互通专用入口
* @param {*} request
* @param {*} response
*/
router.post('/', handleExternalServiceRequest)
/**
* #controller post /api/web/external-service/dispatch
* #desc 外部互通专用入口(兼容路径)
* @param {*} request
* @param {*} response
*/
router.post('/dispatch', handleExternalServiceRequest)
module.exports = router

View File

@ -42,6 +42,7 @@ router.post('/update-system-config', async function(request, response) {
webrtcConfig,
mysqlConfig,
emailConfig,
externalServiceConfig,
} = request.body;
if (!checkRequestParams({
@ -61,6 +62,7 @@ router.post('/update-system-config', async function(request, response) {
webrtcConfig,
mysqlConfig,
emailConfig,
externalServiceConfig,
});
response.json(result);

View File

@ -124,6 +124,24 @@ router.post('/update-channel-file-clear', async function(request, response) {
}
})
/**
* #controller post /api/web/user-clear/clear-self-cache
* #desc 清除当前登录用户相关缓存
* @param {*} request
* @param {*} response
*/
router.post('/clear-self-cache', async function(request, response) {
try {
const loginInfo = request.ctx || {}
const result = await userClearBiz.clearSelfCache({ loginInfo })
response.json(result)
} catch (error) {
tlConsoleError(error)
response.json(tlResponseSvrError())
}
})
module.exports = router;

View File

@ -133,4 +133,25 @@ router.post('/bind-email', async function(request, response) {
});
/**
* #controller get /api/web/user/get-subject-user-list
* #desc 获取按主体(subject)分组的用户列表
* @param {*} request
* @param {*} response
*/
router.get('/get-subject-user-list', async function(request, response) {
try {
const loginInfo = request.ctx || {}
const result = await userBiz.getSubjectUserList({
loginInfo
});
response.json(result);
} catch (error) {
tlConsoleError(error)
response.json(tlResponseSvrError(error));
}
});
module.exports = router;

View File

@ -114,4 +114,32 @@ router.get('/get-user-friend-list', async function(request, response) {
});
/**
* #controller post /api/web/user-friend/silent-add-subject-friend
* #desc 同主体静默建立好友关系(无需申请/同意)
* @param {*} request
* @param {*} response
*/
router.post('/silent-add-subject-friend', async function(request, response) {
try {
const { targetUserId } = request.body;
if (!checkRequestParams({ targetUserId })) {
response.json(tlResponseArgsError("请求参数非法"));
return;
}
const loginInfo = request.ctx || {}
const result = await userFriendBiz.silentAddSubjectFriend({
loginInfo, targetUserId
});
response.json(result);
} catch (error) {
tlConsoleError(error)
response.json(tlResponseSvrError(error));
}
});
module.exports = router;

View File

@ -1,6 +1,6 @@
const {
tlResponseSvrError, tlConsoleError,
tlResponseArgsError, checkRequestParams,
tlResponseArgsError, tlResponseForbidden,
tlResponseSuccess
} = require("../../../utils/utils");
const express = require('express');
@ -16,6 +16,10 @@ const {
}
} = require('../../../utils/constant');
const ssoOnlyLoginResponse = function(){
return tlResponseForbidden('原登录方式已停用,请通过SSO登录')
}
/**
* #controller get /api/web/user-login/login-state
@ -45,34 +49,7 @@ router.get('/login-state', async function(request, response) {
*/
router.post('/login-by-account', async function(request, response) {
try {
const { account, password, fps, inviteCode } = request.body;
const { [LOGIN_TOKEN_KEY]: token } = request.cookies;
if(token){
const loginResult = await userLoginStateBiz.userIsLogin({
token
});
if(loginResult.success){
return response.json(loginResult)
}
}
if (!checkRequestParams({
account, password, fps, inviteCode
})) {
response.json(tlResponseArgsError("请求参数非法"));
return;
}
const result = await userLoginBiz.userLoginByAccount({
account, password, fps, inviteCode
});
response.cookie(LOGIN_TOKEN_KEY, result.data, {
maxAge: LOGIN_TOKEN_EXPIRE, httpOnly: true
});
response.json(result);
response.json(ssoOnlyLoginResponse());
} catch (error) {
tlConsoleError(error)
response.json(tlResponseSvrError())
@ -87,34 +64,7 @@ router.post('/login-by-account', async function(request, response) {
*/
router.post('/login-by-email', async function(request, response) {
try {
const { email, password, fps, inviteCode } = request.body;
const { [LOGIN_TOKEN_KEY]: token } = request.cookies;
if(token){
const loginResult = await userLoginStateBiz.userIsLogin({
token
});
if(loginResult.success){
return response.json(loginResult)
}
}
if (!checkRequestParams({
email, password, fps, inviteCode
})) {
response.json(tlResponseArgsError("请求参数非法"));
return;
}
const result = await userLoginBiz.userLoginByEmail({
email, password, fps, inviteCode
});
response.cookie(LOGIN_TOKEN_KEY, result.data, {
maxAge: LOGIN_TOKEN_EXPIRE, httpOnly: true
});
response.json(result);
response.json(ssoOnlyLoginResponse());
} catch (error) {
tlConsoleError(error)
response.json(tlResponseSvrError())
@ -130,35 +80,43 @@ router.post('/login-by-email', async function(request, response) {
*/
router.post('/login-by-fp', async function(request, response) {
try {
const { username, fps, inviteCode } = request.body;
const { [LOGIN_TOKEN_KEY]: token } = request.cookies;
response.json(ssoOnlyLoginResponse());
} catch (error) {
tlConsoleError(error)
response.json(tlResponseSvrError())
}
});
if(token){
const loginResult = await userLoginStateBiz.userIsLogin({
token
});
if(loginResult.success){
return response.json(loginResult)
}
}
/**
* #controller post /api/web/user-login/login-by-sso-ticket
* #desc 通过SSO票据登录
* @param {*} request
* @param {*} response
*/
router.post('/login-by-sso-ticket', async function(request, response) {
try {
const { token } = request.body;
if (!checkRequestParams({
username, fps, inviteCode
})) {
response.json(tlResponseArgsError("请求参数非法"));
const isValidSsoToken = typeof token === 'string' && (
token.length === 64 || token.startsWith('test-')
)
if (!isValidSsoToken) {
response.json(tlResponseArgsError("SSO票据非法"));
return;
}
const result = await userLoginBiz.userLoginByFingerPrint({
username, fps, inviteCode
const result = await userLoginBiz.userLoginBySsoTicket({
token
});
response.cookie(LOGIN_TOKEN_KEY, result.data, {
maxAge: LOGIN_TOKEN_EXPIRE, httpOnly: true
});
if(result.success){
response.cookie(LOGIN_TOKEN_KEY, result.data, {
maxAge: LOGIN_TOKEN_EXPIRE, httpOnly: true
});
}
response.json(result);
} catch (error) {
tlConsoleError(error)
response.json(tlResponseSvrError())

View File

@ -39,9 +39,9 @@ const channelMedia = require('./channel/channel_media_controller')
// 文件
const cloudFile = require('./cloud/cloud_file_controller')
// 剪贴板
const cutPaste = require('./cut_paste/cut_paste_controller')
const cutPasteShare = require('./cut_paste/cut_paste_share_controller')
// 外部互通
const externalService = require('./external/external_service_controller')
module.exports = {
@ -73,8 +73,7 @@ module.exports = {
"channel-file" : channelFile,
"channel-media" : channelMedia,
"cut-paste" : cutPaste,
"cut-paste-share" : cutPasteShare,
"cloud-file" : cloudFile,
"external-service" : externalService,
}

View File

@ -1,211 +0,0 @@
const { DataTypes, where } = require('sequelize');
const { dbClient } = require('../tables/db')
const { model, fields } = require('../tables/tl_cut_paste')
const Table = model(dbClient, DataTypes).TlCutPaste
const TableName = fields.Name
const TableFields = Object.keys(fields.Def).map(key => fields.Def[key])
const { tlConsoleError, tlConsole, checkRawFieldType } = require("../utils/utils");
/**
* addInfo 接口
* @param {*} data
*/
const addInfo = async function(data){
if(Object.keys(data).length === 0){
tlConsoleError(TableName, "请求dao参数为空")
return null
}
// 参数校验
const checkStatus = checkRawFieldType(Table.rawAttributes, data)
if (!checkStatus) {
tlConsoleError(TableName, "请求dao参数类型错误")
return null
}
const info = await Table.create(data)
tlConsole(TableName, data, info)
return info
}
/**
* addList 接口
* @param {*} dataList
*/
const addList = async function(dataList){
if(dataList.length === 0){
tlConsoleError(TableName, "请求dao参数为空")
return null
}
for(let data of dataList){
if(Object.keys(data).length === 0){
tlConsoleError(TableName, "请求dao参数有为空项")
return null
}
// 参数校验
const checkStatus = checkRawFieldType(Table.rawAttributes, data)
if (!checkStatus) {
tlConsoleError(TableName, "请求dao参数类型错误")
return null
}
}
const list = await Table.bulkCreate(dataList)
tlConsole(TableName, dataList, list)
return list
}
/**
* getInfo 接口
* @param {*} params
* @param {*} fields
*/
const getInfo = async function(params, fields = TableFields){
if(Object.keys(params).length === 0){
tlConsoleError(TableName, "请求dao参数为空")
return null
}
const info = await Table.findOne({
where: params,
attributes: fields
})
return info
}
/**
* getList 接口
* @param {*} params
* @param {*} fields
* @param {*} order
*/
const getList = async function(params, fields = TableFields, order = [['id', 'ASC']]){
if(Object.keys(params).length === 0){
tlConsoleError(TableName, "请求dao参数有为空项")
return null
}
const list = await Table.findAll({
where : params,
attributes: fields,
order: order
})
return list
}
/**
* getListForPage 接口
* @param {*} params
* @param {*} fields
* @param {*} order
* @param {*} page
* @param {*} pageSize
*/
const getListForPage = async function(params, fields = TableFields, order = [['id', 'ASC']], page = 1, pageSize = 10){
if(Object.keys(params).length === 0){
tlConsoleError(TableName, "请求dao参数有为空项")
return null
}
const list = await Table.findAll({
where : params,
attributes: fields,
order: order,
offset: (page - 1) * pageSize,
limit: pageSize
})
return list
}
/**
* updateInfo 接口
* @param {*} params
*/
const updateInfo = async function(params, data){
if(Object.keys(params).length === 0){
tlConsoleError(TableName, "请求dao参数为空")
return null
}
if(Object.keys(data).length === 0){
tlConsoleError(TableName, "请求dao参数为空")
return null
}
// 参数校验
const checkStatus = checkRawFieldType(Table.rawAttributes, data)
if (!checkStatus) {
tlConsoleError(TableName, "请求dao参数类型错误")
return null
}
const info = await Table.update(data, {
where: params
})
tlConsole(TableName, params, data, info)
if(info[0] === 0){
return null
}
return {
count: info[0]
}
}
/**
* deleteInfo 接口
* @param {*} params
*/
const deleteInfo = async function(params){
if(Object.keys(params).length === 0){
tlConsoleError(TableName, "请求dao参数为空")
return null
}
const info = await Table.destroy({
where: params
})
tlConsole(TableName, params, info)
return info
}
/**
* getCount 接口
* @param {*} params
*/
const getCount = async function(params){
if(Object.keys(params).length === 0){
tlConsoleError(TableName, "请求dao参数有为空项")
return null
}
const count = await Table.count({
where : params
})
return count
}
module.exports = {
addInfo, addList,
getInfo, getList, getListForPage,
updateInfo,
deleteInfo,
getCount,
}

View File

@ -1,238 +0,0 @@
const { DataTypes, where } = require('sequelize');
const { dbClient } = require('../tables/db')
const { model, fields } = require('../tables/tl_cut_paste_detail')
const Table = model(dbClient, DataTypes).TlCutPasteDetail
const TableName = fields.Name
const TableFields = Object.keys(fields.Def).map(key => fields.Def[key])
const { tlConsoleError, tlConsole, checkRawFieldType } = require("../utils/utils");
/**
* addInfo 接口
* @param {*} data
*/
const addInfo = async function(data){
if(Object.keys(data).length === 0){
tlConsoleError(TableName, "请求dao参数为空")
return null
}
// 参数校验
const checkStatus = checkRawFieldType(Table.rawAttributes, data)
if (!checkStatus) {
tlConsoleError(TableName, "请求dao参数类型错误")
return null
}
const info = await Table.create(data)
tlConsole(TableName, data, info)
return info
}
/**
* addList 接口
* @param {*} dataList
*/
const addList = async function(dataList){
if(dataList.length === 0){
tlConsoleError(TableName, "请求dao参数为空")
return null
}
for(let data of dataList){
if(Object.keys(data).length === 0){
tlConsoleError(TableName, "请求dao参数有为空项")
return null
}
// 参数校验
const checkStatus = checkRawFieldType(Table.rawAttributes, data)
if (!checkStatus) {
tlConsoleError(TableName, "请求dao参数类型错误")
return null
}
}
const list = await Table.bulkCreate(dataList)
tlConsole(TableName, dataList, list)
return list
}
/**
* getInfo 接口
* @param {*} params
* @param {*} fields
*/
const getInfo = async function(params, fields = TableFields){
if(Object.keys(params).length === 0){
tlConsoleError(TableName, "请求dao参数为空")
return null
}
const info = await Table.findOne({
where: params,
attributes: fields
})
return info
}
/**
* getList 接口
* @param {*} params
* @param {*} fields
* @param {*} order
*/
const getList = async function(params, fields = TableFields, order = [['id', 'ASC']]){
if(Object.keys(params).length === 0){
tlConsoleError(TableName, "请求dao参数有为空项")
return null
}
const list = await Table.findAll({
where : params,
attributes: fields,
order: order
})
return list
}
/**
* getListForPage 接口
* @param {*} params
* @param {*} fields
* @param {*} order
* @param {*} page
* @param {*} pageSize
*/
const getListForPage = async function(params, fields = TableFields, order = [['id', 'ASC']], page = 1, pageSize = 10){
if(Object.keys(params).length === 0){
tlConsoleError(TableName, "请求dao参数有为空项")
return null
}
const list = await Table.findAll({
where : params,
attributes: fields,
order: order,
offset: (page - 1) * pageSize,
limit: pageSize
})
return list
}
/**
* updateInfo 接口
* @param {*} params
*/
const updateInfo = async function(params, data){
if(Object.keys(params).length === 0){
tlConsoleError(TableName, "请求dao参数为空")
return null
}
if(Object.keys(data).length === 0){
tlConsoleError(TableName, "请求dao参数为空")
return null
}
// 参数校验
const checkStatus = checkRawFieldType(Table.rawAttributes, data)
if (!checkStatus) {
tlConsoleError(TableName, "请求dao参数类型错误")
return null
}
const info = await Table.update(data, {
where: params
})
tlConsole(TableName, params, data, info)
if(info[0] === 0){
return null
}
return {
count: info[0]
}
}
/**
* deleteInfo 接口
* @param {*} params
*/
const deleteInfo = async function(params){
if(Object.keys(params).length === 0){
tlConsoleError(TableName, "请求dao参数为空")
return null
}
const info = await Table.destroy({
where: params
})
tlConsole(TableName, params, info)
return info
}
/**
* getCount 接口
* @param {*} params
*/
const getCount = async function(params){
if(Object.keys(params).length === 0){
tlConsoleError(TableName, "请求dao参数有为空项")
return null
}
const count = await Table.count({
where : params
})
return count
}
/**
* getGroupCount 接口
* @param {*} params
* @param {*} group
*/
const getGroupCount = async function(params, group){
if(Object.keys(params).length === 0){
tlConsoleError(TableName, "请求dao参数有为空项")
return null
}
if(Object.keys(group).length === 0){
tlConsoleError(TableName, "请求dao参数有为空项")
return null
}
const count = await Table.count({
where : params,
attributes: [group],
group: group,
})
return count
}
module.exports = {
addInfo, addList,
getInfo, getList, getListForPage,
updateInfo,
deleteInfo,
getCount,
getGroupCount
}

View File

@ -19,6 +19,7 @@ const loginAuthIngoreApi = [
'/api/web/user-login/system-login-state',
'/api/web/user-login/login-by-account',
'/api/web/user-login/login-by-email',
'/api/web/user-login/login-by-sso-ticket',
'/api/web/user-login/login-by-system',
// 注册
@ -28,6 +29,9 @@ const loginAuthIngoreApi = [
// 退出
'/api/web/user-logout/logout',
'/api/web/user-logout/system-logout',
// 外部互通
'/api/web/external-service',
]

View File

@ -22,6 +22,7 @@ const loginRoleIngoreApi = [
'/api/web/user-login/system-login-state',
'/api/web/user-login/login-by-account',
'/api/web/user-login/login-by-email',
'/api/web/user-login/login-by-sso-ticket',
'/api/web/user-login/login-by-system',
// 注册
@ -38,6 +39,9 @@ const loginRoleIngoreApi = [
'/api/web/channel/search-channel-by-id',
// 分享加入频道
'/api/web/channel-user/share-join-channel',
// 外部互通
'/api/web/external-service',
]

View File

@ -5,8 +5,6 @@ const {
userPermission,
companyPermission,
configPermission,
cutPastePermission,
channelPerfix,
channelNoticePerfix,
channelUserPerfix,
@ -68,11 +66,6 @@ const userNormalPermissions = function(){
Object.keys(configPermission).forEach((key) => {
returnPermission.push(...Object.values(configPermission[key]));
})
// 剪切板权限
Object.keys(cutPastePermission).forEach((key) => {
returnPermission.push(...Object.values(cutPastePermission[key]));
})
return returnPermission;
}
@ -107,10 +100,6 @@ const userAdminPermissions = function(){
Object.keys(configPermission).forEach((key) => {
returnPermission.push(...Object.values(configPermission[key]));
})
// 剪切板权限
Object.keys(cutPastePermission).forEach((key) => {
returnPermission.push(...Object.values(cutPastePermission[key]));
})
return returnPermission;
}

View File

@ -11,7 +11,6 @@ const cloudPermissionIdBase = 200000
const companyPermissionIdBase = 300000
const userPermissionIdBase = 400000
const configPermissionIdBase = 500000
const cutPastePermissionIdBase = 600000
// key前缀
const systemWebConfigPerfix = 'SYSTEM_WEB_CONFIG:'
@ -38,7 +37,6 @@ const userLoginPerfix = 'USER_LOGIN:'
const userLogoutPerfix = 'USER_LOGOUT:'
const userClearPerfix = 'USER_CLEAR:'
const configSkinPerfix = 'CONFIG_SKIN:'
const cutPastePerfix = 'CUT_PASTE:'
// 补充前缀
@ -222,7 +220,9 @@ let userPermission = {
// 更新用户头像
UPDATE_USER_AVATAR: userPermissionIdBase + 3,
// 绑定邮箱
BIND_EMAIL: userPermissionIdBase + 4
BIND_EMAIL: userPermissionIdBase + 4,
// 获取按主体分组的用户列表
GET_SUBJECT_USER_LIST: userPermissionIdBase + 5
},
userApply: { // 401000 ~ 401999
// 添加好友申请
@ -257,6 +257,8 @@ let userPermission = {
GET_USER_FRIEND_LIST: userPermissionIdBase + 2003,
// 关注好友
UPDATE_USER_FRIEND_SPECIAL: userPermissionIdBase + 2004,
// 同主体静默建立好友关系
SILENT_ADD_SUBJECT_FRIEND: userPermissionIdBase + 2005,
},
userConfig: { // 403000 ~ 403999
// 获取用户配置
@ -326,6 +328,8 @@ let userPermission = {
UPDATE_CHANNEL_FILE_CLEAR: userPermissionIdBase + 9002,
// 更新频道多消息清理记录
UPDATE_CHANNEL_MUTIL_CLEAR: userPermissionIdBase + 9003,
// 清除当前登录用户相关缓存
CLEAR_SELF_CACHE: userPermissionIdBase + 9004,
}
}
@ -337,33 +341,6 @@ const configPermission = {
}
// 剪切板权限 600000 - 699999
const cutPastePermission = {
cutPaste: { // 600000 ~ 699999
// 添加剪切板
ADD_CUT_PASTE: cutPastePermissionIdBase + 1,
// 获取剪切板列表
GET_CUT_PASTE_LIST: cutPastePermissionIdBase + 2,
// 删除剪切板
DELETE_CUT_PASTE: cutPastePermissionIdBase + 3,
// 更新剪切板标题
UPDATE_CUT_PASTE_TITLE: cutPastePermissionIdBase + 4,
// 更新剪切板密码
UPDATE_CUT_PASTE_PASSWORD: cutPastePermissionIdBase + 5,
// 关闭剪切板
CLOSE_CUT_PASTE: cutPastePermissionIdBase + 6,
// 开启剪切板
OPEN_CUT_PASTE: cutPastePermissionIdBase + 7,
// 添加剪切板内容详情
ADD_CUT_PASTE_DETAIL: cutPastePermissionIdBase + 8,
// 获取剪切板内容详情列表
GET_CUT_PASTE_DETAIL_LIST: cutPastePermissionIdBase + 9,
// 删除剪切板内容详情
DELETE_CUT_PASTE_DETAIL: cutPastePermissionIdBase + 10,
}
}
addPerfix(systemPermission.systemWebConfig, systemWebConfigPerfix)
addPerfix(systemPermission.systemWebCompany, systemWebCompanyPerfix)
addPerfix(systemPermission.systemWebUser, systemWebUserPerfix)
@ -393,8 +370,6 @@ addPerfix(userPermission.userTag, userTagPerfix)
addPerfix(userPermission.userClear, userClearPerfix)
addPerfix(configPermission.skin, configSkinPerfix)
addPerfix(cutPastePermission.cutPaste, cutPastePerfix)
module.exports = {
systemPermission,
@ -403,7 +378,6 @@ module.exports = {
companyPermission,
userPermission,
configPermission,
cutPastePermission,
systemWebConfigPerfix,
systemWebCompanyPerfix,
@ -427,5 +401,4 @@ module.exports = {
userLogoutPerfix,
userTagPerfix,
configSkinPerfix,
cutPastePerfix,
}

View File

@ -5,7 +5,6 @@ const {
userPermission,
companyPermission,
configPermission,
cutPastePermission
} = require('./permission');
const {
@ -58,8 +57,6 @@ const getAllPermissionsMap = function(){
returnPermissionMap = Object.assign(returnPermissionMap, userPermission.userClear)
// 配置权限
returnPermissionMap = Object.assign(returnPermissionMap, configPermission.skin)
// 剪切板权限
returnPermissionMap = Object.assign(returnPermissionMap, cutPastePermission.cutPaste)
return returnPermissionMap;
}

View File

@ -13,7 +13,7 @@ const { Op } = require('sequelize')
* @param {*} data
*/
const addInfo = async function({
companyId, name, type, flag = 0,
companyId, name, type, flag = 0, storeType = '', storeId = '', businessName = '',
}){
if(!companyId){
tlConsoleError(TableName, "请求service参数companyId为空")
@ -46,7 +46,10 @@ const addInfo = async function({
const info = await TlChannelDao.addInfo({
[TlChannelDef.companyId]: companyId,
[TlChannelDef.name]: name,
[TlChannelDef.businessName]: businessName,
[TlChannelDef.type]: type,
[TlChannelDef.storeType]: storeType,
[TlChannelDef.storeId]: storeId,
[TlChannelDef.flag]: flag,
[TlChannelDef.status]: TlChannelStatus.NORMAL,
})
@ -108,6 +111,43 @@ const getInfoByIdNoCompanyId = async function({id}){
return info
}
/**
* getInfoByStore 接口
* @param {*} companyId
* @param {*} storeType
* @param {*} storeId
* @param {*} fields
* @returns
*/
const getInfoByStore = async function({companyId, storeType, storeId}, fields){
if(!companyId){
tlConsoleError(TableName, "请求service参数companyId为空")
return {}
}
if(!storeType){
tlConsoleError(TableName, "请求service参数storeType为空")
return {}
}
if(!storeId){
tlConsoleError(TableName, "请求service参数storeId为空")
return {}
}
const info = await TlChannelDao.getInfo({
[TlChannelDef.companyId]: companyId,
[TlChannelDef.storeType]: storeType,
[TlChannelDef.storeId]: storeId,
}, fields)
if(info == null){
return {}
}
return info
}
/**
* getListByIdList 接口
* @param {*} companyId
@ -439,6 +479,7 @@ module.exports = {
deleteInfoById,
getInfoById,
getInfoByIdNoCompanyId,
getInfoByStore,
getListByIdList,
getListByIdListNoCompanyId,

View File

@ -1,186 +0,0 @@
const { fields } = require('../../tables/tl_cut_paste_detail')
const TlCutPasteDetailDao = require('../../dao/tl_cut_paste_detail_dao')
const TlCutPasteDetailDef = fields.Def
const TlCutPasteDetailType = fields.Type
const TableName = fields.Name
const TableFields = Object.keys(fields.Def).map(key => fields.Def[key])
const { tlConsoleError, tlConsole } = require("../../../src/utils/utils");
/**
* 创建剪贴板详情
* @param {*} data
*/
const addInfo = async function ({
code, cutPasteId, flag, content, type
}) {
// 参数校验
if(!code){
tlConsoleError(TableName, "请求service参数code为空")
return {}
}
if(!cutPasteId){
tlConsoleError(TableName, "请求service参数cutPasteId为空")
return {}
}
if(!content){
tlConsoleError(TableName, "请求service参数content为空")
return {}
}
if(!type){
tlConsoleError(TableName, "请求service参数type为空")
return {}
}
if(flag === undefined || flag === null){
tlConsoleError(TableName, "请求service参数flag为空")
return {}
}
if(![
TlCutPasteDetailType.TEXT,
TlCutPasteDetailType.IMAGE,
TlCutPasteDetailType.FILE,
TlCutPasteDetailType.AUDIO,
TlCutPasteDetailType.VIDEO,
TlCutPasteDetailType.RICH_TEXT,
TlCutPasteDetailType.OTHER,
TlCutPasteDetailType.LINK
].includes(type)){
tlConsoleError(TableName, "请求service参数type不合法")
return {}
}
const info = await TlCutPasteDetailDao.addInfo({
[TlCutPasteDetailDef.code]: code,
[TlCutPasteDetailDef.cutPasteId]: cutPasteId,
[TlCutPasteDetailDef.flag]: flag,
[TlCutPasteDetailDef.content]: content,
[TlCutPasteDetailDef.type]: type
});
if (info === null) {
tlConsoleError(TableName, "请求dao异常")
return {}
}
return info
}
/**
* 删除剪贴板详情
* @param {*} id
* @param {*} companyId
*/
const deleteInfoById = async function ({ id }) {
// 参数校验
if (!id) {
tlConsoleError(TableName, "请求service参数id为空")
return 0
}
const info = await TlCutPasteDetailDao.deleteInfo({
[TlCutPasteDetailDef.id]: id
});
if (info === null) {
tlConsoleError(TableName, "请求dao异常")
return 0
}
return info
}
/**
* 获取剪贴板详情内容
* @param {*} id
* @param {*} fields
*/
const getInfoById = async function ({ id }, fields) {
// 参数校验
if (!id) {
tlConsoleError(TableName, "请求service参数id为空")
return {}
}
const info = await TlCutPasteDetailDao.getInfo({
[TlCutPasteDetailDef.id]: id
}, fields)
if (info === null) {
return {}
}
return info
}
/**
* 获取某个剪贴板的剪贴板详情列表
* @param {*} typeList
* @param {*} cutPasteId
* @param {*} fields
*/
const getListByCutPasteIdAndTypeList = async function ({
cutPasteId, typeList
}, fields) {
// 参数校验
if(!cutPasteId){
tlConsoleError(TableName, "请求service参数cutPasteId为空")
return []
}
let query = {
[TlCutPasteDetailDef.cutPasteId]: cutPasteId,
}
if(typeList && typeList.length > 0){
query[TlCutPasteDetailDef.type] = typeList
}
const infoList = await TlCutPasteDetailDao.getList(query, fields, [
[TlCutPasteDetailDef.createdAt, "DESC"]
]);
if (infoList === null) {
return []
}
return infoList
}
/**
* 通过cutPasteIdList获取剪贴板详情数量
* @param {*} cutPasteIdList
* @param {*} companyId
*/
const getCountByCutPasteIdList = async function ({ cutPasteIdList }) {
// 参数校验
if(!cutPasteIdList){
tlConsoleError(TableName, "请求service参数cutPasteIdList为空")
return {}
}
const counts = await TlCutPasteDetailDao.getGroupCount({
[TlCutPasteDetailDef.cutPasteId]: cutPasteIdList
}, TlCutPasteDetailDef.cutPasteId);
if (counts === null) {
return {}
}
return counts
}
module.exports = {
addInfo,
deleteInfoById,
getInfoById,
getListByCutPasteIdAndTypeList,
getCountByCutPasteIdList
}

View File

@ -1,373 +0,0 @@
const { fields } = require('../../tables/tl_cut_paste')
const TlCutPasteDao = require('../../dao/tl_cut_paste_dao')
const TlCutPasteDef = fields.Def
const TlCutPasteStatus = fields.Status
const TableName = fields.Name
const TableFields = Object.keys(fields.Def).map(key => fields.Def[key])
const { tlConsoleError, tlConsole } = require("../../../src/utils/utils");
const { Op } = require('sequelize')
/**
* 创建剪贴板
* @param {*} data
*/
const addInfo = async function ({
companyId, userId, code, password, flag, title
}) {
// 参数校验
if(!code){
tlConsoleError(TableName, "请求service参数code为空")
return {}
}
if(!companyId){
tlConsoleError(TableName, "请求service参数companyId为空")
return {}
}
if(!userId){
tlConsoleError(TableName, "请求service参数userId为空")
return {}
}
if(!title){
tlConsoleError(TableName, "请求service参数title为空")
return {}
}
if(flag === undefined || flag === null){
tlConsoleError(TableName, "请求service参数flag为空")
return {}
}
const info = await TlCutPasteDao.addInfo({
[TlCutPasteDef.companyId]: companyId,
[TlCutPasteDef.userId]: userId,
[TlCutPasteDef.code]: code,
[TlCutPasteDef.status]: TlCutPasteStatus.USEED,
[TlCutPasteDef.password]: password,
[TlCutPasteDef.flag]: flag,
[TlCutPasteDef.title]: title
});
if (info === null) {
tlConsoleError(TableName, "请求dao异常")
return {}
}
return info
}
/**
* 删除剪贴板
* @param {*} id
* @param {*} companyId
*/
const deleteInfoById = async function ({ companyId, id }) {
// 参数校验
if (!id) {
tlConsoleError(TableName, "请求service参数id为空")
return 0
}
if(!companyId){
tlConsoleError(TableName, "请求service参数companyId为空")
return 0
}
const info = await TlCutPasteDao.deleteInfo({
[TlCutPasteDef.companyId]: companyId,
[TlCutPasteDef.id]: id
});
if (info === null) {
tlConsoleError(TableName, "请求dao异常")
return 0
}
return info
}
/**
* 更新剪贴板
* @param {*} data
* @param {*} companyId
* @param {*} id
*/
const updateInfoById = async function ({ companyId, id }, data) {
// 参数校验
if (Object.keys(data).length === 0) {
tlConsoleError(TableName, "请求service参数为空")
return {}
}
if (!id) {
tlConsoleError(TableName, "请求service参数id为空")
return {}
}
if(!companyId){
tlConsoleError(TableName, "请求service参数companyId为空")
return {}
}
const info = await TlCutPasteDao.updateInfo({
[TlCutPasteDef.companyId]: companyId,
[TlCutPasteDef.id]: id
}, data);
if (info === null) {
tlConsoleError(TableName, "请求dao异常")
return {}
}
return info
}
/**
* 获取用户的剪贴板列表
* @param {*} companyId
* @param {*} userId
* @param {*} fields
*/
const getListByUserId = async function ({ companyId, userId }, fields) {
// 参数校验
if(!companyId){
tlConsoleError(TableName, "请求service参数companyId为空")
return []
}
if(!userId){
tlConsoleError(TableName, "请求service参数userId为空")
return []
}
const infoList = await TlCutPasteDao.getList({
[TlCutPasteDef.companyId]: companyId,
[TlCutPasteDef.userId]: userId
}, fields, [
[TlCutPasteDef.createdAt, "DESC"]
]);
if (infoList === null) {
return []
}
return infoList
}
/**
* 获取剪贴板
* @param {*} companyId
* @param {*} code
* @param {*} fields
*/
const getInfoByCode = async function ({ code }, fields) {
// 参数校验
if(!code){
tlConsoleError(TableName, "请求service参数code为空")
return {}
}
const info = await TlCutPasteDao.getInfo({
[TlCutPasteDef.code]: code
}, fields);
if (info === null) {
return {}
}
return info
}
/**
* 获取剪贴板
* @param {*} companyId
* @param {*} id
* @param {*} fields
*/
const getInfoById = async function ({ companyId, id }, fields) {
// 参数校验
if (!id) {
tlConsoleError(TableName, "请求service参数id为空")
return {}
}
if(!companyId){
tlConsoleError(TableName, "请求service参数companyId为空")
return {}
}
const info = await TlCutPasteDao.getInfo({
[TlCutPasteDef.companyId]: companyId,
[TlCutPasteDef.id]: id
}, fields)
if (info === null) {
return {}
}
return info
}
/**
* 获取剪贴板列表
* @param {*} fields
* @param {*} page
* @param {*} pageSize
*/
const getListForPage = async function ({ }, fields, page, pageSize) {
// 参数校验
if(!page){
tlConsoleError(TableName, "请求service参数page为空")
return []
}
if(!pageSize){
tlConsoleError(TableName, "请求service参数pageSize为空")
return []
}
if(page <= 0){
tlConsoleError(TableName, "请求service参数page不合法")
return []
}
if(pageSize <= 0){
tlConsoleError(TableName, "请求service参数pageSize不合法")
return []
}
if(pageSize > 1000){
tlConsoleError(TableName, "请求service参数pageSize过大")
return []
}
const infoList = await TlCutPasteDao.getListForPage({
[TlCutPasteDef.id]: {
[Op.gte]: 0
}
}, fields, [
[TlCutPasteDef.createdAt, "DESC"]
], page, pageSize);
if (infoList === null) {
return []
}
return infoList
}
/**
* 获取剪贴板列表
* @param {*} keyword
* @param {*} fields
* @param {*} page
* @param {*} pageSize
*/
const getListByKeywordForPage = async function ({ keyword }, fields, page, pageSize) {
// 参数校验
if(!keyword){
tlConsoleError(TableName, "请求service参数keyword为空")
return []
}
if(!page){
tlConsoleError(TableName, "请求service参数page为空")
return []
}
if(!pageSize){
tlConsoleError(TableName, "请求service参数pageSize为空")
return []
}
if(page <= 0){
tlConsoleError(TableName, "请求service参数page不合法")
return []
}
if(pageSize <= 0){
tlConsoleError(TableName, "请求service参数pageSize不合法")
return []
}
if(pageSize > 1000){
tlConsoleError(TableName, "请求service参数pageSize过大")
return []
}
const infoList = await TlCutPasteDao.getListForPage({
[TlCutPasteDef.title]: {
[Op.like]: `%${keyword}%`
}
}, fields, [
[TlCutPasteDef.createdAt, "DESC"]
], page, pageSize);
if (infoList === null) {
return []
}
return infoList
}
/**
* 获取剪贴板数量
*/
const getCount = async function ({ }) {
// 参数校验
const count = await TlCutPasteDao.getCount({
[TlCutPasteDef.id]: {
[Op.gte]: 0
}
});
if (count === null) {
return 0
}
return count
}
/**
* 获取剪贴板数量
* @param {*} keyword
*/
const getCountByKeyword = async function ({ keyword }) {
// 参数校验
if(!keyword){
tlConsoleError(TableName, "请求service参数keyword为空")
return 0
}
const count = await TlCutPasteDao.getCount({
[TlCutPasteDef.title]: {
[Op.like]: `%${keyword}%`
}
});
if (count === null) {
return 0
}
return count
}
module.exports = {
addInfo,
deleteInfoById,
updateInfoById,
getInfoById,
getInfoByCode,
getListByUserId,
getListForPage,
getListByKeywordForPage,
getCount,
getCountByKeyword
}

View File

@ -11,7 +11,7 @@ const { Op } = require('sequelize')
* @param {*} data
*/
const addInfo = async function({
companyId, name, password, roleId, salt, mobile, email, avatarUrl,
companyId, ssoId, subjectType, subjectId, subjectName, name, password, roleId, salt, mobile, email, avatarUrl,
wchatName, wchatOpenId, wchatUnionId, wchatAvatarUrl, flag
}){
// 参数校验
@ -74,6 +74,10 @@ const addInfo = async function({
const info = await TlUserDao.addInfo({
[TlUserDef.companyId]: companyId,
[TlUserDef.ssoId]: ssoId || 0,
[TlUserDef.subjectType]: subjectType || '',
[TlUserDef.subjectId]: subjectId || '',
[TlUserDef.subjectName]: subjectName || '',
[TlUserDef.name]: name,
[TlUserDef.password]: password,
[TlUserDef.roleId]: roleId,
@ -290,6 +294,29 @@ const getInfoByEmailForLogin = async function({email}, fields){
return info
}
/**
* getInfoBySsoIdForLogin 接口
* @param {*} ssoId
* @param {*} fields
* @returns
*/
const getInfoBySsoIdForLogin = async function({ssoId}, fields){
if(!ssoId){
tlConsoleError(TableName, "请求service参数ssoId为空")
return {}
}
const info = await TlUserDao.getInfo({
[TlUserDef.ssoId]: ssoId
}, fields)
if(info === null){
return {}
}
return info
}
/**
* updateInfoById 接口
* @param {*} companyId
@ -622,6 +649,39 @@ const getAdminUser = async function({
/**
* getListWithSubjectByCompanyId 接口
* 获取同公司内有 subject_id 的用户列表(未删除)
* @param {*} companyId
* @param {*} fields
*/
const getListWithSubjectByCompanyId = async function({ companyId }, fields){
if(!companyId){
tlConsoleError(TableName, "请求service参数companyId为空")
return []
}
const list = await TlUserDao.getList({
[TlUserDef.companyId]: companyId,
[TlUserDef.subjectId]: {
[Op.and]: [
{ [Op.ne]: null },
{ [Op.ne]: '' }
]
}
}, fields, [
[TlUserDef.subjectId, 'ASC'],
[TlUserDef.createdAt, 'DESC']
])
if(list === null){
return []
}
return list
}
module.exports = {
addInfo,
updateInfoById,
@ -633,10 +693,12 @@ module.exports = {
getInfoByNameForLogin,
getInfoByMobileForLogin,
getInfoByEmailForLogin,
getInfoBySsoIdForLogin,
getAdminUser,
getListByIdList,
getListByIdListNoCompanyId,
getListWithSubjectByCompanyId,
getListByKeyword,
getListByKeywordForPage,

View File

@ -86,6 +86,22 @@ const setUserInfoByToken = async function({
}
}
/**
* 清除用户登录缓存
* @param {*} userId
*/
const clearUserLoginCache = async function({userId}){
return await cache.clearUserLoginCache({userId})
}
/**
* 清除用户业务缓存(不清登录态)
* @param {*} userId
*/
const clearUserRelatedCache = async function({userId}){
return await cache.clearUserRelatedCache({userId})
}
/**
* 通过userIdList获取登录状态
@ -207,6 +223,8 @@ const generateLoginToken = function(){
module.exports = {
getUserInfoByToken,
setUserInfoByToken,
clearUserLoginCache,
clearUserRelatedCache,
generateLoginToken,
getUserLoginStatusByIdList,
setEmailCode,

View File

@ -14,6 +14,7 @@ const socketGroupApply = require('./handler/group_apply')
const socketGroupApplyPass = require('./handler/group_apply_pass')
const socketGroupApplyReject = require('./handler/group_apply_reject')
const socketChannelFile = require('./handler/channel_file')
const socketChannelReadSync = require('./handler/channel_read_sync')
const socketAuth = require("./handler/auth");
const {socketServerEvent} = require("./event");
@ -106,6 +107,11 @@ module.exports = (io, socket) => {
socket.on(socketServerEvent.channelFile, (data) => {
socketChannelFile.channelFile(io, socket, data)
})
// 频道已读同步
socket.on(socketServerEvent.channelReadSync, (data) => {
socketChannelReadSync.channelReadSync(io, socket, data)
})
// 触发一次count
socketCount.count(io, socket, {})

View File

@ -22,6 +22,8 @@ module.exports = {
heartbeat : "heartbeat",
// 广播聊天消息
channelChat: "channelChat",
// 同步频道已读
channelReadSync: "channelReadSync",
// 广播好友申请
contactApply: "contactApply",
// 通过好友申请

View File

@ -25,6 +25,8 @@ module.exports = {
heartbeat : "heartbeat",
// 广播聊天消息
channelChat: "channelChat",
// 同步频道已读
channelReadSync: "channelReadSync",
// 广播好友申请
contactApply: "contactApply",
// 通过好友申请

View File

@ -56,12 +56,9 @@ async function channelChat(io, socket, data){
const userIds = channelUserList.map(item => item[TlChannelUserDef.userId])
// 广播给频道内的所有用户
// 广播给频道内的所有用户,但排除当前发送 socket,保留同账号其他终端
for(let userId of userIds){
if(userId === loginUserId){
continue
}
io.sockets.in(userId).emit(socketClientEvent.channelChat, {
socket.to(userId).emit(socketClientEvent.channelChat, {
channel: data.channel,
messageInfo: messageInfo,
from: socket.id,

View File

@ -0,0 +1,32 @@
const {socketClientEvent} = require("../event");
const userSessionService = require('../../service/user/tl_user_session_service')
/**
* 同步频道已读消息到同账号其他终端
* @param {*} io
* @param {*} socket
* @param {*} data
*/
async function channelReadSync(io, socket, data){
const token = socket.token;
const {
loginUserId
} = await userSessionService.getUserInfoByToken({token})
if(!loginUserId){
return
}
socket.to(loginUserId).emit(socketClientEvent.channelReadSync, {
channelId: data.channelId,
latestChatReadId: data.latestChatReadId || 0,
latestMediaReadId: data.latestMediaReadId || 0,
latestFileReadId: data.latestFileReadId || 0,
from: socket.id,
})
}
module.exports = {
channelReadSync
}

View File

@ -6,8 +6,11 @@ const tl_channel_fields = {
companyId : 'company_id',
flag : 'flag',
name : 'name',
businessName: 'business_name',
status: 'status',
type: 'type',
storeType: 'store_type',
storeId: 'store_id',
createdAt : 'createdAt',
updatedAt : 'updatedAt',
deletedAt : 'deletedAt',
@ -68,10 +71,25 @@ const tl_channel_model = function(DataTypes){
type: DataTypes.STRING(64),
comment: '频道名称'
},
business_name: {
type: DataTypes.STRING(64),
comment: '业务名称',
defaultValue: '',
},
type: {
type: DataTypes.INTEGER,
comment: '频道类型',
},
store_type: {
type: DataTypes.STRING(64),
comment: '主体群类型',
defaultValue: '',
},
store_id: {
type: DataTypes.STRING(64),
comment: '主体标识',
defaultValue: '',
},
status: {
type: DataTypes.INTEGER,
comment: '频道状态',

View File

@ -1,98 +0,0 @@
const tl_cut_paste_fields = {
Name: 'tl_cut_paste',
Description: '剪贴板表',
Def: {
id : 'id',
companyId : 'company_id',
userId: 'user_id',
title: 'title',
code: 'code',
flag: 'flag',
status: 'status',
password: 'password',
createdAt : 'createdAt',
updatedAt : 'updatedAt',
deletedAt : 'deletedAt',
},
Flag: {
HAS_PASSWORD: 0x1, // 有密码
},
Status: {
USEED: 1, // 使用中
CLOSE: 2, // 关闭
toStr: function(status){
switch(status){
case this.USEED: return '使用中';
case this.CLOSE: return '关闭';
default: return '未知';
}
}
}
}
const tl_cut_paste_model = function(DataTypes){
return {
model : {
id: {
type: DataTypes.INTEGER,
comment: '剪贴板id',
primaryKey: true,
autoIncrement: true
},
company_id: {
type: DataTypes.INTEGER,
comment: '企业id'
},
user_id:{
type: DataTypes.INTEGER,
comment: '属于的用户id',
defaultValue: 0
},
title: {
type: DataTypes.STRING(32),
comment: '剪贴板标题'
},
code: {
type: DataTypes.STRING(32),
comment: '剪贴板码'
},
password: {
type: DataTypes.STRING(32),
comment: '剪贴板密码'
},
flag: {
type: DataTypes.INTEGER,
comment: '标志位',
defaultValue: 0,
},
status: {
type: DataTypes.INTEGER,
comment: '状态',
defaultValue: tl_cut_paste_fields.Status.USEED
},
},
options : {
timestamps: true,
comment: '剪贴板表',
indexes: [{
name: 'created_at_index',
method: 'BTREE',
fields: ['created_at']
}]
}
}
}
module.exports = {
model: function(sequelize, DataTypes){
return {
TlCutPaste: sequelize.define(
'tl_cut_paste',
tl_cut_paste_model(DataTypes).model,
tl_cut_paste_model(DataTypes).options
)
}
},
fields: tl_cut_paste_fields
}

View File

@ -1,96 +0,0 @@
const tl_cut_paste_detail_fields = {
Name: 'tl_cut_paste_detail',
Description: '剪贴板详情表',
Def: {
id : 'id',
code: 'code',
cutPasteId: 'cut_paste_id',
flag: 'flag',
content: 'content',
type: 'type',
createdAt : 'createdAt',
updatedAt : 'updatedAt',
deletedAt : 'deletedAt',
},
Flag: {
},
Type: {
IMAGE: 'image', // 图片
AUDIO: 'audio', // 音频
VIDEO: 'video', // 视频
FILE: 'file', // 文档
TEXT: 'text', // 文本
RICH_TEXT: 'rich_text', // 富文本
LINK: 'link', // 链接
OTHER: 'other', // 其他
toStr: {
'image': '图片',
'audio': '音频',
'video': '视频',
'file': '文档',
'text': '文本',
'rich_text': '富文本',
'link': '链接',
'other': '其他',
}
}
}
const tl_cut_paste_detail_model = function(DataTypes){
return {
model : {
id: {
type: DataTypes.INTEGER,
comment: '剪贴板详情id',
primaryKey: true,
autoIncrement: true
},
code: {
type: DataTypes.STRING(32),
comment: '剪贴板码'
},
cut_paste_id: {
type: DataTypes.INTEGER,
comment: '剪贴板id'
},
type: {
type: DataTypes.STRING(32),
comment: '类型',
defaultValue: tl_cut_paste_detail_fields.Type.TEXT
},
flag: {
type: DataTypes.INTEGER,
comment: '标志位',
defaultValue: 0,
},
content: {
type: DataTypes.TEXT,
comment: '剪贴板内容'
},
},
options : {
timestamps: true,
comment: '剪贴板详情记录表',
indexes: [{
name: 'created_at_index',
method: 'BTREE',
fields: ['created_at']
}]
}
}
}
module.exports = {
model: function(sequelize, DataTypes){
return {
TlCutPasteDetail: sequelize.define(
'tl_cut_paste_detail',
tl_cut_paste_detail_model(DataTypes).model,
tl_cut_paste_detail_model(DataTypes).options
)
}
},
fields: tl_cut_paste_detail_fields
}

View File

@ -4,6 +4,10 @@ const tl_user_fields = {
Def : {
id : 'id',
companyId : 'company_id',
ssoId : 'sso_id',
subjectType : 'subject_type',
subjectId : 'subject_id',
subjectName : 'subject_name',
name : 'name',
password : 'password',
salt : 'salt',
@ -38,6 +42,22 @@ const tl_user_model = function(DataTypes){
type: DataTypes.INTEGER,
comment: '企业id'
},
sso_id: {
type: DataTypes.BIGINT.UNSIGNED,
comment: '外部SSO标识'
},
subject_type: {
type: DataTypes.STRING(32),
comment: '主体类型'
},
subject_id: {
type: DataTypes.STRING(64),
comment: '主体标识'
},
subject_name: {
type: DataTypes.STRING(64),
comment: '主体名称'
},
name: {
type: DataTypes.STRING(20),
comment: '用户名称'

View File

@ -4,6 +4,7 @@ const {
const {
USER_KEYS,
CHANNEL_KEYS,
} = require('./cache_key');
const {
LOGIN : {
@ -51,6 +52,62 @@ const getLoginInfo = async function({token}){
return await redisClient.get(key);
}
/**
* 清除用户登录缓存
* @param {*} userId
*/
const clearUserLoginCache = async function({userId}){
if(!userId){
return
}
const redisClient = getRedisClient();
const loginInfoKeys = []
for await (const key of redisClient.scanIterator({
MATCH: USER_KEYS.USER_LOGIN_INFO + '*',
COUNT: 100
})) {
loginInfoKeys.push(key)
}
for(let i = 0; i < loginInfoKeys.length; i++){
const key = loginInfoKeys[i]
const loginInfo = await redisClient.get(key)
if(!loginInfo){
continue
}
try{
const info = JSON.parse(loginInfo)
if(parseInt(info.loginUserId) === parseInt(userId)){
await redisClient.del(key)
}
}catch(e){
await redisClient.del(key)
}
}
await redisClient.del(USER_KEYS.USER_LOGIN_STATUS + userId)
await redisClient.del(USER_KEYS.USER_INFO + userId)
await redisClient.del(USER_KEYS.USER_CHANNEL_PERMISSION + userId)
}
/**
* 清除用户业务缓存(不踢下线)
* @param {*} userId
*/
const clearUserRelatedCache = async function({userId}){
if(!userId){
return
}
const redisClient = getRedisClient()
await redisClient.del(USER_KEYS.USER_INFO + userId)
await redisClient.del(USER_KEYS.USER_CHANNEL_PERMISSION + userId)
}
/**
* 设置用户登录状态
* 1小时过期
@ -178,6 +235,44 @@ const getUserIdSocketIdMap = async function({userId}){
return await redisClient.hget(cacheKey, userId);
}
/**
* 设置主体群缓存
* @param {*} storeType
* @param {*} storeId
* @param {*} channelId
* @param {*} expireSeconds
*/
const setSubjectChannel = async function({
storeType, storeId, channelId, expireSeconds = 60 * 60 * 24 * 30
}){
if(!storeType || !storeId || !channelId){
return
}
const cacheKey = CHANNEL_KEYS.SUBJECT_CHANNEL + `${storeType}:${storeId}`
const redisClient = getRedisClient()
await redisClient.set(cacheKey, channelId)
await redisClient.expire(cacheKey, expireSeconds)
}
/**
* 获取主体群缓存
* @param {*} storeType
* @param {*} storeId
* @returns
*/
const getSubjectChannel = async function({storeType, storeId}){
if(!storeType || !storeId){
return ''
}
const cacheKey = CHANNEL_KEYS.SUBJECT_CHANNEL + `${storeType}:${storeId}`
const redisClient = getRedisClient()
return await redisClient.get(cacheKey)
}
/**
* 设置邮箱验证码
* 5分钟过期
@ -313,9 +408,12 @@ const getUserChannelRole = async function({userId, channelId}){
module.exports = {
setLoginInfo, getLoginInfo,
clearUserLoginCache,
clearUserRelatedCache,
setUserInfo, getUserInfo,
setUserIdSocketIdMap, getUserIdSocketIdMap,
setSubjectChannel, getSubjectChannel,
getLoginStatus, setLoginStatus,
getLoginStatusList,

View File

@ -3,8 +3,12 @@ const PREFIX = 'TL:CHANNEL:';
const KEYS = {
// 某个频道下用户列表
CHANNEL_USER_LIST: PREFIX + 'CHANNEL_USER_LIST:',
// 主体群缓存
SUBJECT_CHANNEL: PREFIX + 'SUBJECT_CHANNEL:',
}
module.exports = {
CHANNEL_KEYS : KEYS,
CAHNNEL_KEYS : KEYS
}

11
src/utils/external/method.js vendored Normal file
View File

@ -0,0 +1,11 @@
const ExternalServiceMethod = Object.freeze({
ping: 'ping',
ssoCodeToId: 'ssoCodeToId',
getStoreEmployees: 'getStoreEmployees',
ssoTicketExchange: 'sso.ticket.exchange',
})
module.exports = {
ExternalServiceMethod,
}

190
src/utils/external/service.js vendored Normal file
View File

@ -0,0 +1,190 @@
const crypto = require('crypto')
const request = require('request')
const { get_env_config } = require('../../../conf/env_config')
const { tlConsoleError } = require('../utils')
const { ExternalServiceMethod } = require('./method')
const conf = get_env_config()
const getExternalServiceUrl = function(){
return (conf.external_service_url || '').replace(/\/+$/, '')
}
const getExternalServiceSecret = function(){
return conf.external_service_secret || ''
}
const resolveExternalMethod = function({ methodKey = '', method = '' }){
if(methodKey && ExternalServiceMethod[methodKey]){
return ExternalServiceMethod[methodKey]
}
return method
}
const stringifyExternalPayload = function(payload = {}){
return JSON.stringify(payload || {})
}
const encodeExternalPayload = function(payload = {}){
return Buffer.from(stringifyExternalPayload(payload)).toString('base64')
}
const genExternalServiceSign = function(payload = {}){
const content = encodeExternalPayload(payload) + getExternalServiceSecret()
return crypto.createHash('sha256').update(content).digest('hex')
}
const normalizeExternalResponse = function({ response, body }){
if(body && typeof body === 'object'){
return body
}
const success = response.statusCode >= 200 && response.statusCode < 300
return {
success,
code: response.statusCode,
msg: typeof body === 'string' && body ? body : (success ? '请求成功' : '请求失败'),
data: {}
}
}
const requestExternalService = async function({
requestMethod = 'POST',
requestData = {},
timeout = 8000,
}){
const url = getExternalServiceUrl()
if(!url){
return {
success: false,
code: 400,
msg: '外部服务地址未配置',
data: {}
}
}
return await new Promise((resolve) => {
request({
url,
method: requestMethod,
qs: requestData.qs,
body: requestData.body,
json: true,
timeout,
}, function(error, response, body){
if(error){
tlConsoleError('外部服务请求异常', error.message || error)
resolve({
success: false,
code: 500,
msg: error.message || '外部服务请求失败',
data: {}
})
return
}
resolve(normalizeExternalResponse({ response, body }))
})
})
}
const getExternalService = async function({
methodKey = '',
method = '',
data = {},
timeout = 8000,
}){
const externalMethod = resolveExternalMethod({ methodKey, method })
if(!externalMethod){
return {
success: false,
code: 400,
msg: '外部方法未配置',
data: {}
}
}
const payload = {
method: externalMethod,
data,
}
return await requestExternalService({
requestMethod: 'GET',
requestData: {
qs: {
method: payload.method,
data: encodeExternalPayload(payload.data),
sign: genExternalServiceSign(payload),
}
},
timeout,
})
}
const postExternalService = async function({
methodKey = '',
method = '',
data = {},
timeout = 8000,
}){
const externalMethod = resolveExternalMethod({ methodKey, method })
if(!externalMethod){
return {
success: false,
code: 400,
msg: '外部方法未配置',
data: {}
}
}
const payload = {
method: externalMethod,
data,
}
return await requestExternalService({
requestMethod: 'POST',
requestData: {
qs: {
sign: genExternalServiceSign(payload),
},
body: {
method: payload.method,
data: payload.data,
}
},
timeout,
})
}
const pingExternalService = async function({
requestId = '',
timeout = 8000,
}){
return await postExternalService({
methodKey: 'ping',
data: {
requestId,
},
timeout,
})
}
module.exports = {
ExternalServiceMethod,
getExternalServiceUrl,
getExternalServiceSecret,
stringifyExternalPayload,
encodeExternalPayload,
genExternalServiceSign,
getExternalService,
postExternalService,
pingExternalService,
}

31
src/utils/external/subject.js vendored Normal file
View File

@ -0,0 +1,31 @@
const SUBJECT_CHANNEL_STORE_TYPE = {
MAIN: 1,
}
const normalizeExternalSubject = function(subject){
if(!subject || typeof subject !== 'object'){
return {}
}
const subjectId = subject.id
const subjectName = (subject.name || '').toString().trim().slice(0, 64)
const subjectType = (subject.type || '').toString().trim()
if(!subjectId || !subjectType){
return {}
}
return {
storeType: subjectType,
storeId: subjectId.toString(),
storeName: subjectName,
subjectType,
}
}
module.exports = {
SUBJECT_CHANNEL_STORE_TYPE,
normalizeExternalSubject,
}

View File

@ -86,6 +86,10 @@ const getAvatarOssUrl = async function (key = "", expires = 3600) {
return key
}
if(/^https?:\/\//i.test(key)){
return key
}
else if(fileSaveToServer){
let filePath = serverFileUrlTransfer(key)
if(filePath === ''){

View File

@ -0,0 +1,8 @@
{
"folders": [
{
"path": "."
}
],
"settings": {}
}

View File

@ -14,15 +14,22 @@ tl_rtc_app_admin_user_email=tlrtcapp@demo.com
tl_rtc_app_admin_password=123456
#-----------------以下为外部互通服务配置-----------------#
## 外部互通服务地址
tl_rtc_app_external_service_url=http://127.0.0.1:6060/im
## 外部互通服务密钥
tl_rtc_app_external_service_secret="E5#ex.g@,GfL_8?ag"
#-----------------以下为redis缓存相关配置-----------------#
## redis地址
tl_rtc_app_redis_host=localhost
tl_rtc_app_redis_host=112.124.21.102
## redis端口
tl_rtc_app_redis_port=6379
## redis auth密码
tl_rtc_app_redis_password=
tl_rtc_app_redis_password=qwe2019@
## redis db 默认0
tl_rtc_app_redis_db=0
tl_rtc_app_redis_db=8
#-----------------以下为webrtc相关配置-----------------#
@ -44,15 +51,15 @@ tl_rtc_app_webrtc_turn_expire=86400000
## 是否开启数据库
tl_rtc_app_db_open=true
## 数据库地址
tl_rtc_app_db_mysql_host=localhost
tl_rtc_app_db_mysql_host=112.124.21.102
## 数据库端口
tl_rtc_app_db_mysql_port=3306
## 数据库名称
tl_rtc_app_db_mysql_database=tlrtcapp
tl_rtc_app_db_mysql_database=im
## 数据库用户名
tl_rtc_app_db_mysql_user=root
tl_rtc_app_db_mysql_user=im
## 数据库密码
tl_rtc_app_db_mysql_password=123456
tl_rtc_app_db_mysql_password=5yd7i4Z38GExeA8Z
#-----------------以下为oss相关配置-----------------#
@ -67,4 +74,6 @@ tl_rtc_app_mail_port=465
## 邮箱用户名
tl_rtc_app_mail_user=
## 邮箱密码
tl_rtc_app_mail_password=
tl_rtc_app_mail_password=

View File

@ -1,230 +0,0 @@
/***********************************************************************************
************************************************************************************
剪贴板详情 start
************************************************************************************
************************************************************************************/
.tl-rtc-app-right-cut-paste-content{
height: 100%;
width: 100%;
}
.tl-rtc-app-layer-cut-paste-share{
background: var(--skin-body-background) !important;
color: var(--skin-body-color) !important;
}
.tl-rtc-app-layer-cut-paste-share .layui-layer-title{
background: var(--skin-body-background) !important;
color: var(--skin-body-color) !important;
border-radius: 6px;
}
.tl-rtc-app-right-cut-paste-content-top{
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: space-between;
align-items: center;
border-bottom: 1px solid var(--skin-body-border-color);
padding: 5px 10px 5px 10px;
height: 40px;
}
.tl-rtc-app-right-cut-paste-content-top-title{
font-size: 15px;
font-weight: 700;
user-select: none;
width: 40%;
overflow: hidden;
text-overflow: ellipsis;
word-break: break-all;
white-space: nowrap;
}
.tl-rtc-app-right-cut-paste-content-top-tool{
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: flex-end;
font-size: 12px;
width: 60%;
align-items: center;
}
.tl-rtc-app-right-cut-paste-content-top-tool-item{
padding: 2px 5px;
cursor: pointer;
transition: all 0.2s;
border-radius: 4px;
user-select: none;
margin-left: 6px;
border: 0.5px solid var(--skin-body-border-color);
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
}
.tl-rtc-app-right-cut-paste-content-top-tool-item svg{
width: 18px;
height: 18px;
}
.tl-rtc-app-right-cut-paste-content-body{
width: calc(100% - 10px);
height: calc(100% - 56px);
padding: 0px 5px 5px 5px;
overflow: auto;
}
.tl-rtc-app-right-cut-paste-content-title{
line-height: 40px;
font-weight: 700;
user-select: none;
display: flex;
flex-direction: row;
justify-content: center;
margin-top: 10px;
color: #a2a8ac;
}
.tl-rtc-app-right-cut-paste-content-time{
color: #9ba8a4;
font-size: 12px;
margin-left: 20px;
}
.tl-rtc-app-right-cut-paste-content-body-textarea{
width: calc(100% - 32.5px);
height: calc(100% - 61.5px);
padding: 5px 15px;
border: unset;
border-radius: 4px;
background: var(--skin-body-background);
color: var(--skin-body-color);
font-size: 14px;
resize: none;
letter-spacing: 0.5px;
overflow: auto;
outline: unset;
}
.tl-rtc-app-right-cut-paste-content-body-textarea-view{
width: calc(100% - 32.5px);
padding: 15px;
margin: 10px 0;
font-size: 14px;
resize: none;
letter-spacing: .5px;
overflow: hidden;
word-break: break-all;
border: 1px solid var(--skin-body-border-color);
background: var(--skin-meeting-content-history-item-background);
border-radius: 2px;
color: var(--skin-body-color);
}
.tl-rtc-app-right-cut-paste-content-body-time{
font-weight: bold;
margin-bottom: 5px;
}
.tl-rtc-app-right-cut-paste-content-body-time svg{
margin-left: 5px;
}
.tl-rtc-app-right-cut-paste-content-body-title{
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: space-between;
align-items: center;
}
.tl-rtc-app-right-cut-paste-content-body-info{
padding: 5px 0;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: center;
align-items: center;
}
.tl-rtc-app-right-cut-paste-content-body-info svg{
width: 20px;
height: 20px;
padding-left: 5px;
}
.tl-rtc-app-right-cut-paste-content-body-tools svg{
margin-right: 5px;
cursor: pointer;
transition: all 0.2s;
scale: 1.1;
}
.tl-rtc-app-right-cut-paste-content-body-tools svg:hover{
scale: 1.2;
}
.tl-rtc-app-right-cut-paste-content-body-detail{
padding: 5px 0;
cursor: pointer;
}
.tl-rtc-app-right-cut-paste-content-body-no-history{
text-align: center;
margin-top: 50px;
font-size: 16px;
color: #c1bac7;
}
.tl-rtc-app-layer-cut-paste-share{
background: var(--skin-body-background) !important;
color: var(--skin-body-color) !important;
}
.tl-rtc-app-layer-cut-paste-share .layui-layer-title{
color: var(--skin-body-color) !important;
border-color: var(--skin-body-border-color) !important;
border-radius: 6px;
}
.tl-rtc-app-layer-cut-paste-share #tl-rtc-app-cut-paste-share-image{
text-align: center;
user-select: none;
}
.tl-rtc-app-layer-cut-paste-share #tl-rtc-app-cut-paste-share-image img{
width: 70%;
height: 70%;
margin-left: 15%;
margin-top: 7%;
-webkit-user-drag: none;
}
.tl-rtc-app-layer-cut-paste-share .tl-rtc-app-cut-paste-share-tools{
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
margin-top: 8%;
}
.tl-rtc-app-layer-cut-paste-share .tl-rtc-app-cut-paste-share-tools-item{
padding: 5px 10px;
border-radius: 4px;
cursor: pointer;
transition: all 0.2s;
margin: 0 10px;
border: 1px solid var(--skin-body-border-color);
}
/***********************************************************************************
************************************************************************************
剪贴板详情 end
************************************************************************************
************************************************************************************/

View File

@ -1,239 +0,0 @@
/***********************************************************************************
************************************************************************************
剪贴板列表 start
************************************************************************************
************************************************************************************/
#tl-rtc-app .tl-rtc-app-left .tl-rtc-app-left-panel-cut-paste .tl-rtc-app-left-panel-no-cut-paste{
text-align: center;
line-height: 70px;
font-size: 14px;
font-weight: bold;
color: var(--skin-body-color); /** TODO **/
}
.tl-rtc-app-left-panel-no-cut-paste button{
color: var(--skin-body-color); /** TODO **/
}
.tl-rtc-app-left-panel-no-cut-paste button:hover{
color: var(--skin-body-color); /** TODO **/
}
#tl-rtc-app .tl-rtc-app-left .tl-rtc-app-left-panel-cut-paste-top{
height: var(--left-cut-paste-top);
}
#tl-rtc-app .tl-rtc-app-left .tl-rtc-app-left-panel-cut-paste-top-header{
display: flex;
padding: 15px 10px 15px 0px;
flex-direction: row;
justify-content: space-between;
}
#tl-rtc-app .tl-rtc-app-left .tl-rtc-app-left-panel-cut-paste-top-header-title{
font-size: 16px;
font-weight: bold;
color: var(--skin-top-header-title-color);
margin-right: 10px;
margin-left: 20px;
overflow: hidden;
text-overflow: ellipsis;
word-break: break-all;
white-space: nowrap;
width: 70%;
}
#tl-rtc-app .tl-rtc-app-left .tl-rtc-app-left-panel-cut-paste-top-header-tool{
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
transition: all 0.3s;
background: var(--skin-top-header-tool-background);
padding: 2px 5px;
border-radius: 4px;
}
#tl-rtc-app .tl-rtc-app-left .tl-rtc-app-left-panel-cut-paste-top-header-tool svg{
width: 14px;
height: 14px;
fill: #959595;
transition: all 0.3s;
scale: 1.5;
}
#tl-rtc-app .tl-rtc-app-left .tl-rtc-app-left-panel-cut-paste-top-header-tool:hover{
box-shadow: 0 4px 40px #00000026;
}
#tl-rtc-app .tl-rtc-app-left .tl-rtc-app-left-panel-cut-paste-top-header-tool:hover svg{
fill: #333333;
scale: 1.7;
}
#tl-rtc-app .tl-rtc-app-left .tl-rtc-app-left-panel-cut-paste-top-search{
padding: 5px 0;
line-height: 0px;
width: 96%;
margin-left: 2%;
}
#tl-rtc-app .tl-rtc-app-left .tl-rtc-app-left-panel-cut-paste-top-search i{
position: relative;
margin-left: 8px;
top: 16px;
color: var(--skin-cut-paste-top-search-i-color);
}
#tl-rtc-app .tl-rtc-app-left .tl-rtc-app-left-panel-cut-paste-top-search svg{
color: var(--skin-cut-paste-top-search-i-color);
position: relative;
float: right;
right: 8px;
margin-top: -22px;
cursor: pointer;
}
#tl-rtc-app .tl-rtc-app-left .tl-rtc-app-left-panel-cut-paste-top-search input{
width: 100%;
height: 30px;
padding-left: 30px !important;
border-radius: 4px;
background: var(--skin-cut-paste-top-search-input-background);
color: var(--skin-cut-paste-top-search-input-color);
font-size: 13px;
letter-spacing: 1px;
border-width: 0.5px;
border-color: var(--skin-cut-paste-top-search-input-background);
}
#tl-rtc-app .tl-rtc-app-left .tl-rtc-app-left-panel-cut-paste{
height: calc(100% - var(--left-cut-paste-top));
}
#tl-rtc-app .tl-rtc-app-left #cutPasteListSwiper{
height: calc(100% - 180px);
}
#tl-rtc-app .tl-rtc-app-left .tl-rtc-app-left-panel-cut-paste-item{
display: flex;
align-items: center;
cursor: pointer;
border-radius: 2px;
transition: all 0.1s;
}
.tl-rtc-app-left-panel-cut-paste-item-actions{
display: flex;
position: absolute;
right: 10px;
top: 50%;
transform: translateY(-50%);
}
#tl-rtc-app .tl-rtc-app-left .tl-rtc-app-left-panel-cut-paste-item:hover{
background: var(--skin-cut-paste-list-item-hover-background);
}
#tl-rtc-app .tl-rtc-app-left .tl-rtc-app-left-panel-cut-paste-item-active{
background: var(--skin-cut-paste-list-item-hover-background);
}
#tl-rtc-app .tl-rtc-app-left .tl-rtc-app-left-panel-cut-paste-item-top{
background: var(--skin-cut-paste-list-item-top-background);
}
#tl-rtc-app .tl-rtc-app-left .tl-rtc-app-left-panel-cut-paste-item-img{
width: 64px;
}
#tl-rtc-app .tl-rtc-app-left .tl-rtc-app-left-panel-cut-paste-item-img img{
height: 32px;
width: 32px;
margin: 25% 20%;
-webkit-user-drag: none;
border-radius: 3px;
}
#tl-rtc-app .tl-rtc-app-left .tl-rtc-app-left-panel-cut-paste-item-content{
width: calc(100% - 64px);
}
#tl-rtc-app .tl-rtc-app-left .tl-rtc-app-left-panel-cut-paste-item-content div{
overflow: hidden;
text-overflow: ellipsis;
word-break: break-all;
white-space: nowrap;
}
#tl-rtc-app .tl-rtc-app-left .tl-rtc-app-left-panel-cut-paste-item-content-nickname{
font-weight: bold;
font-size: 13px;
margin-top: 5px;
letter-spacing: 0.5px;
}
#tl-rtc-app .tl-rtc-app-left .tl-rtc-app-left-panel-cut-paste-item-content-message{
font-size: 12px;
margin-top: 10px;
color: var(--skin-cut-paste-list-item-time-color);
letter-spacing: 0.5px;
display: flex;
flex-direction: row;
align-items: center;
}
#tl-rtc-app .tl-rtc-app-left .tl-rtc-app-left-panel-cut-paste-item-content-message svg{
height: 15px;
width: 14px;
margin-right: 3px;
margin-left: -4px;
fill: #6bd16b;
}
#tl-rtc-app .tl-rtc-app-left .tl-rtc-app-left-panel-cut-paste-item-content-message
.tl-rtc-app-left-panel-cut-paste-item-content-message-file{
display: flex;
align-items: center;
}
#tl-rtc-app .tl-rtc-app-left .tl-rtc-app-left-panel-cut-paste-item-content-message img{
width: 24px !important;
height: 24px !important;
}
#tl-rtc-app .tl-rtc-app-left .tl-rtc-app-left-panel-cut-paste-item-other{
width: 25%;
}
#tl-rtc-app .tl-rtc-app-left .tl-rtc-app-left-panel-cut-paste-item-other div{
text-align: right;
font-size: 12px;
scale: 0.9;
}
#tl-rtc-app .tl-rtc-app-left .tl-rtc-app-left-panel-cut-paste-item-other-time{
margin-top: 10px;
color: #b8b8b8;
padding-right: 8px;
}
#tl-rtc-app .tl-rtc-app-left .tl-rtc-app-left-panel-cut-paste-item-other-unread{
margin-top: 10px;
padding-right: 8px;
}
#tl-rtc-app .tl-rtc-app-left .tl-rtc-app-left-panel-cut-paste-item-other-unread div{
width: 10px !important;
line-height: 16px !important;
height: 16px !important;
border-radius: 12px;
padding-left: 2px;
padding-right: 5px;
}
/***********************************************************************************
************************************************************************************
剪贴板列表 end
************************************************************************************
************************************************************************************/

View File

@ -1,557 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" />
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>共享剪贴板</title>
<!-- 引入样式 -->
<link rel="stylesheet" href="/static/layui/css/layui.css" media="all">
<link rel="stylesheet" href="/static/css/default.min.css">
<link rel="stylesheet" href="lib-css-sdk.min.css" media="all">
<!-- 引入一些基础库 -->
<script type="text/javascript" src="/static/js/localforage.min.js"></script>
<script type="text/javascript" src="/static/js/vue.min.js"></script>
<script type="text/javascript" src="/static/js/axios.js"></script>
<script type="text/javascript" src="/static/js/highlight.min.js"></script>
<script type="text/javascript" src="/static/js/clipboard.min.js"></script>
<script type="text/javascript" src="/static/js/qrcode.min.js"></script>
<script type="text/javascript" src="/static/layui/font-ext/iconfont.js"></script>
<script type="text/javascript" src="/static/layui/layui.js"></script>
<script></script>
<script>
window.subModule = new Vue({})
</script>
<script type="text/javascript" src="lib-basic-sdk.min.js"> </script>
<style>
html {
box-sizing: border-box;
height: 100%;
width: 100%;
}
body {
height: 100%;
width: 100%;
color: var(--skin-body-color);
background: var(--skin-body-background);
overflow: hidden;
}
.icon {
width: 1em;
height: 1em;
vertical-align: -0.15em;
fill: currentColor;
overflow: hidden;
}
#tl-rtc-app-cut-paste-vistor-html {
height: 100%;
width: 100%;
}
.tl-rtc-app-right-cut-paste-no-content{
height: 50%;
width: 100%;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: center;
font-size: 20px;
color: #d5d1cc;
align-items: center;
}
</style>
</head>
<body>
<div id="tl-rtc-app-cut-paste-vistor-html" v-cloak>
<div class="tl-rtc-app-right-cut-paste-content" v-if="showPage">
<div class="tl-rtc-app-right-cut-paste-content-top">
<div class="tl-rtc-app-right-cut-paste-content-top-title" style="margin-left: 10px !important;">
{{title}}
</div>
<div class="tl-rtc-app-right-cut-paste-content-top-tool">
<div class="tl-rtc-app-right-cut-paste-content-top-tool-item"
id="cut-paste-share-type-pool"
@mouseenter="mouseEnter(event, '分享')"
@mouseleave="mouseLeave"
@click="shareCutPaste()"
>
<svg class="icon" aria-hidden="true">
<use xlink:href="#tl-rtc-app-icon-fenxiang"></use>
</svg>
</div>
<div class="tl-rtc-app-right-cut-paste-content-top-tool-item"
id="cut-paste-history-type-pool"
@mouseenter="mouseEnter(event, '历史记录')"
@mouseleave="mouseLeave"
v-show="showMode === 'textarea'"
@click="showMode = 'histroy'"
>
<svg class="icon" aria-hidden="true" style="scale: 1.2">
<use xlink:href="#tl-rtc-app-icon-zuijinliulan"></use>
</svg>
</div>
<div class="tl-rtc-app-right-cut-paste-content-top-tool-item"
id="cut-paste-textarea-type-pool"
@mouseenter="mouseEnter(event, '粘贴内容')"
@mouseleave="mouseLeave"
v-show="showMode === 'histroy'"
@click="showMode = 'textarea'"
>
<svg class="icon" aria-hidden="true" style="scale: 1.2">
<use xlink:href="#tl-rtc-app-icon-shuru"></use>
</svg>
</div>
</div>
</div>
<div class="tl-rtc-app-right-cut-paste-content-body" v-show="showMode === 'textarea'">
<div class="tl-rtc-app-right-cut-paste-content-title">
<div class="tl-rtc-app-right-cut-paste-content-limit">
{{currentCutPaste.curFormatContent?.length}} / {{maxInputContentLength}}
</div>
<div class="tl-rtc-app-right-cut-paste-content-time" v-show="currentCutPaste.inputContentSaveTime">
{{currentCutPaste.inputContentSaveTime}} 已自动保存
<svg class="icon" aria-hidden="true" style="fill:#4de04d">
<use xlink:href="#tl-rtc-app-icon-70chenggong"></use>
</svg>
</div>
</div>
<pre class="tl-rtc-app-right-cut-paste-content-body-textarea tool-code hljs html" @input="cutPastePreChange"
:contenteditable="true">
</pre>
</div>
<div class="tl-rtc-app-right-cut-paste-content-body" v-show="showMode === 'histroy'">
<div v-show="cutPasteDetailList.length === 0" class="tl-rtc-app-right-cut-paste-content-body-no-history">
暂无记录
</div>
<div v-for="(item, index) in cutPasteDetailList"
v-show="cutPasteDetailList.length > 0"
class="tl-rtc-app-right-cut-paste-content-body-textarea-view"
:id="'cut-paste-content-history-' + item.id"
@click="copyCutPasteContent(item)"
>
<div class="tl-rtc-app-right-cut-paste-content-body-time">
{{item.createTimeFormat}}
<svg class="icon" aria-hidden="true">
<use xlink:href="#tl-rtc-app-icon-leixing"></use>
</svg><small>: {{item.type}}</small>
</div>
<div class="tl-rtc-app-right-cut-paste-content-body-title">
<div class="tl-rtc-app-right-cut-paste-content-body-info">
<small>{{item.content.length}}个字符</small>
</div>
</div>
<div class="tl-rtc-app-right-cut-paste-content-body-detail" v-html="initHighlightContent(item.content)"></div>
</div>
</div>
</div>
<div class="tl-rtc-app-right-cut-paste-no-content" v-else>
{{errorMsg}}
</div>
</div>
</body>
<script>
layui.use([
'layedit', 'form', 'layer', 'laytpl', 'upload',
'dropdown', 'carousel', 'util', 'colorpicker',
'slider', 'carousel', 'element', 'laydate'
], function () {
window.layer = layui.layer;
window.form = layui.form;
window.laydate = layui.laydate;
window.$ = layui.$;
window.layedit = layui.layedit;
window.laytpl = layui.laytpl;
window.upload = layui.upload;
window.dropdown = layui.dropdown;
window.carousel = layui.carousel;
window.util = layui.util;
window.colorpicker = layui.colorpicker;
window.slider = layui.slider;
window.element = layui.element;
window.tl_rtc_app_comm.loadJS('lib-component-sdk.min.js', function () {
new Vue({
el: '#tl-rtc-app-cut-paste-vistor-html',
data: {
title: '共享剪贴板',
cutPasteId: '',
code: '',
cutPasteDetailList: [],
maxInputContentLength: 65000, // 约等于 64kb
showMode: 'textarea', // 显示界面内容,textarea, histroy
cutPasteShareHashKey: 'cut-paste-share',
lang: 'txt',
showPage: false,
errorMsg: '',
password: '',
currentCutPaste: {
id: -1,
content: '',
curInputContent: '',
curFormatContent: '',
preInputContent: '',
preFormatContent: '',
inputContentSaveTime: '',
createTimeFormat: '',
type: '',
}
},
methods: {
/**
* 统一请求包装
* @param {*} url
* @param {*} method
* @param {*} params
* @param {*} data
* @param {*} useCache
* @param {*} cacheTime
* @param {*} headers
* @param {*} delCaches
* @returns
*/
tlRequest: async function ({
url, method, params, data, headers,
useCache, cacheTime, delCaches
}) {
return await new Promise((resolve, reject) => {
window.subModule.$emit('component-api-request', {
url, method, params, data, headers,
useCache, cacheTime, delCaches,
callback: resolve
})
})
},
popSuccessMsg: function (msg) {
window.subModule.$emit('component-popup-add-toast-msg', {
type: 'success',
message: msg
});
},
popWarningMsg: function (msg) {
window.subModule.$emit('component-popup-add-toast-msg', {
type: 'warning',
message: msg
});
},
popErrorMsg: function (msg) {
window.subModule.$emit('component-popup-add-toast-msg', {
type: 'error',
message: msg
});
},
mouseEnter: function (event, title) {
tl_rtc_app_comm.mouseEnterTips({
id: event.target.id,
text: title,
position: 'bottom'
});
},
mouseLeave: function () {
tl_rtc_app_comm.mouseLeaveTips();
},
/**
* 分享剪贴板
*/
shareCutPaste: function () {
let that = this
layer.open({
type: 1,
title: '分享剪贴板',
closeBtn: 0,
skin: 'tl-rtc-app-layer-cut-paste-share',
content: `
<div>
<div id="tl-rtc-app-cut-paste-share-image"></div>
<div class="tl-rtc-app-cut-paste-share-tools">
<div class="tl-rtc-app-cut-paste-share-tools-item" id="copyCutPasteShareLink">复制链接</div>
<div class="tl-rtc-app-cut-paste-share-tools-item" id="saveCutPasteShareImage">保存图片</div>
</div>
</div>
`,
area: ['300px', '350px'],
shadeClose: true,
resize: false,
yes: function (index) {
layer.close(index)
},
success: function (layero, index) {
layero.css({
'border-radius': '6px',
})
let _that = that
const { skinBodyBackground, skinBodyColor } = window.tl_rtc_app_comm.getPropertyValues([
{ key: "skinBodyBackground", value: "skin-body-background" },
{ key: "skinBodyColor", value: "skin-body-color" },
])
let content = window.tl_rtc_app_comm.addUrlHashParams({
[that.cutPasteShareHashKey]: that.code
})
if(content.indexOf('#') !== -1){
let res = content.split('#')
content = res[0] + '/cut-paste.html#' + res[1]
}else if(content.indexOf('?') !== -1){
let res = content.split('?')
content = res[0] + '/cut-paste.html?' + res[1]
}else{
content = content + '/cut-paste.html'
}
window.tl_rtc_app_comm.getQrCode(
"tl-rtc-app-cut-paste-share-image", content, skinBodyColor, skinBodyBackground
)
document.getElementById('copyCutPasteShareLink').addEventListener('click', function () {
window.tl_rtc_app_comm.copyTxt('copyCutPasteShareLink', content)
that.popSuccessMsg('复制成功')
layer.close(index)
})
document.getElementById('saveCutPasteShareImage').addEventListener('click', function () {
window.tl_rtc_app_comm.saveQrCode('tl-rtc-app-cut-paste-share-image')
layer.close(index)
})
}
})
},
/**
* 获取剪贴板内容详情列表
*/
getCutPasteDetailList: async function () {
let that = this
const params = {
code: this.code,
typeList: [],
}
if (!window.tl_rtc_app_comm.checkRequestParams(params)) {
this.popErrorMsg("请求参数非法")
this.errorMsg = "请求异常"
return
}
const { data: cutPasteRes } = await this.tlRequest({
url: '/api/web/cut-paste-share/share-get-cut-paste-list',
method: 'post',
useCache: false,
data: params
})
let password = ''
if(cutPasteRes.code === 403 && cutPasteRes.msg === '密码错误'){
password = await new Promise(resolve => {
layer.prompt({
formType: 0,
title: "输入密码",
btn : ['确定', '取消'],
value: "",
shadeClose : true,
skin: 'layui-layer-prompt tl-rtc-app-layer-cut-paste-set-password',
maxlength : 15,
}, async function (value, index, elem) {
value = value.trim()
layer.close(index)
resolve(value)
})
})
this.password = password
await this.getCutPasteDetailListWithPassword(password)
return
}
if (!cutPasteRes.success) {
this.popErrorMsg(cutPasteRes.msg)
this.errorMsg = cutPasteRes.msg
return
}
// 处理时间
cutPasteRes.data.forEach(item => {
item.createTimeFormat = window.util.timeAgo(item.createdTime)
})
this.cutPasteDetailList = cutPasteRes.data
this.showPage = true
},
/**
* 获取剪贴板内容详情列表
*/
getCutPasteDetailListWithPassword: async function (password) {
let that = this
const params = {
code: this.code,
typeList: [],
password: password
}
if (!window.tl_rtc_app_comm.checkRequestParams(params)) {
this.popErrorMsg("请求参数非法")
this.errorMsg = "请求异常"
return
}
const { data: cutPasteRes } = await this.tlRequest({
url: '/api/web/cut-paste-share/share-get-cut-paste-list',
method: 'post',
useCache: false,
data: params
})
if (!cutPasteRes.success) {
this.popErrorMsg(cutPasteRes.msg)
this.errorMsg = cutPasteRes.msg
return
}
// 处理时间
cutPasteRes.data.forEach(item => {
item.createTimeFormat = window.util.timeAgo(item.createdTime)
})
this.cutPasteDetailList = cutPasteRes.data
this.showPage = true
},
/**
* 保存剪贴板内容
*/
autoSaveCutPasteContent: async function () {
// 获取当前输入内容
const content = this.currentCutPaste.curFormatContent
if(!content){
console.log('内容为空,不保存')
return
}
// 如果内容没有变化,则不保存
if(this.currentCutPaste.preFormatContent === content){
console.log('内容没有变化,不保存')
return
}
if(content && content.length > this.maxInputContentLength){
this.popErrorMsg("内容超出限制")
return
}
let params = {
code: this.code,
password: this.password
}
if(!window.tl_rtc_app_comm.checkRequestParams(params)){
this.popErrorMsg("请求参数非法")
return
}
params.content = content
const { data: cutPasteRes } = await this.tlRequest({
url: '/api/web/cut-paste-share/share-add-cut-paste-detail',
method: 'post',
useCache: false,
data: params
})
if (!cutPasteRes.success) {
this.popErrorMsg(cutPasteRes.msg)
return
}
// 更新
let newData = cutPasteRes.data
newData.createTimeFormat = window.util.timeAgo(newData.createdTime)
this.cutPasteDetailList.unshift(newData)
// 保存成功后,更新preInputContent
this.currentCutPaste.preInputContent = content
this.currentCutPaste.preFormatContent = this.currentCutPaste.curFormatContent
this.currentCutPaste.inputContentSaveTime = new Date().toLocaleString()
},
/**
* 复制内容
* @param {*} item
*/
copyCutPasteContent: function (item) {
let that = this;
window.tl_rtc_app_comm.copyTxt('cut-paste-content-history-' + item.id, item.content, function () {
that.popSuccessMsg('复制成功')
})
},
/**
* 初始化代码高亮
* @param {*} content
* @returns
*/
initHighlightContent: function(content){
if (typeof hljs.getLanguage(this.lang) === "undefined") {
return content
}
let transferContent = hljs.highlight(content, { language: this.lang }).value;
return '<pre><code class="hljs ' + this.lang + '">' + transferContent + '</code></pre>'
},
/**
* 编辑内容
* @param {*} event
*/
cutPastePreChange(event) {
this.currentCutPaste.curInputContent = event.target.innerText;
this.currentCutPaste.curFormatContent = hljs.highlight(
this.lang, this.currentCutPaste.curInputContent
).value;
},
},
mounted: async function () {
// 获取剪贴板code
this.code = window.tl_rtc_app_comm.getRequestHashArgs(this.cutPasteShareHashKey)
if(!this.code){
this.popErrorMsg('剪贴板为空')
return
}
// 获取剪贴板内容详情列表
await this.getCutPasteDetailList()
// 定时,每隔5秒保存一次输入内容
setInterval(async () => {
await this.autoSaveCutPasteContent()
}, 1000 * 5);
},
})
});
});
</script>
</html>

View File

@ -99,20 +99,6 @@
v-cloak>
</tl_rtc_app_module_contact>
<tl_rtc_app_module_cut_paste
@right-module-change="rightModuleChange"
@left-module-change="leftModuleChange"
v-show="leftModule == 'cut_paste'"
:socket="socket"
:is-mobile="isMobile"
:user="user"
:company="company"
:right-module="rightModule"
:left-module="leftModule"
v-cloak>
</tl_rtc_app_module_cut_paste>
<tl_rtc_app_module_setting
@right-module-change="rightModuleChange"
@left-module-change="leftModuleChange"
@ -166,19 +152,6 @@
v-cloak>
</tl_rtc_app_module_contact_content>
<tl_rtc_app_module_cut_paste_content
@right-module-change="rightModuleChange"
@left-module-change="leftModuleChange"
v-show="leftModule == 'cut_paste' && rightModule == 'content'"
:socket="socket"
:is-mobile="isMobile"
:user="user"
:company="company"
:right-module="rightModule"
:left-module="leftModule"
v-cloak>
</tl_rtc_app_module_cut_paste_content>
<tl_rtc_app_module_setting_content
@right-module-change="rightModuleChange"
@left-module-change="leftModuleChange"

View File

@ -279,9 +279,13 @@
if (window.navigator.mediaDevices && window.navigator.mediaDevices.getUserMedia) {
media = window.navigator.mediaDevices.getUserMedia(defaultConstraints);
} else if (window.navigator.mozGetUserMedia) {
media = navigator.mozGetUserMedia(defaultConstraints);
media = new Promise((resolve, reject) => {
window.navigator.mozGetUserMedia(defaultConstraints, resolve, reject);
});
} else if (window.navigator.getUserMedia) {
media = window.navigator.getUserMedia(defaultConstraints)
media = new Promise((resolve, reject) => {
window.navigator.getUserMedia(defaultConstraints, resolve, reject);
});
} else if (window.navigator.webkitGetUserMedia) {
media = new Promise((resolve, reject) => {
window.navigator.webkitGetUserMedia(defaultConstraints, (res) => {
@ -290,6 +294,8 @@
reject(err)
});
})
} else {
media = Promise.reject(new Error('UNSUPPORTED_MEDIA_DEVICES'));
}
return media
},

View File

@ -8,6 +8,7 @@ const tl_rtc_app_socket = new Vue({
ANSWER: 'answer', // rtc-answer
CANDIDATE: 'candidate', // rtc-candidate
CHANNEL_CHAT: 'channelChat', // 频道聊天
CHANNEL_READ_SYNC: 'channelReadSync', // 频道已读同步
CHANNEL_VIDEO_CALL: 'channelVideoCall', // 频道视频通话
CHANNEL_FILE: 'channelFile', // 文件发送
CONTACT_APPLY: 'contactApply', // 好友申请
@ -26,6 +27,7 @@ const tl_rtc_app_socket = new Vue({
CANDIDATE: 'candidate', // rtc-candidate
CHANNEL_VIDEO_CALL: 'channelVideoCall', // 频道视频通话
CHANNEL_CHAT: 'channelChat', // 频道聊天
CHANNEL_READ_SYNC: 'channelReadSync', // 频道已读同步
CONTACT_APPLY: 'contactApply', // 好友申请
CONTACT_APPLY_PASS: 'contactApplyPass', // 通过好友申请
CONTACT_APPLY_REJECT: 'contactApplyReject', // 拒绝好友申请
@ -60,6 +62,7 @@ const tl_rtc_app_socket = new Vue({
this.socket.on(this.ON_EVENT.ANSWER, this.answerSocketHandler)
this.socket.on(this.ON_EVENT.CANDIDATE, this.candidateSocketHandler)
this.socket.on(this.ON_EVENT.CHANNEL_CHAT, this.channelChatSocketHandler)
this.socket.on(this.ON_EVENT.CHANNEL_READ_SYNC, this.channelReadSyncSocketHandler)
this.socket.on(this.ON_EVENT.CHANNEL_FILE, this.channelFileSocketHandler)
this.socket.on(this.ON_EVENT.COUNT, this.countSocketHandler)
this.socket.on(this.ON_EVENT.CONTACT_APPLY, this.contactApplySocketHandler)
@ -145,6 +148,16 @@ const tl_rtc_app_socket = new Vue({
data: data
})
},
/**
* 频道已读同步消息处理
* @param {*} data
*/
channelReadSyncSocketHandler: function(data){
this.emitSubModuleEvent({
event: 'sub-module-channel-list-read-sync-socket',
data: data
})
},
/**
* 视频通话socket消息处理
* @param {*} data

View File

@ -171,9 +171,13 @@ const tl_rtc_app_video = new Vue({
if (window.navigator.mediaDevices && window.navigator.mediaDevices.getUserMedia) {
media = window.navigator.mediaDevices.getUserMedia(defaultConstraints);
} else if (window.navigator.mozGetUserMedia) {
media = navigator.mozGetUserMedia(defaultConstraints);
media = new Promise((resolve, reject) => {
window.navigator.mozGetUserMedia(defaultConstraints, resolve, reject);
});
} else if (window.navigator.getUserMedia) {
media = window.navigator.getUserMedia(defaultConstraints)
media = new Promise((resolve, reject) => {
window.navigator.getUserMedia(defaultConstraints, resolve, reject);
});
} else if (window.navigator.webkitGetUserMedia) {
media = new Promise((resolve, reject) => {
window.navigator.webkitGetUserMedia(defaultConstraints, (res) => {
@ -182,9 +186,28 @@ const tl_rtc_app_video = new Vue({
reject(err)
});
})
} else {
media = Promise.reject(new Error('UNSUPPORTED_MEDIA_DEVICES'));
}
return media
},
/**
* 检查是否存在可用麦克风输入设备
* @returns {Promise<boolean>}
*/
checkAudioInputAvailable: async function(){
if(!(navigator.mediaDevices && navigator.mediaDevices.enumerateDevices)){
return true
}
try{
const devices = await navigator.mediaDevices.enumerateDevices()
return devices.some(device => device.kind === 'audioinput')
}catch(e){
// 枚举失败时交由 getUserMedia 的真实错误处理
return true
}
},
/**
* 打开弹窗
*/
@ -294,9 +317,30 @@ const tl_rtc_app_video = new Vue({
if (this.stream == null) {
try {
if(this.needAudio){
const hasAudioInput = await this.checkAudioInputAvailable()
if(!hasAudioInput){
this.popErrorMsg('未检测到可用麦克风设备,请连接并启用麦克风后重试')
this.stopChannelVideoCall(true)
return
}
}
this.stream = await this.getMediaPlay();
} catch (error) {
console.log(error)
const errorName = error && error.name ? error.name : '';
if (error && error.message === 'UNSUPPORTED_MEDIA_DEVICES') {
this.popErrorMsg('当前浏览器不支持麦克风采集,请使用最新版 Chrome 并通过 HTTPS 访问');
} else if (errorName === 'NotAllowedError' || errorName === 'PermissionDeniedError') {
this.popErrorMsg('麦克风权限被拒绝,请在浏览器站点权限中允许麦克风后重试');
} else if (errorName === 'NotFoundError' || errorName === 'DevicesNotFoundError') {
this.popErrorMsg('未检测到可用麦克风设备,请检查设备连接');
} else if (errorName === 'NotReadableError' || errorName === 'TrackStartError') {
this.popErrorMsg('麦克风被其他应用占用,请关闭占用后重试');
} else if (errorName === 'SecurityError') {
this.popErrorMsg('当前环境不允许访问麦克风,请使用 HTTPS 或 localhost 访问');
}
}
}

View File

@ -156,7 +156,7 @@ const tl_rtc_app_module_channel_list = {
* @param {*} data
* @returns
*/
channelChatSocketHandler: function(data){
channelChatSocketHandler: async function(data){
const { channel, messageInfo } = data
if(!channel || !messageInfo){
data.callback && data.callback()
@ -165,7 +165,7 @@ const tl_rtc_app_module_channel_list = {
// console.log('channelChatSocketHandler', data)
this.addChannelMessageHandler({
await this.addChannelMessageHandler({
channelId: channel, messageInfo
})
@ -176,12 +176,18 @@ const tl_rtc_app_module_channel_list = {
* @param {*} channelId
* @param {*} messageInfo
*/
addChannelMessageHandler: function({
addChannelMessageHandler: async function({
channelId, messageInfo
}){
if(!this.channelsMessageMap[channelId]){
this.channelsMessageMap[channelId] = []
}
// 如果该群不在列表中,先从后端拉取并插入列表
const existInList = this.channels.find(item => item.channelId === channelId)
if(!existInList){
await this.getChannelInfo(channelId)
}
this.updateChannelLatestMessage({
channelId: channelId, extra: messageInfo
@ -413,6 +419,14 @@ const tl_rtc_app_module_channel_list = {
return
}
this.emitSubModuleEvent({
event: 'component-socket-send-socket',
data: {
event: 'channelReadSync',
data: params,
}
})
// 更新侧边栏未读消息数量
await this.emitSubModuleEvent({
event: 'sub-module-sidebar-unread-update',
@ -445,6 +459,73 @@ const tl_rtc_app_module_channel_list = {
message.hasRead = true
}
})
this.refreshChannelUnreadCount()
},
/**
* 同步其他终端的已读状态
* @param {*} data
*/
channelReadSyncSocketHandler: function(data){
const {
channelId, latestChatReadId = 0, latestMediaReadId = 0, latestFileReadId = 0
} = data || {}
if(!channelId){
return
}
const messageList = this.channelsMessageMap[channelId] || []
if(messageList.length === 0){
return
}
messageList.forEach(message => {
const messageType = message.type
let latestReadId = 0
if(['system', 'friend', 'group'].includes(messageType)){
latestReadId = latestChatReadId
}else if(['audio', 'video'].includes(messageType)){
latestReadId = latestMediaReadId
}else if(['p2p', 'offline'].includes(messageType)){
latestReadId = latestFileReadId
}
if(latestReadId && message.id <= latestReadId){
message.hasRead = true
}
})
this.refreshChannelUnreadCount()
},
/**
* 重算频道和侧边栏未读数量
*/
refreshChannelUnreadCount: function(){
let allUnreadCount = 0
this.channels.forEach(channelInfo => {
const messageList = this.channelsMessageMap[channelInfo.channelId] || []
let channelChatUnReadCount = 0
messageList.forEach(message => {
if(!message.hasRead){
channelChatUnReadCount += 1
}
})
channelInfo.channelChatUnReadCount = channelChatUnReadCount
allUnreadCount += channelChatUnReadCount
})
this.emitSubModuleEvent({
event: 'sub-module-sidebar-unread-update',
data: {
name: 'channel', type: 'all', count: allUnreadCount
}
})
this.$forceUpdate()
},
/**
* 更新频道最新消息
@ -1279,6 +1360,7 @@ const tl_rtc_app_module_channel_list = {
// 监听收到socket聊天消息
window.subModule.$on('sub-module-channel-list-chat-socket', this.channelChatSocketHandler)
window.subModule.$on('sub-module-channel-list-read-sync-socket', this.channelReadSyncSocketHandler)
// 移动端返回到频道列表
window.subModule.$on('sub-module-channel-list-go-back', this.channelListGoBack)

View File

@ -76,6 +76,7 @@ const tl_rtc_app_module_contact_content = {
isSelf: '', // 是否是自己
remark: '', // 申请好友信息
friendType: '', // 好友类型
isSameSubject: false, // 是否同主体成员(无需申请直接聊天)
},
applyUserData: { // 申请用户数据
id: '', // 好友申请记录id
@ -154,6 +155,7 @@ const tl_rtc_app_module_contact_content = {
moduleUserSearchDataChange: function({
userId, username, userAvatar, userMobile, userEmail, isSelf,
userCompanyName, isFriend, remark, createTimeFormat, friendType, channelId,
isSameSubject,
callback
}){
this.contentType = 'searchUser'
@ -170,7 +172,8 @@ const tl_rtc_app_module_contact_content = {
remark: remark,
createTimeFormat: createTimeFormat,
friendType: friendType,
channelId: channelId
channelId: channelId,
isSameSubject: !!isSameSubject,
}
this.$emit('right-module-change', 'content')
@ -417,6 +420,54 @@ const tl_rtc_app_module_contact_content = {
return false
});
},
/**
* 同主体静默建立好友关系并直接开始聊天
*/
silentAddSubjectFriend: async function(userInfo){
if(!userInfo || !userInfo.userId){
this.popWarningMsg("用户不存在")
return
}
// 已是好友,直接跳聊天
if(userInfo.channelId){
this.sendMessage(userInfo)
return
}
const params = { targetUserId: userInfo.userId }
if(!window.tl_rtc_app_comm.checkRequestParams(params)){
this.popErrorMsg("请求参数非法")
return
}
const { data: res } = await this.tlRequest({
url: '/api/web/user-friend/silent-add-subject-friend',
method: 'post',
useCache: false,
data: params,
})
if(!res.success){
this.popErrorMsg(res.msg || "建立好友关系失败")
return
}
const channelId = res.data && res.data.channelId
if(!channelId){
this.popErrorMsg("建立好友关系失败,频道不存在")
return
}
// 更新搜索面板数据,标记已是好友,方便后续操作
this.searchUserData = Object.assign({}, this.searchUserData, {
isFriend: true,
channelId: channelId
})
// 直接打开聊天
this.sendMessage(Object.assign({}, userInfo, { channelId }))
},
/**
* 通过好友申请
*/
@ -534,6 +585,12 @@ const tl_rtc_app_module_contact_content = {
sendMessage: async function({
channelId, callback
}){
if(!channelId){
this.popWarningMsg("暂未与该用户建立好友关系,请先添加好友")
callback && callback()
return
}
this.$emit('left-module-change', 'channel')
await this.emitSubModuleEvent({
@ -871,6 +928,7 @@ const tl_rtc_app_module_contact_content = {
:search-user-data="searchUserData"
:is-mobile="propsIsMobile"
@add-user-friend="addUserFriend"
@silent-chat="silentAddSubjectFriend"
@send-message="sendMessage"
@send-video="sendVideo"
@send-audio="sendAudio"

View File

@ -79,6 +79,12 @@ const tl_rtc_app_module_contact_content_search_user = {
addUserFriend: function(){
this.$emit('add-user-friend')
},
/**
* 同主体直接开始聊天
*/
silentChat: function(){
this.$emit('silent-chat', this.propsSearchUserData)
},
/**
* 发送信息
*/
@ -171,6 +177,11 @@ const tl_rtc_app_module_contact_content_search_user = {
<div>发起语音</div>
</div>
</div>
<div class="tl-rtc-app-right-contact-content-tool-btn" v-else-if="!propsSearchUserData.isSelf && propsSearchUserData.isSameSubject">
<button class="layui-btn" @click="silentChat">
<b>开始聊天</b>
</button>
</div>
<div class="tl-rtc-app-right-contact-content-tool-btn" v-else-if="!propsSearchUserData.isSelf">
<button class="layui-btn" @click="addUserFriend">
<b>添加好友</b>

View File

@ -29,6 +29,8 @@ const tl_rtc_app_module_contact_list = {
applyGroupList: [],
// 群组列表
groupList: [],
// 主体分组用户列表
subjectGroupList: [],
// 搜索关键字
searchKey: '',
// 默认选择 '全部' 标签
@ -69,6 +71,19 @@ const tl_rtc_app_module_contact_list = {
return values.indexOf(this.searchKey) > -1
})
},
filterSubjectGroupList: function(){
if(this.searchKey === '' || this.searchKey.trim() === ''){
return this.subjectGroupList
}
return this.subjectGroupList.map(group => {
return {
...group,
members: group.members.filter(item => {
return item.username && item.username.indexOf(this.searchKey) > -1
})
}
}).filter(group => group.members.length > 0)
},
filterApplyContactList: function(){
if(this.searchKey === '' || this.searchKey.trim() === ''){
return this.applyContactList
@ -681,6 +696,55 @@ const tl_rtc_app_module_contact_list = {
showRightModule: true,
}
})
},
/**
* 打开主体成员信息(复用搜索用户面板,支持加好友)
* @param {*} data
*/
openSubjectMemberInfo: function(data){
this.$emit('right-module-change', 'content')
this.emitSubModuleEvent({
event: 'sub-module-contact-content-user-search-data-change',
data: {
userId: data.userId,
username: data.username,
userAvatar: data.userAvatar,
userMobile: data.userMobile || '',
userEmail: data.userEmail || '',
userCompanyName: data.userCompanyName || '',
isFriend: !!data.channelId,
isSelf: false,
channelId: data.channelId || '',
remark: '',
friendType: data.channelId ? '普通好友' : '',
isSameSubject: true,
}
})
this.emitSubModuleEvent({
event: 'sub-module-core-change-module-show',
data: { showRightModule: true }
})
},
/**
* 获取主体分组用户列表
*/
getSubjectUserList: async function(){
const { data: res } = await this.tlRequest({
url: '/api/web/user/get-subject-user-list',
method: 'get',
useCache: true,
cacheTime: 30 * 1000
})
if(!res.success){
return
}
this.subjectGroupList = res.data
this.$forceUpdate()
this.$nextTick(function(){
window.element.init()
})
}
},
mounted: async function(){
@ -703,6 +767,9 @@ const tl_rtc_app_module_contact_list = {
// 获取好友标签列表
await this.getFriendTagList()
// 获取主体分组用户列表
await this.getSubjectUserList()
window.element.on('collapse()', function(data){});
},
created(){
@ -845,6 +912,31 @@ const tl_rtc_app_module_contact_list = {
</div>
</div>
</div>
<template v-for="group in filterSubjectGroupList">
<div class="layui-colla-item" :key="group.subjectId">
<h2 class="layui-colla-title">{{group.subjectName}} ({{group.members.length}})</h2>
<div class="layui-colla-content">
<div class="tl-rtc-app-left-panel-contact-item"
v-for="item in group.members"
:key="item.userId"
@click="openSubjectMemberInfo(item)"
>
<div class="tl-rtc-app-left-panel-contact-item-img">
<img :src="item.userAvatar" alt="">
</div>
<div class="tl-rtc-app-left-panel-contact-item-content">
<div class="tl-rtc-app-left-panel-contact-item-content-nickname">
{{item.username}}
</div>
<div class="tl-rtc-app-left-panel-contact-item-content-state">
<span v-if="item.loginStatus === 0">[离线]</span>
<span v-else>[在线]</span>
</div>
</div>
</div>
</div>
</div>
</template>
</div>
</div>
`,

View File

@ -1,688 +0,0 @@
const tl_rtc_app_module_cut_paste_content = {
props : {
isMobile: {
type: Boolean,
default: false
},
otherSetting: {
type: Object,
default: function(){
return {}
}
},
user: {
type: Object,
default: function(){
return {}
}
},
socket: {
type: Object,
default: function(){
return {}
}
},
leftModule: {
type: String,
default: ''
},
rightModule: {
type: String,
default: ''
}
},
computed: {
propsUser(){
return this.user;
},
propsIsMobile(){
return this.isMobile;
},
propsOtherSetting(){
return this.otherSetting;
},
propsSocket(){
return this.socket;
},
propsLeftModule(){
return this.leftModule;
},
propsRightModule(){
return this.rightModule;
},
},
watch: {
leftModule: function (val) {
},
rightModule: function (val) {
}
},
data : function(){
return {
title: '',
cutPasteId: '',
code: '',
status: '',
cutPasteDetailList: [],
maxInputContentLength: 65000, // 约等于 64kb
showMode: 'textarea', // 显示界面内容,textarea, histroy
cutPasteShareHashKey: 'cut-paste-share',
lang: 'txt',
currentCutPaste: {
id: -1,
content: '',
curInputContent: '',
curFormatContent: '',
preInputContent: '',
preFormatContent: '',
inputContentSaveTime: '',
createTimeFormat: '',
type: '',
}
}
},
methods: {
/**
* 事件触发,向上传递
* @param {*} event
*/
leftModuleChange: function(event){
this.$emit('left-module-change', event)
},
/**
* 事件触发,向上传递
* @param {*} event
*/
rightModuleChange: function(event){
this.$emit('right-module-change', event)
},
mouseEnter: function(event, title){
tl_rtc_app_comm.mouseEnterTips({
id: event.target.id,
text: title,
position: 'bottom'
});
},
mouseLeave: function(){
tl_rtc_app_comm.mouseLeaveTips();
},
/**
* 回退
*/
goBack: function(){
this.emitSubModuleEvent({
event: 'sub-module-core-change-module-show',
data: {
showRightModule: false,
}
})
},
/**
* 分享剪贴板
*/
shareCutPaste: function(){
let that = this
layer.open({
type: 1,
title: '分享剪贴板',
closeBtn: 0,
skin: 'tl-rtc-app-layer-cut-paste-share',
content: `
<div>
<div id="tl-rtc-app-cut-paste-share-image"></div>
<div class="tl-rtc-app-cut-paste-share-tools">
<div class="tl-rtc-app-cut-paste-share-tools-item" id="copyCutPasteShareLink">复制链接</div>
<div class="tl-rtc-app-cut-paste-share-tools-item" id="saveCutPasteShareImage">保存图片</div>
</div>
</div>
`,
area: ['300px', '350px'],
shadeClose: true,
resize: false,
yes: function (index) {
layer.close(index)
},
success: function (layero, index) {
layero.css({
'border-radius': '6px',
})
let _that = that
const { skinBodyBackground, skinBodyColor } = window.tl_rtc_app_comm.getPropertyValues([
{ key: "skinBodyBackground", value: "skin-body-background" },
{ key: "skinBodyColor", value: "skin-body-color" },
])
let content = window.tl_rtc_app_comm.addUrlHashParams({
[that.cutPasteShareHashKey]: that.code
})
if(content.indexOf('#') !== -1){
let res = content.split('#')
content = res[0] + '/cut-paste.html#' + res[1]
}else if(content.indexOf('?') !== -1){
let res = content.split('?')
content = res[0] + '/cut-paste.html?' + res[1]
}else{
content = content + '/cut-paste.html'
}
window.tl_rtc_app_comm.getQrCode(
"tl-rtc-app-cut-paste-share-image", content, skinBodyColor, skinBodyBackground
)
document.getElementById('copyCutPasteShareLink').addEventListener('click', function(){
window.tl_rtc_app_comm.copyTxt('copyCutPasteShareLink', content)
that.popSuccessMsg('复制成功')
layer.close(index)
})
document.getElementById('saveCutPasteShareImage').addEventListener('click', function(){
window.tl_rtc_app_comm.saveQrCode('tl-rtc-app-cut-paste-share-image')
layer.close(index)
})
}
})
},
/**
* 打开剪贴板内容
*/
openCutPasteContent: async function(data){
if('title' in data){
this.title = data.title;
}
if('cutPasteId' in data){
this.cutPasteId = data.cutPasteId;
}
if('code'in data){
this.code = data.code;
}
if('status' in data){
this.status = data.status;
}
await this.getCutPasteDetailList()
data.callback && data.callback()
},
/**
* 获取剪贴板内容详情列表
*/
getCutPasteDetailList: async function(){
let that = this
const params = {
cutPasteId: this.cutPasteId,
typeList: [],
}
if(!window.tl_rtc_app_comm.checkRequestParams(params)){
this.popErrorMsg("请求参数非法")
return
}
const { data: cutPasteRes } = await this.tlRequest({
url: '/api/web/cut-paste/get-cut-paste-detail-list',
method: 'post',
useCache: false,
data: params
})
if(!cutPasteRes.success){
this.popErrorMsg(cutPasteRes.msg)
return
}
// 处理时间
cutPasteRes.data.forEach(item => {
item.createTimeFormat = window.util.timeAgo(item.createdTime)
})
this.cutPasteDetailList = cutPasteRes.data
},
/**
* 保存剪贴板内容
*/
autoSaveCutPasteContent: async function(){
// 获取当前输入内容
const content = this.currentCutPaste.curFormatContent
if(!content){
// console.log('内容为空,不保存')
return
}
// 如果内容没有变化,则不保存
if(this.currentCutPaste.preFormatContent === content){
// console.log('内容没有变化,不保存')
return
}
if(content && content.length > this.maxInputContentLength){
this.popErrorMsg("内容超出限制")
return
}
let params = {
cutPasteId: this.cutPasteId,
}
if(!window.tl_rtc_app_comm.checkRequestParams(params)){
this.popErrorMsg("请求参数非法")
return
}
params.content = content
const { data: cutPasteRes } = await this.tlRequest({
url: '/api/web/cut-paste/add-cut-paste-detail',
method: 'post',
useCache: false,
data: params
})
if(!cutPasteRes.success){
this.popErrorMsg(cutPasteRes.msg)
return
}
// 更新
let newData = cutPasteRes.data
newData.createTimeFormat = window.util.timeAgo(newData.createdTime)
this.cutPasteDetailList.unshift(newData)
// 保存成功后,更新preInputContent
this.currentCutPaste.preInputContent = content
this.currentCutPaste.preFormatContent = this.currentCutPaste.curFormatContent
this.currentCutPaste.inputContentSaveTime = new Date().toLocaleString()
},
/**
* 删除剪贴板内容
* @param {*} item
*/
deleteCutPasteContent: async function(item, event){
event.stopPropagation()
let acceptOrReject = await new Promise(resolve => {
layer.confirm('确认删除当前内容吗?', {
shadeClose: 1
}, function (index) {
resolve(true)
layer.close(index)
}, function (index) {
resolve(false)
});
})
if(!acceptOrReject){
return
}
const params = {
cutPasteDetailId: item.id
}
if(!window.tl_rtc_app_comm.checkRequestParams(params)){
this.popErrorMsg("请求参数非法")
return
}
const { data: cutPasteRes } = await this.tlRequest({
url: '/api/web/cut-paste/delete-cut-paste-detail',
method: 'post',
useCache: false,
data: params
})
if(!cutPasteRes.success){
this.popErrorMsg(cutPasteRes.msg)
return
}
this.cutPasteDetailList = this.cutPasteDetailList.filter(i => i.id !== item.id)
this.popSuccessMsg(cutPasteRes.msg)
},
/**
* 开启剪贴板
*/
openCutPaste: async function(){
const params = {
cutPasteId: this.cutPasteId
}
if(!window.tl_rtc_app_comm.checkRequestParams(params)){
this.popErrorMsg("请求参数非法")
return
}
const { data: cutPasteRes } = await this.tlRequest({
url: '/api/web/cut-paste/open-cut-paste',
method: 'post',
useCache: false,
data: params
})
if(!cutPasteRes.success){
this.popErrorMsg(cutPasteRes.msg)
return
}
// 更新状态
this.status = '使用中'
this.popSuccessMsg(cutPasteRes.msg)
},
/**
* 关闭剪贴板
*/
closeCutPaste: async function(){
let acceptOrReject = await new Promise(resolve => {
layer.confirm('关闭后,他人将无法看到剪贴板内容', {
shadeClose: 1
}, function (index) {
resolve(true)
layer.close(index)
}, function (index) {
resolve(false)
});
})
if(!acceptOrReject){
return
}
const params = {
cutPasteId: this.cutPasteId
}
if(!window.tl_rtc_app_comm.checkRequestParams(params)){
this.popErrorMsg("请求参数非法")
return
}
const { data: cutPasteRes } = await this.tlRequest({
url: '/api/web/cut-paste/close-cut-paste',
method: 'post',
useCache: false,
data: params
})
if(!cutPasteRes.success){
this.popErrorMsg(cutPasteRes.msg)
return
}
// 更新状态
this.status = '已关闭'
this.popSuccessMsg(cutPasteRes.msg)
},
/**
* 复制内容
* @param {*} item
*/
copyCutPasteContent: function(item){
let that = this;
window.tl_rtc_app_comm.copyTxt('cut-paste-content-history-' + item.id, item.content, function(){
that.popSuccessMsg('复制成功')
})
},
/**
* 初始化代码高亮
* @param {*} content
* @returns
*/
initHighlightContent: function(content){
if (typeof hljs.getLanguage(this.lang) === "undefined") {
return content
}
let transferContent = hljs.highlight(content, { language: this.lang }).value;
return '<pre><code class="hljs ' + this.lang + '">' + transferContent + '</code></pre>'
},
/**
* 编辑内容
* @param {*} event
*/
cutPastePreChange(event) {
// 直接获取当前光标位置
const selection = window.getSelection();
const range = selection.getRangeAt(0);
const offset = range.startOffset;
const node = range.startContainer;
// 更新内容
this.currentCutPaste.curInputContent = event.target.innerText;
this.currentCutPaste.curFormatContent = this.currentCutPaste.curInputContent;
// 在下一个 tick 恢复光标位置
this.$nextTick(() => {
try {
const newRange = document.createRange();
newRange.setStart(node, offset);
newRange.setEnd(node, offset);
selection.removeAllRanges();
selection.addRange(newRange);
} catch(e) {
console.warn('Failed to restore cursor position:', e);
}
});
},
/**
* 设置剪贴板密码
*/
setCutPastePassword: async function(){
let that = this
layer.prompt({
formType: 0,
title: "设置剪贴板密码",
btn : ['确定', '取消'],
value: "",
shadeClose : true,
skin: 'layui-layer-prompt tl-rtc-app-layer-cut-paste-set-password',
maxlength : 15,
}, async function (value, index, elem) {
value = value.trim()
if(value.length > 20){
that.popWarningMsg("密码长度不能超过20位")
return false;
}
const params = {
cutPasteId: that.cutPasteId,
password: value
}
if(!window.tl_rtc_app_comm.checkRequestParams(params)){
that.popErrorMsg("请求参数非法")
return
}
const { data: updateRes } = await that.tlRequest({
url: '/api/web/cut-paste/update-cut-paste-password',
method: 'post',
useCache: false,
data: params,
})
if(!updateRes.success){
that.popErrorMsg(updateRes.msg)
layer.close(index)
return
}
that.popSuccessMsg(updateRes.msg)
layer.close(index)
return false
});
},
// 添加光标位置保存和恢复方法
saveCaretPosition(element) {
const selection = window.getSelection();
if (selection.rangeCount > 0) {
return selection.getRangeAt(0);
}
return null;
},
//
restoreCaretPosition(element, range) {
if (range) {
const selection = window.getSelection();
selection.removeAllRanges();
selection.addRange(range);
}
},
},
mounted: async function() {
let that = this
// 定时,每隔5秒保存一次输入内容
setInterval(async () => {
if(that.propsLeftModule !== 'cut_paste' || that.propsRightModule !== 'content'){
return
}
await this.autoSaveCutPasteContent()
}, 1000 * 5);
},
created(){
// 监听打开剪贴板内容
window.subModule.$on('sub-module-cut-paste-content-open', this.openCutPasteContent);
},
template: `
<div class="tl-rtc-app-right-cut-paste-content">
<div class="tl-rtc-app-right-cut-paste-content-top">
<svg class="icon goBack" aria-hidden="true" @click="goBack" style='top: 17px;left: 17px;' v-show='propsIsMobile'>
<use xlink:href="#tl-rtc-app-icon-xiangzuo1"></use>
</svg>
<div class="tl-rtc-app-right-cut-paste-content-top-title">
{{title}}
</div>
<div class="tl-rtc-app-right-cut-paste-content-top-tool">
<div class="tl-rtc-app-right-cut-paste-content-top-tool-item"
id="cut-paste-password-type-pool"
@mouseenter="mouseEnter(event, '设置密码')"
@mouseleave="mouseLeave"
@click="setCutPastePassword"
>
<svg class="icon" aria-hidden="true">
<use xlink:href="#tl-rtc-app-icon-mima"></use>
</svg>
</div>
<div class="tl-rtc-app-right-cut-paste-content-top-tool-item"
id="cut-paste-share-type-pool"
@mouseenter="mouseEnter(event, '分享')"
@mouseleave="mouseLeave"
@click="shareCutPaste()"
>
<svg class="icon" aria-hidden="true">
<use xlink:href="#tl-rtc-app-icon-fenxiang"></use>
</svg>
</div>
<div class="tl-rtc-app-right-cut-paste-content-top-tool-item"
id="cut-paste-history-type-pool"
@mouseenter="mouseEnter(event, '历史记录')"
@mouseleave="mouseLeave"
v-show="showMode === 'textarea'"
@click="showMode = 'histroy'"
>
<svg class="icon" aria-hidden="true" style="scale: 1.2">
<use xlink:href="#tl-rtc-app-icon-zuijinliulan"></use>
</svg>
</div>
<div class="tl-rtc-app-right-cut-paste-content-top-tool-item"
id="cut-paste-textarea-type-pool"
@mouseenter="mouseEnter(event, '粘贴内容')"
@mouseleave="mouseLeave"
v-show="showMode === 'histroy'"
@click="showMode = 'textarea'"
>
<svg class="icon" aria-hidden="true" style="scale: 1.2">
<use xlink:href="#tl-rtc-app-icon-shuru"></use>
</svg>
</div>
<div class="tl-rtc-app-right-cut-paste-content-top-tool-item"
id="cut-paste-close-type-pool"
@mouseenter="mouseEnter(event, '点击关闭')"
@mouseleave="mouseLeave"
v-show="status === '使用中'"
@click="closeCutPaste"
>
<svg class="icon" aria-hidden="true" style="scale: 1.2;fill:red;">
<use xlink:href="#tl-rtc-app-icon-guanbi"></use>
</svg>
</div>
<div class="tl-rtc-app-right-cut-paste-content-top-tool-item"
id="cut-paste-open-type-pool"
@mouseenter="mouseEnter(event, '点击开启')"
@mouseleave="mouseLeave"
v-show="status === '已关闭'"
@click="openCutPaste"
>
<svg class="icon" aria-hidden="true" style="scale: 1.1">
<use xlink:href="#tl-rtc-app-icon-kaishi1"></use>
</svg>
</div>
</div>
</div>
<div class="tl-rtc-app-right-cut-paste-content-body" v-show="showMode === 'textarea'">
<div class="tl-rtc-app-right-cut-paste-content-title">
<div class="tl-rtc-app-right-cut-paste-content-limit">
{{currentCutPaste.curFormatContent?.length}} / {{maxInputContentLength}}
</div>
<div class="tl-rtc-app-right-cut-paste-content-time" v-show="currentCutPaste.inputContentSaveTime">
{{currentCutPaste.inputContentSaveTime}} 已自动保存
<svg class="icon" aria-hidden="true" style="fill:#4de04d">
<use xlink:href="#tl-rtc-app-icon-70chenggong"></use>
</svg>
</div>
</div>
<pre class="tl-rtc-app-right-cut-paste-content-body-textarea tool-code hljs html"
@input="cutPastePreChange"
contenteditable="true"
ref="editor">
</pre>
</div>
<div class="tl-rtc-app-right-cut-paste-content-body" v-show="showMode === 'histroy'">
<div v-show="cutPasteDetailList.length === 0" class="tl-rtc-app-right-cut-paste-content-body-no-history">
暂无记录
</div>
<div v-for="(item, index) in cutPasteDetailList"
v-show="cutPasteDetailList.length > 0"
class="tl-rtc-app-right-cut-paste-content-body-textarea-view"
:id="'cut-paste-content-history-' + item.id"
@click="copyCutPasteContent(item)"
>
<div class="tl-rtc-app-right-cut-paste-content-body-time">
{{item.createTimeFormat}}
<svg class="icon" aria-hidden="true">
<use xlink:href="#tl-rtc-app-icon-leixing"></use>
</svg><small>: {{item.type}}</small>
</div>
<div class="tl-rtc-app-right-cut-paste-content-body-title">
<div class="tl-rtc-app-right-cut-paste-content-body-info">
<small>{{item.content.length}}个字符</small>
</div>
<div class="tl-rtc-app-right-cut-paste-content-body-tools">
<svg class="icon" aria-hidden="true" style="fill:#744343;" @click="deleteCutPasteContent(item, $event)">
<use xlink:href="#tl-rtc-app-icon-huishouzhan"></use>
</svg>
</div>
</div>
<div class="tl-rtc-app-right-cut-paste-content-body-detail" v-html="initHighlightContent(item.content)"></div>
</div>
</div>
</div>
`,
}
window.tl_rtc_app_module_cut_paste_content = tl_rtc_app_module_cut_paste_content

View File

@ -1,124 +0,0 @@
const tl_rtc_app_module_cut_paste = {
props: {
socket: {
type: Object,
default: null
},
company:{
type: Object,
default: function(){
return {
name : ''
}
}
},
user: {
type: Object,
default: function(){
return {
userId: '', // 用户id
username: '', // 用户名称
}
}
},
isMobile: {
type: Boolean,
default: false
},
leftModule: {
type: String,
default: ''
},
rightModule: {
type: String,
default: ''
}
},
computed:{
propsSocket(){
return this.socket;
},
propsUser(){
return this.user;
},
propsCompany(){
return this.company;
},
propsIsMobile(){
return this.isMobile;
},
propsLeftModule(){
return this.leftModule;
},
propsRightModule(){
return this.rightModule;
}
},
watch: {
leftModule: function (val) {
},
rightModule: function (val) {
}
},
data : function(){
return {
}
},
methods: {
/**
* 事件触发,向上传递
* @param {*} event
*/
leftModuleChange: function(event){
this.$emit('left-module-change', event)
},
/**
* 事件触发,向上传递
* @param {*} event
*/
rightModuleChange: function(event){
this.$emit('right-module-change', event)
},
},
mounted() {
},
created() {
},
components:{
'tl_rtc_app_module_cut_paste_top': window.tl_rtc_app_module_cut_paste_top,
'tl_rtc_app_module_cut_paste_list': window.tl_rtc_app_module_cut_paste_list,
},
template: `
<div class="tl-rtc-app-left-panel">
<tl_rtc_app_module_cut_paste_top
:left-module="propsLeftModule"
:right-module="propsRightModule"
:company="propsCompany"
:user="propsUser"
:socket="propsSocket"
:is-mobile="propsIsMobile"
@left-module-change="leftModuleChange"
@right-module-change="rightModuleChange"
v-cloak>
</tl_rtc_app_module_cut_paste_top>
<tl_rtc_app_module_cut_paste_list
:left-module="propsLeftModule"
:right-module="propsRightModule"
:user="propsUser"
:socket="propsSocket"
:is-mobile="propsIsMobile"
@left-module-change="leftModuleChange"
@right-module-change="rightModuleChange"
v-cloak>
</tl_rtc_app_module_cut_paste_list>
</div>
`
}
window.tl_rtc_app_module_cut_paste = tl_rtc_app_module_cut_paste

View File

@ -1,320 +0,0 @@
const tl_rtc_app_module_cut_paste_list = {
props : {
user: {
type: Object,
default: null
},
socket: {
type: Object,
default: null
},
isMobile:{
type: Boolean,
default: false
},
leftModule: {
type: String,
default: ''
},
rightModule: {
type: String,
default: ''
}
},
data : function(){
return {
// 搜索关键字
searchKey : '',
// 剪贴板列表
cutPasteList: [],
// 当前显示的剪贴板
showCutPasteId: -1,
}
},
computed: {
propsUser(){
return this.user;
},
propsSocket(){
return this.socket;
},
propsIsMobile(){
return this.isMobile;
},
filterCutPasteList(){
let that = this
if(this.searchKey.length === 0){
return this.cutPasteList
}
const list = this.cutPasteList.filter(item => {
return item.title.indexOf(that.searchKey) !== -1
})
return list
},
propsLeftModule(){
return this.leftModule;
},
propsRightModule(){
return this.rightModule;
}
},
watch: {
leftModule: function (val) {
},
rightModule: function (val) {
},
cutPasteList: {
handler: function (val) {
},
deep: true,
immediate: true
}
},
methods: {
/**
* 事件触发,向上传递
* @param {*} event
*/
leftModuleChange: function(event){
this.$emit('left-module-change', event)
},
/**
* 事件触发,向上传递
* @param {*} event
*/
rightModuleChange: function(event){
this.$emit('right-module-change', event)
},
/**
* 创建一个共享剪贴板
*/
createCutPaste: async function(){
let that = this
layer.prompt({
formType: 0,
title: "输入新建剪贴板名称",
btn : ['确定', '取消'],
value: "",
shadeClose : true,
skin: 'layui-layer-prompt tl-rtc-app-layer-cut-paste-create',
maxlength : 15,
}, async function (value, index, elem) {
value = value.trim()
if(value.length === 0){
layer.msg("请输入剪贴板名称",{offset: 't'});
return false;
}
const params = {
title: value,
password: ''
}
if(!window.tl_rtc_app_comm.checkRequestParams(params)){
that.popErrorMsg("请求参数非法")
return
}
const { data: cutPasteRes } = await that.tlRequest({
url: '/api/web/cut-paste/add-cut-paste',
method: 'post',
useCache: false,
data: params,
})
if(!cutPasteRes.success){
that.popErrorMsg(cutPasteRes.msg)
layer.close(index)
return
}
that.popSuccessMsg(cutPasteRes.msg)
layer.close(index)
// 获取剪贴板列表
await that.getCutPasteList()
return false
});
},
/**
* 打开剪贴板详情
* @param {*} item
*/
openCutPasteDetail: async function(item){
let that = this
this.$emit('left-module-change', 'cut_paste')
this.$emit('right-module-change', 'content')
// 点击切换频道
if(item.id !== this.showCutPasteId){
this.emitSubModuleEvent({
event: 'sub-module-cut-paste-content-open',
data: {
title: item.title,
cutPasteId: item.id,
code: item.code,
status: item.status,
}
})
}
// 打开右侧模块 - 处理移动端情况
this.emitSubModuleEvent({
event: 'sub-module-core-change-module-show',
data: {
showRightModule: true,
}
})
},
/**
* 获取剪贴板列表
*/
getCutPasteList: async function(){
let that = this
const { data: cutPasteRes } = await this.tlRequest({
url: '/api/web/cut-paste/get-cut-paste-list',
method: 'get',
useCache: true,
cacheTime: 10 * 1000
})
if(!cutPasteRes.success){
this.popErrorMsg(cutPasteRes.msg)
return
}
// 处理时间
cutPasteRes.data.forEach(item => {
item.createTimeFormat = window.util.timeAgo(item.createTime)
})
this.cutPasteList = cutPasteRes.data
},
/**
* 初始化swiper
*/
initSwiper: function(){
const { bodyHeight } = window.tl_rtc_app_comm.getPropertyValues([
{ key: "bodyHeight", value: "body-height" }
])
// 计算编辑器的高度
let height = (
Number(bodyHeight.replace("%", "")) * (
window.innerHeight * Number(bodyHeight.replace("%", "")) / 100
) / 100 - 120
)
let slidesPerView = parseInt(height / 84)
if(height < 500){
slidesPerView = parseInt(height / 70)
}
// 初始化共享剪贴板列表swiper
new Swiper('#cutPasteListSwiper', {
slidesPerView: slidesPerView,
direction: 'vertical',
loop: false,
observer: true,
mousewheel: true, // 鼠标滚轮控制
forceToAxis: true, // 滚动条只能在一个方向上拖动
spaceBetween: 1,
freeMode: {
momentumRatio: 1, // 惯性动量比
momentumBounceRatio: 0, // 滑动反弹
minimumVelocity: 0, // 最小滑动速度
}
});
},
/**
* 用户搜索名称变更
* @param {*} key
*/
searchKeyUpdate: function({
key, callback
}){
this.searchKey = key
callback && callback()
}
},
mounted: async function() {
let that = this
// 获取剪贴板列表
await this.getCutPasteList()
// 初始化swiper
this.initSwiper()
},
created(){
// 监听搜索用户名称
window.subModule.$on('sub-module-cut-paste-search-key-update', this.searchKeyUpdate)
},
template: `
<div class="tl-rtc-app-left-panel-cut-paste">
<div class="tl-rtc-app-left-panel-no-cut-paste" v-if="searchKey.length !== 0 && filterCutPasteList.length === 0">
未找到相关共享剪贴板
</div>
<div style="padding: 20px;" v-if="searchKey.length === 0">
<div class="tl-rtc-app-left-panel-no-cut-paste">
创建一个共享剪贴板
</div>
<div class="tl-rtc-app-left-panel-no-cut-paste">
<button class="layui-btn layui-btn-primary" @click="createCutPaste()">快速创建</button>
</div>
</div>
<div class="swiper" id="cutPasteListSwiper">
<div class="swiper-wrapper">
<div class="tl-rtc-app-left-panel-cut-paste-item swiper-slide"
:class="{
'tl-rtc-app-left-panel-cut-paste-item-active' : showCutPasteId === item.id,
}"
v-for="item in filterCutPasteList"
:id="'cut-paste-item-' + item.id"
@click="openCutPasteDetail(item)"
>
<div class="tl-rtc-app-left-panel-cut-paste-item-img">
<img src="/image/default-avatar.png" alt="">
</div>
<div class="tl-rtc-app-left-panel-cut-paste-item-content">
<div class="tl-rtc-app-left-panel-cut-paste-item-content-nickname">
{{item.title}}
</div>
<div class="tl-rtc-app-left-panel-cut-paste-item-content-message" >
<div class="tl-rtc-app-left-panel-cut-paste-item-content-message-file">
<svg class="icon" aria-hidden="true">
<use xlink:href="#tl-rtc-app-icon-shengboyuyinxiaoxi"></use>
</svg>
<div class="tl-rtc-app-left-panel-cut-paste-item-content-message-file-info">
<span style="font-size: 12px;">
剪贴板共{{item.detailCount}}条记录
</span>
</div>
</div>
</div>
</div>
<div class="tl-rtc-app-left-panel-cut-paste-item-other" v-show="false">
<div class="tl-rtc-app-left-panel-cut-paste-item-other-time">
</div>
<div class="tl-rtc-app-left-panel-cut-paste-item-other-unread">
<div class="layui-badge" style="padding-left: 1px;">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
`,
}
window.tl_rtc_app_module_cut_paste_list = tl_rtc_app_module_cut_paste_list

View File

@ -1,113 +0,0 @@
const tl_rtc_app_module_cut_paste_top = {
props : {
company : {
type : Object,
default : function(){
return {
name : ""
}
}
},
isMobile: {
type: Boolean,
default: false
},
leftModule: {
type: String,
default: ''
},
rightModule: {
type: String,
default: ''
}
},
computed: {
propsCompany(){
return this.company;
},
propsIsMobile(){
return this.isMobile;
},
propsLeftModule() {
return this.leftModule;
},
propsRightModule() {
return this.rightModule;
},
},
watch: {
searchKey : {
deep: true,
immediate: true,
handler: function(cur, pre){
this.emitSubModuleEvent({
event: 'sub-module-cut-paste-search-key-update',
data: {
key: cur
}
})
}
},
leftModule: function (val) {
},
rightModule: function (val) {
}
},
data : function(){
return {
searchKey: '', // 搜索关键字
}
},
methods: {
/**
* 事件触发,向上传递
* @param {*} event
*/
leftModuleChange: function(event){
this.$emit('left-module-change', event)
},
/**
* 事件触发,向上传递
* @param {*} event
*/
rightModuleChange: function(event){
this.$emit('right-module-change', event)
},
/**
* 打开快速操作面板
*/
openQuickOperPanel: function(){
this.emitSubModuleEvent({
event: 'component-popup-add-quick-oper-panel',
})
}
},
mounted() {
},
template: `
<div class="tl-rtc-app-left-panel-cut-paste-top">
<div class="tl-rtc-app-left-panel-cut-paste-top-header">
<div class="tl-rtc-app-left-panel-cut-paste-top-header-title">
共享剪贴板
</div>
<div class="tl-rtc-app-left-panel-cut-paste-top-header-tool">
<svg class="icon" aria-hidden="true" @click="openQuickOperPanel">
<use xlink:href="#tl-rtc-app-icon-tianjia"></use>
</svg>
</div>
</div>
<div class="tl-rtc-app-left-panel-cut-paste-top-search">
<i class="layui-icon layui-icon-search"></i>
<input type="text" v-model="searchKey" autocomplete="off" placeholder="搜索剪贴板" class="layui-input" maxlength="30">
<svg class="icon" aria-hidden="true" @click="searchKey = ''" v-show="searchKey.length > 0">
<use xlink:href="#tl-rtc-app-icon-cuowu"></use>
</svg>
</div>
</div>
`,
}
window.tl_rtc_app_module_cut_paste_top = tl_rtc_app_module_cut_paste_top

View File

@ -48,7 +48,7 @@ const tl_rtc_app_module_login_content = {
},
data : function(){
return {
loginType : 'account',
loginType : 'sso',
}
},
methods: {
@ -93,42 +93,19 @@ const tl_rtc_app_module_login_content = {
},
created(){
// 登录方式改变
window.subModule.$on('sub-module-login-content-data-change', this.moduleDataChange)
},
components : {
'tl_rtc_app_module_login_content_email' : window.tl_rtc_app_module_login_content_email,
'tl_rtc_app_module_login_content_account' : window.tl_rtc_app_module_login_content_account,
},
template: `
<div class="tl-rtc-app-right-login-content">
<svg class="icon goBack" aria-hidden="true" @click="goBack" v-show="isMobile">
<use xlink:href="#tl-rtc-app-icon-xiangzuo1"></use>
</svg>
<tl_rtc_app_module_login_content_account
:is-mobile="propsIsMobile"
v-show="loginType == 'account'"
:socket="propsSocket"
:left-module="propsLeftModule"
:right-module="propsRightModule"
:code-list="propsCodeList"
@left-module-change="leftModuleChange"
@right-module-change="rightModuleChange"
>
</tl_rtc_app_module_login_content_account>
<tl_rtc_app_module_login_content_email
:is-mobile="propsIsMobile"
v-show="loginType == 'email'"
:socket="propsSocket"
:left-module="propsLeftModule"
:right-module="propsRightModule"
:code-list="propsCodeList"
@left-module-change="leftModuleChange"
@right-module-change="rightModuleChange"
>
</tl_rtc_app_module_login_content_email>
<div style="padding: 72px 48px; line-height: 32px; font-size: 16px; color: #666;">
<div style="font-size: 24px; color: #222; margin-bottom: 20px;">请通过 SSO 登录</div>
<div>当前项目已移除帐号登录、邮箱登录和指纹登录入口。</div>
<div>请从统一认证系统进入,认证成功后会自动完成登录并建立 websocket 连接。</div>
</div>
</div>
`,
}

View File

@ -42,23 +42,7 @@ const tl_rtc_app_module_login = {
data : function(){
return {
loginedCacheList: [],
loginedListCacheKey: 'tl_logined_list',
loginList: [
{
name : '帐号登录',
svg: '#tl-rtc-app-icon-gerenzhongxin',
type : 'account',
default : true,
handler: this.handlerAccountLogin
},
{
name : '邮箱登录',
svg: '#tl-rtc-app-icon-youjian1',
type : 'email',
default : false,
handler: this.handlerEmailLogin
}
]
loginedListCacheKey: 'tl_logined_list'
}
},
methods: {
@ -76,18 +60,6 @@ const tl_rtc_app_module_login = {
rightModuleChange: function(event){
this.$emit('right-module-change', event)
},
/**
* 帐号登录
*/
handlerAccountLogin: function(){
this.$emit('right-module-change', 'content')
},
/**
* 邮箱登录
*/
handlerEmailLogin: function(){
this.$emit('right-module-change', 'content')
},
/**
* 设置登录过的帐号缓存到localStorage
* @param {*} userId
@ -164,37 +136,19 @@ const tl_rtc_app_module_login = {
this.getCacheLoginAccount()
},
components:{
'tl_rtc_app_module_login_list': window.tl_rtc_app_module_login_list,
'tl_rtc_app_module_login_mobile': window.tl_rtc_app_module_login_mobile,
},
template: `
<div class="tl-rtc-app-left-panel">
<div class="tl-rtc-app-left-panel-login">
<div class="tl-rtc-app-left-panel-login-top-header">
<div class="tl-rtc-app-left-panel-login-top-header-title">统一认证登录</div>
</div>
<tl_rtc_app_module_login_list v-if="!propsIsMobile"
:login-list='loginList'
:is-mobile="propsIsMobile"
:left-module="propsLeftModule"
:right-module="propsRightModule"
@left-module-change="leftModuleChange"
@right-module-change="rightModuleChange"
v-cloak
>
</tl_rtc_app_module_login_list>
<tl_rtc_app_module_login_mobile v-else
@clean-cache-account="cleanCacheAccount"
:login-list='loginList'
:is-mobile="propsIsMobile"
:logined-cache-list="loginedCacheList"
:left-module="propsLeftModule"
:right-module="propsRightModule"
@left-module-change="leftModuleChange"
@right-module-change="rightModuleChange"
v-cloak
>
</tl_rtc_app_module_login_mobile>
<div class="tl-rtc-app-left-panel-login-item" style="cursor: default; min-height: 168px; align-items: flex-start;">
<div class="tl-rtc-app-left-panel-login-item-name" style="white-space: normal; line-height: 28px; padding-right: 12px;">
当前版本仅支持 SSO 登录,请从统一认证入口进入系统。登录成功后会自动跳转到当前页面。
</div>
</div>
</div>
</div>
`
}

View File

@ -280,6 +280,34 @@ const tl_rtc_app_module_setting_content = {
})
this.popSuccessMsg(userConfigRes.msg)
},
/**
* 清除当前用户缓存(服务端 + 浏览器请求缓存)
*/
clearSelfCache: async function(){
const { data: res } = await this.tlRequest({
url: '/api/web/user-clear/clear-self-cache',
method: 'post',
useCache: false,
data: {},
})
if(!res || !res.success){
this.popErrorMsg((res && res.msg) || '清除缓存失败')
return
}
const token = window.localStorage.getItem('token') || ''
if(token){
await this.emitSubModuleEvent({
event: 'component-cache-del',
data: {
subKeys: [token + ':']
}
})
}
this.popSuccessMsg('清除缓存成功')
}
},
mounted: function() {
@ -368,6 +396,7 @@ const tl_rtc_app_module_setting_content = {
:is-mobile="propsIsMobile"
:other-setting="propsUser.otherSetting"
@update-user-config-other="updateUserConfigOther"
@clear-self-cache="clearSelfCache"
:company="propsCompany"
:user="propsUser"
:left-module="propsLeftModule"

View File

@ -14,7 +14,6 @@ const tl_rtc_app_module_setting_content_normal = {
homePage: 'channel',
sidebarChannelOpen: true,
sidebarContactOpen: true,
sidebarCutPasteOpen: true,
sidebarSettingOpen: true,
}
},
@ -57,7 +56,6 @@ const tl_rtc_app_module_setting_content_normal = {
settingFields: [
'sidebarChannelOpen',
'sidebarContactOpen',
'sidebarCutPasteOpen',
'sidebarSettingOpen',
'homePage'
]
@ -177,18 +175,6 @@ const tl_rtc_app_module_setting_content_normal = {
</div>
</div>
<div class="tl-rtc-app-right-setting-content-normal-block-item">
<div class="tl-rtc-app-right-setting-content-normal-block-item-title">
<svg class="icon" aria-hidden="true" style="padding-right: 5px;">
<use xlink:href="#tl-rtc-app-icon-jianqie"></use>
</svg>
剪贴板
</div>
<div class="tl-rtc-app-right-setting-content-normal-block-item-oper">
<input type="radio" name="homePage" value="cut_paste">
</div>
</div>
<div class="tl-rtc-app-right-setting-content-normal-block-item">
<div class="tl-rtc-app-right-setting-content-normal-block-item-title">
<svg class="icon" aria-hidden="true" style="padding-right: 5px;">
@ -241,18 +227,6 @@ const tl_rtc_app_module_setting_content_normal = {
</div>
</div>
<div class="tl-rtc-app-right-setting-content-normal-block-item">
<div class="tl-rtc-app-right-setting-content-normal-block-item-title">
<svg class="icon" aria-hidden="true" style="padding-right: 5px;">
<use xlink:href="#tl-rtc-app-icon-jianqie"></use>
</svg>
剪贴板
</div>
<div class="tl-rtc-app-right-setting-content-normal-block-item-oper">
<input type="checkbox" name="sidebarCutPasteOpen" lay-skin="switch">
</div>
</div>
<div class="tl-rtc-app-right-setting-content-normal-block-item">
<div class="tl-rtc-app-right-setting-content-normal-block-item-title">
<svg class="icon" aria-hidden="true" style="padding-right: 5px;">

View File

@ -132,6 +132,12 @@ const tl_rtc_app_module_setting_content_other = {
}
})
},
/**
* 清除当前用户缓存
*/
clearSelfCache: function(){
this.$emit('clear-self-cache')
},
},
mounted() {
let that = this
@ -208,6 +214,22 @@ const tl_rtc_app_module_setting_content_other = {
<div class="tl-rtc-app-right-setting-content-other-block" >
<div class="tl-rtc-app-right-setting-content-other-block-title">服务端设置</div>
<div class="tl-rtc-app-right-setting-content-other-block-content">
<div class="tl-rtc-app-right-setting-content-other-block-item">
<div class="tl-rtc-app-right-setting-content-other-block-item-title">
清除我的服务端缓存
<svg class="icon" aria-hidden="true"
id="tl-rtc-app-setting-clear-self-cache"
@mouseenter="mouseEnter(event, '清除当前账号在服务端的用户信息缓存和频道权限缓存')"
@mouseleave="mouseLeave"
>
<use xlink:href="#tl-rtc-app-icon-tishi"></use>
</svg>
</div>
<div class="tl-rtc-app-right-setting-content-other-block-item-oper">
<button class="layui-btn layui-btn-sm layui-btn-danger" @click="clearSelfCache">清除缓存</button>
</div>
</div>
<div class="tl-rtc-app-right-setting-content-other-block-item"
style="display: flex; flex-direction: column; flex-wrap: nowrap; justify-content: center; align-items: flex-start;"
>

View File

@ -116,15 +116,6 @@ const tl_rtc_app_module_sidebar = {
show: false,
handler: this.handlerContact
},
{
svg : '#tl-rtc-app-icon-jianqie',
title : '剪贴板',
active: this.leftModule === 'cut_paste',
name: 'cut_paste',
unread: 0,
show: false,
handler: this.handlerCutPaste
},
{
svg : '#tl-rtc-app-icon-shezhi',
title : '设置',
@ -146,14 +137,6 @@ const tl_rtc_app_module_sidebar = {
}
],
subTools : [
{
id: 'sub-tool-about',
svg : '#tl-rtc-app-icon-wode-guanyuwomen',
title : '关于我们',
name: 'about',
show: true,
handler: this.aboutHandler
},
{
id: 'sub-tool-logout',
svg : '#tl-rtc-app-icon-tuichu',
@ -192,12 +175,6 @@ const tl_rtc_app_module_sidebar = {
handlerContact: function(){
this.$emit('left-module-change', 'contact')
},
/**
* 点击剪贴板
*/
handlerCutPaste: function(){
this.$emit('left-module-change', 'cut_paste')
},
/**
* 点击设置
*/
@ -301,8 +278,6 @@ const tl_rtc_app_module_sidebar = {
return this.propsUser.normalSetting.sidebarChannelOpen;
case 'contact':
return this.propsUser.normalSetting.sidebarContactOpen;
case 'cut_paste':
return this.propsUser.normalSetting.sidebarCutPasteOpen;
case 'setting':
return true; // 设置按钮默认显示
default:
@ -334,13 +309,6 @@ const tl_rtc_app_module_sidebar = {
callback && callback()
},
/**
* 关于我们
* @returns
*/
aboutHandler: function(){
window.open('/website/index.html', '_blank')
},
/**
* 退出登录
* @returns
@ -398,9 +366,6 @@ const tl_rtc_app_module_sidebar = {
if(item.name === 'contact'){
item.show = this.propsUser.normalSetting.sidebarContactOpen
}
if(item.name === 'cut_paste'){
item.show = this.propsUser.normalSetting.sidebarCutPasteOpen
}
// 保存每个工具的原始显示状态(基于用户设置)
if (item.name !== 'more') {
@ -418,6 +383,11 @@ const tl_rtc_app_module_sidebar = {
this.handlerSidebarMenu({})
const sidebarElement = document.querySelector('.tl-rtc-app-left-sidebar');
if (!sidebarElement) {
return
}
// 注册自定义菜单
this.emitSubModuleEvent({
event: 'component-menu-register-custom',
@ -440,8 +410,7 @@ const tl_rtc_app_module_sidebar = {
}
this.adjustToolsVisibility();
});
const sidebarElement = document.querySelector('.tl-rtc-app-left-sidebar');
if (sidebarElement) {
resizeObserver.observe(sidebarElement);
}

View File

@ -1,5 +1,67 @@
// 是否启用中继
let useTurn = (window.localStorage.getItem("tl-rtc-app-use-turn") || "false") === 'true';
const LOGIN_TOKEN_STORAGE_KEY = 'token'
let get_sso_ticket_from_url = function(){
const params = new URLSearchParams(window.location.search)
const token = params.get('token') || ''
const isValidSsoToken = typeof token === 'string' && (
token.length === 64 || token.startsWith('test-')
)
if(!isValidSsoToken){
return ''
}
return token
}
let clear_sso_ticket_from_url = function(){
const url = new URL(window.location.href)
if(!url.searchParams.has('token')){
return
}
url.searchParams.delete('token')
window.history.replaceState({}, document.title, url.toString())
}
let normalize_ws_host_by_page = function(wsHost){
const wsProtocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'
const fallbackHost = wsProtocol + '//' + window.location.host
if(!wsHost || typeof wsHost !== 'string'){
return fallbackHost
}
try{
const parsedWsHost = new URL(wsHost)
const isLocalHost = ['localhost', '127.0.0.1', '0.0.0.0'].includes(parsedWsHost.hostname)
if(isLocalHost){
parsedWsHost.protocol = wsProtocol
parsedWsHost.hostname = window.location.hostname
return parsedWsHost.toString().replace(/\/$/, '')
}
}catch(e){
return fallbackHost
}
return wsHost
}
let listen_token_change_for_cross_tab = function(){
window.addEventListener('storage', function(event){
if(event.key !== LOGIN_TOKEN_STORAGE_KEY){
return
}
if(event.newValue === event.oldValue){
return
}
window.location.reload()
})
}
let load_tl_rtc_app_js = async function(){
let { data : configInitRes } = await axios.get("/api/web/config/init", {
@ -85,6 +147,26 @@ let load_tl_rtc_app_js = async function(){
})
}
const ssoTicket = get_sso_ticket_from_url()
if(ssoTicket){
try{
const { data: ssoLoginRes } = await axios.post('/api/web/user-login/login-by-sso-ticket', {
token: ssoTicket
})
clear_sso_ticket_from_url()
if(ssoLoginRes && ssoLoginRes.success && ssoLoginRes.data){
window.localStorage.setItem('token', ssoLoginRes.data)
window.location.reload()
return
}
}catch(e){
console.error('sso ticket request error:', e.message)
}
clear_sso_ticket_from_url()
}
let { data : loginStateRes } = await axios.get("/api/web/user-login/login-state");
let isLogin = loginStateRes.success
let username = loginStateRes.data.loginUsername
@ -124,6 +206,7 @@ let load_tl_rtc_app_js = async function(){
if(customWss && window.tl_rtc_app_comm.isWssHost(customWss)){
wsHost = customWss;
}
wsHost = normalize_ws_host_by_page(wsHost)
// 浏览器通知
webNotify = messageSetting.webNotify
// 消息红点数量提示
@ -143,9 +226,6 @@ let load_tl_rtc_app_js = async function(){
// 频道
'tl_rtc_app_module_channel': window.tl_rtc_app_module_channel,
'tl_rtc_app_module_channel_content': window.tl_rtc_app_module_channel_content,
// 剪贴板
'tl_rtc_app_module_cut_paste': window.tl_rtc_app_module_cut_paste,
'tl_rtc_app_module_cut_paste_content': window.tl_rtc_app_module_cut_paste_content,
// 设置
'tl_rtc_app_module_setting': window.tl_rtc_app_module_setting,
'tl_rtc_app_module_setting_content': window.tl_rtc_app_module_setting_content,
@ -407,4 +487,5 @@ let load_tl_rtc_app_js = async function(){
})
}
listen_token_change_for_cross_tab()
load_tl_rtc_app_js()