前言

Typecho在前阵子迎来了1.2版本的更新 同时uniapp也进行了重做更新

故老版本的小程序已经无法正常运行

image.png

安装

我先前这篇有详细的教程

问题

Typecho小程序1.2版本适配方案
/**
     * 抛出ajax的回执信息
     *
     * @access public
     * @param string $message 消息体
     * @return void
     */
    public function throwXml($message)
{
        /** 设置http头信息 */
        $this->setContentType('text/xml');

        /** 构建消息体 */
        echo '<?xml version="1.0" encoding="' . $this->getCharset() . '"?>',
        '<response>',
        $this->_parseXml($message),
        '</response>';

        /** 终止后续输出 */
        exit;
    }

    /**
     * 抛出json回执信息
     *
     * @access public
     * @param mixed $message 消息体
     * @return void
     */
    public function throwJson($message)
{
        /** 设置http头信息 */
        $this->setContentType('application/json');

        echo json_encode($message);

        /** 终止后续输出 */
        exit;
    }

代码位置在var/Typecho/Response.php中,如果想要在1.2版本中使用插件,只需要将代码加入到1.2版本的该文件中就可以了

var/Typecho/Response.php

其他配置方法就和之前的是一样的了,注意一定要关闭php7.2版本的display_errors报错功能,不然也不会成功。

Typecho小程序1.2版本来自网络

Last modification:January 4, 2023
If you think my article is useful to you, please feel free to appreciate