perf: 优化首页

This commit is contained in:
kuaifan 2023-02-15 13:30:34 +08:00
parent be8cd95ae4
commit 6a2c56da3e
6 changed files with 218 additions and 26 deletions

View File

@ -800,6 +800,38 @@ class SystemController extends AbstractController
return $data;
}
/**
* @api {get} api/system/get/showitem 18. 首页显示ITEM
*
* @apiDescription 用于判断首页是否显示pro、github、更新日志...
* @apiVersion 1.0.0
* @apiGroup system
* @apiName get__showitem
*
* @apiSuccess {Number} ret 返回状态码1正确、0错误
* @apiSuccess {String} msg 返回信息(错误描述)
* @apiSuccess {Object} data 返回数据
*/
public function get__showitem()
{
$logPath = base_path('CHANGELOG.md');
$logContent = "";
$logVersion = "";
if (file_exists($logPath)) {
$logContent = file_get_contents($logPath);
preg_match("/## \[(.*?)\]/", $logContent, $matchs);
if ($matchs) {
$logVersion = $matchs[1] === "Unreleased" ? $matchs[1] : "v{$matchs[1]}";
}
}
return Base::retSuccess('success', [
'pro' => str_contains(Request::getHost(), "dootask.com") || str_contains(Request::getHost(), "127.0.0.1"),
'github' => env('GITHUB_URL') ?: false,
'updateLog' => $logContent ?: false,
'updateVer' => $logVersion,
]);
}
/**
* @api {get} api/system/get/starthome 18. 启动首页设置信息
*

View File

@ -8,7 +8,11 @@
<div class="logo no-dark-content"></div>
</div>
<div class="header-nav-box header-nav-boxs" v-if="windowWidth > 780">
<Button v-if="proShow" class="header-right-pro no-dark-content" size="small" @click="onPro">{{$L('Pro版')}}</Button>
<template v-if="windowWidth >= 820">
<Button v-if="showItem.pro" class="header-right-pro no-dark-content" size="small" @click="onPro">{{$L('Pro版')}}</Button>
<a v-if="showItem.github" class="header-right-github" :href="showItem.github" target="_blank"><Icon type="logo-github"/></a>
<div v-if="showItem.updateLog" class="header-right-uplog" @click="onUplog">{{$L('更新日志')}}</div>
</template>
<div class="header-right-1">
<Dropdown trigger="click" @on-click="onLanguage">
@ -25,7 +29,7 @@
</DropdownMenu>
</Dropdown>
</div>
<div class="header-right-2">
<div v-if="windowWidth >= 980" class="header-right-2">
<Dropdown trigger="click" @on-click="setTheme">
<a href="javascript:void(0)" class="header-right-2-dropdown">
{{$L('主题皮肤')}}
@ -40,8 +44,13 @@
</DropdownMenu>
</Dropdown>
</div>
<div class="header-right-3" @click="register">{{ $L("注册帐号") }}</div>
<div class="header-right-4 no-dark-content" @click="login">{{ $L("登录") }}</div>
<div v-if="userId > 0" class="header-right-5" @click="login">
<UserAvatar :userid="userId" :size="38"/>
</div>
<template v-else>
<div class="header-right-3" @click="register">{{ $L("注册帐号") }}</div>
<div class="header-right-4 no-dark-content" @click="login">{{ $L("登录") }}</div>
</template>
</div>
<div class="header-nav-box header-nav-boxs" v-else>
<Dropdown trigger="click">
@ -49,8 +58,13 @@
<Icon type="md-menu" class="header-nav-more no-dark-content"/>
</a>
<DropdownMenu slot="list">
<DropdownItem @click.native="login">{{ $L("登录") }}</DropdownItem>
<DropdownItem @click.native="register">{{ $L("注册帐号") }}</DropdownItem>
<DropdownItem v-if="userId > 0" @click.native="login">
<UserAvatar :userid="userId" show-name :show-icon="false"/>
</DropdownItem>
<template v-else>
<DropdownItem @click.native="login">{{ $L("登录") }}</DropdownItem>
<DropdownItem @click.native="register">{{ $L("注册帐号") }}</DropdownItem>
</template>
<Dropdown placement="right-start" @on-click="onLanguage" transfer>
<DropdownItem>
<div class="header-nav-dropdown-item">
@ -194,22 +208,49 @@
<div class="footer-copyright" v-if="homeFooter" v-html="homeFooter"></div>
</div>
</div>
<!--更新日志-->
<Modal
v-model="uplogShow"
:fullscreen="uplogFull"
class-name="page-index-uplog">
<div slot="header">
<div class="uplog-head">
<div class="uplog-title">{{$L('更新日志')}}</div>
<Tag v-if="showItem.updateVer" color="volcano">{{showItem.updateVer}}</Tag>
</div>
</div>
<MarkdownPreview class="uplog-body scrollbar-overlay" :initialValue="showItem.updateLog"/>
<div slot="footer" class="adaption">
<Button type="default" @click="uplogFull=!uplogFull">{{$L(uplogFull ? '缩小查看' : '全屏查看')}}</Button>
</div>
</Modal>
</div>
</template>
<script>
import {mapState} from "vuex";
import {languageList, languageType, setLanguage} from "../language";
import MarkdownPreview from "../components/MDEditor/components/preview";
export default {
components: {MarkdownPreview},
data() {
return {
languageList,
languageType,
proShow: false,
showItem: {
pro: false,
github: '',
updateLog: '',
updateVer: ''
},
needStartHome: false,
homeFooter: '',
uplogShow: false,
uplogFull: false,
};
},
computed: {
@ -242,7 +283,7 @@ export default {
}
}
}
this.proShow = $A.strExists(window.location.host, "dootask.com") || $A.strExists(window.location.host, "127.0.0.1")
this.getShowItem();
this.getNeedStartHome();
},
@ -251,18 +292,36 @@ export default {
this.goForward({name: 'pro'});
},
onUplog() {
this.uplogShow = true
},
setTheme(mode) {
this.$store.dispatch("setTheme", mode)
},
login() {
this.goForward({name: 'login'});
if (this.userId > 0) {
this.goForward({name: 'manage-dashboard'}, true);
} else {
this.goForward({name: 'login'}, true);
}
},
register() {
this.goForward({name: 'login', query: {type: "reg"}});
},
getShowItem() {
this.$store.dispatch("call", {
url: "system/get/showitem",
}).then(({data}) => {
this.showItem = data
}).catch(_ => {
this.showItem = {}
});
},
getNeedStartHome() {
if (this.isSoftware) {
this.needStartHome = false;

View File

@ -378,6 +378,8 @@ export default {
operateStyles: {},
operateVisible: false,
operateItem: {},
needStartHome: false,
}
},
@ -395,6 +397,12 @@ export default {
this.$store.dispatch("getUserInfo").catch(_ => {})
this.$store.dispatch("getTaskPriority").catch(_ => {})
this.$store.dispatch("getReportUnread", 0)
//
this.$store.dispatch("needHome").then(_ => {
this.needStartHome = true
}).catch(_ => {
this.needStartHome = false
})
},
beforeDestroy() {
@ -517,11 +525,12 @@ export default {
},
menu() {
const {userIsAdmin} = this;
const {userIsAdmin, needStartHome} = this;
const array = [
{path: 'taskBrowse', name: '最近打开的任务'}
];
if (userIsAdmin) {
return [
{path: 'taskBrowse', name: '最近打开的任务'},
array.push(...[
{path: 'personal', name: '偏好设置', divided: true},
{path: 'system', name: '系统设置'},
{path: 'clearCache', name: '清除缓存'},
@ -532,13 +541,9 @@ export default {
{path: 'archivedProject', name: '已归档的项目'},
{path: 'team', name: '团队管理', divided: true},
{path: 'logout', name: '退出登录', style: {color: '#f40'}, divided: true},
]
])
} else {
return [
{path: 'taskBrowse', name: '最近打开的任务'},
array.push(...[
{path: 'personal', name: '偏好设置', divided: true},
{path: 'clearCache', name: '清除缓存'},
@ -546,10 +551,19 @@ export default {
{path: 'workReport', name: '工作报告', divided: true},
{path: 'archivedProject', name: '已归档的项目'},
{path: 'logout', name: '退出登录', style: {color: '#f40'}, divided: true},
]
])
}
if (needStartHome) {
array.push(...[
{path: 'goHome', name: '打开首页', divided: true},
{path: 'logout', name: '退出登录', style: {color: '#f40'}}
])
} else {
array.push(...[
{path: 'logout', name: '退出登录', style: {color: '#f40'}, divided: true}
])
}
return array
},
columns() {
@ -735,6 +749,11 @@ export default {
$A.reloadUrl()
});
return;
case 'goHome':
if (this.needStartHome) {
this.goForward({name: 'index', query: {action: 'index'}});
}
return;
case 'logout':
$A.modalConfirm({
title: '退出登录',

View File

@ -239,6 +239,9 @@ body {
&.ivu-modal-fullscreen {
top: 0;
.ivu-modal-content {
border-radius: 0;
}
}
.ivu-modal-header,

View File

@ -39,6 +39,7 @@
}
.header-right-pro {
margin-left: 28px;
padding: 0 10px;
font-size: 12px;
color: #f6ca9d;
@ -47,8 +48,23 @@
border: 0;
}
.header-right-github {
margin-left: 28px;
font-size: 24px;
display: flex;
align-items: center;
cursor: pointer;
color: #ffffff;
}
.header-right-uplog {
margin-left: 28px;
font-size: 16px;
cursor: pointer;
}
.header-right-1 {
margin-left: 30px;
margin-left: 28px;
display: flex;
.header-right-1-dropdown {
@ -59,7 +75,7 @@
.header-right-2 {
font-size: 16px;
margin-left: 30px;
margin-left: 28px;
cursor: pointer;
.header-right-2-dropdown {
@ -70,7 +86,7 @@
.header-right-3 {
font-size: 16px;
margin: 0 30px 0 30px;
margin: 0 28px;
cursor: pointer;
}
@ -85,6 +101,10 @@
cursor: pointer;
padding: 0 10px 0 10px;
}
.header-right-5 {
margin-left: 28px;
}
}
.header-nav-boxs {
@ -306,6 +326,65 @@
}
}
.page-index-uplog {
.uplog-head {
display: flex;
align-items: center;
.uplog-title {
display: inline-block;
vertical-align: middle;
font-size: 18px;
color: $primary-title-color;
font-weight: 500;
margin-right: 6px;
}
}
.ivu-modal-body {
padding: 0 32px !important;
.uplog-body {
max-height: 240px;
overflow-x: hidden;
.markdown-preview {
margin: -20px -12px;
h1 {
font-size: 24px;
margin-bottom: 12px;
&:first-child {
padding-top: 0;
}
}
h2 {
font-size: 18px !important;
padding-top: 2px !important;
}
ul {
li {
padding: 2px 0 2px 2px !important;
&:after {
top: 10px !important;
width: 6px !important;
height: 6px !important;
}
}
}
}
}
}
.ivu-modal-fullscreen {
.ivu-modal-body {
padding: 0 16px !important;
margin: 16px 0 !important;
.uplog-body {
max-height: none;
overflow-x: auto;
.markdown-preview {
margin: 0;
}
}
}
}
}
@media screen and (max-width: 1440px) {
.page-index {
.page-warp {

View File

@ -203,7 +203,7 @@
{"CN": "最后在线","EN": "Last online","TC": "最後在線","KM": "លើអ៊ីនធឺណិតចុងក្រោយ","TH": "ออนไลน์ล่าสุด","KO": "마지막 온라인","JA": "ラストオンライン"},
{"CN": "最后修改","EN": "Last Review","TC": "最後修改","KM": "ការពិនិត្យចុងក្រោយ","TH": "รีวิวครั้งสุดท้าย","KO": "마지막 검토","JA": "最後の口コミ"},
{"CN": "准备发布","EN": "Ready to release","TC": "準備發布","KM": "ត្រៀមខ្លួនរួចរាល់ក្នុងការដោះលែង","TH": "พร้อมที่จะปล่อย","KO": "릴리스 준비","JA": "リリースする準備ができて"},
{"CN": "注册帐号","EN": "Register Account","TC": "註冊帳號","KM": "ចុះឈ្មោះគណនី","TH": "บัญชีลงทะเบียน","KO": "계정 등록","JA": "アカウント登録"},
{"CN": "注册帐号","EN": "Sign up","TC": "註冊帳號","KM": "ចុះឈ្មោះគណនី","TH": "บัญชีลงทะเบียน","KO": "계정 등록","JA": "アカウント登録"},
{"CN": "注册成功","EN": "Registration success","TC": "註冊成功","KM": "ការចុះឈ្មោះជោគជ័យ","TH": "ความสำเร็จการลงทะเบียน","KO": "등록 성공","JA": "登録完了"},
{"CN": "重置密码","EN": "Reset Password","TC": "重置密碼","KM": "កំណត់ពាក្យសម្ងាត់ឡើងវិញ","TH": "รีเซ็ตรหัสผ่าน","KO": "암호를 재설정","JA": "パスワードを再設定する"},
{"CN": "正在研发","EN": "R & D","TC": "正在研發","KM": "r & d","TH": "R & D","KO": "R & D.","JA": "RD"},