1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-04 08:28:11 +00:00

Wiki optimized third (#2406)

This commit is contained in:
shanshuirenjia
2018-09-29 15:47:53 +08:00
committed by Daniel Pan
parent 5cffd4cb69
commit 3ab4cbff4f
22 changed files with 612 additions and 107 deletions

View File

@@ -1,32 +1,20 @@
const siteRoot = window.app.config.siteRoot;
const repoID = window.fileHistory.pageOptions.repoID;
import {siteRoot, historyRepoID, fileServerRoot } from '../components/constants';
import { encodePath } from '../components/utils';
class URLDecorator {
static getUrl(options) {
let url = '';
let params = '';
switch (options.type) {
case 'user_profile':
url = siteRoot + 'profile/' + options.username + '/';
break;
case 'common_lib':
url = siteRoot + '#common/lib/' + repoID + options.path;
break;
case 'view_lib_file':
url = siteRoot + 'lib/' + repoID + '/file' + options.filePath;
break;
case 'download_historic_file':
params = 'p=' + options.filePath;
url = siteRoot + 'repo/' + repoID + '/' + options.objID + '/download?' + params;
url = siteRoot + 'repo/' + historyRepoID + '/' + options.objID + '/download?' + params;
break;
case 'view_historic_file':
params = 'obj_id=' + options.objID + '&commit_id=' + options.commitID + '&p=' + options.filePath;
url = siteRoot + 'repo/' + options.repoID + 'history/files/?' + params;
case 'download_dir_zip_url':
url = fileServerRoot + 'zip/' + options.token;
break;
case 'diff_historic_file':
params = 'commit_id=' + options.commitID + '&p=' + options.filePath;
url = siteRoot + 'repo/text_diff/' + repoID + '/?' + params;
case 'download_file_url':
url = siteRoot + 'lib/' + options.repoID + "/file" + encodePath(options.filePath) + "?dl=1";
break;
default:
url = '';