读取剪切板需要有用户交互,比如点击,第一次需要申请权限

<a-button :disabled="Object.keys(harFiles.valueOf()).length===0" @click="readClipboardText">add record from
          clipboard
        </a-button>
const readClipboardText = async () => {
  try {
    // 请求剪切板读取权限
    const permission = await navigator.permissions.query({name: 'clipboard-read'});

    if (permission.state === 'granted' || permission.state === 'prompt') {
      // 读取文本内容
      let text = await navigator.clipboard.readText()
      console.log(text)
      
    } else {
      alert('请允许剪切板访问权限!');
    }
  } catch (error) {
    console.error('读取失败:', error);
    alert('无法读取剪切板内容,请确保浏览器支持或已授予权限');
  }
};

[2025-02-10 13:40:41] [ERROR] [unknown:0] [0] got error:TimeoutError: elementHandle.hover: Timeout 2000ms exceeded.
Call log:

  • attempting hover action
    2 × waiting for element to be visible and stable

    • element is visible and stable
    • scrolling into view if needed
    • done scrolling
    • performing hover action
    • from
      subtree intercepts pointer events
    • retrying hover action
    • waiting 20ms
    • × waiting for element to be visible and stable

      • element is visible and stable
      • scrolling into view if needed
      • done scrolling
      • performing hover action
      • from
        subtree intercepts pointer events
    • retrying hover action

      • waiting 100ms
    • × waiting for element to be visible and stable

      • element is visible and stable
      • scrolling into view if needed
      • done scrolling
      • performing hover action
      • from
        subtree intercepts pointer events
    • retrying hover action

      • waiting 500ms

<div id="slideBg"> 拦截了指针事件(intercepts pointer events)

安装

pnpm install json-editor-vue

使用

<template>

<JsonEditorVue
        v-model="json"
        mode="text"
        :mainMenuBar="false"
        :statusBar="true"
        :stringified="false"
    />
</template>

<script lang="ts" setup>

import JsonEditorVue from 'json-editor-vue'
const json = {"name":"张三"}
</script>

问题

开发和打包成二进制都没问题,打包mac独立app onefile不显示窗口

if __name__ == "__main__":
    app = QApplication(sys.argv)
    app.setWindowIcon(QIcon("icons/icon.png"))  # 确保 "icon.png" 路径正确,可以是绝对路径或相对路径
    from PyQt5.QtCore import Qt
    QApplication.setAttribute(Qt.AA_DontUseNativeMenuBar, True)


    # 设置全局日志回调(使得代理模块调用 log() 时同时能写入 UI)
    def gui_log(msg):
        window.log(msg)
    LOG_CALLBACK = gui_log

    window = MainWindow()
    window.setWindowTitle("代理")

    window.resize(600, 600)
    window.show()
    sys.exit(app.exec_())

开发,打包二进制没问题,打包mac应用不显示窗口
注释掉python window.resize(600, 600)就好了

参考

def resource_path(relative_path):
    """获取打包后的资源文件路径"""
    if hasattr(sys, '_MEIPASS'):
        # 打包后的路径
        base_path = sys._MEIPASS
    else:
        # 开发阶段的路径
        base_path = os.path.abspath(".")
    return os.path.join(base_path, relative_path)

# 使用示例
icon_path = resource_path("icons/icon.png")

打包参数

pyinstaller --windowed --noconfirm  --add-data "icons:icons" -F main.py