feat: 加了一个按钮用来控制鼠标点击段落中的上标跳转到文献引用
This commit is contained in:
parent
3636fe1c35
commit
e5d267cf70
|
@ -25,5 +25,6 @@
|
||||||
"deepseek-chat": "deepseek-chat (Model needs to be manually changed to this one)",
|
"deepseek-chat": "deepseek-chat (Model needs to be manually changed to this one)",
|
||||||
"caifree": "caifree (Recommended)",
|
"caifree": "caifree (Recommended)",
|
||||||
"custom": "Custom"
|
"custom": "Custom"
|
||||||
}
|
},
|
||||||
|
"鼠标点击段落中的上标跳转到文献引用?": "Click the superscript in the paragraph to jump to the reference?"
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,5 +26,6 @@
|
||||||
"deepseek-chat": "deepseek-chat(需要手动修改模型为这个)",
|
"deepseek-chat": "deepseek-chat(需要手动修改模型为这个)",
|
||||||
"caifree": "caifree(推荐)",
|
"caifree": "caifree(推荐)",
|
||||||
"custom": "自定义"
|
"custom": "自定义"
|
||||||
}
|
},
|
||||||
|
"鼠标点击段落中的上标跳转到文献引用?": "鼠标点击段落中的上标跳转到文献引用?"
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ const statePersistConfig = {
|
||||||
"contentUpdatedFromNetwork",
|
"contentUpdatedFromNetwork",
|
||||||
"isVip",
|
"isVip",
|
||||||
"language",
|
"language",
|
||||||
|
"isJumpToReference",
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ export interface APIState {
|
||||||
contentUpdatedFromNetwork: boolean;
|
contentUpdatedFromNetwork: boolean;
|
||||||
isVip: boolean;
|
isVip: boolean;
|
||||||
language: string;
|
language: string;
|
||||||
|
isJumpToReference: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialState: APIState = {
|
const initialState: APIState = {
|
||||||
|
@ -13,6 +14,7 @@ const initialState: APIState = {
|
||||||
contentUpdatedFromNetwork: false,
|
contentUpdatedFromNetwork: false,
|
||||||
isVip: false,
|
isVip: false,
|
||||||
language: "en",
|
language: "en",
|
||||||
|
isJumpToReference: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const stateSlice = createSlice({
|
export const stateSlice = createSlice({
|
||||||
|
@ -40,6 +42,9 @@ export const stateSlice = createSlice({
|
||||||
setLanguage: (state, action: PayloadAction<string>) => {
|
setLanguage: (state, action: PayloadAction<string>) => {
|
||||||
state.language = action.payload;
|
state.language = action.payload;
|
||||||
},
|
},
|
||||||
|
setIsJumpToReference: (state, action: PayloadAction<boolean>) => {
|
||||||
|
state.isJumpToReference = action.payload;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -50,6 +55,7 @@ export const {
|
||||||
setContentUpdatedFromNetwork,
|
setContentUpdatedFromNetwork,
|
||||||
setIsVip,
|
setIsVip,
|
||||||
setLanguage,
|
setLanguage,
|
||||||
|
setIsJumpToReference,
|
||||||
} = stateSlice.actions;
|
} = stateSlice.actions;
|
||||||
|
|
||||||
export const stateReducer = stateSlice.reducer;
|
export const stateReducer = stateSlice.reducer;
|
||||||
|
|
|
@ -70,6 +70,9 @@ const QEditor = ({ lng }) => {
|
||||||
//读取redux中的API key
|
//读取redux中的API key
|
||||||
const apiKey = useAppSelector((state: any) => state.auth.apiKey);
|
const apiKey = useAppSelector((state: any) => state.auth.apiKey);
|
||||||
const upsreamUrl = useAppSelector((state: any) => state.auth.upsreamUrl);
|
const upsreamUrl = useAppSelector((state: any) => state.auth.upsreamUrl);
|
||||||
|
const isJumpToReference = useAppSelector(
|
||||||
|
(state) => state.state.isJumpToReference
|
||||||
|
);
|
||||||
const [quill, setQuill] = useState<Quill | null>(null);
|
const [quill, setQuill] = useState<Quill | null>(null);
|
||||||
const contentUpdatedFromNetwork = useAppSelector(
|
const contentUpdatedFromNetwork = useAppSelector(
|
||||||
(state) => state.state.contentUpdatedFromNetwork
|
(state) => state.state.contentUpdatedFromNetwork
|
||||||
|
@ -140,6 +143,7 @@ const QEditor = ({ lng }) => {
|
||||||
});
|
});
|
||||||
// 添加点击事件监听器
|
// 添加点击事件监听器
|
||||||
const handleEditorClick = (e) => {
|
const handleEditorClick = (e) => {
|
||||||
|
if (isJumpToReference) {
|
||||||
const range = editor.current!.getSelection();
|
const range = editor.current!.getSelection();
|
||||||
if (range && range.length === 0 && editor.current) {
|
if (range && range.length === 0 && editor.current) {
|
||||||
const [leaf, offset] = editor.current.getLeaf(range.index);
|
const [leaf, offset] = editor.current.getLeaf(range.index);
|
||||||
|
@ -157,6 +161,7 @@ const QEditor = ({ lng }) => {
|
||||||
} else {
|
} else {
|
||||||
console.log("No editor in click.");
|
console.log("No editor in click.");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
editor.current.root.addEventListener("click", handleEditorClick);
|
editor.current.root.addEventListener("click", handleEditorClick);
|
||||||
|
|
|
@ -7,6 +7,7 @@ import {
|
||||||
setUpsreamUrl,
|
setUpsreamUrl,
|
||||||
setSystemPrompt,
|
setSystemPrompt,
|
||||||
} from "@/app/store/slices/authSlice";
|
} from "@/app/store/slices/authSlice";
|
||||||
|
import { setIsJumpToReference } from "@/app/store/slices/stateSlice";
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
import { faArrowLeft } from "@fortawesome/free-solid-svg-icons";
|
import { faArrowLeft } from "@fortawesome/free-solid-svg-icons";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
@ -43,11 +44,18 @@ const Settings = ({ lng }: { lng: string }) => {
|
||||||
const apiKey = useAppSelector((state) => state.auth.apiKey);
|
const apiKey = useAppSelector((state) => state.auth.apiKey);
|
||||||
const upstreamUrl = useAppSelector((state) => state.auth.upsreamUrl);
|
const upstreamUrl = useAppSelector((state) => state.auth.upsreamUrl);
|
||||||
const systemPrompt = useAppSelector((state) => state.auth.systemPrompt);
|
const systemPrompt = useAppSelector((state) => state.auth.systemPrompt);
|
||||||
|
const isJumpToReference = useAppSelector(
|
||||||
|
(state) => state.state.isJumpToReference
|
||||||
|
);
|
||||||
//state
|
//state
|
||||||
const [userConfigNumber, setUserConfigNumber] = useLocalStorage(
|
const [userConfigNumber, setUserConfigNumber] = useLocalStorage(
|
||||||
"userConfigNumber",
|
"userConfigNumber",
|
||||||
"2"
|
"2"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const toggleSwitch = () => {
|
||||||
|
dispatch(setIsJumpToReference(!isJumpToReference));
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<div className="max-w-md rounded overflow-hidden shadow-lg bg-blue-gray-100 z-1000 mx-auto ">
|
<div className="max-w-md rounded overflow-hidden shadow-lg bg-blue-gray-100 z-1000 mx-auto ">
|
||||||
<h1 className="font-bold text-3xl">settings</h1>
|
<h1 className="font-bold text-3xl">settings</h1>
|
||||||
|
@ -134,6 +142,21 @@ const Settings = ({ lng }: { lng: string }) => {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<label className="relative inline-flex items-center cursor-pointer">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
className="sr-only peer"
|
||||||
|
checked={isJumpToReference}
|
||||||
|
onChange={toggleSwitch}
|
||||||
|
/>
|
||||||
|
<div className="w-10 h-4 bg-gray-200 rounded-full peer-checked:bg-blue-600 peer-focus:ring-4 peer-focus:ring-blue-300 dark:peer-focus:ring-blue-800 transition-colors ease-in-out duration-200"></div>
|
||||||
|
<span
|
||||||
|
className={`absolute block bg-white w-3 h-3 rounded-full transition ease-in-out duration-200 transform ${
|
||||||
|
isJumpToReference ? "translate-x-6" : "translate-x-1"
|
||||||
|
} -translate-y-1/2 top-1/2`}
|
||||||
|
></span>
|
||||||
|
{t("鼠标点击段落中的上标跳转到文献引用?")}
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
{
|
|
||||||
"products": {
|
|
||||||
"cart": "Toevoegen aan Winkelwagen"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
{
|
|
||||||
"products": {
|
|
||||||
"cart": "Add to Cart"
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user