zanllp / sd-webui-infinite-image-browsing

A fast and powerful image/video browser for Stable Diffusion webui / ComfyUI / Fooocus / NovelAI / StableSwarmUI, featuring infinite scrolling and advanced search capabilities using image parameters. It also supports standalone operation.
MIT License
973 stars 121 forks source link

控制模式提示的”不再显示“按钮导致的持续警告 Clicking access control mode tips "dontShowAgain" causes continually error warning #714

Closed arqli closed 1 month ago

arqli commented 1 month ago

In my workspace, I need access control due to sharing, so i use .env file to set read-only mode. but the first time load this extension, when it shows access control mode tips, after i click 'dontShowAgain', it continually pops error warning User is not authorized to perform this action. Required permission: read-write, write-only in every operating steps. I have found the problem is cause by the access control mode itself. When clicking 'dontShowAgain', it calls app_fe_setting in API, which need WRITEABLE_PERMISSIONS. Thus "global.dontShowAgain = true" will NOT be applied.

MAYBE this call repeatly trying in background??? which causes continually error warning.

I didn`t research on it further. To solve this problem, I temporarily deleted some local codes in JS file compiled by vue, which corresponds to VUE code in file \vue\src\page\SplitViewTab\emptyStartup.vue line 176-189, to avoid other users click it. By this dealing, other function in this extension runs without abnormalities so far.

To permanently solve this problem, i have 2 ideas as follow:

  1. "global.dontShowAgain = true": put this variable in local cookie (better for multi-user), rather than background database;
  2. add a condition statement in API _app_fesetting, if operation is dontShowAgain, it can be NOT DEPENDS _write_permission_required_

errors

我使用中因为需要共享出去,所以需要访问控制,在 .env 文件中设置了只读模式。 但首次加载此插件,会显示访问控制模式的提示,点击“不再显示”之后会在每一步操作中持续弹出错误警告: User is not authorized to perform this action. Required permission: read-write, write-only 我已经找到此问题是由于访问控制模式本身造成的,点击“不再显示”时,它调用了 API 中的app_fe_setting,这需要写入权限。因此,“global.dontShowAgain = true”语句失效。或许是这个调用在后台的重复尝试导致了持续弹出的错误警告?

我没有进一步研究这个问题。为了解决这个问题,我暂时删除了VUE编译后的 JS 文件中的一些本地代码,这部分代码对应于 VUE 代码文件 \vue\src\page\SplitViewTab\emptyStartup.vue 的第 176-189 行,避免共享的其他用户点击。这样处理后插件中的其他功能目前运行没有异常。

为了永久解决这个问题,我有两个想法如下:

  1. “global.dontShowAgain = true”:将这个变量存放在本地 Cookie 中(更适合多用户的情况),而不是存储在后台数据库中;
  2. 在 API _app_fesetting 中添加一个条件语句,如果操作是“dontShowAgain”,则不需要验证 _write_permissionrequired
arqli commented 1 month ago

进一步研究发现,似乎核心的问题来自watchGlobalSettingChange,其中将conf和lastConf做比较,一旦用户操作设置发生变化,则lastConf和来自globalStore的conf一直会不同,因持续进行比较更新,所以导致持续提示上述问题,代码位于 \vue\src\App.vue中的25-38行。

可以考虑在只读模式下屏蔽对设置更改的请求,不再进行持续更新后台数据库中的设置数据; 也可以将await setAppFeSetting('global', conf) 和 lastConf = cloneDeep(conf)换一下顺序,保证只向后台发送一次更新设置的请求; 或者只在手动调整设置项的时候发起对后台服务器的更新请求(包括权限报错)?

zanllp commented 1 month ago

woc,你看看了这么深了直接提个pr好了

zanllp commented 1 month ago

可以考虑在只读模式下屏蔽对设置更改的请求,不再进行持续更新后台数据库中的设置数据;

加上了