Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
zzlb0224 committed Aug 2, 2024
1 parent 49d7e1c commit 3658e3f
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 40 deletions.
16 changes: 16 additions & 0 deletions addon/locale/zh-CN/addon.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,21 @@ popupRoot-TagsStyle = 标签样式
popupRoot-TagsSetting = 标签设置
popupRoot-Development = 开发中
popupRoot-FollowParent = 跟随
popupRoot-ConfigType-Green = 草绿
popupRoot-ConfigType-Yellow = 菊黄
popupRoot-ConfigType-Red = 虾红
popupRoot-ConfigType-FollowParent = 跟随
popupRoot-WindowType-FollowParent = 跟随
popupRoot-WindowType-FixedPanel = 面板配置
popupRoot-WindowType-PopupPanel = 弹出面板
popupRoot-SortType-RecentUse = 最近使用
popupRoot-SortType-ItemAndRecent = 本条目+最近使用
popupRoot-SortType-UseCountDesc = 使用次数
popupRoot-SortType-CharAsc = 字母顺序
2 changes: 1 addition & 1 deletion addon/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pref("__prefsPrefix__.google-scholar-mirroring", "");

pref("__prefsPrefix__.isCtrlAdd", true);

pref("__prefsPrefix__.windowType", "跟随");
pref("__prefsPrefix__.windowType", "FollowParent");

pref("__prefsPrefix__.blockHUToggle", false);

Expand Down
24 changes: 12 additions & 12 deletions src/component/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ export const ConfigTabArray = [
] as const;
export type ConfigTab = (typeof ConfigTabArray)[number];

export const SortTypeArray = ["最近使用", "本条目+最近使用", "使用次数", "字母顺序"] as const;
export const SortTypeArray = ["RecentUse", "ItemAndRecent", "UseCountDesc", "CharAsc"] as const;
export type SortType = (typeof SortTypeArray)[number];

export const ConfigTypeArray = ["草绿", "菊黄", "虾红", "跟随"] as const;
export const ConfigTypeArray = ["Green", "Yellow", "Red", "FollowParent"] as const;
export type ConfigType = (typeof ConfigTypeArray)[number];

export const WindowTypeArray = ["跟随", "FixedPanel", "PopupPanel"] as const;
export const WindowTypeArray = ["FollowParent", "FixedPanel", "PopupPanel"] as const;
export type WindowType = (typeof WindowTypeArray)[number];

export function loadDefaultConfig(configType: ConfigType) {
let config: Config;
if (configType == "草绿") {
if (configType == "Green") {
return (config = {
windowType: "FixedPanel",
isCtrlAdd: true,
Expand All @@ -47,10 +47,10 @@ export function loadDefaultConfig(configType: ConfigType) {
btnPaddingTB: 3,
btnPaddingLR: 3,
buttonBorderRadius: 5,
sortType: "最近使用",
sortType: "RecentUse",
});
}
if (configType == "菊黄") {
if (configType == "Yellow") {
return (config = {
windowType: "PopupPanel",
isCtrlAdd: true,
Expand All @@ -77,10 +77,10 @@ export function loadDefaultConfig(configType: ConfigType) {
btnPaddingTB: 3,
btnPaddingLR: 3,
buttonBorderRadius: 5,
sortType: "最近使用",
sortType: "RecentUse",
});
}
if (configType == "虾红") {
if (configType == "Red") {
return (config = {
windowType: "PopupPanel",
isCtrlAdd: true,
Expand All @@ -107,12 +107,12 @@ export function loadDefaultConfig(configType: ConfigType) {
btnPaddingTB: 3,
btnPaddingLR: 3,
buttonBorderRadius: 10,
sortType: "最近使用",
sortType: "RecentUse",
});
}
if (configType == "跟随") {
if (configType == "FollowParent") {
return (config = {
windowType: "跟随",
windowType: "FollowParent",
isCtrlAdd: true,
pSingleWindow: false,
bAutoFocus: true,
Expand All @@ -137,7 +137,7 @@ export function loadDefaultConfig(configType: ConfigType) {
btnPaddingTB: 5,
btnPaddingLR: 0,
buttonBorderRadius: 10,
sortType: "最近使用",
sortType: "RecentUse",
});
}
}
Expand Down
52 changes: 26 additions & 26 deletions src/component/PopupRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export function PopupRoot({
const [comment, setComment] = useState("");
const [configTab, setConfigTab] = useState<ConfigTab>(getPrefAs("configTab", "PanelConfig"));
//取代固定窗口和单独窗口
const [windowType, setWindowType] = useState<WindowType>(getPrefAs("windowType", "跟随"));
const [windowType, setWindowType] = useState<WindowType>(getPrefAs("windowType", "FollowParent"));
// const [pSingleWindow, setPSingleWindow] = useState(getPrefAs("pSingleWindow", false));
// const [pFixedContentLocation, setPFixedContentLocation] = useState(getPrefAs("pFixedContentLocation", false));
const [isShowSelectedPopupColorsTag, setShowSelectedPopupColorsTag] = useState(getPrefAs("show-selected-popup-colors-tag", false));
Expand All @@ -89,7 +89,7 @@ export function PopupRoot({
const [fontSize, setFontSize] = useState(getPrefAs("fontSize", 17));
const [lineHeight, setLineHeight] = useState(getPrefAs("lineHeight", "1.45"));
const [btnMarginTB, setbtnMarginTB] = useState(getPrefAs("btnMarginTB", 0));
const [sortType, setSortType] = useState<SortType>(getPrefAs("sortType", "最近使用"));
const [sortType, setSortType] = useState<SortType>(getPrefAs("sortType", "RecentUse"));
const [btnMarginLR, setbtnMarginLR] = useState(getPrefAs("btnMarginLR", 0));
const [btnPaddingTB, setbtnPaddingTB] = useState(getPrefAs("btnPaddingTB", 0));
const [btnPaddingLR, setbtnPaddingLR] = useState(getPrefAs("btnPaddingLR", 0));
Expand Down Expand Up @@ -194,14 +194,14 @@ export function PopupRoot({

// if (rItemShowRelateTags)
groupByResultIncludeFixedTags(relateTags);
if (sortType == "最近使用") {
if (sortType == "RecentUse") {
//2 固定标签 + 最近使用时间
relateTags = relateTags.map(mapDateModified).sort(sortFixedTags100Modified10Asc);
} else if (sortType == "字母顺序") {
} else if (sortType == "CharAsc") {
relateTags = relateTags.sort(sortFixedTags10AscByKey);
} else if (sortType == "使用次数") {
} else if (sortType == "UseCountDesc") {
relateTags = relateTags.sort(sortFixedTags10ValuesLength);
} else if (sortType == "本条目+最近使用") {
} else if (sortType == "ItemAndRecent") {
//3 固定标签 + 本条目 + 修改时间
const itemAnnTags = item
?.getAnnotations()
Expand Down Expand Up @@ -482,7 +482,7 @@ export function PopupRoot({
}}
defaultValue={config.configName}
>
{config.configName}
{getString("popupRoot-ConfigType" + config.configName)}
</button>
),
)}
Expand Down Expand Up @@ -577,7 +577,7 @@ export function PopupRoot({
{WindowTypeArray.map((a) => (
<label>
<input type="radio" value={a} checked={windowType === a} onChange={handleInput("windowType", setWindowType)} />
{a}
{getString("popupRoot-ConfigType" + a)}
</label>
))}
</div>
Expand Down Expand Up @@ -952,7 +952,7 @@ export function PopupRoot({
{SortTypeArray.map((a) => (
<label>
<input type="radio" value={a} checked={sortType === a} onChange={handleInput("sortType", setSortType)} />
{a}
{getString("popupRoot-ConfigType" + a)}
</label>
))}
</div>
Expand Down Expand Up @@ -1005,7 +1005,7 @@ export function PopupRoot({
<div
ref={refContentDiv}
style={{
maxWidth: (windowType == "跟随" && !params.ids ? selectionPopupSize.width - 16 : divMaxWidth) + "px",
maxWidth: (windowType == "FollowParent" && !params.ids ? selectionPopupSize.width - 16 : divMaxWidth) + "px",
maxHeight: divMaxHeight + "px",
overflowY: "scroll",
background: "#f00",
Expand Down Expand Up @@ -1289,20 +1289,20 @@ export function PopupRoot({
ctrlAddOrSaveTags(isAdd, cTag);
return false;
}}
// onMouseDown={(e) => {
// e.preventDefault();
// ztoolkit.log("onMouseDown 复制", e)
// return false
// }}
// onContextMenu={e => {
// e.preventDefault();
// ztoolkit.log("onContextMenu 复制", tag.key)
// new window.Clipboard().readText().then((text) => {
// ztoolkit.log("onContextMenu 复制", tag.key, text);
// (e.currentTarget as HTMLInputElement).value = text;
// })
// return false
// }}
// onMouseDown={(e) => {
// e.preventDefault();
// ztoolkit.log("onMouseDown 复制", e)
// return false
// }}
// onContextMenu={e => {
// e.preventDefault();
// ztoolkit.log("onContextMenu 复制", tag.key)
// new window.Clipboard().readText().then((text) => {
// ztoolkit.log("onContextMenu 复制", tag.key, text);
// (e.currentTarget as HTMLInputElement).value = text;
// })
// return false
// }}
>
<span>[{tag.values.length}]</span>
<span>{tag.key}</span>
Expand Down Expand Up @@ -1431,7 +1431,7 @@ export function PopupRoot({
return (
<>
{/* {JSON.stringify(vars)} */}
{windowType == "跟随" && handleContentDiv()}
{windowType == "FollowParent" && handleContentDiv()}
<Popover
parentElement={parentElement}
boundaryElement={boundaryElement}
Expand All @@ -1452,7 +1452,7 @@ export function PopupRoot({
}
}}
// ref={clickMeButtonRef} // if you'd like a ref to your popover's child, you can grab one here
content={windowType == "跟随" && !params.ids ? handleConfigDiv : handleConfigAndContent}
content={windowType == "FollowParent" && !params.ids ? handleConfigDiv : handleConfigAndContent}
containerStyle={{
marginTop: "42px",
}}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/AnnotationPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ export class AnnotationPopup {
// root.style.width = maxWidth + "px";

// root.style.minWidth = Math.min(width, maxWidth) + "px";
// // 当翻译采用固定大小的时候,跟随它
// // 当翻译采用固定大小的时候,followParent它
// const keepSize = Zotero.Prefs.get(
// `extensions.zotero.ZoteroPDFTranslate.keepPopupSize`,
// true,
Expand Down

0 comments on commit 3658e3f

Please sign in to comment.