Skip to content

Commit

Permalink
new setting
Browse files Browse the repository at this point in the history
  • Loading branch information
ipuppet committed Aug 2, 2023
1 parent f160bd3 commit 36611f8
Show file tree
Hide file tree
Showing 14 changed files with 433 additions and 462 deletions.
11 changes: 1 addition & 10 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,6 @@ function injectContent() {
return `__README__ = ${JSON.stringify(files)}`
})()

const settingStructure = (() => {
try {
const setting = fs.readFileSync(path.join(__dirname, "setting.json"), "utf-8")
return `__SETTING__ = ${setting}`
} catch {
return ""
}
})()

const actions = (() => {
const baseActionPath = path.join(__dirname, "scripts/action")
try {
Expand Down Expand Up @@ -102,7 +93,7 @@ function injectContent() {
}
})()

const contents = [stringsText, configSettings, configInfo, readmeText, settingStructure, actions, entryFileContent]
const contents = [stringsText, configSettings, configInfo, readmeText, actions, entryFileContent]

fs.writeFileSync(entryFilePath, contents.join("\n\n"))
}
Expand Down
12 changes: 4 additions & 8 deletions scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const {
FileManager
} = require("./libs/easy-jsbox")
const { Storage } = require("./dao/storage")
const SettingStructure = require("./setting/setting")
const Clips = require("./ui/clips")
const ActionManager = require("./ui/components/action-manager")

Expand All @@ -34,15 +35,10 @@ class AppKernel extends Kernel {
this.logger = new Logger()
this.logger.printToFile(fileStorage, this.logFilePath)
// Setting
let structure
try {
structure = __SETTING__
} catch {}
this.setting = new Setting({
fileStorage: this.fileStorage,
structure
structure: SettingStructure
})
this.setting.loadConfig()
// Storage
this.storage = new Storage(this)
this.initComponents()
Expand Down Expand Up @@ -204,7 +200,7 @@ class Widget {
logger.error(msg)
}
}
kernel.setting.loadConfig().setReadonly()
kernel.setting.setReadonly()

const storage = new Storage(kernel)
kernel.storage = storage
Expand All @@ -225,7 +221,7 @@ class Widget {

static renderClipboard() {
const setting = new Setting()
setting.loadConfig().setReadonly()
setting.setReadonly()

const widget = Widget.widgetInstance("Clipboard", Widget.kernel())

Expand Down
2 changes: 1 addition & 1 deletion scripts/libs/easy-jsbox.js

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions scripts/setting/experimental/experimental.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const { SettingChild } = require("../../libs/easy-jsbox")
const webdav = require("./webdav")

module.exports = new SettingChild({
icon: "wrench.and.screwdriver",
title: "EXPERIMENTAL"
}).with({
children: [
{
items: [webdav]
}
]
})
50 changes: 50 additions & 0 deletions scripts/setting/experimental/webdav.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const { SettingSwitch, SettingInput, SettingChild } = require("../../libs/easy-jsbox")

module.exports = new SettingChild({
icon: ["cloud", "#FF9900"],
title: "WebDAV"
}).with({
children: [
{
items: [
new SettingSwitch({
icon: ["cloud", "#FF9900"],
title: "WebDAV",
key: "webdav.status",
value: false
})
]
},
{
items: [
new SettingInput({
icon: "link",
title: "HOST",
key: "webdav.host",
value: ""
}),
new SettingInput({
icon: "person",
title: "USER",
type: "input",
key: "webdav.user",
value: ""
}),
new SettingInput({
icon: "person.badge.key",
title: "PASSWORD",
type: "input",
key: "webdav.password",
value: ""
}),
new SettingInput({
icon: "link",
title: "BASEPATH",
type: "input",
key: "webdav.basepath",
value: ""
})
]
}
]
})
46 changes: 46 additions & 0 deletions scripts/setting/general/action.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const { SettingScript, SettingChild } = require("../../libs/easy-jsbox")

module.exports = new SettingChild({
icon: ["bolt.circle", "#FF6633"],
title: "ACTIONS"
}).with({
children: [
{
items: [
new SettingScript({
icon: ["bolt.circle", "#FF6633"],
title: "IMPORT_EXAMPLE_ACTIONS",
value: "this.method.importExampleAction"
}).with({
script: "this.method.importExampleAction"
})
]
},
{
items: [
new SettingScript({
icon: "square.and.arrow.up",
title: "EXPORT"
}).with({
script: "this.method.exportAction"
}),
new SettingScript({
icon: ["square.and.arrow.down", "#FFCC33"],
title: "IMPORT"
}).with({
script: "this.method.importAction"
})
]
},
{
items: [
new SettingScript({
icon: ["arrow.2.circlepath", "red"],
title: "REBUILD_ACTION_DATABASE"
}).with({
script: "this.method.rebuildAction"
})
]
}
]
})
74 changes: 74 additions & 0 deletions scripts/setting/general/clip.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
const { SettingSwitch, SettingScript, SettingNumber, SettingPush, SettingChild } = require("../../libs/easy-jsbox")

module.exports = new SettingChild({
icon: ["doc.on.clipboard", "#FFCC66"],
title: "CLIPS"
}).with({
children: [
{
items: [
new SettingSwitch({
icon: ["link", "#FF6633"],
title: "UNIVERSAL_CLIPBOARD",
key: "clipboard.universal",
value: true
}),
new SettingScript({
icon: ["cursorarrow.rays", "#FF6633"],
title: "Tips"
}).with({
script: "$ui.alert({title:$l10n('UNIVERSAL_CLIPBOARD'),message:$l10n('UNIVERSAL_CLIPBOARD_TIPS')})"
})
]
},
{
items: [
new SettingPush({
icon: ["trash", "red"],
title: "RECYCLE_BIN",
key: "clipboard.recycleBin"
}).with({ view: "this.method.recycleBin" })
]
},
{
items: [
new SettingNumber({
icon: ["text.alignleft", "#FFCC66"],
title: "MAX_ITEM_LENGTH",
key: "clipboard.maxItemLength",
value: 100
}),
new SettingSwitch({
icon: ["square.and.arrow.down.on.square", "#FF6633"],
title: "AUTO_SAVE",
key: "clipboard.autoSave",
value: true
})
]
},
{
items: [
new SettingScript({
icon: "square.and.arrow.up",
title: "EXPORT"
}).with({ script: "this.method.exportClipboard" }),
new SettingScript({
icon: ["square.and.arrow.down", "#FFCC33"],
title: "IMPORT"
}).with({ script: "this.method.importClipboard" })
]
},
{
items: [
new SettingScript({
icon: ["arrow.2.circlepath", "red"],
title: "REBUILD_DATABASE"
}).with({ script: "this.method.rebuildDatabase" }),
new SettingScript({
icon: ["trash", "red"],
title: "DELETE_ALL_DATA"
}).with({ script: "this.method.deleteAllData" })
]
}
]
})
43 changes: 43 additions & 0 deletions scripts/setting/general/editor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const { SettingSwitch, SettingInput, SettingNumber, SettingChild } = require("../../libs/easy-jsbox")

module.exports = new SettingChild({
icon: ["pencil.circle", "#CC0099"],
title: "EDITOR"
}).with({
children: [
{
title: "CLIPS",
items: [
new SettingNumber({
icon: ["wand.and.stars", "#FF6633"],
title: "TEXT_INSETS",
key: "editor.text.insets",
value: 300
})
]
},
{
title: "CODE",
items: [
new SettingSwitch({
icon: ["list.number", "#6699CC"],
title: "SHOW_LINE_NUMBER",
key: "editor.code.lineNumbers",
value: false
}),
new SettingInput({
icon: ["wand.and.stars", "#FF6633"],
title: "LIGHT_MODE_THEME",
key: "editor.code.lightTheme",
value: "atom-one-light"
}),
new SettingInput({
icon: ["wand.and.stars", "#FF6633"],
title: "DARK_MODE_THEME",
key: "editor.code.darkTheme",
value: "atom-one-dark"
})
]
}
]
})
85 changes: 85 additions & 0 deletions scripts/setting/general/keyboard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
const {
SettingSwitch,
SettingStepper,
SettingScript,
SettingTab,
SettingNumber,
SettingPush,
SettingChild,
SettingImage
} = require("../../libs/easy-jsbox")

module.exports = new SettingChild({
icon: ["keyboard", "#a2a5a6"],
title: "KEYBOARD"
}).with({
children: [
{
items: [
new SettingPush({
icon: "rectangle.3.offgrid.fill",
title: "PREVIEW",
key: "keyboard.previewAndHeight",
value: 267
}).with({ view: "this.method.previewKeyboard" })
]
},
{
items: [
new SettingTab({
icon: ["rectangle.topthird.inset.filled", "#A569BD"],
title: "DISPLAY_MODE",
key: "keyboard.displayMode",
value: 0
}).with({ items: ["list", "matrix"] }),
new SettingSwitch({
icon: ["checkerboard.rectangle", "#1899c4"],
title: "USE_BLUR",
key: "keyboard.blur",
value: false
}),
new SettingImage({
icon: ["photo", "#FFCC66"],
title: "BACKGROUND_IMAGE",
key: "keyboard.background.image"
})
]
},
{
items: [
new SettingSwitch({
icon: ["globe", "#1899c4"],
title: "SWITCH_AFTER_INSERT",
key: "keyboard.switchAfterInsert",
value: false
}),
new SettingSwitch({
icon: ["cursor.rays", "#FF8C00"],
title: "TAPTIC_ENGINE",
key: "keyboard.tapticEngine",
value: true
}),
new SettingStepper({
icon: ["cursor.rays", "#FF8C00"],
title: "TAPTIC_ENGINE_LEVEL",
key: "keyboard.tapticEngineLevel",
value: 1
}).with({ min: 0, max: 2 }),
new SettingScript({
icon: "paperplane",
title: "QUICK_START_SCRIPTS"
}).with({ script: "this.method.setKeyboardQuickStart" })
]
},
{
items: [
new SettingNumber({
icon: ["rays", "#FFCC33"],
title: "DELETE_DELAY",
key: "keyboard.deleteDelay",
value: 0.05
})
]
}
]
})
Loading

0 comments on commit 36611f8

Please sign in to comment.