upgrade.html 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. {extend name="base"/}
  2. {block name="resources"}
  3. <style>
  4. .layui-layer-content {
  5. word-break: break-all;
  6. line-height: 24px;
  7. overflow: auto !important;
  8. }
  9. .single-filter-box{
  10. display: block;
  11. }
  12. .upgrade-tips p{margin-bottom: 5px;}
  13. .upgrade-tips p:last-child{margin-bottom: 0;}
  14. </style>
  15. {/block}
  16. {block name="main"}
  17. <div class="layui-collapse tips-wrap">
  18. <div class="layui-colla-item">
  19. <h2 class="layui-colla-title">操作提示</h2>
  20. <ul class="layui-colla-content layui-show">
  21. <li>一、建议在系统升级前将网站的文件权限全部修改为777,保证系统备份文件、下载文件和覆盖文件的正常进行</li>
  22. <li>二、在升级完成后,为保证网站的安全,需要重新设置文件权限。建议进行如下修改</li>
  23. <li>1、runtime文件夹,upload文件夹依旧为777权限</li>
  24. <li>2、其他文件设置为755权限</li>
  25. <li>三、升级完成,升级文件存放目录(网站根目录/upload/upgrade/)</li>
  26. </ul>
  27. </div>
  28. </div>
  29. <!-- 操作栏 -->
  30. <div class="single-filter-box top">
  31. <button class="layui-btn" id="upgrade_btn">一键升级</button>
  32. <button class="layui-btn" id="refresh_btn">一键刷新</button>
  33. </div>
  34. <table id="version_list" lay-filter="version_list"></table>
  35. <script type="text/html" id="operation">
  36. <div class="table-btn">
  37. <a class="layui-btn" lay-event="upgrade_desc">查看更新说明</a>
  38. <a class="layui-btn" lay-event="upgrade_file">查看更新文件</a>
  39. </div>
  40. </script>
  41. <script type="text/html" id="upgrade_desc">
  42. <div style="height:100%; overflow-y: auto;">
  43. <div><span>需更新版本数:{{d.scripts.length}}</span></div>
  44. <table class="layui-table" lay-skin="lg">
  45. <colgroup>
  46. <col width="20%">
  47. <col width="80%">
  48. </colgroup>
  49. <thead>
  50. <tr>
  51. <th>版本号</th>
  52. <th>更新说明</th>
  53. </tr>
  54. </thead>
  55. <tbody>
  56. {{# layui.each(d.scripts, function(index, item){ }}
  57. <tr>
  58. <td>{{item.version_no}}</td>
  59. <td>{{item.description}}</td>
  60. </tr>
  61. {{# }) }}
  62. </tbody>
  63. </table>
  64. </div>
  65. </script>
  66. <script type="text/html" id="upgrade_file">
  67. <div style="height:100%; overflow-y: auto;">
  68. <div><span>需更新文件数:{{d.files.length}}</span></div>
  69. <table class="layui-table" lay-skin="lg">
  70. <tbody>
  71. {{# layui.each(d.files, function(index, item){ }}
  72. <tr>
  73. <td>{{item.file_path}}</td>
  74. </tr>
  75. {{# }) }}
  76. </tbody>
  77. </table>
  78. </div>
  79. </script>
  80. <script type="text/html" id="right_check">
  81. <div style="height:100%; overflow-y: auto;">
  82. <div><span>共有{{d.length}}个文件或文件夹不可写,请先修正这些问题,再继续升级</span></div>
  83. <table class="layui-table" lay-skin="lg">
  84. <thead>
  85. <tr>
  86. <th>类型</th>
  87. <th>路径</th>
  88. </tr>
  89. </thead>
  90. <tbody>
  91. {{# layui.each(d, function(index, item){ }}
  92. <tr>
  93. <td>{{item.type_name}}</td>
  94. <td>{{item.path}}</td>
  95. </tr>
  96. {{# }) }}
  97. </tbody>
  98. </table>
  99. </div>
  100. </script>
  101. {/block}
  102. {block name="script"}
  103. <script>
  104. //升级的权限检测
  105. var right_check = null;
  106. var system_upgrade_info_ready = null;
  107. layui.use(['form', 'laytpl'], function() {
  108. var table,
  109. laytpl = layui.laytpl,
  110. form = layui.form;
  111. form.render();
  112. table = new Table({
  113. elem: '#version_list',
  114. url: ns.url("shop/upgrade/upgrade"),
  115. parseData: function(res){ //res 即为原始返回的数据
  116. if (res.code == 0) {
  117. right_check = res.data.right_check;
  118. system_upgrade_info_ready = res.data.system_upgrade_info_ready;
  119. return {
  120. "code": res.code, //解析接口状态
  121. "msg": res.message, //解析提示文本
  122. "data": res.data.system_upgrade_info_ready //解析数据列表
  123. };
  124. } else {
  125. return {
  126. "code": res.code, //解析接口状态
  127. "msg": res.message, //解析提示文本
  128. "data": [] //解析数据列表
  129. };
  130. }
  131. },
  132. page: false,
  133. cols: [
  134. [{
  135. field: 'type_name',
  136. title: '主体',
  137. width: '10%',
  138. unresize: 'false',
  139. templet: function (data) {
  140. return data.goods_name;
  141. }
  142. },{
  143. field: 'type_name',
  144. title: '操作类型',
  145. width: '10%',
  146. unresize: 'false',
  147. templet: function (data) {
  148. return data.action_name;
  149. }
  150. }, {
  151. field: 'current_version_name',
  152. title: '当前版本',
  153. width: '10%',
  154. unresize: 'false'
  155. }, {
  156. field: 'latest_version_name',
  157. title: '最新版本',
  158. width: '10%',
  159. unresize: 'false'
  160. }, {
  161. field: 'scripts',
  162. title: '更新版本数',
  163. width: '10%',
  164. unresize: 'false',
  165. templet: function (data) {
  166. return data.scripts.length;
  167. }
  168. }, {
  169. field: 'files',
  170. title: '更新文件数',
  171. width: '10%',
  172. unresize: 'false',
  173. templet: function (data) {
  174. return data.files.length;
  175. }
  176. }, {
  177. title: '操作',
  178. toolbar: '#operation',
  179. unresize: 'false',
  180. align:'right'
  181. }]
  182. ]
  183. });
  184. /**
  185. * 监听工具栏操作
  186. */
  187. table.tool(function(obj) {
  188. var data = obj.data,
  189. event = obj.event;
  190. switch (event) {
  191. case 'upgrade_desc':
  192. upgradeDesc(data);
  193. break;
  194. case 'upgrade_file':
  195. upgradeFile(data);
  196. break;
  197. }
  198. });
  199. //详情说明
  200. function upgradeDesc(data) {
  201. var uploadHtml = $("#upgrade_desc").html();
  202. laytpl(uploadHtml).render(data, function(html) {
  203. layer.open({
  204. type: 1,
  205. title: '更新说明',
  206. area: ['700px', '600px'],
  207. content: html
  208. });
  209. })
  210. }
  211. //更新文件
  212. function upgradeFile(data) {
  213. var uploadHtml = $("#upgrade_file").html();
  214. laytpl(uploadHtml).render(data, function(html) {
  215. layer.open({
  216. type: 1,
  217. title: '更新文件',
  218. area: ['700px', '600px'],
  219. content: html
  220. });
  221. })
  222. }
  223. $("#upgrade_btn").click(function(){
  224. if(system_upgrade_info_ready === null){
  225. layer.msg('数据正在获取中,请稍候');
  226. return false;
  227. }
  228. if(system_upgrade_info_ready.length <= 0){
  229. layer.msg('暂无可以升级的内容');
  230. return false;
  231. }
  232. if(right_check.length > 0){
  233. var uploadHtml = $("#right_check").html();
  234. laytpl(uploadHtml).render(right_check, function(html) {
  235. layer.open({
  236. type: 1,
  237. title: '权限检测',
  238. area: ['700px', '500px'],
  239. content: html
  240. });
  241. });
  242. return false;
  243. }
  244. layer.open({
  245. title: '注意事项',
  246. area: ['400px'],
  247. btn: ['继续'],
  248. content: `<div class="upgrade-tips"><p>1、升级前请先检查防火墙以及cc拦截是否已经关闭。</p>
  249. <p>2、强烈建议清理runtime下的子文件夹,做好备份工作(后台程序、数据库),方便后期与售后人员协调。</p>
  250. <p>3、升级完成后,点击一键刷新按钮(授权升级—>系统升级功能),清理runtime缓存,清理浏览器缓存,Ctrl+F5强制刷新。</p>
  251. <p>4、重置自定义首页,可在模板选择中选择。</p></div>`,
  252. yes: function () {
  253. window.location.href = ns.url("shop/upgrade/upgradeAction");
  254. }
  255. });
  256. });
  257. $("#refresh_btn").click(function () {
  258. var index = layer.load(2);
  259. $.ajax({
  260. type: "post",
  261. url: ns.url('shop/upgrade/refresh'),
  262. dataType: "JSON",
  263. success: function (res) {
  264. layer.msg(res.message);
  265. layer.close(index);
  266. }
  267. });
  268. });
  269. });
  270. </script>
  271. {/block}