diff --git a/dbm-ui/frontend/src/locales/zh-cn.json b/dbm-ui/frontend/src/locales/zh-cn.json index 1dc2f391ee..8eecfaf466 100644 --- a/dbm-ui/frontend/src/locales/zh-cn.json +++ b/dbm-ui/frontend/src/locales/zh-cn.json @@ -3630,5 +3630,6 @@ "请按行输入IP,每行代表一个单元格的值。多个IP用逗号、空格、|分隔": "请按行输入IP,每行代表一个单元格的值。多个IP用逗号、空格、|分隔", "无只读主机": "无只读主机", "批量录入:按行录入,快速批量输入多个单元格的值": "批量录入:按行录入,快速批量输入多个单元格的值", + "指定特殊字符(s)": "指定特殊字符(s)", "这行勿动!新增翻译请在上一行添加!": "" } diff --git a/dbm-ui/frontend/src/services/source/permission.ts b/dbm-ui/frontend/src/services/source/permission.ts index 8420e5a08d..c607d4a1ab 100644 --- a/dbm-ui/frontend/src/services/source/permission.ts +++ b/dbm-ui/frontend/src/services/source/permission.ts @@ -40,29 +40,30 @@ interface AdminPasswordResultItem { }[]; } +const path = '/apis/conf/password_policy'; + /** * 查询密码安全策略 */ export const getPasswordPolicy = (params: { name: string }) => - http.get('/apis/conf/password_policy/get_password_policy/', params); + http.get(`${path}/get_password_policy/`, params); /** * 更新密码安全策略 */ export const updatePasswordPolicy = (params: PasswordPolicy & { reset: boolean }) => - http.post('/apis/conf/password_policy/update_password_policy/', params); + http.post(`${path}/update_password_policy/`, params); /** * 查询随机化周期 */ export const queryRandomCycle = (params = {}, payload = {} as IRequestPayload) => - http.get('/apis/conf/password_policy/query_random_cycle/', params, payload); + http.get(`${path}/query_random_cycle/`, params, payload); /** * 更新随机化周期 */ -export const modifyRandomCycle = (params: RamdomCycle) => - http.post('/apis/conf/password_policy/modify_random_cycle/', params); +export const modifyRandomCycle = (params: RamdomCycle) => http.post(`${path}/modify_random_cycle/`, params); /** * 获取符合密码强度的字符串 @@ -70,7 +71,7 @@ export const modifyRandomCycle = (params: RamdomCycle) => export const getRandomPassword = (params?: { security_type: string }) => http.get<{ password: string; - }>('/apis/conf/password_policy/get_random_password/', params); + }>(`${path}/get_random_password/`, params); /** * 修改实例密码(admin) @@ -85,11 +86,16 @@ export const modifyAdminPassword = (params: { cluster_type: ClusterTypes; role: string; }[]; + // 是否异步 + is_async?: boolean; }) => - http.post<{ - success: AdminPasswordResultItem[] | null; - fail: AdminPasswordResultItem[] | null; - }>('/apis/conf/password_policy/modify_admin_password/', params); + http.post< + | { + success: AdminPasswordResultItem[] | null; + fail: AdminPasswordResultItem[] | null; + } + | string // 异步修改时返回root_id + >(`${path}/modify_admin_password/`, params); /** * 查询生效实例密码(admin) @@ -102,11 +108,23 @@ export const queryAdminPassword = (params: { instances?: string; db_type?: DBTypes; }) => - http.post>('/apis/conf/password_policy/query_admin_password/', params).then((res) => ({ + http.post>(`${path}/query_admin_password/`, params).then((res) => ({ ...res, results: res.results.map((item) => new AdminPasswordModel(item)), })); +/** + * 查询异步密码修改执行结果 + */ +export const queryAsyncModifyResult = (params: { root_id: string }) => + http.post<{ + data: { + success: AdminPasswordResultItem[] | null; + fail: AdminPasswordResultItem[] | null; + }; + status: string; + }>(`${path}/query_async_modify_result/`, params); + /** * 获取公钥列表 */ @@ -123,4 +141,4 @@ export const getRSAPublicKeys = (params: { names: string[] }) => * 校验密码强度 */ export const verifyPasswordStrength = (params: { security_type: string; password: string }) => - http.post('/apis/conf/password_policy/verify_password_strength/', params); + http.post(`${path}/verify_password_strength/`, params); diff --git a/dbm-ui/frontend/src/views/db-manage/common/password-input/Index.vue b/dbm-ui/frontend/src/views/db-manage/common/password-input/Index.vue index a8645496bb..2a42c3e580 100644 --- a/dbm-ui/frontend/src/views/db-manage/common/password-input/Index.vue +++ b/dbm-ui/frontend/src/views/db-manage/common/password-input/Index.vue @@ -127,8 +127,8 @@ }, }); - const { run: getPasswordPolicyRun } = useRequest(getPasswordPolicy, { - manual: true, + useRequest(getPasswordPolicy, { + defaultParams: [{ name: passwordParam.value }], onSuccess(data) { const { min_length: minLength, @@ -198,6 +198,13 @@ }, }); + watch( + () => props.dbType, + () => { + modelValue.value = ''; + }, + ); + /** * 获取加密密码 */ @@ -287,18 +294,6 @@ tippyInstance.hide(); }; - watch(modelValue, () => { - if (modelValue.value) { - debounceVerifyPassword(); - } - }); - - onMounted(() => { - getPasswordPolicyRun({ - name: passwordParam.value, - }); - }); - onUnmounted(() => { tippyInstance.destroy(); }); diff --git a/dbm-ui/frontend/src/views/temporary-paassword-modify/index/Index.vue b/dbm-ui/frontend/src/views/temporary-paassword-modify/index/Index.vue index 36ea5b556c..c7dfcafa65 100644 --- a/dbm-ui/frontend/src/views/temporary-paassword-modify/index/Index.vue +++ b/dbm-ui/frontend/src/views/temporary-paassword-modify/index/Index.vue @@ -14,25 +14,27 @@