@@ -14,7 +14,8 @@ const state = {
1414 publicSettings : { } ,
1515 hasValidLicense : false ,
1616 authMethods : { } ,
17- themeColors : JSON . parse ( localStorage . getItem ( 'themeColors' ) ) || { }
17+ themeColors : JSON . parse ( localStorage . getItem ( 'themeColors' ) ) || { } ,
18+ tableActionButtonType : 'default'
1819}
1920
2021const mutations = {
@@ -26,6 +27,7 @@ const mutations = {
2627 SET_PUBLIC_SETTINGS : ( state , settings ) => {
2728 state . publicSettings = settings
2829 state . themeColors = settings ?. INTERFACE ?. theme_info ?. colors || { }
30+ state . tableActionButtonType = settings ?. INTERFACE . theme_info [ 'table-action-button' ] || 'default'
2931
3032 if ( settings [ 'XPACK_ENABLED' ] ) {
3133 state . hasValidLicense = settings [ 'XPACK_LICENSE_IS_VALID' ]
@@ -47,55 +49,63 @@ const actions = {
4749 // get user Profile
4850 getPublicSettings ( { commit, state } , isOpen ) {
4951 return new Promise ( ( resolve , reject ) => {
50- getPublicSettings ( isOpen ) . then ( response => {
51- const data = response || { }
52- if ( isOpen ) {
53- const faviconURL = data [ 'INTERFACE' ] ?. favicon
54- let link = document . querySelector ( "link[rel*='icon']" )
55- if ( ! link ) {
56- link = document . createElement ( 'link' )
57- link . type = 'image/x-icon'
58- link . rel = 'shortcut icon'
59- document . getElementsByTagName ( 'head' ) [ 0 ] . appendChild ( link )
60- }
61- if ( faviconURL ) {
62- link . href = faviconURL
63- }
64- // 动态修改Title
65- document . title = data ?. INTERFACE ?. login_title || ''
66- }
67- const responseThemeColors = data ?. INTERFACE ?. theme_info ?. colors || { }
68- const cachedThemeColors = ( ( ) => {
69- if ( state . themeColors && Object . keys ( state . themeColors ) . length > 0 ) {
70- return state . themeColors
71- }
72- try {
73- return JSON . parse ( localStorage . getItem ( 'themeColors' ) ) || { }
74- } catch ( error ) {
75- return { }
52+ getPublicSettings ( isOpen )
53+ . then ( response => {
54+ const data = response || { }
55+ if ( isOpen ) {
56+ const faviconURL = data [ 'INTERFACE' ] ?. favicon
57+ let link = document . querySelector ( "link[rel*='icon']" )
58+ if ( ! link ) {
59+ link = document . createElement ( 'link' )
60+ link . type = 'image/x-icon'
61+ link . rel = 'shortcut icon'
62+ document . getElementsByTagName ( 'head' ) [ 0 ] . appendChild ( link )
63+ }
64+ if ( faviconURL ) {
65+ link . href = faviconURL
66+ }
67+ // 动态修改Title
68+ document . title = data ?. INTERFACE ?. login_title || ''
7669 }
77- } ) ( )
78- const themeColors =
79- Object . keys ( responseThemeColors ) . length > 0 ? responseThemeColors : cachedThemeColors
80- const nextSettings = {
81- ...data ,
82- INTERFACE : {
83- ...( data ?. INTERFACE || { } ) ,
84- theme_info : {
85- ...( data ?. INTERFACE ?. theme_info || { } ) ,
86- colors : themeColors
70+
71+ const responseThemeColors = data ?. INTERFACE ?. theme_info ?. colors || { }
72+
73+ const cachedThemeColors = ( ( ) => {
74+ if ( state . themeColors && Object . keys ( state . themeColors ) . length > 0 ) {
75+ return state . themeColors
76+ }
77+ try {
78+ return JSON . parse ( localStorage . getItem ( 'themeColors' ) ) || { }
79+ } catch ( error ) {
80+ return { }
8781 }
82+ } ) ( )
83+
84+ const themeColors =
85+ Object . keys ( responseThemeColors ) . length > 0 ? responseThemeColors : cachedThemeColors
86+ const nextSettings = {
87+ ...data ,
88+ INTERFACE : {
89+ ...( data ?. INTERFACE || { } ) ,
90+ theme_info : {
91+ ...( data ?. INTERFACE ?. theme_info || { } ) ,
92+ colors : themeColors
93+ }
94+ }
95+ }
96+
97+ commit ( 'SET_PUBLIC_SETTINGS' , nextSettings )
98+ changeThemeColors ( themeColors || { } )
99+ resolve ( response )
100+ } )
101+ . catch ( error => {
102+ if ( error . response && error . response . status === 400 ) {
103+ alert (
104+ '自 v3.6 版本开始,要求配置可信任域名或主机,否则无法正常使用, 查看: https://github.com/jumpserver/jumpserver/releases/tag/v3.6.0'
105+ )
88106 }
89- }
90- commit ( 'SET_PUBLIC_SETTINGS' , nextSettings )
91- changeThemeColors ( themeColors || { } )
92- resolve ( response )
93- } ) . catch ( error => {
94- if ( error . response && error . response . status === 400 ) {
95- alert ( '自 v3.6 版本开始,要求配置可信任域名或主机,否则无法正常使用, 查看: https://github.com/jumpserver/jumpserver/releases/tag/v3.6.0' )
96- }
97- reject ( error )
98- } )
107+ reject ( error )
108+ } )
99109 } )
100110 } ,
101111 changeThemeStyle ( { commit } , themeColors ) {
@@ -108,12 +118,15 @@ const actions = {
108118 return new Promise ( ( resolve , reject ) => {
109119 const url = '/api/v1/settings/setting/?category=auth'
110120 const data = { [ key ] : value }
111- request . patch ( url , data ) . then ( res => {
112- state . authMethods [ key ] = value
113- resolve ( res )
114- } ) . catch ( error => {
115- reject ( error )
116- } )
121+ request
122+ . patch ( url , data )
123+ . then ( res => {
124+ state . authMethods [ key ] = value
125+ resolve ( res )
126+ } )
127+ . catch ( error => {
128+ reject ( error )
129+ } )
117130 } )
118131 } ,
119132 getAuthMethods ( { commit, state } ) {
@@ -122,12 +135,15 @@ const actions = {
122135 resolve ( state . authMethods )
123136 } else {
124137 const url = '/api/v1/settings/setting/?category=auth'
125- request . get ( url ) . then ( res => {
126- state . authMethods = res
127- resolve ( res )
128- } ) . catch ( error => {
129- reject ( error )
130- } )
138+ request
139+ . get ( url )
140+ . then ( res => {
141+ state . authMethods = res
142+ resolve ( res )
143+ } )
144+ . catch ( error => {
145+ reject ( error )
146+ } )
131147 }
132148 } )
133149 }
0 commit comments