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.
feat: enhance system settings management with new dependency and cust…
…omization tabs - Introduced new tabs for managing system settings: 'Customize' and 'Dependency'. - Refactored SystemDetail.vue to utilize the new tab components for better organization. - Added form validation and file upload handling for custom logos in the Customize tab. - Implemented state management for dependency settings, including auto-install options. - Updated internationalization files to include new labels for dependency management. - Improved the overall user experience by streamlining the settings interface and enhancing functionality. These changes provide a more structured approach to managing system settings, improving usability and clarity in the user interface.
- Loading branch information
Showing
24 changed files
with
468 additions
and
310 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
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
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,3 @@ | ||
export declare global { | ||
type GeneralConcept = 'customize'; | ||
} |
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 |
---|---|---|
@@ -1,6 +1,18 @@ | ||
export declare global { | ||
interface Setting extends BaseModel { | ||
interface Setting<T = Record<string, any>> extends BaseModel { | ||
key: string; | ||
value: { [key: string]: any }; | ||
value: T; | ||
} | ||
|
||
interface SettingCustomize { | ||
custom_title?: string; | ||
show_custom_title?: boolean; | ||
custom_logo?: string; | ||
show_custom_logo?: boolean; | ||
hide_platform_version?: boolean; | ||
} | ||
|
||
interface SettingDependency { | ||
auto_install?: boolean; | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,29 +1,64 @@ | ||
import useRequest from '@/services/request'; | ||
import { getMd5 } from '@/utils'; | ||
|
||
const { get, post, put } = useRequest(); | ||
|
||
export default { | ||
namespaced: true, | ||
state: { | ||
customize: { key: 'customize', value: {} }, | ||
const getDefaultSetting = (key: string): Setting => { | ||
return { key, value: {} }; | ||
}; | ||
|
||
const state = { | ||
settings: {}, | ||
} as SystemStoreState; | ||
|
||
const getters = {} as SystemStoreGetters; | ||
|
||
const mutations = { | ||
setSetting: (state: SystemStoreState, { key, value }) => { | ||
state.settings[key] = value || getDefaultSetting(key); | ||
}, | ||
resetSetting: (state: SystemStoreState, { key }) => { | ||
state.settings[key] = getDefaultSetting(key); | ||
}, | ||
getters: {}, | ||
mutations: { | ||
setCustomize(state, siteTitle) { | ||
state.customize = { ...siteTitle }; | ||
}, | ||
setSettings: (state: SystemStoreState, { settings }) => { | ||
state.settings = settings; | ||
}, | ||
actions: { | ||
getCustomize: async ({ state }: StoreActionContext<SystemStoreState>) => { | ||
const res = await get('/settings/customize'); | ||
state.customize = res.data || { key: 'customize', value: {} }; | ||
}, | ||
saveCustomize: async ({ state }: StoreActionContext<SystemStoreState>) => { | ||
if (!state.customize._id) { | ||
await post('/settings/customize', state.customize); | ||
} else { | ||
await put('/settings/customize', state.customize); | ||
} | ||
}, | ||
resetSettings: (state: SystemStoreState) => { | ||
state.settings = {}; | ||
}, | ||
} as SystemStoreMutations; | ||
|
||
const actions = { | ||
getSetting: async ( | ||
{ commit }: StoreActionContext<SystemStoreState>, | ||
{ key }: { key: string } | ||
) => { | ||
const res = await get(`/settings/${key}`); | ||
const resData = res.data || getDefaultSetting(key); | ||
commit('setSetting', { key, value: resData }); | ||
}, | ||
saveSetting: async ( | ||
_: StoreActionContext<SystemStoreState>, | ||
{ | ||
key, | ||
value, | ||
}: { | ||
key: string; | ||
value: Setting; | ||
} | ||
) => { | ||
if (!value._id) { | ||
await post(`/settings/${key}`, value); | ||
} else { | ||
await put(`/settings/${key}`, value); | ||
} | ||
}, | ||
} as SystemStoreActions; | ||
|
||
export default { | ||
namespaced: true, | ||
state, | ||
getters, | ||
mutations, | ||
actions, | ||
} 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 |
---|---|---|
@@ -1,5 +1,8 @@ | ||
import md5 from 'md5'; | ||
|
||
export const getMd5 = (text: string): string => { | ||
return md5(text).toString(); | ||
export const getMd5 = (value: any): string => { | ||
if (typeof value !== 'string') { | ||
value = JSON.stringify(value); | ||
} | ||
return md5(value).toString(); | ||
}; |
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
Oops, something went wrong.