mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-14 04:32:49 +00:00
perf: 新增查看更新日志
This commit is contained in:
parent
d6a7c19cbf
commit
244991e8e8
@ -1059,24 +1059,38 @@ class SystemController extends AbstractController
|
||||
* @apiGroup system
|
||||
* @apiName get__updatelog
|
||||
*
|
||||
* @apiParam {Number} [take] 获取数量,10-100
|
||||
*
|
||||
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
|
||||
* @apiSuccess {String} msg 返回信息(错误描述)
|
||||
* @apiSuccess {Object} data 返回数据
|
||||
*/
|
||||
public function get__updatelog()
|
||||
{
|
||||
$take = min(100, max(10, intval(Request::input('take'))));
|
||||
$logPath = base_path('CHANGELOG.md');
|
||||
$logContent = "";
|
||||
$logVersion = "";
|
||||
$logContent = "";
|
||||
$logResults = [];
|
||||
if (file_exists($logPath)) {
|
||||
$logContent = file_get_contents($logPath);
|
||||
preg_match("/## \[(.*?)\]/", $logContent, $matchs);
|
||||
if ($matchs) {
|
||||
$logVersion = $matchs[1] === "Unreleased" ? $matchs[1] : "v{$matchs[1]}";
|
||||
$content = file_get_contents($logPath);
|
||||
$sections = preg_split("/## \[(.*?)\]/", $content, -1, PREG_SPLIT_DELIM_CAPTURE);
|
||||
for ($i = 1; $i < count($sections) && count($logResults) < $take; $i += 2) {
|
||||
$logResults[] = [
|
||||
'title' => $sections[$i],
|
||||
'content' => $sections[$i + 1]
|
||||
];
|
||||
}
|
||||
}
|
||||
if ($logResults) {
|
||||
$logVersion = $logResults[0]['title'];
|
||||
$logContent = implode("\n", array_map(function($item) {
|
||||
return "## " . $item['title'] . $item['content'];
|
||||
}, $logResults));
|
||||
}
|
||||
return Base::retSuccess('success', [
|
||||
'updateLog' => $logContent ?: false,
|
||||
'logVersion' => $logVersion,
|
||||
'updateLog' => $logContent,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@ -16,17 +16,15 @@
|
||||
v-for="(item, key) in menu"
|
||||
:key="key"
|
||||
:class="classNameRoute(item.path, item.divided)"
|
||||
@click="toggleRoute(item.path)">{{$L(item.name)}}</li>
|
||||
<li
|
||||
v-if="!!clientNewVersion"
|
||||
class="flex"
|
||||
:class="classNameRoute('version', true)"
|
||||
@click="toggleRoute('version')">
|
||||
<AutoTip disabled>{{$L('版本')}}: {{version}}</AutoTip>
|
||||
<Badge :text="clientNewVersion"/>
|
||||
</li>
|
||||
<li v-else class="version divided" @click="onVersion">
|
||||
<AutoTip>{{$L('版本')}}: {{version}}</AutoTip>
|
||||
@click="toggleRoute(item.path)">
|
||||
<template v-if="item.path === 'version'">
|
||||
<AutoTip disabled>{{$L(item.name)}}</AutoTip>
|
||||
<Badge v-if="!!clientNewVersion" :text="clientNewVersion"/>
|
||||
</template>
|
||||
<template v-else-if="item.path === 'version-show'">
|
||||
<AutoTip>{{$L(item.name)}}: {{version}}</AutoTip>
|
||||
</template>
|
||||
<span v-else>{{$L(item.name)}}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@ -101,6 +99,8 @@ export default {
|
||||
])
|
||||
}
|
||||
menu.push(...[
|
||||
{path: 'version', name: '更新日志', divided: true},
|
||||
{path: 'version-show', name: '版本'},
|
||||
{path: 'clearCache', name: '清除缓存', divided: true},
|
||||
{path: 'logout', name: '退出登录'},
|
||||
])
|
||||
@ -163,8 +163,8 @@ export default {
|
||||
});
|
||||
break;
|
||||
|
||||
case 'version':
|
||||
Store.set('updateNotification', null);
|
||||
case 'version-show':
|
||||
this.onVersion();
|
||||
break;
|
||||
|
||||
case 'privacy':
|
||||
@ -176,6 +176,10 @@ export default {
|
||||
break;
|
||||
|
||||
default:
|
||||
if (path === 'version' && !!this.clientNewVersion) {
|
||||
Store.set('updateNotification', null);
|
||||
return
|
||||
}
|
||||
this.goForward({name: 'manage-setting-' + path});
|
||||
break;
|
||||
}
|
||||
@ -201,6 +205,7 @@ export default {
|
||||
|
||||
classNameRoute(path, divided) {
|
||||
return {
|
||||
"flex": true,
|
||||
"active": this.windowLandscape && this.routeName === `manage-setting-${path}`,
|
||||
"divided": !!divided
|
||||
};
|
||||
|
||||
55
resources/assets/js/pages/manage/setting/version.vue
Normal file
55
resources/assets/js/pages/manage/setting/version.vue
Normal file
@ -0,0 +1,55 @@
|
||||
<template>
|
||||
<div class="setting-item submit">
|
||||
<div class="version-box">
|
||||
<div v-if="loadIng" class="version-load">{{$L('加载中...')}}</div>
|
||||
<VMPreview v-else :value="updateLog"/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="scss">
|
||||
.version-box {
|
||||
overflow: auto;
|
||||
padding: 24px 34px;
|
||||
.version-load {
|
||||
font-size: 16px;
|
||||
}
|
||||
.vuepress-markdown-body {
|
||||
padding: 0 !important;
|
||||
color: inherit;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
import VMPreview from "../../../components/VMEditor/preview.vue";
|
||||
|
||||
export default {
|
||||
components: {VMPreview},
|
||||
data() {
|
||||
return {
|
||||
loadIng: 0,
|
||||
updateLog: '',
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.getLog();
|
||||
},
|
||||
methods: {
|
||||
getLog() {
|
||||
this.loadIng++;
|
||||
this.$store.dispatch("call", {
|
||||
url: 'system/get/updatelog',
|
||||
data: {
|
||||
take: 20
|
||||
}
|
||||
}).then(({data}) => {
|
||||
this.updateLog = data.updateLog;
|
||||
}).catch(({msg}) => {
|
||||
$A.messageError(msg);
|
||||
}).finally(_ => {
|
||||
this.loadIng--;
|
||||
});
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
5
resources/assets/js/routes.js
vendored
5
resources/assets/js/routes.js
vendored
@ -94,6 +94,11 @@ export default [
|
||||
path: 'system',
|
||||
component: () => import('./pages/manage/setting/system.vue'),
|
||||
},
|
||||
{
|
||||
name: 'manage-setting-version',
|
||||
path: 'version',
|
||||
component: () => import('./pages/manage/setting/version.vue'),
|
||||
},
|
||||
{
|
||||
name: 'manage-setting-delete',
|
||||
path: 'delete',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user