作者归档:admin

command color

命令行颜色

代码

<?php
declare (strict_types = 1);

namespace app\admin\command;

use think\console\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\input\Option;
use think\console\output\formatter\Style;
use think\console\Output;

class Hello extends Command
{
    protected function configure()
    {
        // 指令配置
        $this->setName('hello')
            ->setDescription('php think hello --ansi 演示命令行颜色');
    }

    protected function execute(Input $input, Output $output)
    {   
        $output->info("info");
        $output->error("error");
        $output->warning("warning");
        $output->highlight("highlight"); 
        $output->question("question"); 
        /*$question = $output->confirm($input, 'Continue with this action?', false); 
        if (!$question) {
            return;
        }*/

    }
}

添加至php think

add_action("console",function(&$console){
    if(!is_cli()){return;}
    // php think hello
    $console['hello'] = "app\admin\command\Hello"; 
});  

运行

php think hello --ansi

效果

uni滚动加载 mescroll-body

<template>
	<view>
		<mescroll-body top="0" :up="upOption" :down="downOption" @init="mescrollInit" @down="downCallback"
			@up="upCallback"> 
			<view class="" style="font-size: 28rpx;"> 
				  <view class="card t-center" v-for="v in list" @click="nav('/active_bm/index/detail?id='+v.id)"> 
						<image mode="aspectFit" :src="v.image_http" style="width: 100%;"></image>
						<view>{{v.title}}</view>
				  </view>
			</view>
		</mescroll-body> 

		<cl-toast ref="toast"></cl-toast>
		<cl-message ref="message"></cl-message>
		<t-login-phone @logined="logined" :visible='show_login_phone'></t-login-phone>
	</view>
</template>

<script>
	var _this
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	export default {
		mixins: [MescrollMixin], // 使用mixin 
		data() {
			return { 
				where: {
					page: 1,
					per_page: 10
				},
				upOption: {
					page: {
						size: 10 // 每页数据的数量,默认10
					},
					noMoreSize: 5, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
					empty: {
						tip: '暂无相关数据'
					},
					textNoMore: '-- 到底了 --'
				},
				downOption: {
					auto: false, //是否在初始化后,自动执行downCallback; 默认true 
				},
				list: [],
				is_load: false,
				vip_card: {},
				row: {},
				visible: false,
			}
		},
		onLoad() {
			_this = this
		},
		onShow() { 
		},
		methods: {
			view_detail(v) {
				this.nav('/active_bm/index/detail?id='+v.id)
			}, 
			swiper_change() {
				let index = this.active_swiper
				this.yue = this.vip_card[index].amount
			},
			logined() {
				this.reload()
			},

			/*下拉刷新的回调 */
			downCallback() {
				this.where.page = 1
				this.load() 
				this.mescroll.resetUpScroll();
			},
			upCallback(page) {
				this.where.page = page.num
				this.load()
			},
			reload() {
				this.where.page = 1
				this.load() 
			},
			load() { 
				_this.ajax(_this.config.active_bm.index, _this.where).then(res => {
					_this.is_load = true
					if(res.code != 0){
						_this.mescroll.endBySize(0, 0);
						return;
					} 
					if (res.current_page == 1) {
						_this.list = []
					}
					for (let i in res.data) {
						_this.list.push(res.data[i])
					}
					_this.mescroll.endBySize(res.total_cur, res.total);
				})
			}
		}
	};
</script>

<style lang="scss">
	.fuwu {

		.space-between {
			margin-bottom: 10rpx;
		}
	}

	page {
		background-color: #F5F7FA;
	}

	.page-community {
		/deep/.cl-tabs__bar-item {
			color: #848484;
		}

		.tabBar {
			/deep/.cl-tabs__bar {
				background-color: rgba(0, 0, 0, 0) !important;

				.cl-tabs__bar-item.is-active {
					font-size: 34rpx;
				}

				.cl-tabs__line {
					height: 6rpx;
					border-radius: 4rpx;
				}
			}
		}

		.list {
			.item {
				/deep/.cl-button.cl-button--primary {
					background-color: #F5F7FA;
					width: 136rpx;
					height: 58rpx;

					.cl-button__text {
						color: #28B5B5;
					}
				}
			}
		}
	}
</style>

用户后台

目录

app/a_user_admin 

后台地址

/a_user_admin/login

添加菜单

add_user_access('书籍.novel_book',[
    'url'=>'novel/book/index'
],1);

用户首页

add_action("user.index",function(){
    echo 1;
});

检测用户是否可以访问用户后台

do_action("user.check",$user);

登录前

do_action("user.login",$user);

发验证码前

do_action("user.phone_code",$user);

页面

<?php global $vue;user_header(); ?>

<div id="" style="padding-top:20px;">
  
</div>

<?php user_footer();?>

SSL泛解析证书

使用

首次生成证书

php think  webtool:ssl yourdomain.com issue_ca_ssl

续签证书

php think  webtool:ssl yourdomain.com renew_ca_ssl

同步证书至宝塔

php think  webtool:ssl_to_bt 0

配置.env

bt_url = http://IP:8098/
bt_key = 

依赖ZeroSSL

安装

wget -O -  https://get.acme.sh | sh -s email=yourmailaddress
或使用国内
curl https://gitcode.net/cert/cn-acme.sh/-/raw/master/install.sh?inline=false | sh -s email=yourmailaddress 

其中yourmailaddress是邮件地址

ln -s ~/.acme.sh/acme.sh

选择CA服务器

推荐zerossl

~/.acme.sh/acme.sh --set-default-ca --server letsencrypt
~/.acme.sh/acme.sh --set-default-ca --server buypass
~/.acme.sh/acme.sh --set-default-ca --server zerossl

  • letsencrypt https://acme-v02.api.letsencrypt.org/directory
  • letsencrypt_test https://acme-staging-v02.api.letsencrypt.org/directory
  • buypass https://api.buypass.com/acme/directory
  • buypass_test https://api.test4.buypass.no/acme/directory
  • zerossl https://acme.zerossl.com/v2/DV90
  • sslcom https://acme.ssl.com/sslcom-dv-rsa, https://acme.ssl.com/sslcom-dv-ecc
  • google https://dv.acme-v02.api.pki.goog/directory
  • googletest https://dv.acme-v02.test-api.pki.goog/directory