Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
fage2022 committed Aug 14, 2024
1 parent 6072384 commit 87be883
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 39 deletions.
4 changes: 0 additions & 4 deletions demo/react-js/src/styles/common.less
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
/**--------------此处定义全局的样式---------------*/
//主色调
@primary: #C93939;
//顶部高度
@header-height: 84px;
//左侧宽度
@sider-width: 240px;
@sider-bg: #292b37;

10 changes: 0 additions & 10 deletions demo/react-js/src/styles/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
/*
* @description: 样式公共入口(行内样式、引入此配置)
* @author: Jack Chen @懒人码农
* @Date: 2022-04-24 12:02:57
* @LastEditors: Jack Chen
* @LastEditTime: 2022-04-25 09:58:10
*/

const theme = {
// 主题色
primaryColor: "#C93939",
siderWidth: "240px",
sideIconWidth: "80px"
// todo
};

export default theme;
7 changes: 0 additions & 7 deletions demo/react-js/src/styles/mixins.less
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//-----------------此处定义公共的类样式 ------------------------

//页面标题
.page-title {
text-align: center;
}
Expand All @@ -9,7 +6,6 @@
margin-bottom: 10px;
}

//详情表述标题样式
.descriptions-title {
flex: auto;
overflow: hidden;
Expand Down Expand Up @@ -59,15 +55,12 @@
}
}

// 放开antd 的form 的label高度
.special-label{
//修改特殊表单子项label高度
.ant-form-item-label > label{
height: unset;
}
}

//底部footer 操作模块
.footer {
margin-top: 20px;
display: flex;
Expand Down
14 changes: 7 additions & 7 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"author": "CESS <[email protected]>",
"homepage": "https://www.cess.cloud",
"license": "MIT",
"version": "0.2.3",
"version": "0.2.4",
"description": "A js-sdk for Cess Project with file storage",
"main": "./dist/index.js",
"module": "./dist/index.js",
Expand Down
37 changes: 33 additions & 4 deletions src/api/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ export default class File extends ControlBase {
let ret = await this.api.query.fileBank.file(fileHash);
let hu = ret.toHuman();
let data = ret.toJSON();
console.log('======in there======', { ret, hu, data });
if (data && data.owner && data.owner.length > 0) {
for (let i = 0; i < data.owner.length; i++) {
let n = hu.owner[i].fileName;
Expand Down Expand Up @@ -101,8 +100,38 @@ export default class File extends ControlBase {
};
}
}
async queryFileInfo(fileHash) {
try {
let ret = await this.api.query.fileBank.dealMap(fileHash);
if (!ret) {
return { msg: 'ok' };
}
let json = ret.toJSON();
let hu = ret.toHuman();
let data = {
fid: fileHash,
fileSize: json.fileSize,
fileSizeStr: formatterSize(json.fileSize),
user: hu.user.user,
bucketName: hu.user.bucketName,
fileName: hu.user.fileName,
territoryName: hu.user.territoryName,
};
return {
msg: "ok",
data,
};
} catch (error) {
console.error(error);
return {
msg: "ok",
errMsg: error.message,
error: JSON.stringify(error),
};
}
}

async uploadFile(accountId32, fileObj, territory, bucketName, progressCb = null, message = null, sign = null, acc, evmacc) {
async uploadFile(accountId32, fileObj, territory, progressCb = null, message = null, sign = null, acc, evmacc) {
try {
if (!message) {
message = "<Bytes>cess-js-sdk-frontend-" + new Date().valueOf() + "</Bytes>";
Expand All @@ -122,7 +151,7 @@ export default class File extends ControlBase {
}
const headers = {
Territory: territory,
Bucket: bucketName,
Bucket: 'cess',
Account: accountId32,
Message: message,
Signature: sign,
Expand Down Expand Up @@ -152,7 +181,7 @@ export default class File extends ControlBase {

async downloadFile(fileHash, saveName) {
let url = this.gatewayURL + fileHash;
let ret = await fileHelper.download(url, saveName, this.log);
let ret = await fileHelper.download(url + "/download", saveName, this.log);
return ret;
}

Expand Down
4 changes: 2 additions & 2 deletions src/default-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ export default {
'wss://testnet-rpc.cess.network/ws/',
],
keyringOption: { type: "sr25519", ss58Format: 11330 },
gatewayURL: "http://deoss-pub-gateway.cess.cloud/",
gatewayAddr: "cXhwBytXqrZLr1qM5NHJhCzEMckSTzNKw17ci2aHft6ETSQm9"
gatewayURL: "https://deoss-sgp.cess.network",
gatewayAddr: "cXf3X3ugTnivQA9iDRYmLNzxSqybgDtpStBjFcBZEoH33UVaz"
};
8 changes: 4 additions & 4 deletions src/util/file-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
*/
import { sleep } from "./index";
const CHUNK_SIZE = 1024 * 1024;
const CHUNK_SIZE = 1024 * 1024 * 10;
export function download(url, savePath, log) {
return new Promise(async (resolve, reject) => {
try {
Expand Down Expand Up @@ -37,7 +37,7 @@ export async function upload(url, file, header, log, progressCb) {
log("uploading to ", url);

const xhr = new XMLHttpRequest();
xhr.open("PUT", url, true);
xhr.open("PUT", url + "/file", true);
Object.keys(header).forEach((key) => {
xhr.setRequestHeader(key, header[key]);
});
Expand Down Expand Up @@ -109,7 +109,7 @@ export async function uploadWithChunk(url, file, header, log, progressCb, blockI
await sleep(500);
}
stime = new Date().getTime();
res = await postFile(url, file, header, start, end);
res = await postFile(url + "/chunks", file, header, start, end);
if (res.msg == 'ok') {
// console.log(res);
break;
Expand Down Expand Up @@ -159,7 +159,7 @@ function postFile(url, file, header, start, end) {
xhr.setRequestHeader(key, header[key]);
});
xhr.onload = function () {
let data = 'response' in xhr ? xhr.response : xhr.responseText;
let data = 'response' in xhr ? xhr.response : xhr.responseText;
if (xhr.status === 200) {
resolve({ msg: "ok", data });
} else {
Expand Down

0 comments on commit 87be883

Please sign in to comment.