wenhongquan 7 ماه پیش
والد
کامیت
76ec69c2f1
6فایلهای تغییر یافته به همراه181 افزوده شده و 5 حذف شده
  1. 98 0
      INSTALLATION_FIX_GUIDE.md
  2. 2 2
      uperp/config/desktop.py
  3. 3 3
      uperp/hooks.py
  4. 23 0
      uperp/install.py
  5. 48 0
      uperp/permissions.py
  6. 7 0
      uperp/public/image/logo.svg

+ 98 - 0
INSTALLATION_FIX_GUIDE.md

@@ -0,0 +1,98 @@
+# Uperp 应用重新安装指南
+
+## 问题解决方案
+
+主页菜单没有显示的问题已经修复,主要修复了以下几个问题:
+
+### 1. 权限函数路径错误
+- 修复前: `"uperp.api.has_app_permission"`
+- 修复后: `"uperp.uperp.api.has_app_permission"`
+
+### 2. 添加了 Logo 文件
+- 创建了 `/uperp/public/image/logo.svg`
+- 使用了符合 ERPNext 风格的 SVG 图标
+
+### 3. 改进了桌面配置
+- 使用了正确的图标格式: `octicon octicon-gear`
+- 设置了美观的颜色: `#667eea`
+
+### 4. 添加了安装后处理
+- 创建了 `install.py` 文件
+- 在安装后自动刷新桌面和缓存
+
+## 重新安装步骤
+
+为了让所有配置生效,请按以下步骤重新安装应用:
+
+```bash
+# 1. 进入 bench 目录
+cd /path/to/your/bench
+
+# 2. 卸载现有应用(如果已安装)
+bench uninstall-app uperp
+
+# 3. 重新安装应用
+bench install-app uperp
+
+# 4. 重启所有服务
+bench restart
+
+# 5. 清除所有缓存
+bench clear-cache
+bench clear-website-cache
+
+# 6. 重新构建资源
+bench build
+
+# 7. 重新生成桌面
+bench execute frappe.desk.desktop.sync_desktop
+```
+
+## 验证步骤
+
+安装完成后:
+
+1. **检查应用列表**:
+   - 进入 ERPNext 主页
+   - 查看应用列表中是否有 "Uperp" 应用
+
+2. **检查桌面模块**:
+   - 在主页左侧菜单中查找 "Uperp" 模块
+   - 模块应该显示齿轮图标和紫色主题
+
+3. **测试页面访问**:
+   - 直接访问: `http://your-site/test`
+   - 通过菜单点击进入测试页面
+
+4. **测试API**:
+   - 在测试页面中点击 "测试连接" 按钮
+   - 确认数据能正常加载
+
+## 可能的问题和解决方案
+
+### 问题1: 菜单仍然不显示
+解决方案:
+```bash
+bench execute frappe.clear_cache
+bench execute frappe.desk.desktop.sync_desktop
+bench restart
+```
+
+### 问题2: 权限错误
+解决方案:
+- 检查用户角色是否有足够权限
+- 确认 `has_app_permission` 函数返回 `True`
+
+### 问题3: 静态文件404错误
+解决方案:
+```bash
+bench build
+bench restart
+```
+
+### 问题4: 页面无法访问
+解决方案:
+- 检查 `templates/pages/test.html` 和 `test.py` 文件是否存在
+- 确认路由配置正确
+
+安装完成后,你应该能在 ERPNext 主页左侧菜单中看到 "Uperp" 模块,并可以通过它访问测试页面。

+ 2 - 2
uperp/config/desktop.py

@@ -8,8 +8,8 @@ def get_data():
     return [
         {
             "module_name": "Uperp",
-            "color": "grey",
-            "icon": "fa fa-cog",
+            "color": "#667eea",
+            "icon": "octicon octicon-gear",
             "type": "module",
             "label": _("Uperp"),
             "description": _("Uperp应用管理"),

+ 3 - 3
uperp/hooks.py

@@ -14,10 +14,10 @@ app_license = "mit"
 add_to_apps_screen = [
 	{
 		"name": "uperp",
-		"logo": "/assets/uperp/logo.png",
+		"logo": "/assets/uperp/image/logo.svg",
 		"title": "Uperp",
 		"route": "/test",
-		"has_permission": "uperp.api.has_app_permission"
+		"has_permission": "uperp.uperp.api.has_app_permission"
 	}
 ]
 
@@ -83,7 +83,7 @@ page_js = {"test" : "public/js/test-page.js"}
 # ------------
 
 # before_install = "uperp.install.before_install"
-# after_install = "uperp.install.after_install"
+after_install = "uperp.install.after_install"
 
 # Uninstallation
 # ------------

+ 23 - 0
uperp/install.py

@@ -0,0 +1,23 @@
+import frappe
+from frappe import _
+
+
+def after_install():
+    """
+    应用安装后的处理
+    """
+    try:
+        # 清除缓存,重新生成桌面
+        frappe.clear_cache()
+
+        # 重新构建桌面
+        from frappe.desk.desktop import sync_desktop
+        sync_desktop()
+
+        # 显示成功消息
+        frappe.msgprint(_("Uperp 应用安装成功!请刷新页面查看新的菜单。"))
+
+    except Exception as e:
+        frappe.log_error(f"Uperp 安装后处理失败: {str(e)}")
+
+    return True

+ 48 - 0
uperp/permissions.py

@@ -0,0 +1,48 @@
+import frappe
+from frappe import _
+
+
+def has_permission(doc, user=None):
+    """
+    检查用户是否有权限访问文档
+    """
+    return True
+
+
+def get_permission_query_conditions(user):
+    """
+    获取权限查询条件
+    """
+    if not user:
+        user = frappe.session.user
+
+    # 这里可以添加更复杂的权限逻辑
+    return ""
+
+
+def can_read(doc, user=None):
+    """
+    检查是否可以读取
+    """
+    return True
+
+
+def can_write(doc, user=None):
+    """
+    检查是否可以写入
+    """
+    return True
+
+
+def can_create(doc, user=None):
+    """
+    检查是否可以创建
+    """
+    return True
+
+
+def can_delete(doc, user=None):
+    """
+    检查是否可以删除
+    """
+    return True

+ 7 - 0
uperp/public/image/logo.svg

@@ -0,0 +1,7 @@
+<svg width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
+<rect width="64" height="64" rx="8" fill="#667eea"/>
+<path d="M20 20h24v4h-20v16h16v4h-20z" fill="white"/>
+<path d="M28 32h16v4h-12v8h8v4h-12z" fill="white"/>
+<circle cx="48" cy="16" r="8" fill="#764ba2"/>
+<text x="32" y="52" text-anchor="middle" fill="white" font-family="Arial, sans-serif" font-size="12" font-weight="bold">UP</text>
+</svg>