支持设置加密文件夹下的文件;优化UI

PyOne3.0
abbeyokgo 5 years ago
parent 7027e468be
commit e73aa60bc3
  1. 6
      admin.py
  2. 4
      config.py.sample
  3. 7
      run.py
  4. 23
      templates/admin/setting.html
  5. 7
      update.sh

@ -21,7 +21,8 @@ admin = Blueprint('admin', __name__,url_prefix='/admin')
############功能函数
def set(key,value,user='A'):
allow_key=['title','downloadUrl_timeout','allow_site','password','client_secret','client_id','share_path','other_name','tj_code','ARIA2_HOST','ARIA2_PORT','ARIA2_SECRET','ARIA2_SCHEME','show_secret']
allow_key=['title','downloadUrl_timeout','allow_site','password','client_secret','client_id','share_path'\
,'other_name','tj_code','ARIA2_HOST','ARIA2_PORT','ARIA2_SECRET','ARIA2_SCHEME','show_secret','encrypt_file']
if key not in allow_key:
return u'禁止修改'
print 'set {}:{}'.format(key,value)
@ -93,6 +94,7 @@ def setting():
password1=request.form.get('password1')
password2=request.form.get('password2')
show_secret=request.form.get('show_secret','no')
encrypt_file=request.form.get('encrypt_file','no')
new_password=password
if ((password1 is not None and password2 is None) or (password1 is None and password2 is not None)):
flash(u'请输入新密码或者二次确认新密码')
@ -109,6 +111,7 @@ def setting():
set('ARIA2_SECRET',ARIA2_SECRET)
set('ARIA2_SCHEME',ARIA2_SCHEME)
set('show_secret',show_secret)
set('encrypt_file',encrypt_file)
set('password',new_password)
# reload()
rd.set('title',title)
@ -120,6 +123,7 @@ def setting():
rd.set('ARIA2_SECRET',ARIA2_SECRET)
rd.set('ARIA2_SCHEME',ARIA2_SCHEME)
rd.set('show_secret',show_secret)
rd.set('encrypt_file',encrypt_file)
rd.set('password',new_password)
flash('更新成功')
return render_template('admin/setting.html')

@ -34,6 +34,10 @@ ARIA2_SCHEME="http"
#搜索模式
show_secret="no"
#文件是否支持加密--no-文件夹加密的情况下,如果直接访问该文件夹下的文件链接,则会跳过密码
encrypt_file="no"
od_users={
"A":{
"client_id":"",

@ -503,8 +503,6 @@ def index(path='A:/'):
# except:
# action='download'
resp,total = FetchData(path=path,page=page,per_page=50,sortby=sortby,order=order,dismiss=True)
if total=='files':
return show(resp['id'],user,action)
#是否有密码
password,_,cur=has_item(path,'.password')
md5_p=md5(path)
@ -518,11 +516,14 @@ def index(path='A:/'):
return resp
if password!=False:
if (not request.cookies.get(md5_p) or request.cookies.get(md5_p)!=password) and has_verify_==False:
if total=='files' and GetConfig('encrypt_file')=="no":
return show(resp['id'],user,action)
return render_template('password.html',path=path,cur_user=user)
if total=='files':
return show(resp['id'],user,action)
readme,ext_r=GetReadMe(path)
head,ext_d=GetHead(path)
#参数
resp,total = FetchData(path=path,page=page,per_page=50,sortby=sortby,order=order,dismiss=True)
pagination=Pagination(query=None,page=page, per_page=50, total=total, items=None)
if path.split(':',1)[-1]=='/':
path=':'.join([path.split(':',1)[0],''])

@ -13,16 +13,19 @@
</div>
<div class="mdui-textfield">
<h4>搜索结果是否展示“加密文件”</h4>
<select class="mdui-select" name="show_secret" mdui-select>
{%if GetConfig('show_secret')=='yes'%}
<option value="no"></option>
<option value="yes" selected></option>
{%else%}
<option value="yes"></option>
<option value="no" selected></option>
{%endif%}
</select>
<h4>搜索结果是否展示“加密文件”(开启之后,前台搜索结果会展示出加密文件夹及加密文件夹下的文件)</h4>
<label class="mdui-switch">
<input type="checkbox" name="show_secret" {%if GetConfig('show_secret')=='yes'%}checked{%endif%}/>
<i class="mdui-switch-icon"></i>
</label>
</div>
<div class="mdui-textfield">
<h4>加密文件夹下的文件是否加密(本选项是配合前一个选项新增的选项,看个人需求开启)</h4>
<label class="mdui-switch">
<input type="checkbox" name="encrypt_file" {%if GetConfig('encrypt_file')=='yes'%}checked{%endif%}/>
<i class="mdui-switch-icon"></i>
</label>
</div>
<div class="mdui-textfield">

@ -19,6 +19,12 @@ update_config(){
if [ $num == 0 ]; then
echo 'show_secret="no"' >> config.py
fi
um=`cat config.py | grep "encrypt_file" | wc -l`
if [ $num == 0 ]; then
echo 'encrypt_file="no"' >> config.py
fi
}
restart(){
@ -37,6 +43,7 @@ echo "2019.01.14更新版本,修复bug"
echo "2019.01.18更新版本,修复bug;添加搜索功能"
echo "2019.01.21更新版本,添加功能:后台直接添加盘符...避免小白添加配置出现各种问题"
echo "2019.01.23更新版本:修复设置了共享目录后设置README/HEAD/密码出错的bug;优化更新文件列表假死的bug"
echo "2019.01.24更新版本:支持设置加密文件夹下的文件;优化UI"
update_config
restart
echo "---------------------------------------------------------------"

Loading…
Cancel
Save