mirror of
https://github.com/jumpserver/lina.git
synced 2025-09-19 17:54:37 +00:00
perf: 完成公告功能
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-alert
|
<el-alert
|
||||||
v-if="!isViewed()"
|
v-if="enabled && !isViewed()"
|
||||||
type="success"
|
type="success"
|
||||||
:center="false"
|
:center="false"
|
||||||
:title="this.$t('common.Announcement') + ': ' + announcement.subject"
|
:title="this.$t('common.Announcement') + ': ' + announcement.subject"
|
||||||
@@ -8,39 +8,50 @@
|
|||||||
>
|
>
|
||||||
<span> {{ announcement.content }}</span>
|
<span> {{ announcement.content }}</span>
|
||||||
<span v-if="announcement.link">
|
<span v-if="announcement.link">
|
||||||
<el-link :href="announcement.link" class="link-more"> 查看更多</el-link> <i class="fa fa-share-square-o" />
|
<el-link :href="announcement.link" target="_blank" class="link-more"> 查看更多</el-link> <i class="fa fa-share-square-o" />
|
||||||
</span>
|
</span>
|
||||||
</el-alert>
|
</el-alert>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { mapGetters } from 'vuex'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Announcement',
|
name: 'Announcement',
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
viewedKey: 'AnnouncementViewed',
|
viewedKey: 'AnnouncementViewed'
|
||||||
announcement: {
|
}
|
||||||
id: 'abcd',
|
},
|
||||||
subject: '伟大的中国共产党万岁, 伟大中华民族万岁,伟大的中国人民万岁',
|
computed: {
|
||||||
content: '人民民日报刊发“宣言”文章:我们为什么能够成功,1840年鸦片战争以后,国家蒙辱、人民蒙难、文明蒙尘,\n' +
|
...mapGetters([
|
||||||
' 中华民族遭受了前所未有的劫难。从此,实现中华民族伟大复兴就成为中国人民和中华民族最伟大的梦想,成为近代以来中国全部历史的主题。\n' +
|
'publicSettings'
|
||||||
' 为了实现民族复兴的梦想,中国人民奋起抗争,各种力量前仆后继,各种方案轮番试验.',
|
]),
|
||||||
link: 'https://www.qq.com'
|
announcement() {
|
||||||
}
|
const ann = this.publicSettings.ANNOUNCEMENT
|
||||||
|
return { subject: ann['SUBJECT'], content: ann['CONTENT'], link: ann['LINK'] }
|
||||||
|
},
|
||||||
|
enabled() {
|
||||||
|
return this.publicSettings.ANNOUNCEMENT_ENABLED
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onClose() {
|
onClose() {
|
||||||
localStorage.setItem(this.viewedKey, this.announcement.id)
|
localStorage.setItem(this.viewedKey, this.announcement.subject)
|
||||||
},
|
},
|
||||||
isViewed() {
|
isViewed() {
|
||||||
const viewedId = localStorage.getItem(this.viewedKey)
|
const viewedId = localStorage.getItem(this.viewedKey)
|
||||||
return viewedId === this.announcement.id
|
return viewedId === this.announcement.subject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
.link-more {
|
||||||
|
font-size: 10px;
|
||||||
|
margin-left: 10px;
|
||||||
|
border-bottom: solid 1px;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
70
src/views/settings/Basic/announcement.vue
Normal file
70
src/views/settings/Basic/announcement.vue
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<el-button v-if="!value" type="default" size="mini" @click="visible=true">{{ $t('setting.Enable') }}</el-button>
|
||||||
|
<el-button v-else type="primary" size="mini" @click="visible=true">{{ $t('setting.Setting') }}</el-button>
|
||||||
|
<Dialog
|
||||||
|
v-if="visible"
|
||||||
|
:visible.sync="visible"
|
||||||
|
:title="title"
|
||||||
|
:destroy-on-close="true"
|
||||||
|
:show-cancel="false"
|
||||||
|
:show-confirm="false"
|
||||||
|
width="70%"
|
||||||
|
v-on="$listeners"
|
||||||
|
>
|
||||||
|
<GenericCreateUpdateForm v-bind="config" @submitSuccess="submitSuccess" />
|
||||||
|
</Dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import Dialog from '@/components/Dialog'
|
||||||
|
import { GenericCreateUpdateForm } from '@/layout/components'
|
||||||
|
export default {
|
||||||
|
name: 'Announcement',
|
||||||
|
components: {
|
||||||
|
Dialog, GenericCreateUpdateForm
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
value: {
|
||||||
|
type: Boolean,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
title: '公告',
|
||||||
|
visible: false,
|
||||||
|
config: {
|
||||||
|
fields: [
|
||||||
|
['', ['ANNOUNCEMENT_ENABLED', 'ANNOUNCEMENT']]
|
||||||
|
],
|
||||||
|
fieldsMeta: {
|
||||||
|
ANNOUNCEMENT: {
|
||||||
|
fields: [
|
||||||
|
'SUBJECT', 'CONTENT', 'LINK'
|
||||||
|
],
|
||||||
|
fieldsMeta: {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
successUrl: { name: 'Settings', params: { activeMenu: 'Basic' }},
|
||||||
|
url: '/api/v1/settings/setting/?category=basic',
|
||||||
|
submitMethod() {
|
||||||
|
return 'patch'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
submitSuccess(res) {
|
||||||
|
this.$emit('input', !!res[this.enableField])
|
||||||
|
this.visible = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
@@ -9,6 +9,7 @@
|
|||||||
:submit-method="submitMethod"
|
:submit-method="submitMethod"
|
||||||
:has-detail-in-msg="false"
|
:has-detail-in-msg="false"
|
||||||
:on-perform-success="onPerformSuccess"
|
:on-perform-success="onPerformSuccess"
|
||||||
|
class="form"
|
||||||
/>
|
/>
|
||||||
</IBox>
|
</IBox>
|
||||||
</template>
|
</template>
|
||||||
@@ -17,6 +18,7 @@
|
|||||||
import GenericCreateUpdateForm from '@/layout/components/GenericCreateUpdateForm'
|
import GenericCreateUpdateForm from '@/layout/components/GenericCreateUpdateForm'
|
||||||
import { IBox } from '@/components'
|
import { IBox } from '@/components'
|
||||||
import rules from '@/components/DataForm/rules'
|
import rules from '@/components/DataForm/rules'
|
||||||
|
import Announcement from './announcement'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Basic',
|
name: 'Basic',
|
||||||
@@ -32,6 +34,11 @@ export default {
|
|||||||
'SITE_URL', 'USER_GUIDE_URL',
|
'SITE_URL', 'USER_GUIDE_URL',
|
||||||
'GLOBAL_ORG_DISPLAY_NAME'
|
'GLOBAL_ORG_DISPLAY_NAME'
|
||||||
]
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'功能', [
|
||||||
|
'TICKETS_ENABLED', 'ANNOUNCEMENT_ENABLED'
|
||||||
|
]
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
fieldsMeta: {
|
fieldsMeta: {
|
||||||
@@ -42,6 +49,10 @@ export default {
|
|||||||
hidden: () => {
|
hidden: () => {
|
||||||
return !this.$store.getters.hasValidLicense
|
return !this.$store.getters.hasValidLicense
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
ANNOUNCEMENT_ENABLED: {
|
||||||
|
// label: '公告',
|
||||||
|
component: Announcement
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
successUrl: { name: 'Settings', params: { activeMenu: 'Basic' }},
|
successUrl: { name: 'Settings', params: { activeMenu: 'Basic' }},
|
||||||
@@ -60,5 +71,8 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
.form >>> .form-buttons {
|
||||||
|
padding-top: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
@@ -22,7 +22,7 @@ export default {
|
|||||||
[
|
[
|
||||||
this.$t('common.Basic'),
|
this.$t('common.Basic'),
|
||||||
[
|
[
|
||||||
'EMAIL_SUFFIX', 'TICKETS_ENABLED'
|
'EMAIL_SUFFIX'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
@@ -68,7 +68,7 @@ export default {
|
|||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.form >>> .form-buttons {
|
.form >>> .form-buttons {
|
||||||
padding-top: 50px;
|
padding-top: 30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
import TabPage from '@/layout/components/TabPage'
|
import TabPage from '@/layout/components/TabPage'
|
||||||
import AutoDataForm from '@/components/AutoDataForm'
|
import AutoDataForm from '@/components/AutoDataForm'
|
||||||
import IBox from '@/components/IBox'
|
import IBox from '@/components/IBox'
|
||||||
import Basic from './Basic'
|
import Basic from './Basic/index'
|
||||||
import Email from './Email/index'
|
import Email from './Email/index'
|
||||||
import Auth from './Auth'
|
import Auth from './Auth'
|
||||||
import Ldap from './Ldap'
|
import Ldap from './Ldap'
|
||||||
|
Reference in New Issue
Block a user