diff --git a/src/api/user.js b/src/api/user.js
index ec59eca..cfd24f3 100644
--- a/src/api/user.js
+++ b/src/api/user.js
@@ -9,6 +9,43 @@ export function login(data) {
})
}
+/**
+ * 加载ldap配置
+ * @returns {*}
+ */
+export function loadLdapConfig() {
+ return request({
+ url: 'ldap/config',
+ method: 'get'
+ })
+}
+
+/**
+ * 更新ldap配置
+ * @param data
+ * @returns {*}
+ */
+export function updateLdapConfig(data) {
+ return request({
+ url: 'ldap/config',
+ method: 'put',
+ data
+ })
+}
+
+/**
+ * 测试ldap配置
+ * @param data
+ * @returns {*}
+ */
+export function testLdapConfig(data) {
+ return request({
+ url: 'ldap/test-config',
+ method: 'put',
+ data
+ })
+}
+
export function getInfo(params) {
return request({
url: 'user/userInfo',
diff --git a/src/views/setting/cloudManager.vue b/src/views/setting/cloudManager.vue
index 1ef149d..f2e8fb2 100644
--- a/src/views/setting/cloudManager.vue
+++ b/src/views/setting/cloudManager.vue
@@ -9,47 +9,104 @@
-
网盘名称:
-
-
-
-
-
网盘Logo:
-
-
-
-
-
点击更换Logo
-
启用webp:
-
-
-
-
+
+
+ 网盘名称:
+
+
+
+
+ 网盘Logo:
+
+
+
+
+ 点击更换Logo
+ 启用webp:
+
+
+
+
将图片转换为webp格式存储,在不降低图片质量的情况下,极大降低图片文件的体积,建议开启.
什么是webp?
-
- 网盘同步:
-
- {{syncPercent}}%
-
- 一般用于初始化操作, 将文件数据同步到数据库
- 重置角色、菜单:
-
-
-
- 一般用于初始化角色、菜单数据
+
+
网盘同步:
+
+
+ {{ syncPercent }}%
+
+
一般用于初始化操作, 将文件数据同步到数据库
+
重置角色、菜单:
+
+
+
+
一般用于初始化角色、菜单数据
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 测试链接
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 保存配置
+
+
+
+
@@ -61,11 +118,15 @@ import settingApi, {getSetting} from "@/api/setting-api";
import Bus from "@/assets/js/bus";
import Logo from "@/components/Logo";
import getPageTitle from "@/utils/get-page-title";
+import UploadImageInput from "@/components/input/UploadImageInput.vue";
+import roleApi from "@/api/role";
+import { loadLdapConfig, testLdapConfig, updateLdapConfig} from '@/api/user'
export default {
- components: {Logo},
+ components: {UploadImageInput, Logo},
data() {
return {
+ activeName: '1',
uploadUrl: `${process.env.VUE_APP_BASE_API}/user/setting/upload_logo?jmal-token=${this.$store.state.user.token}&name=${this.$store.state.user.name}`,
title: '网盘管理',
syncLoading: false,
@@ -76,7 +137,40 @@ export default {
netdiskName: 'JmalCloud',
showAckBtn: false,
inputNetdiskNameWidth: 150,
- logoFileTypeList: ['image/svg+xml', 'image/jpg', 'image/png', 'image/jpeg']
+ logoFileTypeList: ['image/svg+xml', 'image/jpg', 'image/png', 'image/jpeg'],
+ ldapFormData: {
+ enable: true,
+ ldapServer: '',
+ defaultRoleList: [],
+ baseDN: '',
+ password: '',
+ loginName: ''
+ },
+ roleList: [],
+ ldapStatusOptions: [{
+ value: true,
+ label: '启用'
+ }, {
+ value: false,
+ label: '禁用'
+ }],
+ rules: {
+ ldapServer: [
+ {required: true, message: '请填写LDAP服务器', trigger: 'submit'}
+ ],
+ defaultRoleList: [
+ {required: true, message: '请选择默认角色', trigger: 'submit'}
+ ],
+ baseDN: [
+ {required: true, message: '请填写 Base DN', trigger: 'submit'}
+ ],
+ loginName: [
+ {required: true, message: '请填写登录名', trigger: 'submit'}
+ ]
+ },
+ testLdapConfigLoading: false,
+ saveLdapConfigLoading: false,
+ testLdapConfigResult: -1,
}
},
mounted() {
@@ -89,15 +183,60 @@ export default {
this.syncLoading = false
}
})
+ if (this.$route.query.tab) {
+ this.activeName = this.$route.query.tab
+ if (this.activeName === '2') {
+ this.getRoleList()
+ this.getLdapConfig()
+ }
+ }
},
destroyed() {
Bus.$off()
},
+ computed: {
+ ldapTestBtn() {
+ return !(this.ldapFormData.ldapServer.length > 0 && this.ldapFormData.baseDN.length > 0 && (this.ldapFormData.password ? this.ldapFormData.password.length > 0 : false))
+ },
+ ldapSaveBtn() {
+ return !(!this.ldapTestBtn && this.ldapFormData.defaultRoleList.length > 0 && this.ldapFormData.loginName.length > 0)
+ }
+ },
methods: {
+ doTestLdapConfig() {
+ this.testLdapConfigLoading = true
+ testLdapConfig(this.ldapFormData).then(() => {
+ this.testLdapConfigLoading = false
+ this.testLdapConfigResult = 0
+ this.$message.success("连接成功")
+ }).catch(() => {
+ this.testLdapConfigResult = 1
+ this.testLdapConfigLoading = false
+ });
+ },
+ saveLdapConfig() {
+ this.saveLdapConfigLoading = true
+ updateLdapConfig(this.ldapFormData).then(() => {
+ this.saveLdapConfigLoading = false
+ this.$message.success("保存成功")
+ }).catch(() => {
+ this.saveLdapConfigLoading = false
+ });
+ },
+ handleClick(tab) {
+ this.$router.push({query: {tab: tab.name}})
+ if (tab.name === '2') {
+ this.getRoleList()
+ this.getLdapConfig()
+ }
+ },
handleAvatarSuccess(res) {
if (res.code === 0) {
this.logoFileName = res.data
- this.$store.dispatch('user/setLogo', {netdiskName: this.netdiskName, netdiskLogo: this.logoFileName}).then(()=> {
+ this.$store.dispatch('user/setLogo', {
+ netdiskName: this.netdiskName,
+ netdiskLogo: this.logoFileName
+ }).then(() => {
Bus.$emit('updateLogo')
})
} else {
@@ -128,6 +267,16 @@ export default {
}
})
},
+ getRoleList() {
+ roleApi.roleList().then(res => {
+ this.roleList = res.data;
+ })
+ },
+ getLdapConfig() {
+ loadLdapConfig().then(res => {
+ this.ldapFormData = res.data;
+ })
+ },
inputNetdiskName(input) {
if (input) {
this.showAckBtn = true
@@ -146,15 +295,18 @@ export default {
}
//中文,数字,字母,下划线
const reg = /^[a-zA-Z0-9_\u4e00-\u9fa5]+$/;
- if(reg.test(this.netdiskName)) {
+ if (reg.test(this.netdiskName)) {
settingApi.updateNetdiskName({netdiskName: this.netdiskName}).then(() => {
- this.$store.dispatch('user/setLogo', {netdiskName: this.netdiskName, netdiskLogo: this.logoFileName}).then(()=> {
+ this.$store.dispatch('user/setLogo', {
+ netdiskName: this.netdiskName,
+ netdiskLogo: this.logoFileName
+ }).then(() => {
Bus.$emit('updateLogo')
document.title = getPageTitle(this.$route.meta.title)
})
this.$message.success("网盘名称 修改成功")
this.setInputBlur()
- }).catch(()=>{
+ }).catch(() => {
this.setInputBlur()
})
} else {
@@ -218,7 +370,7 @@ export default {