diff --git a/chrome/os/ime/background.js b/chrome/os/ime/background.js index 17d761e77fd8f24ddbd7c6eee69790a9d872b353..1046980830f56506b529f972fda437360a725753 100755 --- a/chrome/os/ime/background.js +++ b/chrome/os/ime/background.js @@ -40,6 +40,11 @@ goog.ime.chrome.os.Background = function() { this.vk_enable = false; + let layout = window.localStorage.getItem("layout") || 'us'; + if (layout !== 'us'){ + chrome.inputMethodPrivate.setXkbLayout(`us(${layout})`); + } + /** * The local storage handler. * @@ -190,4 +195,5 @@ var imeBackground; (function() { imeBackground = new goog.ime.chrome.os.Background(); + }) (); diff --git a/chrome/os/ime/model.js b/chrome/os/ime/model.js index c6211fadf9c7f5b1e70dded45b24637f164b78e5..7eb4e8de21898a6ebf0ccff44bcc6912d7d47167 100755 --- a/chrome/os/ime/model.js +++ b/chrome/os/ime/model.js @@ -446,7 +446,7 @@ goog.ime.chrome.os.Model.prototype.revert = async function() { if (this.source == '') { this.notifyUpdates(); this.fetchCandidates_(); - this.clear()(); + this.clear(); } else { this.notifyUpdates(); if (deletedChar == '\'') { diff --git a/chrome/os/ime/pinyin/option.html b/chrome/os/ime/pinyin/option.html index 387e77cc2057a61ad6ee0a2b8a44dc0733d45c43..4cbb191e3a628e19cd0fbd6f07d44d32ba682cf0 100755 --- a/chrome/os/ime/pinyin/option.html +++ b/chrome/os/ime/pinyin/option.html @@ -26,6 +26,21 @@
+ +

键盘布局

+
+ + +
+
+ + +
+
+ + +
+

设置单页候选词数量

diff --git a/chrome/os/ime/pinyin/option.js b/chrome/os/ime/pinyin/option.js index abf1824bd026b8c0410608b04d27fd02995aed7c..caaf5d65b9fcae859db81b4ddc5dbeb3e705cd95 100644 --- a/chrome/os/ime/pinyin/option.js +++ b/chrome/os/ime/pinyin/option.js @@ -36,6 +36,21 @@ document.getElementsByName("schema").forEach(function (ele) { } }) +function setKeyboardLayout(layout) { + let xkbLayout = layout === 'us' ? 'us' : `us(${layout})`; + let savedLayout = window.localStorage.getItem("layout"); + if(layout !== savedLayout){ + chrome.inputMethodPrivate.setXkbLayout(xkbLayout); + } + document.getElementById(layout).checked = true; + window.localStorage.setItem("layout", layout); +} + +document.getElementsByName("layout").forEach(function (ele) { + ele.onclick = async function handleClick() { + await setKeyboardLayout(ele.value); + } +}) function updateFuzzyCheckBox(options) { document.getElementsByName("fuzzy").forEach(function (ele) { if (options.includes(ele.value)) { @@ -83,5 +98,6 @@ document.getElementsByName("fuzzy").forEach(function (ele) { document.getElementById("pageSize").value = window.localStorage.getItem("pageSize") || 8; +setKeyboardLayout(window.localStorage.getItem("layout") || 'us') setSchema(""); getFuzzy();