From 14cbfdc843d3e1b4d3d82c7a03a18e1f44cc34f9 Mon Sep 17 00:00:00 2001 From: shijian <2954700422@qq.com> Date: Wed, 27 Dec 2023 23:22:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9get.copy,=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E4=B8=80=E4=B8=AAconfig=E5=8F=AA=E6=9C=89getter=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- noname/get/index.js | 18 ++++-------------- noname/library/index.js | 14 +++++++++++++- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/noname/get/index.js b/noname/get/index.js index 2fdde3581..97a2943ea 100644 --- a/noname/get/index.js +++ b/noname/get/index.js @@ -1118,21 +1118,11 @@ export class Get extends Uninstantable { * @returns {T} */ static copy(obj) { - if (get.objtype(obj) == 'object') { - var copy = {}; - for (var i in obj) { - copy[i] = get.copy(obj[i]); - } - return copy; + try { + return structuredClone(obj); } - else if (Array.isArray(obj)) { - var copy = []; - for (var i = 0; i < obj.length; i++) { - copy.push(get.copy(obj[i])); - } - return copy; - } - else { + catch { + // obj不可序列化时 return obj; } } diff --git a/noname/library/index.js b/noname/library/index.js index 36d2f83d5..73c445fc1 100644 --- a/noname/library/index.js +++ b/noname/library/index.js @@ -4272,15 +4272,27 @@ export class Library extends Uninstantable { get init() { return lib.configMenu.view.config.show_characternamepinyin.init; }, + set init(newVal) { + lib.configMenu.view.config.show_characternamepinyin.init = newVal; + }, get unfrequent() { return lib.configMenu.view.config.show_characternamepinyin.unfrequent; }, + set unfrequent(newVal) { + lib.configMenu.view.config.show_characternamepinyin.unfrequent = newVal; + }, get item() { return lib.configMenu.view.config.show_characternamepinyin.item; }, + set item(newVal) { + lib.configMenu.view.config.show_characternamepinyin.item = newVal; + }, get visualMenu() { return lib.configMenu.view.config.show_characternamepinyin.visualMenu; - } + }, + set visualMenu(newVal) { + lib.configMenu.view.config.show_characternamepinyin.visualMenu = newVal; + }, } } },