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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <div>
  3. <h4 id="about-desc" class="ui header">简介
  4. <a class="edit-icon" href="javascript:void(0)" @click="editClick">
  5. <i class="gray edit outline icon"></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" :autosize="{minRows:2,maxRows:6}"></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').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. console.log("--watch----------")
  77. this.getRepoName();
  78. this.getDesc();
  79. this.getWeb();
  80. }
  81. },
  82. editDataFunc(formName) {
  83. this.$refs[formName].validate((valid)=>{
  84. if (valid) {
  85. this.$axios({
  86. method: 'post',
  87. url: this.url,
  88. header: {'content-type': 'application/x-www-form-urlencoded'},
  89. data: this.qs.stringify({
  90. _csrf: csrf,
  91. action: 'update',
  92. repo_name: this.info.repo_name,
  93. description: this.info.desc,
  94. website: this.info.index_web
  95. })
  96. }).then((res) => {
  97. location.reload();
  98. this.editDataDialog = false;
  99. }).catch((error) => {
  100. this.editDataDialog = false;
  101. })
  102. }
  103. else {
  104. return false;
  105. }
  106. })
  107. },
  108. getUrl() {
  109. const url = `${window.location.pathname}/settings`;
  110. this.url = url;
  111. }
  112. },
  113. mounted() {
  114. this.getUrl();
  115. this.getRepoName();
  116. this.getDesc();
  117. this.getWeb();
  118. },
  119. created() {
  120. }
  121. };
  122. </script>
  123. <style scoped>
  124. .edit-icon{
  125. float: right;
  126. font-size: 16px;
  127. display: block;
  128. top: -2px;
  129. color: #8c92a4;
  130. background-color: transparent;
  131. }
  132. </style>