add more update sources

This commit is contained in:
printempw 2016-08-27 16:29:20 +08:00
parent 6e726df521
commit 12d3538904
2 changed files with 78 additions and 46 deletions

View File

@ -10,11 +10,23 @@
return array(
'github' => [
'name' => 'GitHub',
'update_url' => 'https://work.prinzeugen.net/update.json',
'name' => 'GitHub',
'update_url' => 'https://work.prinzeugen.net/update.json',
'description' => '从 <a href="https://prinzeugen.net/">作者主机</a> 上取更新信息GitHub Releases 上取更新包。国内主机可能会奇慢无比,请注意。'
],
'nyavm' => [
'name' => 'NyaVM',
'update_url' => 'http://anycast.cdn.nyavm.net/',
'description' => '啦啦啦'
],
'little_service' => [
'name' => 'LittleService-COS',
'update_url' => 'http://cos.littleservice.cn/bs/update.json',
'description' => '由 <a href="http://littleqiu.net/">Little_Qiu</a> 及其 <a href="http://studio.littleservice.cn/">团队</a> 维护的非官方更新源,国内主机使用可能会获得一定的加速 Buff。不建议海外主机的用户使用。'
],
'local' => [
'name' => 'LocalHost开发用',
'update_url' => 'http://127.0.0.1/test/update.json'
'name' => 'LocalHost',
'update_url' => 'http://127.0.0.1/test/update.json',
'description' => '开发用,请勿选择(炸了别怪我)'
]
);

View File

@ -2,6 +2,13 @@
@section('title', '检查更新')
@section('style')
<style type="text/css">
.description { margin: 7px 0 0 0; color: #555; }
.description a { color: #3c8dbc; }
</style>
@endsection
@section('content')
<!-- Content Wrapper. Contains page content -->
@ -55,7 +62,7 @@
<tr>
<td class="key">下载地址:</td>
<td class="value">
<a href="{{ $updater->getUpdateInfo()['releases'][$updater->latest_version]['release_url'] }}">@GitHub</a>
<a href="{!! $updater->getUpdateInfo()['releases'][$updater->latest_version]['release_url'] !!}">@GitHub</a>
</td>
</tr>
@ -92,7 +99,8 @@
<h3 class="box-title">注意事项</h3>
</div><!-- /.box-header -->
<div class="box-body">
<p>下载更新需要连接 GitHub 服务器,国内主机可能会长时间无响应。</p>
<p>请根据你的主机所在位置(国内/国外)选择更新源。</p>
<p>如错选至相对于你的主机速度较慢的源,可能会造成检查/下载更新页面长时间无响应。</p>
</div><!-- /.box-body -->
</div>
</div>
@ -102,50 +110,53 @@
<div class="box-header with-border">
<h3 class="box-title">更新选项</h3>
</div><!-- /.box-header -->
<div class="box-body">
<form method="post" action="../admin/update">
<div class="box-body">
<?php
if (isset($_POST['submit'])) {
$_POST['check_update'] = isset($_POST['check_update']) ? $_POST['check_update'] : "0";
<form method="post" action="../admin/update">
<div class="box-body">
<?php
if (isset($_POST['submit'])) {
$_POST['check_update'] = isset($_POST['check_update']) ? $_POST['check_update'] : "0";
foreach ($_POST as $key => $value) {
if ($key != "option" && $key != "submit")
Option::set($key, $value);
}
echo '<div class="callout callout-success">设置已保存。</div>';
} ?>
<table class="table">
<tbody>
foreach ($_POST as $key => $value) {
if ($key != "option" && $key != "submit")
Option::set($key, $value);
}
echo '<div class="callout callout-success">设置已保存。</div>';
} ?>
<table class="table">
<tbody>
<tr>
<td class="key">检查更新</td>
<td class="value">
<label for="check_update">
<input {{ (Option::get('check_update') == '1') ? 'checked="true"' : '' }} type="checkbox" id="check_update" name="check_update" value="1"> 自动检查更新并提示
</label>
</td>
</tr>
<tr>
<td class="key">检查更新</td>
<td class="value">
<label for="check_update">
<input {{ (Option::get('check_update') == '1') ? 'checked="true"' : '' }} type="checkbox" id="check_update" name="check_update" value="1"> 自动检查更新并提示
</label>
</td>
</tr>
<tr>
<td class="key">更新源</td>
<td class="value">
<select class="form-control" name="update_source">
@foreach ($updater->getUpdateSources() as $key => $value)
<option {{ (Option::get('update_source') == $key) ? 'selected="selected"' : '' }} value="{{ $key }}">{{ $value['name'] }}</option>
@endforeach
</select>
</td>
</tr>
</tbody>
</table>
</div><!-- /.box-body -->
<div class="box-footer">
<button type="submit" name="submit" class="btn btn-primary">提交</button>
</div>
</form>
</div><!-- /.box-body -->
<?php $current_source = Option::get('update_source'); ?>
<tr>
<td class="key">更新源</td>
<td class="value">
<select class="form-control" name="update_source">
@foreach ($updater->getUpdateSources() as $key => $value)
<option {!! $current_source == $key ? 'selected="selected"' : '' !!} value="{{ $key }}">{{ $value['name'] }}</option>
@endforeach
</select>
@foreach ($updater->getUpdateSources() as $key => $value)
<p class="description" id="{{ $key }}" {!! $current_source == $key ? '' : 'style="display: none;"' !!}>{!! $value['description'] !!}</p>
@endforeach
</td>
</tr>
</tbody>
</table>
</div><!-- /.box-body -->
<div class="box-footer">
<button type="submit" name="submit" class="btn btn-primary">提交</button>
</div>
</form>
</div>
</div>
@ -154,3 +165,12 @@
</div><!-- /.content-wrapper -->
@endsection
@section('script')
<script>
$('select[name=update_source]').change(function() {
$('.description').hide();
$('#' + this.value).show();
});
</script>
@endsection