rabin 1 jaar geleden
bovenliggende
commit
28e23fa65c

+ 8 - 0
config/base.php

@@ -129,6 +129,14 @@ $config['template'] = array
 		'task/list' => 'tasks',
 	),
 	*/
+
+	# 定义组件别名 也可以直接用Dever::setAlias('area', 'marea');
+	/*
+    'alias' => array
+    (
+        'area' => 'marea',
+    ),
+    */
 );
 
 return $config;

+ 9 - 0
vendor/dever-main/framework/dever.php

@@ -1830,4 +1830,13 @@ class Dever
             return self::getOrderNum($prefix, $table, $col);
         }
     }
+
+    public static function setAlias($project, $alias)
+    {
+        if (!self::config('base')->alias) {
+            self::config('base')->alias = array();
+        }
+        $config[$project] = $alias;
+        self::config('base')->alias = array_merge(self::config('base')->alias, $config);
+    }
 }

+ 3 - 0
vendor/dever-main/framework/src/Dever/Data/Model/Handle.php

@@ -470,6 +470,9 @@ class Handle
                 $this->config['link'] = false;
             }
 
+            if (Config::get('base')->alias && isset(Config::get('base')->alias[$this->config['project']['name']])) {
+                $this->config['project']['name'] = Config::get('base')->alias[$this->config['project']['name']];
+            }
             $this->db()->table($this->config['project']['name'] . '_' . $this->config['name'], $this->index, true, $this->config['table'], $this->config['db_prefix'], $this->config['link']);
 
             $this->create();

+ 1 - 0
vendor/dever-main/framework/src/Dever/Data/Store.php

@@ -149,6 +149,7 @@ class Store
     public function table($table, $name = '', $state = true, $alias = '', $prefix = false, $link = false)
     {
         $this->config['link'] = $link;
+        # 后续增加表名别名功能
         $this->alias = $alias ? $alias : $table;
         if ($prefix) {
             $table = $prefix . '_' . $table;

+ 5 - 0
vendor/dever-main/framework/src/Dever/Loader/Import.php

@@ -293,9 +293,14 @@ class Import
             }
             self::load('manage/src/lib/log')->add($project, $table, $menu_id, '', $log[0], $param, $id);
         }
+        /*
         if ((strpos($this->key, 'manage/') !== false || strpos($this->key, 'manage11.') !== false) && strpos($this->key, 'manage/auth') === false && strpos($this->key, 'manage/src/auth') === false && strpos($this->key, 'manage/project') === false && strpos($this->key, 'manage/lib') === false) {
             self::load('manage/auth.init');
         }
+        */
+        if (strstr($this->key, 'manage/') && !strstr($this->key, 'manage/auth') && !strstr($this->key, 'manage/lib') && !strstr($this->key, 'manage/project')) {
+            self::load('manage/auth.init');
+        }
     }
 
     /**