Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion public/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"message": "Bypass List"
},
"config_section_advance": {
"message": "Advance Config"
"message": "Advanced Config"
},
"config_reference_bypass_list": {
"message": "Learn more about bypass list"
Expand Down
9 changes: 7 additions & 2 deletions src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,16 @@ class StatsProvider {
// this.stats.addFailedRequest(details);
// TODO: update indicator
const proxySetting = await getCurrentProxySetting();
console.log("onResponseStarted", details);
if (details.tabId > 0 && proxySetting.activeProfile) {
let parsedUrl: URL;
try {
parsedUrl = new URL(details.url);
} catch {
return;
}
const ret = await findProfile(
proxySetting.activeProfile,
new URL(details.url)
parsedUrl
);

StatsProvider.stats.setCurrentProfile(details.tabId, ret);
Expand Down
1 change: 0 additions & 1 deletion src/components/configs/AutoSwitchInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ const getConditionInputRule = (type: AutoSwitchType): FieldRule<string> => {
case "url":
return {
validator: async (value: string, cb: (message?: string) => void) => {
console.log("test");
let u;
try {
u = new URL(value || "");
Expand Down
1 change: 0 additions & 1 deletion src/components/controls/ThemeSwitcher.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const onDarkModeChanged = (newMode: DarkMode) => {
};

const toggleDarkMode = async () => {
console.log(await currentDarkMode());
switch (await currentDarkMode()) {
case DarkMode.Dark:
onDarkModeChanged(DarkMode.Light);
Expand Down
4 changes: 1 addition & 3 deletions src/pages/PopupPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,12 @@ onMounted(async () => {

const jumpTo = (to: RouteLocationRaw) => {
const path = router.resolve(to).fullPath;
window.open(`/index.html#${path}`, import.meta.url);
// window.open(router.resolve(to).href, import.meta.url)
window.open(`/index.html#${path}`, "_blank");
};

// actions
const setProxyByProfile = async (val: ProxyProfile) => {
try {
console.log(toRaw(val));
await setProxy(toRaw(val));
activeProfile.value = toRaw(val);
} catch (e: any) {
Expand Down
4 changes: 2 additions & 2 deletions src/services/preference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ export async function changeDarkMode(newMode: DarkMode) {

switch (newMode) {
case DarkMode.Dark:
document && document.body.setAttribute("arco-theme", "dark");
document?.body?.setAttribute("arco-theme", "dark");
break;
case DarkMode.Light:
document && document.body.removeAttribute("arco-theme");
document?.body?.removeAttribute("arco-theme");
break;
}
}
2 changes: 1 addition & 1 deletion src/services/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ async function overwriteProfiles(profiles: ProfilesStorage) {
// Deep clone to remove any Proxy objects before saving
const clonedProfiles = deepClone(profiles);
await Host.set(keyProfileStorage, clonedProfiles);
onProfileUpdateListeners.map((cb) => cb(profiles));
onProfileUpdateListeners.forEach((cb) => cb(profiles));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/services/proxy/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class ProfileAuthProvider {
];

// check if there's any matching host and port
auths.map((item) => {
auths.forEach((item) => {
if (!item) return;

if (
Expand Down
2 changes: 1 addition & 1 deletion src/services/proxy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export async function refreshProxy() {
const newProfile = await getProfile(current.activeProfile.profileID);

// if it's preset profiles, then do nothing
if (!newProfile || current.activeProfile.proxyType in ["system", "direct"]) {
if (!newProfile || ["system", "direct"].includes(current.activeProfile.proxyType)) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/services/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
* which cannot clone Proxy objects.
*/
export function deepClone<T>(obj: T): T {
return JSON.parse(JSON.stringify(obj));
return structuredClone(obj);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The switch to structuredClone() introduces a critical issue. The documentation for deepClone states its purpose is to 'remove all Proxy objects (e.g., from Vue reactivity)', which is necessary before saving to chrome.storage.

However, structuredClone() cannot clone Proxy objects and will throw a DataCloneError. The previous JSON.parse(JSON.stringify()) implementation correctly handled this by serializing the underlying raw object from the proxy.

While some call sites might use toRaw() before cloning, others (like in profile.ts) may not, leading to runtime errors when saving profiles. Given this, I recommend reverting to the previous implementation to ensure reactive objects are handled correctly.

Suggested change
return structuredClone(obj);
return JSON.parse(JSON.stringify(obj));

}