SecuritySettings.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template>
  2. <el-form :model="ruleForm" :rules="rules" status-icon>
  3. <el-divider content-position="left">{{lang.modify_pwd}}</el-divider>
  4. <el-form-item :label="lang.modify_pwd" prop="new_pwd">
  5. <el-input type="password" v-model="ruleForm.new_pwd" />
  6. </el-form-item>
  7. <el-form-item :label="lang.enter_again" prop="new_pwd2">
  8. <el-input type="password" v-model="ruleForm.new_pwd2" />
  9. </el-form-item>
  10. <el-form-item>
  11. <el-button type="primary" @click="submit">
  12. {{ lang.submit }}
  13. </el-button>
  14. </el-form-item>
  15. <el-divider content-position="left">{{lang.logout}}</el-divider>
  16. <el-form-item>
  17. <el-button type="primary" @click="logout">
  18. {{ lang.logout }}
  19. </el-button>
  20. </el-form-item>
  21. </el-form>
  22. </template>
  23. <script setup>
  24. import { reactive, ref } from 'vue'
  25. import { ElNotification } from 'element-plus'
  26. import lang from '../i18n/i18n';
  27. import { getCurrentInstance } from 'vue'
  28. const app = getCurrentInstance()
  29. const $http = app.appContext.config.globalProperties.$http
  30. const ruleForm = reactive({
  31. new_pwd: "",
  32. new_pwd2: ""
  33. })
  34. const rules = reactive({
  35. new_pwd: [{ required: true, message: lang.err_required_pwd, trigger: 'blur' },],
  36. new_pwd2: [{ required: true, message: lang.err_required_pwd, trigger: 'blur' },],
  37. })
  38. const logout = function(){
  39. $http.post("/api/logout", { }).then(res => {
  40. location.reload();
  41. })
  42. }
  43. const submit = function () {
  44. if (ruleForm.new_pwd == ""){
  45. return
  46. }
  47. if (ruleForm.new_pwd != ruleForm.new_pwd2) {
  48. ElNotification({
  49. title: 'Error',
  50. message: lang.err_pwd_diff,
  51. type: 'error',
  52. })
  53. return
  54. }
  55. $http.post("/api/settings/modify_password", { password: ruleForm.new_pwd }).then(res => {
  56. ElNotification({
  57. title: res.errorNo == 0 ? lang.succ : lang.fail,
  58. message: res.data,
  59. type: res.errorNo == 0 ? 'success' : 'error',
  60. })
  61. })
  62. }
  63. </script>