2024-09-19 11:12:10 +08:00
|
|
|
import { siteRoot, historyRepoID, fileServerRoot } from './constants';
|
2018-10-09 10:56:59 +08:00
|
|
|
import { Utils } from './utils';
|
2018-09-12 17:01:48 +08:00
|
|
|
class URLDecorator {
|
|
|
|
|
|
|
|
static getUrl(options) {
|
|
|
|
let url = '';
|
|
|
|
let params = '';
|
|
|
|
switch (options.type) {
|
2019-01-31 17:37:02 +08:00
|
|
|
case 'download_historic_file':
|
2021-08-31 11:28:39 +08:00
|
|
|
params = 'p=' + Utils.encodePath(options.filePath);
|
2019-01-31 17:37:02 +08:00
|
|
|
url = siteRoot + 'repo/' + historyRepoID + '/' + options.objID + '/download?' + params;
|
|
|
|
break;
|
|
|
|
case 'download_file_url':
|
2024-09-20 12:35:42 +08:00
|
|
|
url = fileServerRoot + 'repos/' + options.repoID + '/files/' + Utils.encodePath(options.filePath) + '/?op=download';
|
2019-01-31 17:37:02 +08:00
|
|
|
break;
|
|
|
|
case 'file_revisions':
|
2019-02-11 17:38:28 +08:00
|
|
|
params = 'p=' + Utils.encodePath(options.filePath);
|
2019-01-31 17:37:02 +08:00
|
|
|
url = siteRoot + 'repo/file_revisions/' + options.repoID + '/?' + params;
|
|
|
|
break;
|
|
|
|
case 'open_via_client':
|
|
|
|
url = 'seafile://openfile?repo_id=' + options.repoID + '&path=' + Utils.encodePath(options.filePath);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
url = '';
|
|
|
|
break;
|
2018-09-12 17:01:48 +08:00
|
|
|
}
|
|
|
|
return url;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-04-12 15:54:05 +08:00
|
|
|
export default URLDecorator;
|