backend.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. window.Popper = require('popper.js').default;
  2. window.$ = window.jQuery = require('admin-lte/bower_components/jquery/dist/jquery.min.js');
  3. require('admin-lte/bower_components/bootstrap/dist/js/bootstrap.min.js');
  4. require('admin-lte/dist/js/adminlte.min.js');
  5. require('admin-lte/plugins/iCheck/icheck.min.js');
  6. require("bootstrapvalidator/dist/js/bootstrapValidator.min.js");
  7. require("inline-attachment/src/inline-attachment.js");
  8. require("inline-attachment/src/codemirror-4.inline-attachment.js");
  9. require("./moell.js");
  10. window.markdownEditorInit = function () {
  11. var inlineAttachmentConfig = {
  12. uploadUrl: '/backend/upload/image',
  13. extraHeaders: {
  14. 'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
  15. }
  16. };
  17. var simplemde = new SimpleMDE({
  18. element: $("#markdown-editor")[0],
  19. spellChecker: false,
  20. renderingConfig: {
  21. codeSyntaxHighlighting: true
  22. },
  23. });
  24. inlineAttachment.editors.codemirror4.attach(simplemde.codemirror,
  25. inlineAttachmentConfig);
  26. };
  27. $(function() {
  28. var validatorDefaultParam = {
  29. live: 'disables',
  30. message: "This Values is not valid",
  31. feedbackIcons: {
  32. valid: 'glyphicon ',
  33. invalid: 'glyphicon ',
  34. validating: 'glyphicon glyphicon-refresh'
  35. }
  36. };
  37. /* 文章分类操作验证 */
  38. $("#category-form").bootstrapValidator({
  39. validatorDefaultParam,
  40. fields: {
  41. name: {
  42. validators: {
  43. notEmpty: {
  44. message: "分类名称不能为空"
  45. }
  46. }
  47. }
  48. }
  49. });
  50. $("#category-form #reset-btn").click(function(){
  51. var categoryForm = $("#category-form");
  52. categoryForm.data('bootstrapValidator').resetForm(true);
  53. categoryForm[0].reset();
  54. });
  55. $("#article-form").bootstrapValidator({
  56. live: 'disables',
  57. message: "This Values is not valid",
  58. feedbackIcons: {
  59. valid: 'glyphicon ',
  60. invalid: 'glyphicon ',
  61. validating: 'glyphicon glyphicon-refresh'
  62. },
  63. fields : {
  64. title : {
  65. validators : {
  66. notEmpty : {
  67. message : "文章标题不能为空"
  68. }
  69. }
  70. },
  71. cate_id : {
  72. validators : {
  73. notEmpty : {
  74. message : "请选择文章分类"
  75. }
  76. }
  77. }
  78. }
  79. });
  80. $("#article-form #reset-btn").click(function(){
  81. var articleForm = $("#article-form");
  82. articleForm.data('bootstrapValidator').resetForm(true);
  83. articleForm[0].reset();
  84. });
  85. /* user add */
  86. $("#user-form").bootstrapValidator({
  87. validatorDefaultParam,
  88. fields : {
  89. name : {
  90. validators : {
  91. notEmpty : {
  92. message : "请输入姓名"
  93. },
  94. stringLength : {
  95. min : 2,
  96. max : 30,
  97. message : '姓名长度必须在2-30'
  98. }
  99. }
  100. },
  101. email : {
  102. validators : {
  103. notEmpty : {
  104. message : "请输入登录邮箱"
  105. },
  106. emailAddress : {
  107. message : "请输入正确的登录邮箱"
  108. }
  109. }
  110. },
  111. password : {
  112. validators : {
  113. notEmpty : {
  114. message : "请输入正确的登录密码"
  115. },
  116. stringLength : {
  117. min : 8,
  118. max : 30,
  119. message : '请输入8-30位的密码'
  120. }
  121. }
  122. }
  123. }
  124. });
  125. $("#user-form #reset-btn").click(function(){
  126. $("#user-form").data('bootstrapValidator').resetForm(true);
  127. $("#user-form")[0].reset();
  128. });
  129. /* user edit */
  130. $("#edit-user-form").bootstrapValidator({
  131. validatorDefaultParam,
  132. fields : {
  133. name : {
  134. validators : {
  135. notEmpty : {
  136. message : "请输入姓名"
  137. },
  138. stringLength : {
  139. min : 2,
  140. max : 30,
  141. message : '姓名长度必须在2-30'
  142. }
  143. }
  144. },
  145. email : {
  146. validators : {
  147. notEmpty : {
  148. message : "请输入登录邮箱"
  149. },
  150. emailAddress : {
  151. message : "请输入正确的登录邮箱"
  152. }
  153. }
  154. },
  155. password : {
  156. validators : {
  157. stringLength : {
  158. min : 8,
  159. max : 30,
  160. message : '请输入8-30位的密码'
  161. }
  162. }
  163. }
  164. }
  165. });
  166. $("#edit-user-form #reset-btn").click(function(){
  167. $("#user-form").data('bootstrapValidator').resetForm(true);
  168. $("#user-form")[0].reset();
  169. });
  170. $("#tag-form").bootstrapValidator({
  171. validatorDefaultParam,
  172. fields : {
  173. name: {
  174. validators: {
  175. notEmpty: {
  176. message: "请输入文章标签名"
  177. }
  178. }
  179. }
  180. }
  181. });
  182. $("#tag-form #reset-btn").click(function(){
  183. $("#tag-form").data('bootstrapValidator').resetForm(true);
  184. $("#tag-form")[0].reset();
  185. });
  186. $("#link-form").bootstrapValidator({
  187. validatorDefaultParam,
  188. fields : {
  189. name: {
  190. validators: {
  191. notEmpty: {
  192. message: "请输入链接名"
  193. }
  194. }
  195. },
  196. url : {
  197. validators: {
  198. notEmpty: {
  199. message: "URL不能为空"
  200. },
  201. uri: {
  202. message: '请输入合法的URL地址'
  203. }
  204. }
  205. }
  206. }
  207. });
  208. $("#link-form #reset-btn").click(function(){
  209. $("#link-form").data('bootstrapValidator').resetForm(true);
  210. $("#link-form")[0].reset();
  211. });
  212. $("#navigation-form").bootstrapValidator({
  213. validatorDefaultParam,
  214. fields : {
  215. name: {
  216. validators: {
  217. notEmpty: {
  218. message: "请输入导航名"
  219. }
  220. }
  221. },
  222. url : {
  223. validators: {
  224. notEmpty: {
  225. message: "URL不能为空"
  226. },
  227. uri: {
  228. message: '请输入合法的URL地址'
  229. }
  230. }
  231. }
  232. }
  233. });
  234. $("#navigation-form #reset-btn").click(function(){
  235. $("#navigation-form").data('bootstrapValidator').resetForm(true);
  236. $("#navigation-form")[0].reset();
  237. });
  238. $("#page-form").bootstrapValidator({
  239. live: 'disables',
  240. message: "This Values is not valid",
  241. feedbackIcons: {
  242. valid: 'glyphicon ',
  243. invalid: 'glyphicon ',
  244. validating: 'glyphicon glyphicon-refresh'
  245. },
  246. fields : {
  247. title : {
  248. validators : {
  249. notEmpty : {
  250. message : "页面标题不能为空"
  251. }
  252. }
  253. }
  254. }
  255. });
  256. });