feat: 支持共享剪贴板/优化部署流程/文档更新

This commit is contained in:
iamtsm 2025-06-13 23:08:01 +08:00
parent 2c7f2211ea
commit 1415e3084a
37 changed files with 6511 additions and 71 deletions

View File

@ -1,3 +1,5 @@
中文: [README_ZH.md](README_ZH.md)
<p align="center">
<img src="web-res/image/tlrtcapp-logo.svg" alt="TL-RTC-APP Logo">
</p>
@ -8,72 +10,62 @@
### Installation Steps
1. Clone the repository:
1. Prerequisites
```bash
Make sure Node.js (v16+), npm, MySQL (5.7+), and Redis (4.0+) are installed.
```
2. Clone the repository:
```bash
git clone https://github.com/tl-open-source/tl-rtc-app.git
```
2. Navigate into the project directory:
3. Enter the project directory:
```bash
cd tl-rtc-app
```
3. Install dependencies:
4. Install dependencies:
```bash
npm install
```
4. Install pm2 globally:
5. Install pm2 globally:
```bash
npm install pm2 -g
```
5. Start the super admin API service:
6. Start the service:
```bash
pm2 start npm --name=tl-rtc-app-super-api -- run http-super-api
npm run http
```
or
Or (for audio/video, screen sharing, live streaming, etc.):
```bash
pm2 start npm --name=tl-rtc-app-super-api -- run https-super-api
npm run https
```
6. Start the API service:
7. Build frontend resources:
```bash
pm2 start npm --name=tl-rtc-app-api -- run http-api
```
or
```bash
pm2 start npm --name=tl-rtc-app-api -- run https-api
gulp default
```
7. Start the Socket service:
### Usage Instructions
```bash
pm2 start npm --name=tl-rtc-app-socket -- run http-socket
```
or
1. Open your browser and visit `http://localhost:9096` (by default).
```bash
pm2 start npm --name=tl-rtc-app-socket -- run https-socket
```
### Usage
1. Open your browser and visit `http://localhost:9096` (default).
2. Use the admin panel for managing the IM application at `http://localhost:9098` (default).
2. Manage IM applications through the admin panel at `http://localhost:9098/system.html` (by default).
### License
This project is licensed under the MIT License. For more information, please refer to the [LICENSE](LICENSE) file.
This project is licensed under the MIT License. For more details, please refer to the [LICENSE](LICENSE) file.
### Disclaimer

View File

@ -1,3 +1,5 @@
英文: [README.md](README.md)
<p align="center">
<img src="web-res/image/tlrtcapp-logo.svg" alt="TL-RTC-APP Logo">
</p>
@ -6,71 +8,61 @@
<img src="web-res/image/channel-chat.png" alt="TL-RTC-APP Channel Chat">
</p>
### 安装步骤
1. 克隆仓库:
1. 前提条件
```bash
确保已安装 Node.js (v16+) 和 npm,mysql(5.7+), redis(4.0+)。
```
2. 克隆仓库:
```bash
git clone https://github.com/tl-open-source/tl-rtc-app.git
```
2. 进入项目目录:
3. 进入项目目录:
```bash
cd tl-rtc-app
```
3. 安装依赖:
4. 安装依赖:
```bash
npm install
```
4. 安装pm2:
5. 安装pm2:
```bash
npm install pm2 -g
```
5. 启动后台管理服务:
6. 启动服务:
```bash
pm2 start npm --name=tl-rtc-app-super-api -- run http-super-api
npm run http
```
或者
或者 (如需体验音视频/屏幕共享/直播等功能):
```bash
pm2 start npm --name=tl-rtc-app-super-api -- run https-super-api
npm run https
```
6. 启动Api服务:
7. 打包前端资源:
```bash
pm2 start npm --name=tl-rtc-app-api -- run http-api
```
或者
```bash
pm2 start npm --name=tl-rtc-app-api -- run https-api
gulp default
```
7. 启动Socket服务:
```bash
pm2 start npm --name=tl-rtc-app-socket -- run http-socket
```
或者
```bash
pm2 start npm --name=tl-rtc-app-socket -- run https-socket
```
### 使用说明
1. 打开浏览器并访问 `http://localhost:9096` (默认)。
2. 通过管理端应用进行IM应用管理 `http://localhost:9098` (默认)。
2. 通过管理端应用进行IM应用管理 `http://localhost:9098/system.html` (默认)。
### 许可证

View File

@ -211,6 +211,13 @@ 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',

View File

@ -1,14 +1,10 @@
{
"name": "tl-rtc-app",
"version": "0.0.2",
"description": "webrtc, video, draw, chat",
"version": "0.0.3",
"description": "webrtc, p2p, file, video, draw, chat",
"scripts": {
"http-api": "cross-env tl_rtc_app_env_mode=http node tlapi",
"http-super-api": "cross-env tl_rtc_app_env_mode=http node tlsuperapi",
"http-socket": "cross-env tl_rtc_app_env_mode=http node tlsocket",
"https-api": "cross-env tl_rtc_app_env_mode=https node tlapi",
"https-super-api": "cross-env tl_rtc_app_env_mode=https node tlsuperapi",
"https-socket": "cross-env tl_rtc_app_env_mode=https node tlsocket"
"http": "pm2 start pm2.config.http.json",
"https": "pm2 start pm2.config.https.json"
},
"repository": {
"type": "git",

31
pm2.config.http.json Normal file
View File

@ -0,0 +1,31 @@
{
"apps": [
{
"name": "tl-rtc-app-super-api",
"script": "node tlsuperapi",
"instances": 1,
"max_memory_restart": "500M",
"env": {
"tl_rtc_app_env_mode": "http"
}
},
{
"name": "tl-rtc-app-api",
"script": "node tlapi",
"instances": 1,
"max_memory_restart": "500M",
"env": {
"tl_rtc_app_env_mode": "http"
}
},
{
"name": "tl-rtc-app-socket",
"script": "node tlsocket",
"instances": 1,
"max_memory_restart": "500M",
"env": {
"tl_rtc_app_env_mode": "http"
}
}
]
}

31
pm2.config.https.json Normal file
View File

@ -0,0 +1,31 @@
{
"apps": [
{
"name": "tl-rtc-app-super-api",
"script": "node tlsuperapi",
"instances": 1,
"max_memory_restart": "500M",
"env": {
"tl_rtc_app_env_mode": "https"
}
},
{
"name": "tl-rtc-app-api",
"script": "node tlapi",
"instances": 1,
"max_memory_restart": "500M",
"env": {
"tl_rtc_app_env_mode": "https"
}
},
{
"name": "tl-rtc-app-socket",
"script": "node tlsocket",
"instances": 1,
"max_memory_restart": "500M",
"env": {
"tl_rtc_app_env_mode": "https"
}
}
]
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,308 @@
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

@ -0,0 +1,67 @@
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

@ -39,6 +39,11 @@ 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')
module.exports = {
"system-web-config" : systemWebConfig,
"system-web-company" : systemWebCompany,
@ -68,5 +73,8 @@ module.exports = {
"channel-file" : channelFile,
"channel-media" : channelMedia,
"cut-paste" : cutPaste,
"cut-paste-share" : cutPasteShare,
"cloud-file" : cloudFile,
}

211
src/dao/tl_cut_paste_dao.js Normal file
View File

@ -0,0 +1,211 @@
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

@ -0,0 +1,238 @@
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

@ -5,6 +5,7 @@ const {
userPermission,
companyPermission,
configPermission,
cutPastePermission,
channelPerfix,
channelNoticePerfix,
@ -67,6 +68,10 @@ 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;
}
@ -102,6 +107,10 @@ 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,6 +11,7 @@ const cloudPermissionIdBase = 200000
const companyPermissionIdBase = 300000
const userPermissionIdBase = 400000
const configPermissionIdBase = 500000
const cutPastePermissionIdBase = 600000
// key前缀
const systemWebConfigPerfix = 'SYSTEM_WEB_CONFIG:'
@ -37,6 +38,7 @@ const userLoginPerfix = 'USER_LOGIN:'
const userLogoutPerfix = 'USER_LOGOUT:'
const userClearPerfix = 'USER_CLEAR:'
const configSkinPerfix = 'CONFIG_SKIN:'
const cutPastePerfix = 'CUT_PASTE:'
// 补充前缀
@ -335,6 +337,33 @@ 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)
@ -364,6 +393,8 @@ addPerfix(userPermission.userTag, userTagPerfix)
addPerfix(userPermission.userClear, userClearPerfix)
addPerfix(configPermission.skin, configSkinPerfix)
addPerfix(cutPastePermission.cutPaste, cutPastePerfix)
module.exports = {
systemPermission,
@ -372,6 +403,7 @@ module.exports = {
companyPermission,
userPermission,
configPermission,
cutPastePermission,
systemWebConfigPerfix,
systemWebCompanyPerfix,
@ -395,4 +427,5 @@ module.exports = {
userLogoutPerfix,
userTagPerfix,
configSkinPerfix,
cutPastePerfix,
}

View File

@ -5,6 +5,7 @@ const {
userPermission,
companyPermission,
configPermission,
cutPastePermission
} = require('./permission');
const {
@ -57,7 +58,9 @@ 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

@ -0,0 +1,186 @@
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

@ -0,0 +1,373 @@
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

@ -94,6 +94,7 @@ const addDefaultInfo = async function({companyId, userId}){
normal: JSON.stringify({
sidebarChannelOpen: true,
sidebarContactOpen: true,
sidebarCutPasteOpen: true,
sidebarSettingOpen: true,
homePage: 'channel',
}),

View File

@ -0,0 +1,98 @@
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

@ -0,0 +1,96 @@
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

@ -28,6 +28,8 @@ const tl_user_config_fields = {
sidebarChannelOpen: 'sidebarChannelOpen',
// 侧边栏-联系人
sidebarContactOpen: 'sidebarContactOpen',
// 侧边栏-剪贴板
sidebarCutPasteOpen: 'sidebarCutPasteOpen',
// 侧边栏-设置
sidebarSettingOpen: 'sidebarSettingOpen',
// 首页

View File

@ -1,5 +1,5 @@
#-----------------以下为基础配置-----------------#
tl_rtc_app_version=0.0.2
tl_rtc_app_version=0.0.3
## 后台管理端口
tl_rtc_app_super_api_port=9098
## api服务端口

View File

@ -0,0 +1,230 @@
/***********************************************************************************
************************************************************************************
剪贴板详情 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

@ -0,0 +1,239 @@
/***********************************************************************************
************************************************************************************
剪贴板列表 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

@ -254,6 +254,11 @@
.tl-rtc-app-right-channel-content-body-reply-content-block{
width: calc(100% - 20px) !important;
}
.tl-rtc-app-right-cut-paste-content-top-title
{
margin-left: 30px;
}
/***********************************************************************************
************************************************************************************
主界面布局 end

View File

@ -8,7 +8,6 @@ html {
--sidebar-width: 65px;
--left-width: 315px;
--left-channel-top: 130px;
--left-p2p-channel-top: 90px;
--left-contact-top: 100px;
--left-cut-paste-top: 90px;
--left-login-top: 30px;
@ -217,6 +216,16 @@ html {
--skin-face-search-input-background: #F8F9FB;
--skin-face-search-input-color: #3333339e;
--skin-face-content-title-color: #999;
/* 剪贴板相关配色 */
--skin-cut-paste-top-search-i-color: #c8c8c8;
--skin-cut-paste-top-search-input-background: #F8F9FB;
--skin-cut-paste-top-search-input-color: #3333339e;
--skin-cut-paste-list-item-hover-background: #d2deff96;
--skin-cut-paste-list-item-top-background: #e5ebfc96;
--skin-cut-paste-list-item-message-color: #777777;
--skin-cut-paste-list-item-time-color: #b8b8b8;
}

557
web-res/cut-paste.html Normal file
View File

@ -0,0 +1,557 @@
<!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>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 108 KiB

After

Width:  |  Height:  |  Size: 323 KiB

View File

@ -26,6 +26,7 @@
<script type="text/javascript" src="/static/js/axios.js"></script>
<script type="text/javascript" src="/static/js/clipboard.min.js"></script>
<script type="text/javascript" src="/static/js/highlight.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>
@ -95,6 +96,20 @@
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"
@ -147,6 +162,19 @@
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

@ -0,0 +1,688 @@
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

@ -0,0 +1,124 @@
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

@ -0,0 +1,320 @@
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

@ -0,0 +1,113 @@
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

@ -14,6 +14,7 @@ const tl_rtc_app_module_setting_content_normal = {
homePage: 'channel',
sidebarChannelOpen: true,
sidebarContactOpen: true,
sidebarCutPasteOpen: true,
sidebarSettingOpen: true,
}
},
@ -56,6 +57,7 @@ const tl_rtc_app_module_setting_content_normal = {
settingFields: [
'sidebarChannelOpen',
'sidebarContactOpen',
'sidebarCutPasteOpen',
'sidebarSettingOpen',
'homePage'
]
@ -175,6 +177,18 @@ 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;">
@ -227,6 +241,18 @@ 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

@ -116,6 +116,15 @@ 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 : '设置',
@ -183,6 +192,12 @@ const tl_rtc_app_module_sidebar = {
handlerContact: function(){
this.$emit('left-module-change', 'contact')
},
/**
* 点击剪贴板
*/
handlerCutPaste: function(){
this.$emit('left-module-change', 'cut_paste')
},
/**
* 点击设置
*/
@ -286,6 +301,8 @@ 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:
@ -381,6 +398,9 @@ 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') {

View File

@ -143,6 +143,9 @@ 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,

1358
web-res/static/js/highlight.min.js vendored Normal file

File diff suppressed because one or more lines are too long