forked from element-plus/element-plus
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
207 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const system: LViewsSystem = { | ||
customizeSiteTitle: 'Customize Site Title', | ||
siteTitle: 'Site Title', | ||
}; | ||
|
||
export default system; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const system: LViewsSystem = { | ||
customizeSiteTitle: '是否自定义网站标题', | ||
siteTitle: '网站标题', | ||
}; | ||
|
||
export default system; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
interface LViewsSystem { | ||
customizeSiteTitle: string; | ||
siteTitle: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
export declare global { | ||
interface Setting extends BaseModel { | ||
key: string; | ||
value: { [key: string]: string }; | ||
value: { [key: string]: any }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import {GetterTree, Module, MutationTree} from 'vuex'; | ||
|
||
declare global { | ||
interface SystemStoreModule extends Module<SystemStoreState, RootStoreState> { | ||
getters: SystemStoreGetters; | ||
mutations: SystemStoreMutations; | ||
actions: SystemStoreActions; | ||
} | ||
|
||
interface SystemStoreState { | ||
siteTitle: Setting; | ||
} | ||
|
||
interface SystemStoreGetters extends GetterTree<SystemStoreState, RootStoreState> { | ||
} | ||
|
||
interface SystemStoreMutations extends MutationTree<SystemStoreState> { | ||
setSiteTitle: StoreMutation<SystemStoreState, Setting>; | ||
} | ||
|
||
interface SystemStoreActions extends BaseStoreActions { | ||
getSiteTitle: StoreAction<SystemStoreState>; | ||
saveSiteTitle: StoreAction<SystemStoreState>; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import {RouteRecordRaw} from 'vue-router'; | ||
|
||
const endpoint = 'system'; | ||
|
||
export default [ | ||
{ | ||
name: 'SystemDetail', | ||
path: endpoint, | ||
component: () => import('@/views/system/detail/SystemDetail.vue'), | ||
}, | ||
] as Array<RouteRecordRaw>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import useRequest from "@/services/request"; | ||
|
||
const { | ||
get, | ||
put, | ||
} = useRequest(); | ||
|
||
export default { | ||
namespaced: true, | ||
state: { | ||
siteTitle: {}, | ||
}, | ||
getters: {}, | ||
mutations: { | ||
setSiteTitle(state, siteTitle) { | ||
state.siteTitle = {...siteTitle}; | ||
} | ||
}, | ||
actions: { | ||
getSiteTitle: async ({state}: StoreActionContext<SystemStoreState>) => { | ||
const res = await get('/settings/site_title'); | ||
state.siteTitle = res.data; | ||
console.debug(state.siteTitle); | ||
}, | ||
saveSiteTitle: async ({state}: StoreActionContext<SystemStoreState>) => { | ||
console.debug(state.siteTitle); | ||
await put('/settings/site_title', state.siteTitle); | ||
}, | ||
} | ||
} as SystemStoreModule; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<template> | ||
<div class="system-detail"> | ||
<cl-nav-actions> | ||
<cl-nav-action-group-detail-common | ||
:show-back-button="false" | ||
:show-save-button="true" | ||
@save="onSave" | ||
/> | ||
</cl-nav-actions> | ||
<cl-form> | ||
<cl-form-item | ||
:span="1" | ||
:label="t('views.system.customizeSiteTitle')" | ||
> | ||
<cl-switch v-model="siteTitle.value.customize_site_title" @change="onSiteTitleChange"/> | ||
</cl-form-item> | ||
<cl-form-item | ||
:span="3" | ||
:label="t('views.system.siteTitle')" | ||
> | ||
<el-input | ||
v-model="siteTitle.value.site_title" | ||
:disabled="!siteTitle.value.customize_site_title" | ||
placeholder="网站标题" | ||
@change="onSiteTitleChange" | ||
/> | ||
</cl-form-item> | ||
</cl-form> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import {onBeforeMount, ref} from "vue"; | ||
import {translate} from "@/utils"; | ||
import {useStore} from "vuex"; | ||
import {ElMessage} from "element-plus"; | ||
const t = translate; | ||
const ns = 'system'; | ||
const store = useStore(); | ||
const { | ||
system: state, | ||
} = store.state as RootStoreState; | ||
const siteTitle = ref<Setting>({ | ||
key: 'site_title', | ||
value: { | ||
customize_site_title: false, | ||
site_title: '', | ||
} | ||
}); | ||
const onSiteTitleChange = () => { | ||
store.commit(`${ns}/setSiteTitle`, siteTitle.value) | ||
}; | ||
onBeforeMount(async () => { | ||
await store.dispatch(`${ns}/getSiteTitle`); | ||
siteTitle.value = state.siteTitle; | ||
}); | ||
const onSave = async () => { | ||
await store.dispatch(`${ns}/saveSiteTitle`); | ||
await ElMessage.success(t('common.message.success.save')); | ||
}; | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.system-detail { | ||
background-color: #ffffff; | ||
min-height: 100%; | ||
.el-form { | ||
padding: 20px; | ||
} | ||
} | ||
</style> |