[Feature][UI] Interface settings add switches for experimental features. (#12537)

This commit is contained in:
songjianet 2022-10-27 09:45:16 +08:00 committed by GitHub
parent 4b4d0b92a3
commit 9c2a290012
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 38 additions and 30 deletions

View File

@ -16,8 +16,9 @@
*/ */
export default { export default {
log: { refresh_time: 'Log Auto Refresh Time',
refresh_time: 'Log Auto Refresh Time', experimental_feature: 'Experimental Feature',
} request_settings: 'Request Settings',
} dynamic_task_component: 'Dynamic Task Component'
}

View File

@ -16,8 +16,9 @@
*/ */
export default { export default {
log: { refresh_time: '自动刷新时间',
refresh_time: '自动刷新时间', experimental_feature: '实验性功能',
} request_settings: '请求设置',
} dynamic_task_component: '动态任务组件'
}

View File

@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
interface LogTimerStore { interface UISettingStore {
logTimer: number logTimer: number
} }
export { LogTimerStore } export { UISettingStore }

View File

@ -16,11 +16,11 @@
*/ */
import { defineStore } from 'pinia' import { defineStore } from 'pinia'
import { LogTimerStore } from './types' import { UISettingStore } from './types'
export const useLogTimerStore = defineStore({ export const useUISettingStore = defineStore({
id: 'logTimer', id: 'ui-setting',
state: (): LogTimerStore => ({ state: (): UISettingStore => ({
logTimer: 0, logTimer: 0,
}), }),
persist: true, persist: true,

View File

@ -38,15 +38,15 @@ import { useI18n } from 'vue-i18n'
import { useAsyncState } from '@vueuse/core' import { useAsyncState } from '@vueuse/core'
import { queryLog } from '@/service/modules/log' import { queryLog } from '@/service/modules/log'
import { stateType } from '@/common/common' import { stateType } from '@/common/common'
import { useLogTimerStore } from '@/store/logTimer/logTimer' import { useUISettingStore } from '@/store/ui-setting/ui-setting'
import Card from '@/components/card' import Card from '@/components/card'
import LogModal from '@/components/log-modal' import LogModal from '@/components/log-modal'
const BatchTaskInstance = defineComponent({ const BatchTaskInstance = defineComponent({
name: 'task-instance', name: 'task-instance',
setup() { setup() {
const logTimerStore = useLogTimerStore() const uiSettingStore = useUISettingStore()
const logTimer = logTimerStore.getLogTimer const logTimer = uiSettingStore.getLogTimer
const { t, variables, getTableData, createColumns } = useTable() const { t, variables, getTableData, createColumns } = useTable()
const requestTableData = () => { const requestTableData = () => {

View File

@ -39,7 +39,7 @@ import { useI18n } from 'vue-i18n'
import { useAsyncState } from '@vueuse/core' import { useAsyncState } from '@vueuse/core'
import { queryLog } from '@/service/modules/log' import { queryLog } from '@/service/modules/log'
import { streamStateType } from '@/common/common' import { streamStateType } from '@/common/common'
import { useLogTimerStore } from '@/store/logTimer/logTimer' import { useUISettingStore } from '@/store/ui-setting/ui-setting'
import Card from '@/components/card' import Card from '@/components/card'
import LogModal from '@/components/log-modal' import LogModal from '@/components/log-modal'
@ -47,8 +47,8 @@ const BatchTaskInstance = defineComponent({
name: 'task-instance', name: 'task-instance',
setup() { setup() {
let setIntervalP: number let setIntervalP: number
const logTimerStore = useLogTimerStore() const uiSettingStore = useUISettingStore()
const logTimer = logTimerStore.getLogTimer const logTimer = uiSettingStore.getLogTimer
const { t, variables, getTableData, createColumns } = useTable() const { t, variables, getTableData, createColumns } = useTable()
const onUpdatePageSize = () => { const onUpdatePageSize = () => {

View File

@ -54,7 +54,7 @@ import './x6-style.scss'
import { queryLog } from '@/service/modules/log' import { queryLog } from '@/service/modules/log'
import { useAsyncState } from '@vueuse/core' import { useAsyncState } from '@vueuse/core'
import utils from '@/utils' import utils from '@/utils'
import { useLogTimerStore } from '@/store/logTimer/logTimer' import { useUISettingStore } from '@/store/ui-setting/ui-setting'
const props = { const props = {
// If this prop is passed, it means from definition detail // If this prop is passed, it means from definition detail
@ -85,8 +85,8 @@ export default defineComponent({
const route = useRoute() const route = useRoute()
const theme = useThemeStore() const theme = useThemeStore()
const logTimerStore = useLogTimerStore() const uiSettingStore = useUISettingStore()
const logTimer = logTimerStore.getLogTimer const logTimer = uiSettingStore.getLogTimer
// Whether the graph can be operated // Whether the graph can be operated
provide('readonly', toRef(props, 'readonly')) provide('readonly', toRef(props, 'readonly'))

View File

@ -16,22 +16,22 @@
*/ */
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { NSelect, NSpace } from 'naive-ui' import { NSelect, NSpace, NSwitch } from 'naive-ui'
import { defineComponent } from 'vue' import { defineComponent } from 'vue'
import { useLogTimerStore } from '@/store/logTimer/logTimer' import { useUISettingStore } from '@/store/ui-setting/ui-setting'
import Card from '@/components/card' import Card from '@/components/card'
// Update LogTimer store when select value is updated // Update LogTimer store when select value is updated
const handleUpdateValue = (logTimer: number) => { const handleUpdateValue = (logTimer: number) => {
const logTimerStore = useLogTimerStore() const uiSettingStore = useUISettingStore()
logTimerStore.setLogTimer(logTimer) uiSettingStore.setLogTimer(logTimer)
} }
const setting = defineComponent({ const setting = defineComponent({
name: 'ui-setting', name: 'ui-setting',
setup() { setup() {
const logTimerStore = useLogTimerStore() const uiSettingStore = useUISettingStore()
const defaultLogTimer = logTimerStore.getLogTimer const defaultLogTimer = uiSettingStore.getLogTimer
const logTimerMap = { const logTimerMap = {
0: 'Off', 0: 'Off',
@ -75,8 +75,9 @@ const setting = defineComponent({
return ( return (
<Card style={{ marginLeft: '25%', width: '50%' }} title={t('menu.ui_setting')}> <Card style={{ marginLeft: '25%', width: '50%' }} title={t('menu.ui_setting')}>
<h4>{t('ui_setting.request_settings')}</h4>
<NSpace align='center' justify='space-between'> <NSpace align='center' justify='space-between'>
<span>{t('ui_setting.log.refresh_time')}</span> <span>{t('ui_setting.refresh_time')}</span>
<NSelect <NSelect
style={{ width: '200px' }} style={{ width: '200px' }}
default-value={this.logTimerMap[this.defaultLogTimer]} default-value={this.logTimerMap[this.defaultLogTimer]}
@ -84,6 +85,11 @@ const setting = defineComponent({
onUpdateValue={handleUpdateValue} onUpdateValue={handleUpdateValue}
/> />
</NSpace> </NSpace>
<h4>{t('ui_setting.experimental_feature')}</h4>
<NSpace align='center' justify='space-between'>
<span>{t('ui_setting.dynamic_task_component')}</span>
<NSwitch round={false}></NSwitch>
</NSpace>
</Card> </Card>
) )
} }