From 5955a03d2c039463f0891d5e5be4e16cd93eb3ca Mon Sep 17 00:00:00 2001 From: augushong Date: Mon, 25 Sep 2023 10:35:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0view=E7=9A=84=E6=89=A9?= =?UTF-8?q?=E5=B1=95=E6=9E=B6=E6=9E=84=EF=BC=9B=E8=B0=83=E6=95=B4think-vie?= =?UTF-8?q?w=E4=BE=9D=E8=B5=96=EF=BC=9B=E5=8F=91=E5=B8=83=E6=96=B0?= =?UTF-8?q?=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/command/admin/Version.php | 10 +- composer.json | 4 +- composer.lock | 43 +--- .../base}/admin/view/common/_require.html | 0 .../base}/admin/view/debug/log/_common.js | 0 .../base}/admin/view/debug/log/index.html | 0 .../base}/admin/view/debug/log/index.js | 0 .../base}/admin/view/index/_common.js | 0 .../base}/admin/view/index/demo.html | 0 .../base}/admin/view/index/edit_admin.html | 0 .../base}/admin/view/index/edit_admin.js | 0 .../base}/admin/view/index/edit_password.html | 0 .../base}/admin/view/index/edit_password.js | 0 .../base}/admin/view/index/index.html | 0 .../base}/admin/view/index/index.js | 0 .../base}/admin/view/index/welcome.html | 0 .../base}/admin/view/index/welcome.js | 0 .../base}/admin/view/layout/default.html | 0 .../base}/admin/view/login/_common.js | 0 .../base}/admin/view/login/ext/demo.html | 0 .../base}/admin/view/login/index.html | 0 .../base}/admin/view/login/index.js | 0 .../base}/admin/view/mall/cate/_common.js | 0 .../base}/admin/view/mall/cate/add.html | 0 .../base}/admin/view/mall/cate/add.js | 0 .../base}/admin/view/mall/cate/edit.html | 0 .../base}/admin/view/mall/cate/edit.js | 0 .../base}/admin/view/mall/cate/index.html | 0 .../base}/admin/view/mall/cate/index.js | 0 .../base}/admin/view/mall/goods/_common.js | 0 .../base}/admin/view/mall/goods/add.html | 0 .../base}/admin/view/mall/goods/add.js | 0 .../base}/admin/view/mall/goods/edit.html | 0 .../base}/admin/view/mall/goods/edit.js | 0 .../base}/admin/view/mall/goods/index.html | 0 .../base}/admin/view/mall/goods/index.js | 0 .../base}/admin/view/mall/goods/read.html | 0 .../base}/admin/view/mall/goods/read.js | 0 .../base}/admin/view/mall/goods/stock.html | 0 .../base}/admin/view/mall/goods/stock.js | 0 .../base}/admin/view/mall/tag/_common.js | 0 .../base}/admin/view/mall/tag/add.html | 0 .../base}/admin/view/mall/tag/add.js | 0 .../base}/admin/view/mall/tag/edit.html | 0 .../base}/admin/view/mall/tag/edit.js | 0 .../base}/admin/view/mall/tag/index.html | 0 .../base}/admin/view/mall/tag/index.js | 0 .../base}/admin/view/system/admin/_common.js | 0 .../base}/admin/view/system/admin/add.html | 0 .../base}/admin/view/system/admin/add.js | 0 .../base}/admin/view/system/admin/edit.html | 0 .../base}/admin/view/system/admin/edit.js | 0 .../base}/admin/view/system/admin/index.html | 0 .../base}/admin/view/system/admin/index.js | 0 .../admin/view/system/admin/password.html | 0 .../base}/admin/view/system/admin/password.js | 0 .../base}/admin/view/system/auth/_common.js | 0 .../base}/admin/view/system/auth/add.html | 0 .../base}/admin/view/system/auth/add.js | 0 .../admin/view/system/auth/authorize.html | 0 .../base}/admin/view/system/auth/authorize.js | 0 .../base}/admin/view/system/auth/edit.html | 0 .../base}/admin/view/system/auth/edit.js | 0 .../base}/admin/view/system/auth/index.html | 0 .../base}/admin/view/system/auth/index.js | 0 .../base}/admin/view/system/config/_common.js | 0 .../base}/admin/view/system/config/index.html | 0 .../base}/admin/view/system/config/index.js | 0 .../base}/admin/view/system/config/logo.html | 0 .../base}/admin/view/system/config/site.html | 0 .../admin/view/system/config/upload.html | 0 .../base}/admin/view/system/menu/_common.js | 0 .../base}/admin/view/system/menu/add.html | 0 .../base}/admin/view/system/menu/add.js | 0 .../base}/admin/view/system/menu/edit.html | 0 .../base}/admin/view/system/menu/edit.js | 0 .../base}/admin/view/system/menu/index.html | 0 .../base}/admin/view/system/menu/index.js | 0 .../base}/admin/view/system/node/_common.js | 0 .../base}/admin/view/system/node/index.html | 0 .../base}/admin/view/system/node/index.js | 0 .../base}/admin/view/system/quick/_common.js | 0 .../base}/admin/view/system/quick/add.html | 0 .../base}/admin/view/system/quick/add.js | 0 .../base}/admin/view/system/quick/edit.html | 0 .../base}/admin/view/system/quick/edit.js | 0 .../base}/admin/view/system/quick/index.html | 0 .../base}/admin/view/system/quick/index.js | 0 .../admin/view/system/uploadfile/_common.js | 0 .../admin/view/system/uploadfile/add.html | 0 .../base}/admin/view/system/uploadfile/add.js | 0 .../admin/view/system/uploadfile/index.html | 0 .../admin/view/system/uploadfile/index.js | 0 extend/think/view/driver/Think.php | 235 ++++++++++++++++++ 94 files changed, 244 insertions(+), 48 deletions(-) rename {app => extend/base}/admin/view/common/_require.html (100%) rename {app => extend/base}/admin/view/debug/log/_common.js (100%) rename {app => extend/base}/admin/view/debug/log/index.html (100%) rename {app => extend/base}/admin/view/debug/log/index.js (100%) rename {app => extend/base}/admin/view/index/_common.js (100%) rename {app => extend/base}/admin/view/index/demo.html (100%) rename {app => extend/base}/admin/view/index/edit_admin.html (100%) rename {app => extend/base}/admin/view/index/edit_admin.js (100%) rename {app => extend/base}/admin/view/index/edit_password.html (100%) rename {app => extend/base}/admin/view/index/edit_password.js (100%) rename {app => extend/base}/admin/view/index/index.html (100%) rename {app => extend/base}/admin/view/index/index.js (100%) rename {app => extend/base}/admin/view/index/welcome.html (100%) rename {app => extend/base}/admin/view/index/welcome.js (100%) rename {app => extend/base}/admin/view/layout/default.html (100%) rename {app => extend/base}/admin/view/login/_common.js (100%) rename {app => extend/base}/admin/view/login/ext/demo.html (100%) rename {app => extend/base}/admin/view/login/index.html (100%) rename {app => extend/base}/admin/view/login/index.js (100%) rename {app => extend/base}/admin/view/mall/cate/_common.js (100%) rename {app => extend/base}/admin/view/mall/cate/add.html (100%) rename {app => extend/base}/admin/view/mall/cate/add.js (100%) rename {app => extend/base}/admin/view/mall/cate/edit.html (100%) rename {app => extend/base}/admin/view/mall/cate/edit.js (100%) rename {app => extend/base}/admin/view/mall/cate/index.html (100%) rename {app => extend/base}/admin/view/mall/cate/index.js (100%) rename {app => extend/base}/admin/view/mall/goods/_common.js (100%) rename {app => extend/base}/admin/view/mall/goods/add.html (100%) rename {app => extend/base}/admin/view/mall/goods/add.js (100%) rename {app => extend/base}/admin/view/mall/goods/edit.html (100%) rename {app => extend/base}/admin/view/mall/goods/edit.js (100%) rename {app => extend/base}/admin/view/mall/goods/index.html (100%) rename {app => extend/base}/admin/view/mall/goods/index.js (100%) rename {app => extend/base}/admin/view/mall/goods/read.html (100%) rename {app => extend/base}/admin/view/mall/goods/read.js (100%) rename {app => extend/base}/admin/view/mall/goods/stock.html (100%) rename {app => extend/base}/admin/view/mall/goods/stock.js (100%) rename {app => extend/base}/admin/view/mall/tag/_common.js (100%) rename {app => extend/base}/admin/view/mall/tag/add.html (100%) rename {app => extend/base}/admin/view/mall/tag/add.js (100%) rename {app => extend/base}/admin/view/mall/tag/edit.html (100%) rename {app => extend/base}/admin/view/mall/tag/edit.js (100%) rename {app => extend/base}/admin/view/mall/tag/index.html (100%) rename {app => extend/base}/admin/view/mall/tag/index.js (100%) rename {app => extend/base}/admin/view/system/admin/_common.js (100%) rename {app => extend/base}/admin/view/system/admin/add.html (100%) rename {app => extend/base}/admin/view/system/admin/add.js (100%) rename {app => extend/base}/admin/view/system/admin/edit.html (100%) rename {app => extend/base}/admin/view/system/admin/edit.js (100%) rename {app => extend/base}/admin/view/system/admin/index.html (100%) rename {app => extend/base}/admin/view/system/admin/index.js (100%) rename {app => extend/base}/admin/view/system/admin/password.html (100%) rename {app => extend/base}/admin/view/system/admin/password.js (100%) rename {app => extend/base}/admin/view/system/auth/_common.js (100%) rename {app => extend/base}/admin/view/system/auth/add.html (100%) rename {app => extend/base}/admin/view/system/auth/add.js (100%) rename {app => extend/base}/admin/view/system/auth/authorize.html (100%) rename {app => extend/base}/admin/view/system/auth/authorize.js (100%) rename {app => extend/base}/admin/view/system/auth/edit.html (100%) rename {app => extend/base}/admin/view/system/auth/edit.js (100%) rename {app => extend/base}/admin/view/system/auth/index.html (100%) rename {app => extend/base}/admin/view/system/auth/index.js (100%) rename {app => extend/base}/admin/view/system/config/_common.js (100%) rename {app => extend/base}/admin/view/system/config/index.html (100%) rename {app => extend/base}/admin/view/system/config/index.js (100%) rename {app => extend/base}/admin/view/system/config/logo.html (100%) rename {app => extend/base}/admin/view/system/config/site.html (100%) rename {app => extend/base}/admin/view/system/config/upload.html (100%) rename {app => extend/base}/admin/view/system/menu/_common.js (100%) rename {app => extend/base}/admin/view/system/menu/add.html (100%) rename {app => extend/base}/admin/view/system/menu/add.js (100%) rename {app => extend/base}/admin/view/system/menu/edit.html (100%) rename {app => extend/base}/admin/view/system/menu/edit.js (100%) rename {app => extend/base}/admin/view/system/menu/index.html (100%) rename {app => extend/base}/admin/view/system/menu/index.js (100%) rename {app => extend/base}/admin/view/system/node/_common.js (100%) rename {app => extend/base}/admin/view/system/node/index.html (100%) rename {app => extend/base}/admin/view/system/node/index.js (100%) rename {app => extend/base}/admin/view/system/quick/_common.js (100%) rename {app => extend/base}/admin/view/system/quick/add.html (100%) rename {app => extend/base}/admin/view/system/quick/add.js (100%) rename {app => extend/base}/admin/view/system/quick/edit.html (100%) rename {app => extend/base}/admin/view/system/quick/edit.js (100%) rename {app => extend/base}/admin/view/system/quick/index.html (100%) rename {app => extend/base}/admin/view/system/quick/index.js (100%) rename {app => extend/base}/admin/view/system/uploadfile/_common.js (100%) rename {app => extend/base}/admin/view/system/uploadfile/add.html (100%) rename {app => extend/base}/admin/view/system/uploadfile/add.js (100%) rename {app => extend/base}/admin/view/system/uploadfile/index.html (100%) rename {app => extend/base}/admin/view/system/uploadfile/index.js (100%) create mode 100644 extend/think/view/driver/Think.php diff --git a/app/common/command/admin/Version.php b/app/common/command/admin/Version.php index fe7eed9..b770707 100644 --- a/app/common/command/admin/Version.php +++ b/app/common/command/admin/Version.php @@ -12,18 +12,20 @@ use think\console\Output; class Version extends Command { - public const VERSION = 'v2.0.43'; + public const VERSION = 'v2.0.44'; public const LAYUI_VERSION = '2.8.16'; public const COMMENT = [ - '调整更新逻辑', + '实现view的扩展架构', + '调整think-view依赖', '发布新版本', ]; public const UPDATE_TIPS = [ - '本次调整了append类型的更新文件列表,', - '建议删除以下目录的内容,再重新获取更新,以便初始化相关类,但如果您定制了相关文件,请不要删除,可以参考最新版本的代码调整文件', + '本次更新调整了composer依赖,请根据实际情况调整', + '删除 think-view', + '引入 topthink/think-template-view', ]; protected function configure() diff --git a/composer.json b/composer.json index 1dbacd4..69fa819 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,6 @@ "topthink/framework": "^8.0", "topthink/think-orm": "^3.0", "topthink/think-multi-app": "^1.0", - "topthink/think-view": "^2.0", "topthink/think-captcha": "^3.0", "guzzlehttp/guzzle": "^7.4", "phpoffice/phpspreadsheet": "^1.22", @@ -32,7 +31,8 @@ "overtrue/flysystem-cos": "^5.0", "iidestiny/flysystem-oss": "^4.0", "czproject/git-php": "^4.2", - "localheinz/diff": "^1.1" + "localheinz/diff": "^1.1", + "topthink/think-template": "^3.0" }, "require-dev": { "symfony/var-dumper": "^4.2" diff --git a/composer.lock b/composer.lock index cb07b6d..ba60511 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "eabe0953a10d42f429663eb3c42834a5", + "content-hash": "cf930a793fc0588ec1f01c7e8bfb5ea6", "packages": [ { "name": "aliyuncs/oss-sdk-php", @@ -2458,47 +2458,6 @@ "source": "https://github.com/top-think/think-template/tree/v3.0.0" }, "time": "2023-02-25T12:11:14+00:00" - }, - { - "name": "topthink/think-view", - "version": "v2.0.0", - "source": { - "type": "git", - "url": "https://github.com/top-think/think-view.git", - "reference": "d2a076011c96d2edd8016703a827fb54b2683c62" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/top-think/think-view/zipball/d2a076011c96d2edd8016703a827fb54b2683c62", - "reference": "d2a076011c96d2edd8016703a827fb54b2683c62", - "shasum": "" - }, - "require": { - "php": ">=8.0.0", - "topthink/think-template": "^3.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "think\\view\\driver\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "liu21st", - "email": "liu21st@gmail.com" - } - ], - "description": "thinkphp template driver", - "support": { - "issues": "https://github.com/top-think/think-view/issues", - "source": "https://github.com/top-think/think-view/tree/v2.0.0" - }, - "time": "2023-02-25T12:18:09+00:00" } ], "packages-dev": [ diff --git a/app/admin/view/common/_require.html b/extend/base/admin/view/common/_require.html similarity index 100% rename from app/admin/view/common/_require.html rename to extend/base/admin/view/common/_require.html diff --git a/app/admin/view/debug/log/_common.js b/extend/base/admin/view/debug/log/_common.js similarity index 100% rename from app/admin/view/debug/log/_common.js rename to extend/base/admin/view/debug/log/_common.js diff --git a/app/admin/view/debug/log/index.html b/extend/base/admin/view/debug/log/index.html similarity index 100% rename from app/admin/view/debug/log/index.html rename to extend/base/admin/view/debug/log/index.html diff --git a/app/admin/view/debug/log/index.js b/extend/base/admin/view/debug/log/index.js similarity index 100% rename from app/admin/view/debug/log/index.js rename to extend/base/admin/view/debug/log/index.js diff --git a/app/admin/view/index/_common.js b/extend/base/admin/view/index/_common.js similarity index 100% rename from app/admin/view/index/_common.js rename to extend/base/admin/view/index/_common.js diff --git a/app/admin/view/index/demo.html b/extend/base/admin/view/index/demo.html similarity index 100% rename from app/admin/view/index/demo.html rename to extend/base/admin/view/index/demo.html diff --git a/app/admin/view/index/edit_admin.html b/extend/base/admin/view/index/edit_admin.html similarity index 100% rename from app/admin/view/index/edit_admin.html rename to extend/base/admin/view/index/edit_admin.html diff --git a/app/admin/view/index/edit_admin.js b/extend/base/admin/view/index/edit_admin.js similarity index 100% rename from app/admin/view/index/edit_admin.js rename to extend/base/admin/view/index/edit_admin.js diff --git a/app/admin/view/index/edit_password.html b/extend/base/admin/view/index/edit_password.html similarity index 100% rename from app/admin/view/index/edit_password.html rename to extend/base/admin/view/index/edit_password.html diff --git a/app/admin/view/index/edit_password.js b/extend/base/admin/view/index/edit_password.js similarity index 100% rename from app/admin/view/index/edit_password.js rename to extend/base/admin/view/index/edit_password.js diff --git a/app/admin/view/index/index.html b/extend/base/admin/view/index/index.html similarity index 100% rename from app/admin/view/index/index.html rename to extend/base/admin/view/index/index.html diff --git a/app/admin/view/index/index.js b/extend/base/admin/view/index/index.js similarity index 100% rename from app/admin/view/index/index.js rename to extend/base/admin/view/index/index.js diff --git a/app/admin/view/index/welcome.html b/extend/base/admin/view/index/welcome.html similarity index 100% rename from app/admin/view/index/welcome.html rename to extend/base/admin/view/index/welcome.html diff --git a/app/admin/view/index/welcome.js b/extend/base/admin/view/index/welcome.js similarity index 100% rename from app/admin/view/index/welcome.js rename to extend/base/admin/view/index/welcome.js diff --git a/app/admin/view/layout/default.html b/extend/base/admin/view/layout/default.html similarity index 100% rename from app/admin/view/layout/default.html rename to extend/base/admin/view/layout/default.html diff --git a/app/admin/view/login/_common.js b/extend/base/admin/view/login/_common.js similarity index 100% rename from app/admin/view/login/_common.js rename to extend/base/admin/view/login/_common.js diff --git a/app/admin/view/login/ext/demo.html b/extend/base/admin/view/login/ext/demo.html similarity index 100% rename from app/admin/view/login/ext/demo.html rename to extend/base/admin/view/login/ext/demo.html diff --git a/app/admin/view/login/index.html b/extend/base/admin/view/login/index.html similarity index 100% rename from app/admin/view/login/index.html rename to extend/base/admin/view/login/index.html diff --git a/app/admin/view/login/index.js b/extend/base/admin/view/login/index.js similarity index 100% rename from app/admin/view/login/index.js rename to extend/base/admin/view/login/index.js diff --git a/app/admin/view/mall/cate/_common.js b/extend/base/admin/view/mall/cate/_common.js similarity index 100% rename from app/admin/view/mall/cate/_common.js rename to extend/base/admin/view/mall/cate/_common.js diff --git a/app/admin/view/mall/cate/add.html b/extend/base/admin/view/mall/cate/add.html similarity index 100% rename from app/admin/view/mall/cate/add.html rename to extend/base/admin/view/mall/cate/add.html diff --git a/app/admin/view/mall/cate/add.js b/extend/base/admin/view/mall/cate/add.js similarity index 100% rename from app/admin/view/mall/cate/add.js rename to extend/base/admin/view/mall/cate/add.js diff --git a/app/admin/view/mall/cate/edit.html b/extend/base/admin/view/mall/cate/edit.html similarity index 100% rename from app/admin/view/mall/cate/edit.html rename to extend/base/admin/view/mall/cate/edit.html diff --git a/app/admin/view/mall/cate/edit.js b/extend/base/admin/view/mall/cate/edit.js similarity index 100% rename from app/admin/view/mall/cate/edit.js rename to extend/base/admin/view/mall/cate/edit.js diff --git a/app/admin/view/mall/cate/index.html b/extend/base/admin/view/mall/cate/index.html similarity index 100% rename from app/admin/view/mall/cate/index.html rename to extend/base/admin/view/mall/cate/index.html diff --git a/app/admin/view/mall/cate/index.js b/extend/base/admin/view/mall/cate/index.js similarity index 100% rename from app/admin/view/mall/cate/index.js rename to extend/base/admin/view/mall/cate/index.js diff --git a/app/admin/view/mall/goods/_common.js b/extend/base/admin/view/mall/goods/_common.js similarity index 100% rename from app/admin/view/mall/goods/_common.js rename to extend/base/admin/view/mall/goods/_common.js diff --git a/app/admin/view/mall/goods/add.html b/extend/base/admin/view/mall/goods/add.html similarity index 100% rename from app/admin/view/mall/goods/add.html rename to extend/base/admin/view/mall/goods/add.html diff --git a/app/admin/view/mall/goods/add.js b/extend/base/admin/view/mall/goods/add.js similarity index 100% rename from app/admin/view/mall/goods/add.js rename to extend/base/admin/view/mall/goods/add.js diff --git a/app/admin/view/mall/goods/edit.html b/extend/base/admin/view/mall/goods/edit.html similarity index 100% rename from app/admin/view/mall/goods/edit.html rename to extend/base/admin/view/mall/goods/edit.html diff --git a/app/admin/view/mall/goods/edit.js b/extend/base/admin/view/mall/goods/edit.js similarity index 100% rename from app/admin/view/mall/goods/edit.js rename to extend/base/admin/view/mall/goods/edit.js diff --git a/app/admin/view/mall/goods/index.html b/extend/base/admin/view/mall/goods/index.html similarity index 100% rename from app/admin/view/mall/goods/index.html rename to extend/base/admin/view/mall/goods/index.html diff --git a/app/admin/view/mall/goods/index.js b/extend/base/admin/view/mall/goods/index.js similarity index 100% rename from app/admin/view/mall/goods/index.js rename to extend/base/admin/view/mall/goods/index.js diff --git a/app/admin/view/mall/goods/read.html b/extend/base/admin/view/mall/goods/read.html similarity index 100% rename from app/admin/view/mall/goods/read.html rename to extend/base/admin/view/mall/goods/read.html diff --git a/app/admin/view/mall/goods/read.js b/extend/base/admin/view/mall/goods/read.js similarity index 100% rename from app/admin/view/mall/goods/read.js rename to extend/base/admin/view/mall/goods/read.js diff --git a/app/admin/view/mall/goods/stock.html b/extend/base/admin/view/mall/goods/stock.html similarity index 100% rename from app/admin/view/mall/goods/stock.html rename to extend/base/admin/view/mall/goods/stock.html diff --git a/app/admin/view/mall/goods/stock.js b/extend/base/admin/view/mall/goods/stock.js similarity index 100% rename from app/admin/view/mall/goods/stock.js rename to extend/base/admin/view/mall/goods/stock.js diff --git a/app/admin/view/mall/tag/_common.js b/extend/base/admin/view/mall/tag/_common.js similarity index 100% rename from app/admin/view/mall/tag/_common.js rename to extend/base/admin/view/mall/tag/_common.js diff --git a/app/admin/view/mall/tag/add.html b/extend/base/admin/view/mall/tag/add.html similarity index 100% rename from app/admin/view/mall/tag/add.html rename to extend/base/admin/view/mall/tag/add.html diff --git a/app/admin/view/mall/tag/add.js b/extend/base/admin/view/mall/tag/add.js similarity index 100% rename from app/admin/view/mall/tag/add.js rename to extend/base/admin/view/mall/tag/add.js diff --git a/app/admin/view/mall/tag/edit.html b/extend/base/admin/view/mall/tag/edit.html similarity index 100% rename from app/admin/view/mall/tag/edit.html rename to extend/base/admin/view/mall/tag/edit.html diff --git a/app/admin/view/mall/tag/edit.js b/extend/base/admin/view/mall/tag/edit.js similarity index 100% rename from app/admin/view/mall/tag/edit.js rename to extend/base/admin/view/mall/tag/edit.js diff --git a/app/admin/view/mall/tag/index.html b/extend/base/admin/view/mall/tag/index.html similarity index 100% rename from app/admin/view/mall/tag/index.html rename to extend/base/admin/view/mall/tag/index.html diff --git a/app/admin/view/mall/tag/index.js b/extend/base/admin/view/mall/tag/index.js similarity index 100% rename from app/admin/view/mall/tag/index.js rename to extend/base/admin/view/mall/tag/index.js diff --git a/app/admin/view/system/admin/_common.js b/extend/base/admin/view/system/admin/_common.js similarity index 100% rename from app/admin/view/system/admin/_common.js rename to extend/base/admin/view/system/admin/_common.js diff --git a/app/admin/view/system/admin/add.html b/extend/base/admin/view/system/admin/add.html similarity index 100% rename from app/admin/view/system/admin/add.html rename to extend/base/admin/view/system/admin/add.html diff --git a/app/admin/view/system/admin/add.js b/extend/base/admin/view/system/admin/add.js similarity index 100% rename from app/admin/view/system/admin/add.js rename to extend/base/admin/view/system/admin/add.js diff --git a/app/admin/view/system/admin/edit.html b/extend/base/admin/view/system/admin/edit.html similarity index 100% rename from app/admin/view/system/admin/edit.html rename to extend/base/admin/view/system/admin/edit.html diff --git a/app/admin/view/system/admin/edit.js b/extend/base/admin/view/system/admin/edit.js similarity index 100% rename from app/admin/view/system/admin/edit.js rename to extend/base/admin/view/system/admin/edit.js diff --git a/app/admin/view/system/admin/index.html b/extend/base/admin/view/system/admin/index.html similarity index 100% rename from app/admin/view/system/admin/index.html rename to extend/base/admin/view/system/admin/index.html diff --git a/app/admin/view/system/admin/index.js b/extend/base/admin/view/system/admin/index.js similarity index 100% rename from app/admin/view/system/admin/index.js rename to extend/base/admin/view/system/admin/index.js diff --git a/app/admin/view/system/admin/password.html b/extend/base/admin/view/system/admin/password.html similarity index 100% rename from app/admin/view/system/admin/password.html rename to extend/base/admin/view/system/admin/password.html diff --git a/app/admin/view/system/admin/password.js b/extend/base/admin/view/system/admin/password.js similarity index 100% rename from app/admin/view/system/admin/password.js rename to extend/base/admin/view/system/admin/password.js diff --git a/app/admin/view/system/auth/_common.js b/extend/base/admin/view/system/auth/_common.js similarity index 100% rename from app/admin/view/system/auth/_common.js rename to extend/base/admin/view/system/auth/_common.js diff --git a/app/admin/view/system/auth/add.html b/extend/base/admin/view/system/auth/add.html similarity index 100% rename from app/admin/view/system/auth/add.html rename to extend/base/admin/view/system/auth/add.html diff --git a/app/admin/view/system/auth/add.js b/extend/base/admin/view/system/auth/add.js similarity index 100% rename from app/admin/view/system/auth/add.js rename to extend/base/admin/view/system/auth/add.js diff --git a/app/admin/view/system/auth/authorize.html b/extend/base/admin/view/system/auth/authorize.html similarity index 100% rename from app/admin/view/system/auth/authorize.html rename to extend/base/admin/view/system/auth/authorize.html diff --git a/app/admin/view/system/auth/authorize.js b/extend/base/admin/view/system/auth/authorize.js similarity index 100% rename from app/admin/view/system/auth/authorize.js rename to extend/base/admin/view/system/auth/authorize.js diff --git a/app/admin/view/system/auth/edit.html b/extend/base/admin/view/system/auth/edit.html similarity index 100% rename from app/admin/view/system/auth/edit.html rename to extend/base/admin/view/system/auth/edit.html diff --git a/app/admin/view/system/auth/edit.js b/extend/base/admin/view/system/auth/edit.js similarity index 100% rename from app/admin/view/system/auth/edit.js rename to extend/base/admin/view/system/auth/edit.js diff --git a/app/admin/view/system/auth/index.html b/extend/base/admin/view/system/auth/index.html similarity index 100% rename from app/admin/view/system/auth/index.html rename to extend/base/admin/view/system/auth/index.html diff --git a/app/admin/view/system/auth/index.js b/extend/base/admin/view/system/auth/index.js similarity index 100% rename from app/admin/view/system/auth/index.js rename to extend/base/admin/view/system/auth/index.js diff --git a/app/admin/view/system/config/_common.js b/extend/base/admin/view/system/config/_common.js similarity index 100% rename from app/admin/view/system/config/_common.js rename to extend/base/admin/view/system/config/_common.js diff --git a/app/admin/view/system/config/index.html b/extend/base/admin/view/system/config/index.html similarity index 100% rename from app/admin/view/system/config/index.html rename to extend/base/admin/view/system/config/index.html diff --git a/app/admin/view/system/config/index.js b/extend/base/admin/view/system/config/index.js similarity index 100% rename from app/admin/view/system/config/index.js rename to extend/base/admin/view/system/config/index.js diff --git a/app/admin/view/system/config/logo.html b/extend/base/admin/view/system/config/logo.html similarity index 100% rename from app/admin/view/system/config/logo.html rename to extend/base/admin/view/system/config/logo.html diff --git a/app/admin/view/system/config/site.html b/extend/base/admin/view/system/config/site.html similarity index 100% rename from app/admin/view/system/config/site.html rename to extend/base/admin/view/system/config/site.html diff --git a/app/admin/view/system/config/upload.html b/extend/base/admin/view/system/config/upload.html similarity index 100% rename from app/admin/view/system/config/upload.html rename to extend/base/admin/view/system/config/upload.html diff --git a/app/admin/view/system/menu/_common.js b/extend/base/admin/view/system/menu/_common.js similarity index 100% rename from app/admin/view/system/menu/_common.js rename to extend/base/admin/view/system/menu/_common.js diff --git a/app/admin/view/system/menu/add.html b/extend/base/admin/view/system/menu/add.html similarity index 100% rename from app/admin/view/system/menu/add.html rename to extend/base/admin/view/system/menu/add.html diff --git a/app/admin/view/system/menu/add.js b/extend/base/admin/view/system/menu/add.js similarity index 100% rename from app/admin/view/system/menu/add.js rename to extend/base/admin/view/system/menu/add.js diff --git a/app/admin/view/system/menu/edit.html b/extend/base/admin/view/system/menu/edit.html similarity index 100% rename from app/admin/view/system/menu/edit.html rename to extend/base/admin/view/system/menu/edit.html diff --git a/app/admin/view/system/menu/edit.js b/extend/base/admin/view/system/menu/edit.js similarity index 100% rename from app/admin/view/system/menu/edit.js rename to extend/base/admin/view/system/menu/edit.js diff --git a/app/admin/view/system/menu/index.html b/extend/base/admin/view/system/menu/index.html similarity index 100% rename from app/admin/view/system/menu/index.html rename to extend/base/admin/view/system/menu/index.html diff --git a/app/admin/view/system/menu/index.js b/extend/base/admin/view/system/menu/index.js similarity index 100% rename from app/admin/view/system/menu/index.js rename to extend/base/admin/view/system/menu/index.js diff --git a/app/admin/view/system/node/_common.js b/extend/base/admin/view/system/node/_common.js similarity index 100% rename from app/admin/view/system/node/_common.js rename to extend/base/admin/view/system/node/_common.js diff --git a/app/admin/view/system/node/index.html b/extend/base/admin/view/system/node/index.html similarity index 100% rename from app/admin/view/system/node/index.html rename to extend/base/admin/view/system/node/index.html diff --git a/app/admin/view/system/node/index.js b/extend/base/admin/view/system/node/index.js similarity index 100% rename from app/admin/view/system/node/index.js rename to extend/base/admin/view/system/node/index.js diff --git a/app/admin/view/system/quick/_common.js b/extend/base/admin/view/system/quick/_common.js similarity index 100% rename from app/admin/view/system/quick/_common.js rename to extend/base/admin/view/system/quick/_common.js diff --git a/app/admin/view/system/quick/add.html b/extend/base/admin/view/system/quick/add.html similarity index 100% rename from app/admin/view/system/quick/add.html rename to extend/base/admin/view/system/quick/add.html diff --git a/app/admin/view/system/quick/add.js b/extend/base/admin/view/system/quick/add.js similarity index 100% rename from app/admin/view/system/quick/add.js rename to extend/base/admin/view/system/quick/add.js diff --git a/app/admin/view/system/quick/edit.html b/extend/base/admin/view/system/quick/edit.html similarity index 100% rename from app/admin/view/system/quick/edit.html rename to extend/base/admin/view/system/quick/edit.html diff --git a/app/admin/view/system/quick/edit.js b/extend/base/admin/view/system/quick/edit.js similarity index 100% rename from app/admin/view/system/quick/edit.js rename to extend/base/admin/view/system/quick/edit.js diff --git a/app/admin/view/system/quick/index.html b/extend/base/admin/view/system/quick/index.html similarity index 100% rename from app/admin/view/system/quick/index.html rename to extend/base/admin/view/system/quick/index.html diff --git a/app/admin/view/system/quick/index.js b/extend/base/admin/view/system/quick/index.js similarity index 100% rename from app/admin/view/system/quick/index.js rename to extend/base/admin/view/system/quick/index.js diff --git a/app/admin/view/system/uploadfile/_common.js b/extend/base/admin/view/system/uploadfile/_common.js similarity index 100% rename from app/admin/view/system/uploadfile/_common.js rename to extend/base/admin/view/system/uploadfile/_common.js diff --git a/app/admin/view/system/uploadfile/add.html b/extend/base/admin/view/system/uploadfile/add.html similarity index 100% rename from app/admin/view/system/uploadfile/add.html rename to extend/base/admin/view/system/uploadfile/add.html diff --git a/app/admin/view/system/uploadfile/add.js b/extend/base/admin/view/system/uploadfile/add.js similarity index 100% rename from app/admin/view/system/uploadfile/add.js rename to extend/base/admin/view/system/uploadfile/add.js diff --git a/app/admin/view/system/uploadfile/index.html b/extend/base/admin/view/system/uploadfile/index.html similarity index 100% rename from app/admin/view/system/uploadfile/index.html rename to extend/base/admin/view/system/uploadfile/index.html diff --git a/app/admin/view/system/uploadfile/index.js b/extend/base/admin/view/system/uploadfile/index.js similarity index 100% rename from app/admin/view/system/uploadfile/index.js rename to extend/base/admin/view/system/uploadfile/index.js diff --git a/extend/think/view/driver/Think.php b/extend/think/view/driver/Think.php new file mode 100644 index 0000000..df65af6 --- /dev/null +++ b/extend/think/view/driver/Think.php @@ -0,0 +1,235 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\view\driver; + +use think\App; +use think\helper\Str; +use think\Template; +use think\template\exception\TemplateNotFoundException; + +class Think +{ + // 模板引擎实例 + private $template; + + // 模板引擎参数 + protected $config = [ + // 默认模板渲染规则 1 解析为小写+下划线 2 全部转换小写 3 保持操作方法 + 'auto_rule' => 1, + // 视图目录名 + 'view_dir_name' => 'view', + // 模板起始路径 + 'view_path' => '', + // 模板文件后缀 + 'view_suffix' => 'html', + // 模板文件名分隔符 + 'view_depr' => DIRECTORY_SEPARATOR, + // 是否开启模板编译缓存,设为false则每次都会重新编译 + 'tpl_cache' => true, + ]; + + public function __construct(private App $app, array $config = []) + { + $this->config = array_merge($this->config, (array) $config); + + if (empty($this->config['cache_path'])) { + $this->config['cache_path'] = $app->getRuntimePath() . 'temp' . DIRECTORY_SEPARATOR; + } + + $this->template = new Template($this->config); + $this->template->setCache($app->cache); + $this->template->extend('$Think', function (array $vars) { + $type = strtoupper(trim(array_shift($vars))); + $param = implode('.', $vars); + + return match ($type) { + 'CONST' => strtoupper($param), + 'CONFIG' => 'config(\'' . $param . '\')', + 'LANG' => 'lang(\'' . $param . '\')', + 'NOW' => "date('Y-m-d g:i a',time())", + 'LDELIM' => '\'' . ltrim($this->getConfig('tpl_begin'), '\\') . '\'', + 'RDELIM' => '\'' . ltrim($this->getConfig('tpl_end'), '\\') . '\'', + default => defined($type) ? $type : '\'\'', + }; + }); + + $this->template->extend('$Request', function (array $vars) { + // 获取Request请求对象参数 + $method = array_shift($vars); + if (!empty($vars)) { + $params = implode('.', $vars); + if ('true' != $params) { + $params = '\'' . $params . '\''; + } + } else { + $params = ''; + } + + return 'app(\'request\')->' . $method . '(' . $params . ')'; + }); + } + + /** + * 检测是否存在模板文件. + * @param string $template 模板文件或者模板规则 + * @return bool + */ + public function exists(string $template): bool + { + if ('' == pathinfo($template, PATHINFO_EXTENSION)) { + // 获取模板文件名 + $template = $this->parseTemplate($template); + } + + return is_file($template); + } + + /** + * 渲染模板文件. + * @param string $template 模板文件 + * @param array $data 模板变量 + * @return void + */ + public function fetch(string $template, array $data = []): void + { + if ('' == pathinfo($template, PATHINFO_EXTENSION)) { + // 获取模板文件名 + $template = $this->parseTemplate($template); + } + + // 模板不存在 抛出异常 + if (!is_file($template)) { + throw new TemplateNotFoundException('template not exists:' . $template, $template); + } + + $this->template->fetch($template, $data); + } + + /** + * 渲染模板内容. + * @param string $template 模板内容 + * @param array $data 模板变量 + * @return void + */ + public function display(string $template, array $data = []): void + { + $this->template->display($template, $data); + } + + /** + * 自动定位模板文件. + * @param string $template 模板文件规则 + * @return string + */ + private function parseTemplate(string $template): string + { + // 分析模板文件规则 + $request = $this->app['request']; + + // 获取视图根目录 + if (strpos($template, '@')) { + // 跨模块调用 + list($app, $template) = explode('@', $template); + } else { + $app = $this->app->http->getName(); + } + + $view = $this->config['view_dir_name']; + + $app_path = $this->app->getAppPath() . $view . DIRECTORY_SEPARATOR; + $base_app_path = $this->app->getRootPath() . 'extend' . DIRECTORY_SEPARATOR . 'base' . DIRECTORY_SEPARATOR . $app . DIRECTORY_SEPARATOR . $view . DIRECTORY_SEPARATOR; + $view_app_path = $this->app->getRootPath() . $view . DIRECTORY_SEPARATOR . ($app ? $app . DIRECTORY_SEPARATOR : ''); + + $depr = $this->config['view_depr']; + + if (0 !== strpos($template, '/')) { + $template = str_replace(['/', ':'], $depr, $template); + $controller = $request->controller(); + + if (strpos($controller, '.')) { + $pos = strrpos($controller, '.'); + $controller = substr($controller, 0, $pos) . '.' . Str::snake(substr($controller, $pos + 1)); + } else { + $controller = Str::snake($controller); + } + + if ($controller) { + if ('' == $template) { + // 如果模板文件名为空 按照默认模板渲染规则定位 + if (2 == $this->config['auto_rule']) { + $template = $request->action(true); + } elseif (3 == $this->config['auto_rule']) { + $template = $request->action(); + } else { + $template = Str::snake($request->action()); + } + + $template = str_replace('.', DIRECTORY_SEPARATOR, $controller) . $depr . $template; + } elseif (false === strpos($template, $depr)) { + $template = str_replace('.', DIRECTORY_SEPARATOR, $controller) . $depr . $template; + } + } + } else { + $template = str_replace(['/', ':'], $depr, substr($template, 1)); + } + + $view_file_path = ltrim($template, '/') . '.' . ltrim($this->config['view_suffix'], '.'); + + $view_path = ''; + $file_path = ''; + if (is_file($app_path . $view_file_path)) { + // 优先app下的view + $view_path = $app_path; + $file_path = $app_path . $view_file_path; + } elseif (is_file($base_app_path . $view_file_path)) { + // 查找extend下的view + $view_path = $base_app_path; + $file_path = $base_app_path . $view_file_path; + } else { + // 查找根目录下的view + $view_path = $view_app_path; + $file_path = $view_app_path . $view_file_path; + } + + $this->template->view_path = $view_path; + + return $file_path; + } + + /** + * 配置模板引擎. + * @param array $config 参数 + * @return void + */ + public function config(array $config): void + { + $this->template->config($config); + $this->config = array_merge($this->config, $config); + } + + /** + * 获取模板引擎配置. + * @param string $name 参数名 + * @return void|string + */ + public function getConfig(string $name) + { + return $this->template->getConfig($name); + } + + public function __call($method, $params) + { + return call_user_func_array([$this->template, $method], $params); + } +}