chengkun
2025-08-29 73cdff843994b42beef7a22844326f83fee104de
app/admin/util/Opadmin.php
@@ -94,7 +94,14 @@
        return $this->getlogininfo($tempinfo['id']);
    }
    
    //////获取用户登录信息///////////
    /**
     * 获取用户登录信息
     * @param $id
     * @return array
     * @throws DataNotFoundException
     * @throws DbException
     * @throws ModelNotFoundException
     */
    public function getlogininfo($id = ''): array {
        $subwhere['id'] = $id;
        $info = Db::name('administrators')->field($this->commfield)->where($subwhere)->find();
@@ -124,7 +131,10 @@
        return $msg;
    }
    
    /////账号登录信息///////////////
    /**
     * 更新用户信息
     * @return bool
     */
    private function updateInfo(): bool {
        $temp['login_time'] = time();
        $temp['login_ip'] = getIP();
@@ -136,6 +146,10 @@
            return FALSE;
    }
    
    /**
     * 写入登陆日志
     * @return void
     */
    private function writelogs(): void {
        //////登陆记录//////////
        $d['login_ip'] = getIP();
@@ -145,10 +159,8 @@
    }
    
    /**
     * +----------------------------------------------------------
     * 保存session
     * +----------------------------------------------------------
     * +----------------------------------------------------------
     * @return void
     */
    public function saveSession(): void {
        session($this->kinfo, $this->info);
@@ -156,11 +168,8 @@
    }
    
    /**
     * +----------------------------------------------------------
     * 判断用户是否登陆
     * @return bool
     * +----------------------------------------------------------
     * +----------------------------------------------------------
     */
    public function islogin(): bool {
        if (isset($this->info['id']) && $this->info['id'] != '')
@@ -170,11 +179,8 @@
    }
    
    /**
     * +----------------------------------------------------------
     * 用户退出
     * @return bool
     * +----------------------------------------------------------
     * +----------------------------------------------------------
     */
    public function loginout(): bool {
        $this->info = "";
@@ -185,12 +191,16 @@
        return TRUE;
    }
    
    /**
     * 获取菜单
     * @return array
     */
    public function menu(): array {
        $condition['show_menu'] = 1;
        $order = 'order_id asc,id asc';
        $list = Db::name('admin_menu')
            ->field("id,title,menu_index,menu_icon,show_menu,menu_url,father_id")
            ->cacheAlways(TRUE, 0, 'admin_menu')
            ->cache(60)
            ->where($condition)
            ->order($order)
            ->withAttr('menu_index', function ($value) {
@@ -215,7 +225,7 @@
            }
            return $result_arr;
        } else {
            return array();
            return [];
        }
    }