plugins.blade.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. @extends('layouts.base')
  2. @section('title', trans('插件管理'))
  3. @section('content')
  4. <style>
  5. .content{
  6. background: #eff3f6;
  7. padding: 10px!important;
  8. }
  9. .con{
  10. padding-bottom:20px;
  11. position:relative;
  12. border-radius: 8px;
  13. min-height: 100vh;
  14. background: #fff;
  15. }
  16. .con .setting .block{
  17. padding:10px;
  18. background-color:#fff;
  19. border-radius: 8px;
  20. }
  21. .con .setting .block .title{
  22. font-size:18px;
  23. margin-bottom:15px;
  24. display:flex;
  25. align-items:center;
  26. justify-content:space-between;
  27. }
  28. .el-form-item{
  29. padding-left:300px;
  30. margin-bottom:10px!important;
  31. }
  32. .el-form-item__label{
  33. margin-right:30px;
  34. }
  35. .add{
  36. width: 155px;
  37. height: 36px;
  38. border-radius: 4px;
  39. color: #ffffff;
  40. display:flex;
  41. align-items:center;
  42. justify-content:center;
  43. background-color: #29ba9c;
  44. }
  45. .el-table--fit{
  46. margin-top:-10px;
  47. }
  48. b{
  49. font-size:14px;
  50. }
  51. .vue-crumbs a {
  52. color: #333;
  53. }
  54. .vue-crumbs a:hover {
  55. color: #29ba9c;
  56. }
  57. .vue-crumbs {
  58. margin: 0 20px;
  59. font-size: 14px;
  60. color: #333;
  61. font-weight: 400;
  62. padding-bottom: 10px;
  63. line-height: 32px;
  64. }
  65. .el-checkbox__inner{
  66. border:solid 1px #56be69!important;
  67. }
  68. .el-table--border::after, .el-table--group::after, .el-table::before{
  69. background-color:#fff;
  70. }
  71. </style>
  72. <div id='re_content' >
  73. <template>
  74. </template>
  75. <div class="con">
  76. <div class="setting">
  77. <div class="block">
  78. <div class="title"><div style="display:flex;align-items:center;"><div style="display:flex;align-items:center;"><span style="width: 4px;height: 18px;background-color: #29ba9c;margin-right:15px;display:inline-block;"></span><b>插件管理</b><span style="color: #999999;font-size:12px;display:inline-block;margin-left:16px;">如存在未授权插件,您可能正在使用盗版插件,为了保障您的权益,请尽快联系客服处理!</span></div><span></div><el-button type="primary"><a href="{{yzWebUrl('plugin.plugins-market.Controllers.new-market.show')}}" style="color:#fff;">插件安装/升级</a></el-button></div>
  79. <div>
  80. <div>
  81. <el-input placeholder="请输入插件名称" v-model="search_form.title" style="width:15%;margin-right:15px;"></el-input>
  82. <template>
  83. <el-select placeholder="是否授权" v-model="search_form.permit_status" style="margin-right:15px;">
  84. <el-option
  85. v-for="item in permit"
  86. :key="item.value"
  87. :label="item.label"
  88. :value="item.value">
  89. </el-option>
  90. </el-select>
  91. </template>
  92. <template>
  93. <el-select placeholder="全部状态" v-model="search_form.status" style="margin-right:15px;">
  94. <el-option
  95. v-for="item in action"
  96. :key="item.value"
  97. :label="item.label"
  98. :value="item.value">
  99. </el-option>
  100. </el-select>
  101. </template>
  102. <template>
  103. <el-select placeholder="是否可升级" v-model="search_form.update_status" style="margin-right:15px;">
  104. <el-option
  105. v-for="item in update"
  106. :key="item.value"
  107. :label="item.label"
  108. :value="item.value">
  109. </el-option>
  110. </el-select>
  111. </template>
  112. <el-button type="primary" @click="search">搜索</el-button>
  113. </div>
  114. <div style="margin-top:20px;">
  115. <el-button type="primary" class="btn-one" @click="allChoose">全选</el-button>
  116. <el-button type="primary" class="btn-one" @click="allOpen">批量启用</el-button>
  117. <el-button type="danger" class="btn-two" @click="allClose">批量禁用</el-button>
  118. @if(YunShop::app()->role == 'founder') {{--判断是不是超级管理员--}}
  119. <el-button type="danger" class="btn-two" @click="allDelete">批量卸载</el-button>
  120. @endif
  121. </div>
  122. </div>
  123. </div>
  124. <div style="background: #eff3f6;width:100%;height:15px;"></div>
  125. <div class="block" style="padding-top:20px;">
  126. <div class="title"><div style="display:flex;align-items:center;"><span style="width: 4px;height: 18px;background-color: #29ba9c;margin-right:15px;display:inline-block;"></span><b>插件列表</b><span style="color: #999999;font-size:12px;display:inline-block;margin-left:16px;"><span>插件总数:{{$countPlugin}} 已授权插件:{{$countPlugin-$unPermitPlugin}} 未授权插件:{{$unPermitPlugin}}</span></div></div>
  127. </div>
  128. <template style="margin-top:-10px;">
  129. <el-table
  130. :data="list"
  131. style="padding:0 10px"
  132. style="width: 100%">
  133. <el-table-column
  134. align="center"
  135. label="选择"
  136. width="100">
  137. <template slot-scope="scope">
  138. <el-checkbox v-model="scope.row.choose" @change="getStatus(scope.row)" :disabled = " scope.row.name=='plugins-market' " ></el-checkbox>
  139. </template>
  140. </el-table-column>
  141. <el-table-column
  142. prop="title"
  143. align="center"
  144. label="插件名称"
  145. label="100">
  146. </el-table-column>
  147. <el-table-column
  148. prop="version"
  149. align="center"
  150. label="当前版本"
  151. label="100">
  152. </el-table-column>
  153. <el-table-column
  154. prop="new_version"
  155. align="center"
  156. label="最新版本"
  157. label="100">
  158. <template slot-scope="scope" >
  159. [[scope.row.new_version]]
  160. <span style="margin-left:5px;color:#29BA9C;" v-if="scope.row.update">可升级</span>
  161. </template>
  162. </el-table-column>
  163. <el-table-column
  164. prop="permit_status"
  165. align="center"
  166. label="是否授权"
  167. label="100">
  168. <template slot-scope="scope" >
  169. <div v-if="scope.row.permit_status=='已授权'" style="color:#29BA9C;">已授权</div>
  170. <div v-if="scope.row.permit_status=='未授权'" style="color:red;">未授权</div>
  171. </template>
  172. </el-table-column>
  173. <el-table-column
  174. align="center"
  175. label="状态"
  176. label="100">
  177. <template slot-scope="scope" >
  178. <el-switch
  179. @change="changeStatus(scope.row)"
  180. v-model="scope.row.status"
  181. >
  182. </el-switch>
  183. </template>
  184. </el-table-column>
  185. @if(YunShop::app()->role == 'founder') {{--判断是不是超级管理员--}}
  186. <el-table-column
  187. align="center"
  188. label="操作"
  189. label="100">
  190. <template slot-scope="scope" >
  191. <el-button type="danger" @click="deletePlugin(scope.row)" :disabled = " scope.row.name=='plugins-market' " >卸载</el-button>
  192. </template>
  193. </el-table-column>
  194. @endif
  195. </el-table>
  196. </template>
  197. </div>
  198. </div>
  199. </div>
  200. <script>
  201. var vm = new Vue({
  202. el: "#re_content",
  203. delimiters: ['[[', ']]'],
  204. data() {
  205. let data = {!! $data ?: '[]' !!}
  206. return {
  207. is_all_choose:false,
  208. activeName: 'one',
  209. all_loading:false,
  210. page:1,
  211. page_size:1,
  212. loading:false,
  213. search_loading:false,
  214. search_form:{},
  215. real_search_form:{},
  216. value:'',
  217. form:{
  218. link:'',
  219. checkList:[],
  220. },
  221. permit: [
  222. {
  223. value: '已授权',
  224. label: '已授权'
  225. },
  226. {
  227. value: '未授权',
  228. label: '未授权'
  229. },
  230. ],
  231. permit: [
  232. {
  233. value: '已授权',
  234. label: '已授权'
  235. },
  236. {
  237. value: '未授权',
  238. label: '未授权'
  239. },
  240. ],
  241. permit: [
  242. {
  243. value: '已授权',
  244. label: '已授权'
  245. },
  246. {
  247. value: '未授权',
  248. label: '未授权'
  249. },
  250. ],
  251. action: [
  252. {
  253. value: 'enable',
  254. label: '启用'
  255. },
  256. {
  257. value: 'disable',
  258. label: '禁用'
  259. },
  260. ],
  261. update: [
  262. {
  263. value: '可升级',
  264. label: '可升级'
  265. },
  266. ],
  267. list: data,
  268. }
  269. },
  270. created(){
  271. let arr =[]
  272. this.list.forEach((item,index)=>{
  273. item.choose=false;
  274. if(Number(String(item.new_version).split('.').join(''))>Number(String(item.version).split('.').join(''))){
  275. item.update=true
  276. }else{
  277. item.update=false
  278. }
  279. arr.push(item)
  280. this.$forceUpdate()
  281. })
  282. this.list=arr;
  283. },
  284. mounted () {
  285. },
  286. methods: {
  287. getStatus(){
  288. let arr=[]
  289. this.list.forEach((item,index)=>{
  290. arr.push(item)
  291. })
  292. this.list=arr
  293. this.$forceUpdate()
  294. },
  295. changeStatus(item){
  296. let json={
  297. name:item.name,
  298. action:item.status?'enable':'disable'
  299. }
  300. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  301. this.$http.post('{!! yzWebFullUrl('plugins.manage') !!}',json).then(function (response){
  302. if (response.data.result) {
  303. this.$message({message:response.data.msg,type:"success"});
  304. this.loading = false;
  305. }else {
  306. this.$message({message: response.data.msg,type: 'error'});
  307. }
  308. loading.close();
  309. let a = window.location.href+"&"+Math.floor((Math.random()*10)+1);;
  310. window.location.href = a ;
  311. },function (response) {
  312. console.log(response);
  313. this.loading = false;
  314. }
  315. );
  316. },
  317. allChoose() {
  318. let arr=[]
  319. if(!this.is_all_choose){
  320. this.list.forEach((item,index)=>{
  321. if(item.name !== 'plugins-market'){
  322. item.choose=true
  323. }
  324. arr.push(item)
  325. this.$forceUpdate()
  326. })
  327. this.is_all_choose=true
  328. }else{
  329. this.list.forEach((item,index)=>{
  330. if(item.name !== 'plugins-market'){
  331. item.choose=false
  332. }
  333. arr.push(item)
  334. this.$forceUpdate()
  335. })
  336. this.is_all_choose=false
  337. }
  338. this.list=arr
  339. this.$forceUpdate()
  340. },
  341. allClose(){
  342. let vals=[]
  343. this.list.forEach((item,index)=>{
  344. if(item.choose){
  345. vals.push(item.name)
  346. }
  347. })
  348. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  349. this.$http.post('{!! yzWebFullUrl('plugins.batchMange') !!}',{names:vals.join(','),action:'disable'}).then(function (response){
  350. if (response.data.result) {
  351. this.$message({message:response.data.msg,type:"success"});
  352. this.loading = false;
  353. }else {
  354. this.$message({message: response.data.msg,type: 'error'});
  355. }
  356. loading.close();
  357. location.reload();
  358. },function (response) {
  359. console.log(response);
  360. this.loading = false;
  361. }
  362. );
  363. },
  364. allOpen(){
  365. let vals=[]
  366. this.list.forEach((item,index)=>{
  367. if(item.choose){
  368. vals.push(item.name)
  369. }
  370. })
  371. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  372. this.$http.post('{!! yzWebFullUrl('plugins.batchMange') !!}',{names:vals.join(','),action:'enable'}).then(function (response){
  373. if (response.data.result) {
  374. this.$message({message:response.data.msg,type:"success"});
  375. this.loading = false;
  376. }else {
  377. this.$message({message: response.data.msg,type: 'error'});
  378. }
  379. loading.close();
  380. location.reload();
  381. },function (response) {
  382. console.log(response);
  383. this.loading = false;
  384. }
  385. );
  386. },
  387. allDelete(){
  388. this.$confirm('卸载插件后,将删除插件文件、整站无法使用该插件!如插件已经停止供应,将无法再次安装! 是否继续?', '温馨提示', {
  389. confirmButtonText: '确定',
  390. cancelButtonText: '取消',
  391. type: 'warning'
  392. }).then(() => {
  393. let vals=[]
  394. this.list.forEach((item,index)=>{
  395. if(item.choose){
  396. vals.push(item.name)
  397. }
  398. })
  399. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  400. this.$http.post('{!! yzWebFullUrl('plugins.batchMange') !!}',{names:vals.join(','),action:'delete'}).then(function (response){
  401. if (response.data.result) {
  402. this.$message({message:response.data.msg,type:"success"});
  403. this.loading = false;
  404. }else {
  405. this.$message({message: response.data.msg,type: 'error'});
  406. }
  407. loading.close();
  408. location.reload();
  409. },function (response) {
  410. console.log(response);
  411. this.loading = false;
  412. }
  413. );
  414. }).catch(() => {
  415. this.$message({
  416. type: 'info',
  417. message: '已取消卸载'
  418. });
  419. });
  420. },
  421. search() {
  422. this.search_loading = true;
  423. this.$http.post('{!! yzWebFullUrl('plugins.get-plugin-data') !!}',{search:this.search_form}
  424. ).then(function (response) {
  425. if (response.data.result){
  426. this.list=response.data.data
  427. let arr=[]
  428. this.list.forEach((item,index)=>{
  429. item.choose=false;
  430. if(Number(String(item.new_version).split('.').join(''))>Number(String(item.version).split('.').join(''))){
  431. item.update=true
  432. }else{
  433. item.update=false
  434. }
  435. arr.push(item)
  436. this.$forceUpdate()
  437. })
  438. this.list=arr;
  439. this.real_search_form=Object.assign({},this.search_form);
  440. }
  441. else {
  442. this.$message({message: response.data.msg,type: 'error'});
  443. }
  444. this.search_loading = false;
  445. },function (response) {
  446. this.search_loading = false;
  447. this.$message({message: response.data.msg,type: 'error'});
  448. }
  449. );
  450. },
  451. deletePlugin(item){
  452. this.$confirm('卸载插件后,将删除插件文件、整站无法使用该插件!如插件已经停止供应,将无法再次安装! 是否继续?', '温馨提示', {
  453. confirmButtonText: '确定',
  454. cancelButtonText: '取消',
  455. type: 'warning'
  456. }).then(() => {
  457. let json={
  458. name:item.name,
  459. action:'delete'
  460. }
  461. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  462. this.$http.post('{!! yzWebFullUrl('plugins.manage') !!}',json).then(function (response){
  463. if (response.data.result) {
  464. this.$message({message:response.data.msg,type:"success"});
  465. this.loading = false;
  466. }else {
  467. this.$message({message: response.data.msg,type: 'error'});
  468. }
  469. loading.close();
  470. location.reload();
  471. },function (response) {
  472. console.log(response);
  473. this.loading = false;
  474. }
  475. );
  476. }).catch(() => {
  477. this.$message({
  478. type: 'info',
  479. message: '已取消卸载'
  480. });
  481. });
  482. },
  483. },
  484. });
  485. </script>
  486. @endsection