æå±åæ¯: æ件路å¾: æå±åæ¯: æ件路å¾: æ¤å¤å¯è½åå¨ä¸åéå±ç¤ºçå
容ï¼é¡µé¢ä¸äºå±ç¤ºãæ¨å¯éè¿ç¸å
³ç¼è¾åè½èªæ¥å¹¶ä¿®æ¹ã å¦æ¨ç¡®è®¤å
容æ æ¶å ä¸å½ç¨è¯ / 纯广åå¯¼æµ / æ´å / ä½ä¿è²æ
/ ä¾µæ / çç / èå / æ ä»·å¼å
容æè¿æ³å½å®¶æå
³æ³å¾æ³è§çå
容ï¼å¯ç¹å»æ交è¿è¡ç³è¯ï¼æ们å°å°½å¿«ä¸ºæ¨å¤çã".concat(htmlSafe(branch), "
").concat(htmlSafe(readonly_item), " 确认åæ¶åæ¯ä¸è¿ä¸ªè·¯å¾çåªè¯»æ è®°ï¼\n ");
gitGCModal.confirm("åæ¶åªè¯»", confirmString, function() {
var parentsReadonly = isParentsReadonly(readonly_item)
if (parentsReadonly) {
return gitGCModal.alert('æ示', 'åªè¯»è®°å½ä¸åå¨ï¼æç¶çº§ç®å½ä¸ºåªè¯»',function () {
location.reload()
})
}
$.ajax({
url: "/crudapi/crudapi-admin-web/readonly",
type: 'DELETE',
data: {
branch: branch,
path: readonly_item
},
success: function(res) {
if (res.code !== 0) {
gitGCModal.alert("æ示", res.msg, function() {
location.reload();
})
}else {
$parent.removeClass('readonly-item')
if (gon.readonlyItems) {
gon.readonlyItems.splice(gon.readonlyItems.indexOf(readonly_item), 1)
}
if (type === 'file') {
$icon.removeClass('icon-file-readonly readonly-icon')
$icon.addClass('icon-file')
} else {
$icon.removeClass('icon-folder-readonly readonly-icon')
$icon.addClass('icon-folders')
}
$icon.popup('destroy')
$item.removeAttr('data-readonly')
location.reload();
}
}
})
})
}
// åªè¯»è¿æ»¤
function isTreeItemReadonly(path, readonlyItems) {
var item = readonlyItems.find(function(item) {
if (item.slice(-1) === '/') {
return path.indexOf(item) === INDEX_BEGIN_WITH_READONLY_DIR
} else {
return path === item
}
})
return item !== undefined
}
function getItemPath(path) {
var path_type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'file';
return path_type === 'file' ? path : "".concat(path, "/");
}
// å¯ç¨å¼æ¥åªè¯»å·®å¼åç次æ°
var is_can_readonly = false
// å¼æ¥å¯¹æ件æ è¿è¡åªè¯»å·®å¼åæ¾ç¤º
function markTree() {
$.ajax({
url: "/crudapi/crudapi-admin-web/readonly",
method: 'get',
data: {
"branch": "master"
},
success:function(result) {
var readonlyItems = result.readonly_items
gon.readonlyItems = readonlyItems
$(".tree-list-item").each(function(){
$this = $(this)
var path = $this.attr('data-path')
var type = $this.attr('data-type')
var item_path = getItemPath(path, type)
var readonly = isTreeItemReadonly(item_path, readonlyItems)
$icon = $this.find('i')
$parent = $this.parent('.tree-item')
if (readonly) {
$parent.addClass('readonly-item')
$this.attr('data-readonly', '')
$icon.attr('class', "iconfont icon-".concat(type, "-readonly readonly-icon"));
$icon.attr('data-readonly', '')
$icon.popup({
content: "åªè¯»",
className : {
popup: 'ui popup dark',
},
position: 'top center'
})
} else {
var className = type === 'file' ? 'file' : 'folders'
$this.removeAttr('data-readonly')
$icon.attr('class', "iconfont icon-".concat(className));
$icon.removeAttr('data-readonly')
}
})
}
})
}
// è¥å·²å¼å¯åªè¯»åè½ï¼å¯¹ç®å½è¿è¡åªè¯»å·®å¼åæ è®°
if (is_can_readonly) {
markTree()
}
// æ·»å åªè¯»æ è®°
function addReadonlyMark(path, $item) {
var $icon = $($item.context.children[0])
var $parent = $item.parent('.tree-item')
var type = $parent.data('type')
var branch = $parent.data('branch')
var readonly_item = $item.data('path')
if (type !== 'file') {
readonly_item += "/"
}
var confirmString = "\n
".concat(htmlSafe(branch), "
").concat(htmlSafe(readonly_item), " 确认å°åæ¯ä¸çè¿ä¸ªè·¯å¾æ 记为åªè¯»ï¼\n ");
gitGCModal.confirm("æ è®°åªè¯»", confirmString,function (){
$.ajax({
url: "/crudapi/crudapi-admin-web/readonly",
type: 'POST',
data: {
branch: branch,
path: readonly_item,
},
success: function(res) {
if (res.code !== 0) {
gitGCModal.alert("æ示", res.msg,function (){
location.reload();
})
} else {
// ä¹åæªå¼å¯åªè¯»åè½
if (!is_can_readonly) {
is_can_readonly = true
return markTree()
}
$parent.addClass('readonly-item')
var existReadonlyItems = gon.readonlyItems || []
existReadonlyItems.push(readonly_item)
gon.readonlyItems = existReadonlyItems
$icon.popup({
content: "åªè¯»",
className : {
popup: 'ui popup dark',
},
position: 'top center'
})
if (type === 'file') {
$icon.removeClass('icon-file')
$icon.addClass('icon-file-readonly readonly-icon')
} else {
$icon.removeClass('icon-folders')
$icon.addClass('icon-folder-readonly readonly-icon')
}
$item.attr('data-readonly', '')
location.reload();
}
}
})
})
}
function removeFile(path, file_name) {
var file_name = file_name || path
var content = "ç¡®å®è¦å é¤ %{name} åï¼".replace('%{name}', htmlSafe(file_name));
gitGCModal.confirm("å é¤", content, function() {
$.ajax({
type: "DELETE",
dataType: "JSON",
url: "/crudapi/crudapi-admin-web/delete/" + path,
success: function(res) {
if (res.status != 1) {
var alert_message = res.message || "å é¤å¤±è´¥"
return gitGCModal.alert("æ示", alert_message)
}
if ($('.tree-item-file-name').length == 2) {
window.location.href = '/' + gon.user_project;
if(file_name.toUpperCase()==='LICENSE'){
window.location.reload();
}
} else {
window.location.href = window.location.pathname;
if(file_name.toUpperCase()==='LICENSE'){
window.location.reload();
}
}
}
});
})
}
// å é¤å模å
function removeSubmodule(deleteUrl, $item) {
if (!deleteUrl) return
var file_name = $item.text().trim()
var content = "æ¤æä½æ æ³æ¢å¤ï¼ç¡®å®è¦å é¤å模å%{name}ï¼".replace('%{name}', htmlSafe(file_name));
new GiteeModalHelper({
approveText: "å é¤å¹¶æ交æ¨é",
cancelText: "åæ¶",
okText: "å é¤å¹¶æ交æ¨é",
}).confirm("å é¤", content, function() {
$.ajax({
type: "DELETE",
dataType: "JSON",
url: deleteUrl,
success: function(res) {
if (res.status == 200) {
$item.closest('.row.tree-item').remove();
window.location.reload();
} else {
Flash.error(res.message, 5000)
}
},
error: function (err) {
err.responseJSON && Flash.error(err.responseJSON.message);
},
});
})
}
function rename(file_hex) {
$(".row.tree-item").show();
$(".tree-item-rename").hide();
if($("."+file_hex).is(':hidden') == true) return;
$("."+file_hex).hide();
var _t = $(".rename-"+file_hex);
src = _t.attr('src_text')
if(src==undefined){
newName = _t.find("[name='new_filename']").val()
_t.attr('src_text',newName)
}else{
_t.find("[name='new_filename']").val(_t.attr('src_text'))
}
$(".rename-"+file_hex).css("display","");
}
setTimeout(function(){
$(".popup-save").click(function(){
form = $(this).parents(".ui.form")
file_hex = $(this).parents(".row.tree-item").attr("file_hex");
new_filename = $.trim(form.find("[name='new_filename']").val())
overwrite = false
$('.tree-item-file-name').find('a').each(function(a){
title = $(this).attr('title');
if(title != undefined){
if (title.split('/')[0] == new_filename) {
overwrite = true;
}
}
});
if(overwrite){
form.find("[name='new_filename']").focus();
gitGCModal.alert("æ示", "åå¨ç¸åçæ件å,请修æ¹åéè¯")
return;
}
$.ajax({
type: 'POST',
url: "/crudapi/crudapi-admin-web/rename/"+ form.attr('path').replace(/\+/g, '%20'),
data:
{
new_filename: new_filename
},
success: function(o){
if(o.status == 1){
href = window.location.href.split('?')[0]
window.location.href = href;
}else {
var alert_message = o.message || "éå½å失败"
gitGCModal.alert("æ示", alert_message)
}
},
dataType: "json"
});
})
$(".popup-close").click(function(){
$(".row.tree-item").show();
$(".tree-item-rename").hide();
})
$('.tree-item-file-name, .tree-item-submodule-name').each(function() {
var $this = $(this);
if (typeof $this.parent().attr('file_hex') === 'undefined') {
return;
}
$this.on('contextmenu', function(event) {
event.preventDefault();
createContextMenu($this, event.pageX, event.pageY);
})
})
},1000)
})
1. å¼æºçæ
2. åä½ã人ã软件
3. è¯ä¼°æ¨¡å