CKUIToolkit

A simple settings modal framework.

目前為 2022-03-17 提交的版本,檢視 最新版本

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.cn-greasyfork.org/scripts/441653/1029231/CKUIToolkit.js

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

作者
CKylinMC
版本
1.0
建立日期
2022-03-17
更新日期
2022-03-17
尺寸
20.8 KB
授權條款
GPL-3.0-only

通过JSON/对象创建设置对话框

        const sampleCfg = {
            title: '设置',
            settings: [
                {
                    name: 'simple-text',
                    type: 'text',
                    label: '简单文本',
                }, {
                    name: 'simple-toggle',
                    type: 'toggle',
                    label: '简单开关',
                    description: '这是一个简单的开关',
                    value: false,
                }, {
                    name: 'simple-input',
                    type: 'input',
                    label: '简单输入框',
                    description: '这是一个简单的输入框',
                    value: '',
                }, {
                    name: 'simple-num-input',
                    type: 'inputnumber',
                    label: '简单数字输入框',
                    description: '这是一个简单的输入框',
                    value: 0,
                    min: 0,
                    max: 100,
                    step: 1,
                }, {
                    name: 'simple-long-input',
                    type: 'inputarea',
                    label: '简单长文本输入框',
                    description: '这是一个简单的输入框',
                    value: '',
                    checker: ()=>true,
                }, {
                    name: 'simple-select',
                    type: 'select',
                    label: '简单选择框',
                    description: '这是一个简单的选择框',
                    value: '',
                    options: [
                        { opt: '选项1', value: '1' },
                        { opt: '选项2', value: '2' },
                    ]
                }, {
                    name: 'text-toggle',
                    type: 'texttoggle',
                    description: '这是一个简单的选择框',
                    before: '开关当前处于',
                    on: '开',
                    off: '关',
                    after: '状态',
                    value: false,
                },{
                    name: 'simple-raw',
                    type: 'raw',
                    contents: {
                        text:'RAW!!!!'
                    },
                }, {
                    name: 'header',
                    type: 'header',
                    label: '分区A',
                }, {
                    name: 'btns',
                    type: 'btns',
                    btns: [
                        {
                            label: "1111111111111111111111111111",
                            onclick: async () => console.log(123)
                        },
                        {
                            label: "2222"
                        },
                        {
                            label: "3333"
                        },
                        {
                            label: "4444"
                        },
                    ],
                }, {
                    name: 'window-a',
                    type: 'window',
                    label: '窗口A',
                    config: {
                        title: '窗口A',
                        settings: [
                            {
                                name: 'window-a-sub-a',
                                type: 'text',
                                label: '窗口A子项A',
                            }
                        ]
                    }
                }
            ]
        };
        CKUIToolkit.showSettings(sampleCfg).then(it=>console.log('result:',it,'\nOrigin:',sampleCfg));