-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable some menu items in read-only mode #11733
Changes from all commits
ed3afe6
0999115
a24f509
71efa33
f8cca61
b235527
e77faf7
56c565c
7049f89
e33acd5
bf5ac0c
9a6ee2d
0ccc969
fb79491
e242a8f
484d3ee
717b250
e95a54d
2f2e743
9e79ce7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,8 @@ export class App { | |
registerServiceWorker(`${Constants.SERVICE_WORKER_PATH}?v=${Constants.SIYUAN_VERSION}`); | ||
/// #endif | ||
addBaseURL(); | ||
addScriptSync(`${Constants.PROTYLE_CDN}/js/lute/lute.min.js?v=${Constants.SIYUAN_VERSION}`, "protyleLuteScript"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这一块比较复杂,没有必要请不要进行改动。如有必要的话请只修改关联部分即可。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这一块是为了与其他端调用顺序统一, 方便之后进行维护 |
||
addScript(`${Constants.PROTYLE_CDN}/js/protyle-html.js?v=${Constants.SIYUAN_VERSION}`, "protyleWcHtmlScript"), | ||
|
||
this.appId = Constants.SIYUAN_APPID; | ||
window.siyuan = { | ||
|
@@ -153,24 +155,40 @@ export class App { | |
}; | ||
|
||
fetchPost("/api/system/getConf", {}, async (response) => { | ||
addScriptSync(`${Constants.PROTYLE_CDN}/js/lute/lute.min.js?v=${Constants.SIYUAN_VERSION}`, "protyleLuteScript"); | ||
addScript(`${Constants.PROTYLE_CDN}/js/protyle-html.js?v=${Constants.SIYUAN_VERSION}`, "protyleWcHtmlScript"); | ||
window.siyuan.config = response.data.conf; | ||
await loadPlugins(this); | ||
getLocalStorage(() => { | ||
fetchGet(`/appearance/langs/${window.siyuan.config.appearance.lang}.json?v=${Constants.SIYUAN_VERSION}`, (lauguages: IObject) => { | ||
window.siyuan.languages = lauguages; | ||
window.siyuan.menus = new Menus(this); | ||
bootSync(); | ||
|
||
const promises = [ | ||
loadPlugins(this), | ||
new Promise<void>(resolve => getLocalStorage(resolve)), | ||
new Promise<void>(resolve => fetchGet( | ||
`/appearance/langs/${window.siyuan.config.appearance.lang}.json?v=${Constants.SIYUAN_VERSION}`, | ||
(lauguages: IObject) => { | ||
window.siyuan.languages = lauguages; | ||
resolve(); | ||
}, | ||
)), | ||
]; | ||
|
||
if (!window.siyuan.config.readonly) { | ||
promises.push(new Promise<void>(resolve => { | ||
fetchPost("/api/setting/getCloudUser", {}, userResponse => { | ||
window.siyuan.user = userResponse.data; | ||
onGetConfig(response.data.start, this); | ||
account.onSetaccount(); | ||
setTitle(window.siyuan.languages.siyuanNote); | ||
initMessage(); | ||
resolve(); | ||
}); | ||
}); | ||
}); | ||
})); | ||
} | ||
|
||
await Promise.all(promises); | ||
|
||
if (!window.siyuan.config.readonly) { | ||
bootSync(); | ||
} | ||
|
||
window.siyuan.menus = new Menus(this); | ||
onGetConfig(response.data.start, this); | ||
account.onSetaccount(); | ||
setTitle(window.siyuan.languages.siyuanNote); | ||
initMessage(); | ||
}); | ||
setNoteBook(); | ||
initBlockPopover(this); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -448,6 +448,7 @@ export const exportMd = (id: string) => { | |
label: window.siyuan.languages.template, | ||
iconClass: "ft__error", | ||
icon: "iconMarkdown", | ||
disabled: window.siyuan.config.readonly, | ||
click: async () => { | ||
const result = await fetchSyncPost("/api/block/getRefText", {id: id}); | ||
|
||
|
@@ -507,8 +508,9 @@ export const exportMd = (id: string) => { | |
}); | ||
}); | ||
return; | ||
} else if (response.code === 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 修改参见第一条 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 此处更改是为了避免出现异常但仍推送成功消息提示 |
||
showMessage(window.siyuan.languages.exportTplSucc); | ||
} | ||
showMessage(window.siyuan.languages.exportTplSucc); | ||
}); | ||
dialog.destroy(); | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,9 +37,10 @@ class App { | |
if (!window.webkit?.messageHandlers && !window.JSAndroid) { | ||
registerServiceWorker(`${Constants.SERVICE_WORKER_PATH}?v=${Constants.SIYUAN_VERSION}`); | ||
} | ||
addBaseURL(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 请参见第二点进行修改 |
||
addScriptSync(`${Constants.PROTYLE_CDN}/js/lute/lute.min.js?v=${Constants.SIYUAN_VERSION}`, "protyleLuteScript"); | ||
addScript(`${Constants.PROTYLE_CDN}/js/protyle-html.js?v=${Constants.SIYUAN_VERSION}`, "protyleWcHtmlScript"); | ||
addBaseURL(); | ||
|
||
this.appId = Constants.SIYUAN_APPID; | ||
window.siyuan = { | ||
zIndex: 10, | ||
|
@@ -89,30 +90,7 @@ class App { | |
fetchPost("/api/system/getConf", {}, async (confResponse) => { | ||
window.siyuan.config = confResponse.data.conf; | ||
correctHotkey(siyuanApp); | ||
await loadPlugins(this); | ||
getLocalStorage(() => { | ||
fetchGet(`/appearance/langs/${window.siyuan.config.appearance.lang}.json?v=${Constants.SIYUAN_VERSION}`, (lauguages: IObject) => { | ||
window.siyuan.languages = lauguages; | ||
window.siyuan.menus = new Menus(this); | ||
document.title = window.siyuan.languages.siyuanNote; | ||
bootSync(); | ||
loadAssets(confResponse.data.conf.appearance); | ||
initMessage(); | ||
initAssets(); | ||
fetchPost("/api/setting/getCloudUser", {}, userResponse => { | ||
window.siyuan.user = userResponse.data; | ||
fetchPost("/api/system/getEmojiConf", {}, emojiResponse => { | ||
window.siyuan.emojis = emojiResponse.data as IEmoji[]; | ||
setNoteBook(() => { | ||
initFramework(this, confResponse.data.start); | ||
initRightMenu(this); | ||
openChangelog(); | ||
}); | ||
}); | ||
}); | ||
addGA(); | ||
}); | ||
}); | ||
|
||
document.addEventListener("touchstart", handleTouchStart, false); | ||
document.addEventListener("touchmove", handleTouchMove, false); | ||
document.addEventListener("touchend", (event) => { | ||
|
@@ -140,6 +118,51 @@ class App { | |
} | ||
} | ||
}); | ||
|
||
const promises = [ | ||
loadPlugins(this), | ||
new Promise<void>(resolve => getLocalStorage(resolve)), | ||
new Promise<void>(resolve => fetchGet( | ||
`/appearance/langs/${window.siyuan.config.appearance.lang}.json?v=${Constants.SIYUAN_VERSION}`, | ||
(lauguages: IObject) => { | ||
window.siyuan.languages = lauguages; | ||
resolve(); | ||
}, | ||
)), | ||
new Promise<void>(resolve => { | ||
fetchPost("/api/setting/getEmojiConf", {}, emojiResponse => { | ||
window.siyuan.emojis = emojiResponse.data as IEmoji[]; | ||
resolve(); | ||
}); | ||
}), | ||
]; | ||
|
||
if (!window.siyuan.config.readonly) { | ||
promises.push(new Promise<void>(resolve => { | ||
fetchPost("/api/setting/getCloudUser", {}, userResponse => { | ||
window.siyuan.user = userResponse.data; | ||
resolve(); | ||
}); | ||
})); | ||
} | ||
|
||
await Promise.all(promises); | ||
|
||
if (!window.siyuan.config.readonly) { | ||
bootSync(); | ||
} | ||
|
||
window.siyuan.menus = new Menus(this); | ||
document.title = window.siyuan.languages.siyuanNote; | ||
loadAssets(confResponse.data.conf.appearance); | ||
initMessage(); | ||
initAssets(); | ||
setNoteBook(() => { | ||
initFramework(this, confResponse.data.start); | ||
initRightMenu(this); | ||
openChangelog(); | ||
}); | ||
addGA(); | ||
}); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1665,6 +1665,7 @@ export class Gutter { | |
window.siyuan.menus.menu.append(new MenuItem({ | ||
label: window.siyuan.languages.wechatReminder, | ||
icon: "iconMp", | ||
disabled: window.siyuan.config.readonly, | ||
click() { | ||
openWechatNotify(nodeElement); | ||
} | ||
|
@@ -1676,6 +1677,7 @@ export class Gutter { | |
accelerator: window.siyuan.config.keymap.editor.general.quickMakeCard.custom, | ||
iconHTML: '<svg class="b3-menu__icon" style="color:var(--b3-theme-primary)"><use xlink:href="#iconRiffCard"></use></svg>', | ||
icon: "iconRiffCard", | ||
disabled: window.siyuan.config.readonly, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 相关的快捷键和其他菜单中的类似项也需要进行处理,须逐一核对。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 如何禁用相关的快捷键? 目前已找到的其他菜单中的类似项已在只读模式下禁用,但不排除还有未找到的菜单项 |
||
click() { | ||
quickMakeCard(protyle, [nodeElement]); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,7 @@ export const saveScroll = (protyle: IProtyle, getObject = false) => { | |
|
||
export const getDocByScroll = (options: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个方法就是通过 scrollAttr 打开的,传入如果为空就没有意义了。这种场景是? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 场景未知, 该问题是在发现控制台输出异常后定位到的 |
||
protyle: IProtyle, | ||
scrollAttr: IScrollAttr, | ||
scrollAttr?: IScrollAttr, | ||
mergedOptions?: IOptions, | ||
cb?: () => void | ||
focus?: boolean, | ||
|
@@ -61,7 +61,7 @@ export const getDocByScroll = (options: { | |
actions = [Constants.CB_GET_UNUNDO]; | ||
} | ||
} | ||
if (options.scrollAttr.zoomInId) { | ||
if (options.scrollAttr?.zoomInId) { | ||
fetchPost("/api/filetree/getDoc", { | ||
id: options.scrollAttr.zoomInId, | ||
size: Constants.SIZE_GET_MAX, | ||
|
@@ -100,9 +100,9 @@ export const getDocByScroll = (options: { | |
return; | ||
} | ||
fetchPost("/api/filetree/getDoc", { | ||
id: options.scrollAttr.rootId || options.mergedOptions?.blockId || options.protyle.block?.rootID || options.scrollAttr.startId, | ||
startID: options.scrollAttr.startId, | ||
endID: options.scrollAttr.endId, | ||
id: options.scrollAttr?.rootId || options.mergedOptions?.blockId || options.protyle.block?.rootID || options.scrollAttr?.startId, | ||
startID: options.scrollAttr?.startId, | ||
endID: options.scrollAttr?.endId, | ||
query: options.protyle.query?.key, | ||
queryMethod: options.protyle.query?.method, | ||
queryTypes: options.protyle.query?.types, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -150,8 +150,10 @@ export const initAssets = () => { | |
return; | ||
} | ||
} | ||
window.siyuan.config.appearance = response.data.appearance; | ||
loadAssets(response.data.appearance); | ||
if (response.code === 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 参照第一点进行修改 |
||
window.siyuan.config.appearance = response.data.appearance; | ||
loadAssets(response.data.appearance); | ||
} | ||
}); | ||
}); | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@88250 修改过后台请求处理,为保持所有请求的一致性处理,这个没有其他情况的话请不要进行修改。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
用户在只读模式下打开设置面板后该请求会自动发出并返回异常, 因此需要额外处理一下