Commit e9179cd5 authored by liujiaxin's avatar liujiaxin

调整退出清空数据,添加上传音视频图片,存到omt上了

parent 7252cf24
......@@ -269,9 +269,9 @@ const items = [
{
name: 'add'
},
// {
// name: 'upload'
// },
{
name: 'upload'
},
{
name: 'hand_tool'
},
......@@ -552,13 +552,13 @@ const items = [
items={toolItems}
currentTool={tool}
handleToolClick={handleToolClick} />
{tool === 'color_picker' && strokeColor ?
{tool === 'color_picker' && strokeColor && roomStore.state.me.role == 'teacher'?
<SketchPicker
color={strokeColor}
onChangeComplete={onColorChanged} />
: null}
</> : null}
{/*<UploadPanel />*/}
<UploadPanel />
{children ? children : null}
</div>
{/*me.role === 'teacher' && room ?
......
......@@ -242,8 +242,8 @@
box-shadow:0px 2px 4px 0px rgba(0,0,0,0.1);
border-radius:6px;
border:1px solid rgba(219,226,229,1);
top: 183px;
left: 63px;
top: 275px/*183*/;
right: 63px;
z-index: 5;
position: absolute;
pointer-events: all;
......
......@@ -3,7 +3,7 @@ import OSS from "ali-oss";
import uuidv4 from 'uuid/v4';
import { PPTProgressListener, UploadManager } from "../../../utils/upload-manager";
import { PptKind, Room } from "white-web-sdk";
import { ossConfig, ossClient, resolveFileInfo } from '../../../utils/helper';
import {ossConfig, ossClient, resolveFileInfo, getOssClient} from '../../../utils/helper';
import { whiteboard } from '../../../stores/whiteboard';
export type UploadBtnProps = {
......@@ -22,6 +22,7 @@ export const UploadBtn: React.FC<UploadBtnProps> = ({
try {
const file = event.currentTarget.files[0];
if (file) {
const ossClient = await getOssClient();
const uploadManager = new UploadManager(ossClient, room);
const pptConverter = whiteboard.client.pptConverter(roomToken);
await uploadManager.convertFile(
......@@ -43,6 +44,7 @@ export const UploadBtn: React.FC<UploadBtnProps> = ({
try {
const file = event.currentTarget.files[0];
if (file) {
const ossClient = await getOssClient();
const uploadManager = new UploadManager(ossClient, room);
const pptConverter = whiteboard.client.pptConverter(roomToken);
await uploadManager.convertFile(
......@@ -65,6 +67,7 @@ export const UploadBtn: React.FC<UploadBtnProps> = ({
if (file) {
const uploadFileArray: File[] = [];
uploadFileArray.push(file);
const ossClient = await getOssClient();
const uploadManager = new UploadManager(ossClient, room);
const $whiteboard = document.getElementById('whiteboard') as HTMLDivElement;
if ($whiteboard) {
......@@ -83,14 +86,16 @@ export const UploadBtn: React.FC<UploadBtnProps> = ({
}
const uploadAudioVideo = async (event: any) => {
event.persist();
const ossClient = await getOssClient();
const uploadManager = new UploadManager(ossClient, room);
const file = event.currentTarget.files[0];
const file = event.target.files[0];
if (file) {
try {
const {fileName, fileType} = resolveFileInfo(file);
const path = `/${ossConfig.folder}`
const uuid = uuidv4();
const res = await uploadManager.addFile(`${path}/video-${fileName}${uuid}`, file,
const res = await uploadManager.addFile(`${path}/${uuid}${fileName}`, file,
onProgress
);
const isHttps = res.indexOf("https") !== -1;
......@@ -139,13 +144,14 @@ export const UploadBtn: React.FC<UploadBtnProps> = ({
<label htmlFor="upload-image">
<div className="upload-image-resource"></div>
<div className="text-container">
<div className="title">Convert Picture</div>
<div className="title">上传图片</div>
<div className="description">bmp, jpg, png, gif</div>
</div>
</label>
<input id="upload-image" accept="image/*,.bmp,.jpg,.png,.gif"
onChange={uploadImage} type="file"></input>
</div>
{/*
<div className="slice-dash"></div>
<div className="upload-items">
<label htmlFor="upload-dynamic">
......@@ -168,12 +174,13 @@ export const UploadBtn: React.FC<UploadBtnProps> = ({
</label>
<input id="upload-static" accept=".doc,.docx,.ppt,.pptx,.pdf" onChange={uploadStatic} type="file"></input>
</div>
*/}
<div className="slice-dash"></div>
<div className="upload-items">
<label htmlFor="upload-video">
<div className="upload-static-resource"></div>
<div className="text-container">
<div className="title">Upload audio/video</div>
<div className="title">上传音视频</div>
<div className="description">mp4,mp3</div>
</div>
</label>
......@@ -181,4 +188,4 @@ export const UploadBtn: React.FC<UploadBtnProps> = ({
</div>
</div>
)
}
\ No newline at end of file
}
......@@ -155,7 +155,6 @@ export const RootProvider: React.FC<any> = ({children}) => {
if (location.pathname === '/') {
return;
}
const room = value.roomState;
GlobalStorage.save('agora_room', {
me: room.me,
......
......@@ -82,7 +82,7 @@ function HomePage() {
///////////////////////////////
/*
session.roomName = "test_01__123";// userInfo["class_id"];
// session.yourName = userInfo["nick_name"];
session.role = `${session.yourName}`==="1"?"teacher":"student";
......@@ -128,10 +128,10 @@ function HomePage() {
ref.current = false;
globalStore.stopLoading();
})
*/
///////////////////////////////
///////////////////////////////
/*
endPoint.login({username: session.yourName, password: session.yourPass}).then((userInfo: any) => {
console.log(userInfo);
session.roomName = userInfo["class_id"];// userInfo["class_id"];
......@@ -186,7 +186,7 @@ function HomePage() {
message: err
})
});
*/
}
......
......@@ -50,6 +50,13 @@ export class EndPoint {
userToken: string = '';
recordId: string = '';
async sts () {
let response = await AgoraFetch(`https://omt.iplayabc.com/api/oss/live/static`, {
method: 'GET',
});
let json = await response.json();
return json.data;
}
async login(data: any) {
let json = await AgoraFetchJson({
url: `${ENDPOINT}/api/login`,
......@@ -219,3 +226,5 @@ export class EndPoint {
}
export const endPoint = new EndPoint();
// @ts-ignore
window.endPoint = endPoint;
......@@ -329,7 +329,6 @@ export class RoomStore {
await this.rtmClient.addOrUpdateChannelAttributes(data);
}
async stageUp3333(uid: string) {
debugger
let studentsOrder: any[] = [...this.state.studentsOrder];
const data: any = {};
......@@ -1462,7 +1461,8 @@ export class RoomStore {
}
async exitAll() {
console.log('exitAll')
console.log('exitAll');
try {
if (this.state.me.role == 'teacher') {
await this.rtmClient.clearChannelAttributes()
......@@ -1491,6 +1491,7 @@ export class RoomStore {
console.log("[agora-web] remove event listener");
webClient.exit().then(() => {
console.log("[agora-web] do remove event listener");
GlobalStorage.clear('agora_room');
}).catch(console.warn)
.finally(() => {
roomStore.removeLocalStream();
......
......@@ -2,6 +2,7 @@ import { RoomMessage } from './agora-rtm-client';
import * as _ from 'lodash';
import OSS from 'ali-oss';
import {TOOL_TYPE} from "./types";
import {endPoint} from "../services/agora-end-points";
export interface OSSConfig {
accessKeyId: string,
......@@ -19,7 +20,32 @@ export const ossConfig: OSSConfig = {
"folder": process.env.REACT_APP_AGORA_OSS_BUCKET_FOLDER as string
}
export const ossClient = null ; //new OSS(ossConfig);
export let ossClient: any = null;
let ossExpire = 0;
export async function getOssClient () {
return new Promise( (resolve, reject) => {
if (ossExpire < Date.now()) {
ossClient = null;
}
if (ossClient) {
resolve(ossClient);
return
}
endPoint.sts().then((resp: any) => {
ossExpire = resp.Expiration;
ossClient = new OSS({
region: resp.region,
accessKeyId: resp.AccessKeyId,
accessKeySecret: resp.AccessKeySecret,
stsToken: resp.SecurityToken,
bucket: resp.bucket
});
resolve(ossClient);
})
})
}
const OSS_PREFIX = process.env.REACT_APP_AGORA_RECORDING_OSS_URL as string;
......
......@@ -3,7 +3,7 @@ import uuidv4 from 'uuid/v4';
import {Room, PptConverter, PptKind, Ppt} from 'white-web-sdk';
import MD5 from 'js-md5';
import { whiteboard } from '../stores/whiteboard';
import { resolveFileInfo } from './helper';
import {ossConfig, resolveFileInfo} from './helper';
export type imageSize = {
width: number
......@@ -53,7 +53,7 @@ export class UploadManager {
this.room = room;
this.ossUploadCallback = ossUploadCallback;
}
public async convertFile(
rawFile: File,
pptConverter: PptConverter,
......@@ -210,7 +210,7 @@ export class UploadManager {
}
}
private async handleUploadTask(task: TaskType, onProgress?: PPTProgressListener): Promise<void> {
const fileUrl: string = await this.addFile(`${task.uuid}${task.imageFile.file.name}`, task.imageFile.file, onProgress);
const fileUrl: string = await this.addFile(`/${ossConfig.folder}/${task.uuid}${task.imageFile.file.name}`, task.imageFile.file, onProgress);
this.room.completeImageUpload(task.uuid, fileUrl);
}
......@@ -237,4 +237,4 @@ export class UploadManager {
throw new Error(`upload to ali oss error, status is ${res.res.status}`);
}
}
}
\ No newline at end of file
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment