1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-13 13:50:07 +00:00

merge 10.0

This commit is contained in:
杨顺强
2023-11-24 14:44:18 +08:00
parent 0909025605
commit 087700d9fb
6 changed files with 31 additions and 11 deletions

View File

@@ -8,6 +8,7 @@
"name": "seahub-frontend", "name": "seahub-frontend",
"version": "0.1.0", "version": "0.1.0",
"dependencies": { "dependencies": {
"@codemirror/view": "^6.22.0",
"@gatsbyjs/reach-router": "1.3.9", "@gatsbyjs/reach-router": "1.3.9",
"@seafile/react-image-lightbox": "2.0.2", "@seafile/react-image-lightbox": "2.0.2",
"@seafile/resumablejs": "1.1.16", "@seafile/resumablejs": "1.1.16",

View File

@@ -3,6 +3,7 @@
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"dependencies": { "dependencies": {
"@codemirror/view": "^6.22.0",
"@gatsbyjs/reach-router": "1.3.9", "@gatsbyjs/reach-router": "1.3.9",
"@seafile/react-image-lightbox": "2.0.2", "@seafile/react-image-lightbox": "2.0.2",
"@seafile/resumablejs": "1.1.16", "@seafile/resumablejs": "1.1.16",

View File

@@ -1,6 +1,7 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import CodeMirror from '@uiw/react-codemirror'; import CodeMirror from '@uiw/react-codemirror';
import { EditorView } from "@codemirror/view"
import { loadLanguage } from '@uiw/codemirror-extensions-langs'; import { loadLanguage } from '@uiw/codemirror-extensions-langs';
import { Utils } from '../../utils/utils'; import { Utils } from '../../utils/utils';
@@ -64,6 +65,7 @@ class SeafileCodeMirror extends React.Component {
{...options} {...options}
onChange={this.onChange} onChange={this.onChange}
basicSetup={DEFAULT_CODEMIRROR_OPTIONS} basicSetup={DEFAULT_CODEMIRROR_OPTIONS}
extensions={[EditorView.lineWrapping]}
/> />
</div> </div>
); );

View File

@@ -7,6 +7,7 @@ import FileView from './components/file-view/file-view';
import SeafileCodeMirror from './components/seafile-codemirror'; import SeafileCodeMirror from './components/seafile-codemirror';
import FileViewTip from './components/file-view/file-view-tip'; import FileViewTip from './components/file-view/file-view-tip';
import { seafileAPI } from './utils/seafile-api'; import { seafileAPI } from './utils/seafile-api';
import { Utils } from './utils/utils';
import './css/text-file-view.css'; import './css/text-file-view.css';
const { const {
@@ -64,7 +65,7 @@ class ViewFileText extends React.Component {
if (!this.isParticipant) { if (!this.isParticipant) {
this.addParticipant(); this.addParticipant();
} }
let dirPath = '/'; let dirPath = Utils.getDirName(filePath);
return ( return (
seafileAPI.getUpdateLink(repoID, dirPath).then((res) => { seafileAPI.getUpdateLink(repoID, dirPath).then((res) => {
const uploadLink = res.data; const uploadLink = res.data;

View File

@@ -234,8 +234,13 @@ class ShareLinks(APIView):
tmp_key = f"{repo_id}_{path}" tmp_key = f"{repo_id}_{path}"
if tmp_key not in repo_folder_permission_dict: if tmp_key not in repo_folder_permission_dict:
permission = seafile_api.check_permission_by_path(repo_id, path, username) try:
permission = seafile_api.check_permission_by_path(repo_id,
path,
username)
repo_folder_permission_dict[tmp_key] = permission repo_folder_permission_dict[tmp_key] = permission
except Exception:
repo_folder_permission_dict[tmp_key] = ''
links_info = [] links_info = []
for fs in fileshares: for fs in fileshares:

View File

@@ -230,7 +230,7 @@ class WOPIFilesView(APIView):
dirent = seafile_api.get_dirent_by_path(repo_id, file_path) dirent = seafile_api.get_dirent_by_path(repo_id, file_path)
if dirent: if dirent:
last_modified = datetime.datetime.utcfromtimestamp(dirent.mtime) last_modified = datetime.datetime.utcfromtimestamp(dirent.mtime)
result['LastModifiedTime'] = last_modified.isoformat() result['LastModifiedTime'] = last_modified.strftime('%Y-%m-%dT%H:%M:%S.%fZ')
except Exception as e: except Exception as e:
logger.error(e) logger.error(e)
return HttpResponse(json.dumps({}), status=500, return HttpResponse(json.dumps({}), status=500,
@@ -245,14 +245,16 @@ class WOPIFilesView(APIView):
absolute_uri = request.build_absolute_uri('/') absolute_uri = request.build_absolute_uri('/')
result['PostMessageOrigin'] = urllib.parse.urljoin(absolute_uri, SITE_ROOT).strip('/') result['PostMessageOrigin'] = urllib.parse.urljoin(absolute_uri, SITE_ROOT).strip('/')
result['HideSaveOption'] = True result['HideSaveOption'] = True if not can_edit else False
result['HideExportOption'] = True result['HideExportOption'] = True if not can_download else False
result['EnableOwnerTermination'] = True result['EnableOwnerTermination'] = True
result['SupportsLocks'] = True result['SupportsLocks'] = True
result['SupportsGetLock'] = True result['SupportsGetLock'] = True
result['DisablePrint'] = True if not can_download else False result['DisablePrint'] = True if not can_download else False
result['HidePrintOption'] = True if not can_download else False result['HidePrintOption'] = True if not can_download else False
result['DisableCopy'] = True if not can_download else False
result['DisableExport'] = True if not can_download else False
result['SupportsUpdate'] = True if can_edit else False result['SupportsUpdate'] = True if can_edit else False
result['UserCanWrite'] = True if can_edit else False result['UserCanWrite'] = True if can_edit else False
@@ -449,14 +451,22 @@ class WOPIFilesContentsView(APIView):
resp = requests.post(update_url, files=files, data=data) resp = requests.post(update_url, files=files, data=data)
if resp.status_code != 200: if resp.status_code != 200:
logger.error('update_url: {}'.format(update_url)) logger.error('update_url: {}'.format(update_url))
logger.error('parameter file: {}'.format(files['file'][:100])) logger.error('parameter file: {}'.format(files['file'][1][:100]))
logger.error('parameter file_name: {}'.format(files['file_name'])) logger.error('parameter file_name: {}'.format(files['file'][0]))
logger.error('parameter target_file: {}'.format(files['target_file'])) logger.error('parameter target_file: {}'.format(data['target_file']))
logger.error('response: {}'.format(resp.__dict__)) logger.error('response: {}'.format(resp.__dict__))
return HttpResponse(json.dumps({}), status=500, content_type=json_content_type)
except Exception as e: except Exception as e:
logger.error(e) logger.error(e)
return HttpResponse(json.dumps({}), status=500, return HttpResponse(json.dumps({}), status=500,
content_type=json_content_type) content_type=json_content_type)
return HttpResponse(json.dumps({}), status=200, result = dict()
content_type=json_content_type) try:
dirent = seafile_api.get_dirent_by_path(repo_id, file_path)
if dirent:
last_modified = datetime.datetime.utcfromtimestamp(dirent.mtime)
result['LastModifiedTime'] = last_modified.strftime('%Y-%m-%dT%H:%M:%S.%fZ')
except Exception as e:
logger.error(e)
return HttpResponse(json.dumps(result), status=200, content_type=json_content_type)