Selaa lähdekoodia

Update:更新匹配规则

Jinhui Zhu 5 vuotta sitten
vanhempi
commit
a30da66bd7
2 muutettua tiedostoa jossa 5 lisäystä ja 39 poistoa
  1. 1 2
      src/Library/Image.php
  2. 4 37
      src/Router/Parse/Normal.php

+ 1 - 2
src/Library/Image.php

@@ -199,6 +199,7 @@ class Image
 	 *
 	 * 剪切圖片到指定大小
 	 * @param String $bigImg 原始圖片
+     * @param String $smallImg 小图地址
 	 * @param Int $width 寬
 	 * @param Int $height高
 	 * @param String $smallImg 縮放後保存的圖片
@@ -223,8 +224,6 @@ class Image
 				$im = imagecreatefrompng($bigImg);
 				break;
 		}
-		$srcW = imagesx($im);//获取大图宽
-		$srcH = imagesy($im);//获取大图高
 		if($image[2] == 3)
 		{
 			$tn = imagecrate($width, $height);//创建小图

+ 4 - 37
src/Router/Parse/Normal.php

@@ -106,6 +106,10 @@ class Normal
                 $configArr = explode(':', $config);
                 $interSet = array_intersect_assoc($configArr, $dir);
                 if($interSet) {
+                    if($configArr == $interSet) {
+                        $register = ['rule' => $config, 'val' => $val, 'interSet' => $interSet];
+                        break;
+                    }
                     $countInterSet = count($interSet);
                     if(isset($configArr[$countInterSet]) && ($configArr[$countInterSet] == '*' || (isset($dirInfo[$dirInfo[$key]]) && $configArr[$countInterSet] == $dirInfo[$dirInfo[$key]]))) {
                         if($matchLen < $countInterSet) {
@@ -130,43 +134,6 @@ class Normal
         }
         //解析规则
         return $this->matchVal($match['match']['val'], $dirInfo);
-        /*
-        preg_match_all("/\{[\d]{1,}\}|[\*]{1}/", $rulesVal, $rules);
-
-        if(empty($rules) || empty($rules[0])) {
-            $info = $this->getInfoFromDirInfo($dirInfo);
-            $match['controller'] = $info['controller'];
-            $match['action'] = $info['action'];
-        }
-        $maxIndex = 0;
-        //获取*位置最大值索引值
-        if(preg_match("/[\*]{1}/", $rulesVal)) {
-            foreach($rules[0] as $val) {
-                $val = intval(str_replace(array('{', '}'), '', $val));
-                if($val > $maxIndex) $maxIndex = $val;
-            }
-            $maxIndex++;
-        }
-        $replacements = $rules[0];
-        foreach($rules[0] as $key => $val)
-        {
-            if(preg_match("/\{[\d]{1,}\}/", $val)) {
-                $index = str_replace(array('{', '}'), '', $val);
-                $replacements[$key] = $dirInfo[$index] ?? 'index';
-                $rulesVal = preg_replace("/\{[\d]{1,}\}/", $replacements[$key], $rulesVal, 1);
-            }else if($val == '*'){
-                $replacements[$key] = $dirInfo[$maxIndex] ?? 'index';
-                //一次只替换一个,用于匹配多次
-                $rulesVal = preg_replace("/[\*]{1}/", $replacements[$key], $rulesVal, 1);
-                $maxIndex++;
-            }
-        }
-        list($controller, $action) = explode(":", $rulesVal);
-        $match['controller'] = $controller;
-        $match['action'] = $action ?? 'index';
-        $match['replacements'] = $replacements;
-        $match['rulesVal'] = $rulesVal;
-        return $match;*/
     }
 
     /**