fix: add manual oauth link copy for linux

This commit is contained in:
Leafd 2025-10-10 16:51:44 -04:00
parent 0feffa4a50
commit 3ec4f3386a
No known key found for this signature in database
GPG key ID: D44AE7A3699406BE
3 changed files with 60 additions and 6 deletions

View file

@ -36,6 +36,11 @@ fn get_app_version(app: tauri::AppHandle) -> String {
app.package_info().version.to_string()
}
#[tauri::command]
fn get_current_os() -> String {
std::env::consts::OS.to_string()
}
#[derive(Clone, serde::Serialize)]
struct LogEntry {
ts: i64,
@ -112,6 +117,7 @@ pub fn run() {
.invoke_handler(tauri::generate_handler![
greet,
get_app_version,
get_current_os,
get_recent_logs,
database::get_platform_info,

View file

@ -84,6 +84,7 @@ const presenceFetchInProgress = ref(false);
const oauthUrl = ref<string | null>(null);
const nextPresenceFetchAllowedAt = ref<number>(0);
const lastPresenceFetchAt = ref<number>(0);
const currentOs = ref<string | null>(null);
const currentPage = ref<'home' | 'projects' | 'statistics' | 'settings'>('home');
@ -131,6 +132,7 @@ onMounted(async () => {
await loadAuthState();
await loadApiConfig();
await loadHackatimeInfo();
await loadCurrentOs();
try {
const appVersion = await invoke("get_app_version") as string;
@ -333,6 +335,16 @@ async function loadHackatimeInfo() {
}
}
async function loadCurrentOs() {
try {
currentOs.value = await invoke("get_current_os") as string;
console.log("Current OS detected:", currentOs.value);
} catch (error) {
console.error("Failed to detect current OS:", error);
currentOs.value = null;
}
}
async function loadPresenceData() {
if (presenceFetchInProgress.value) {
return;
@ -574,6 +586,7 @@ async function handleInstallNow() {
:isLoading="isLoading"
:isDevMode="isDevMode"
:oauthUrl="oauthUrl"
:currentOs="currentOs"
@authenticate="authenticate"
@handleDirectOAuthAuth="handleDirectOAuthAuth"
@openOAuthUrlManually="openOAuthUrlManually"

View file

@ -83,6 +83,28 @@
</span>
</button>
<!-- Linux-specific OAuth URL copy section -->
<div v-if="currentOs === 'linux' && oauthUrl" class="mt-6 mb-6 p-4 bg-[#2A1F2B] border border-white/20 rounded-lg">
<p class="text-white/70 text-sm mb-3" style="font-family: 'Outfit', sans-serif;">
<strong>Linux:</strong> Copy the link to open in your browser manually
</p>
<div class="flex gap-2">
<input
:value="oauthUrl"
readonly
class="flex-1 p-3 bg-[#3D2C3E] border border-white/20 rounded-lg text-white font-mono text-xs focus:outline-none focus:border-[#E99682] transition-colors select-all"
@click="($event.target as HTMLInputElement)?.select()"
/>
<button
@click="copyOAuthUrl"
class="px-4 py-3 rounded-lg border-2 border-[rgba(0,0,0,0.35)] font-bold text-sm transition-all bg-[#E99682] text-white hover:bg-[#d88672]"
style="font-family: 'Outfit', sans-serif;"
>
Copy
</button>
</div>
</div>
<button
@click="cancelAuth"
class="text-white/60 text-base hover:text-white transition-colors font-medium"
@ -108,12 +130,6 @@ const emit = defineEmits<{
openOAuthUrlManually: [];
}>();
defineProps<{
isLoading: boolean;
isDevMode: boolean;
oauthUrl: string | null;
}>();
const authInProgress = ref(false);
const directToken = ref('');
@ -138,6 +154,25 @@ function handleDirectAuth() {
directToken.value = '';
}
}
const props = defineProps<{
isLoading: boolean;
isDevMode: boolean;
oauthUrl: string | null;
currentOs: string | null;
}>();
async function copyOAuthUrl() {
if (!props.oauthUrl) return;
try {
await navigator.clipboard.writeText(props.oauthUrl);
alert("OAuth URL copied to clipboard!");
} catch (error) {
console.error("Failed to copy OAuth URL:", error);
alert("Failed to copy OAuth URL to clipboard");
}
}
</script>
<style scoped>