You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

EditAboutInfo.vue 3.6 kB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <div>
  3. <h4 id="about-desc" class="ui header desc-home">简介
  4. <a class="edit-icon" href="javascript:void(0)" @click="editClick">
  5. <i class="gray edit outline icon" style="margin-right: 0;"></i>
  6. </a>
  7. </h4>
  8. <edit-dialog-cmpt
  9. :vmContext="vmContext"
  10. dialogTitle="编辑仓库信息"
  11. v-model="editDataDialog"
  12. :deleteCallback="editDataFunc"
  13. :deleteLoading ="editDataListLoading"
  14. deleteParam = "ruleForm"
  15. @input="initForm"
  16. >
  17. <div slot="title">
  18. </div>
  19. <div slot="content">
  20. <el-form label-position="top" :model="info" :rules="rule" ref="ruleForm">
  21. <el-form-item label="简介" prop="desc">
  22. <el-input v-model="info.desc" type="textarea" placeholder="请输入内容" :autosize="{minRows:4,maxRows:6}" maxlength="255" show-word-limit></el-input>
  23. </el-form-item>
  24. <el-form-item label="主页" prop="index_web" >
  25. <el-input v-model="info.index_web" placeholder="主页(eg: https://git.openi.org.cn)"></el-input>
  26. </el-form-item>
  27. </el-form>
  28. </div>
  29. </edit-dialog-cmpt>
  30. </div>
  31. </template>
  32. <script>
  33. const {_AppSubUrl, _StaticUrlPrefix, csrf} = window.config;
  34. import editDialogCmpt from './basic/editDialog.vue';
  35. export default {
  36. components: {
  37. editDialogCmpt,
  38. },
  39. data() {
  40. return {
  41. vmContext: this,
  42. editDataDialog: false,
  43. editDataListLoading: false,
  44. url: '',
  45. info: {
  46. desc: '',
  47. index_web: '',
  48. repo_name_name: '',
  49. },
  50. // rule1:[{min:3,max:5,message:'1',trigger:"blur"}],
  51. rule: {
  52. index_web: [
  53. {required: false, pattern: /(^$)|(^(http|https):\/\/(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).*)|(^(http|https):\/\/[a-zA-Z0-9]+([_\-\.][a-zA-Z0-9]+)*\.[a-zA-Z]{2,10}(:[0-9]{1,10})?(\?.*)?(\/.*)?$)/,message:'请输入有效的URL',tigger:['change','blur']}
  54. ]
  55. }
  56. };
  57. },
  58. methods: {
  59. editClick() {
  60. this.editDataDialog = true;
  61. },
  62. getDesc() {
  63. const el = $('span.description').text();
  64. this.info.desc = el;
  65. },
  66. getWeb() {
  67. const el = $('a.link.edit-link').text();
  68. this.info.index_web = el;
  69. },
  70. getRepoName() {
  71. const el = this.url.split('/')[2];
  72. this.info.repo_name = el;
  73. },
  74. initForm(diaolog) {
  75. if (diaolog === false) {
  76. this.getRepoName();
  77. this.getDesc();
  78. this.getWeb();
  79. }
  80. },
  81. editDataFunc(formName) {
  82. this.$refs[formName].validate((valid)=>{
  83. if (valid) {
  84. this.$axios({
  85. method: 'post',
  86. url: this.url,
  87. header: {'content-type': 'application/x-www-form-urlencoded'},
  88. data: this.qs.stringify({
  89. _csrf: csrf,
  90. action: 'update',
  91. repo_name: this.info.repo_name,
  92. description: this.info.desc,
  93. website: this.info.index_web
  94. })
  95. }).then((res) => {
  96. location.reload();
  97. this.editDataDialog = false;
  98. }).catch((error) => {
  99. this.editDataDialog = false;
  100. })
  101. }
  102. else {
  103. return false;
  104. }
  105. })
  106. },
  107. getUrl() {
  108. const url = `${window.location.pathname}/settings`;
  109. this.url = url;
  110. }
  111. },
  112. mounted() {
  113. this.getUrl();
  114. this.getRepoName();
  115. this.getDesc();
  116. this.getWeb();
  117. },
  118. created() {
  119. }
  120. };
  121. </script>
  122. <style scoped>
  123. .edit-icon{
  124. color: #8c92a4;
  125. }
  126. .desc-home{
  127. display: flex;
  128. justify-content: space-between;
  129. }
  130. </style>