Skip to content

Commit

Permalink
fix query history
Browse files Browse the repository at this point in the history
  • Loading branch information
jlvihv committed Jun 17, 2024
1 parent 391853c commit 5940e49
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "liveship"
version = "0.1.21"
version = "0.1.22"
description = "liveship is a compact and user-friendly live stream recording tool that captures live streams as video files."
authors = ["jlvihv"]
email = "[email protected]"
Expand Down
1 change: 0 additions & 1 deletion src-tauri/src/ffmpeg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ fn build_ffmpeg_record_command(url: &str, filename: &str, proxy: Option<String>)
let max_muxing_queue_size = "1024";
let mut ffmpeg_command = vec![];
if let Some(proxy) = &proxy {
println!("proxy: {}", proxy);
ffmpeg_command.extend_from_slice(&["-http_proxy", proxy.as_str()] as &[&str]);
}
let record_command = vec![
Expand Down
1 change: 0 additions & 1 deletion src-tauri/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ pub mod query_history {

#[tauri::command]
pub async fn add_query_history(history: QueryHistory) -> Result<(), String> {
println!("add_query_history: {:?}", history);
kv::query_history::add(&history).map_err(|e| {
eprintln!("Could not add query history: {}", e);
e.to_string()
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,6 @@ pub struct ProxyConfig {
pub struct QueryHistory {
pub url: String,
pub anchor_name: String,
pub platform_kind: PlatformKind,
pub platform_kind: String,
pub created_at: i64,
}
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"productName": "liveship",
"version": "0.1.21",
"version": "0.1.22",
"identifier": "app.happyship.liveship",
"build": {
"beforeDevCommand": "bun run dev",
Expand Down
2 changes: 1 addition & 1 deletion src/lib/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,6 @@ export interface ProxyConfig {
export interface QueryHistory {
url: string;
anchorName: string;
platformKind: PlatformKind;
platformKind: string;
createdAt: number;
}
45 changes: 28 additions & 17 deletions src/routes/record/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
let errorMessage = $state('');
let inPlan = $state(false);
let useProxy = $state(false);
let recordingOption: RecordingOption = $state({ useProxy: null });
let proxyAddress = $state('');
let queryHistory: { url: string; anchorName: string; platformKind: PlatformKind }[] = $state([]);
const tryLinks: string[] = [
'https://live.douyin.com/790601393533',
Expand Down Expand Up @@ -107,14 +107,14 @@
streamUrl = liveInfo.streams[0].url;
}
let queryHistory: QueryHistory = {
let newQueryHistory: QueryHistory = {
url,
anchorName: liveInfo.anchorName,
platformKind: liveInfo.platformKind,
createdAt: new Date().getTime()
};
await invoke('add_query_history', {
history: queryHistory
history: newQueryHistory
});
queryHistory = await invoke('get_all_query_history');
} catch (err) {
Expand Down Expand Up @@ -155,11 +155,9 @@
const checked = (event.target as HTMLInputElement).checked;
if (checked) {
const proxyConfig = await getProxyConfig();
if (proxyConfig && recordingOption.useProxy === null) {
recordingOption.useProxy = proxyConfig.address;
if (proxyConfig && proxyAddress === '') {
proxyAddress = proxyConfig.address;
}
} else {
recordingOption.useProxy = null;
}
} catch (e) {
console.error('handle use proxy change error: ', e);
Expand Down Expand Up @@ -233,7 +231,7 @@
autoRecord,
stream,
liveInfo: liveInfo!,
option: recordingOption
option: getRecordingOption()
});
toast.success($t('recordAlreadyStarted'));
await isInPlan();
Expand All @@ -245,6 +243,18 @@
loading = false;
}
function getRecordingOption(): RecordingOption {
if (useProxy) {
return {
useProxy: proxyAddress
};
} else {
return {
useProxy: undefined
};
}
}
async function stopRecord() {
closeDialog(stopRecordDialogId);
if (url === '') {
Expand Down Expand Up @@ -280,6 +290,14 @@
// 最后,删除 localStorage 中的 ffmpegDownloading
localStorage.removeItem('ffmpegDownloading');
}
function clear() {
inputRef!.value = '';
url = '';
liveInfo = undefined;
errorMessage = '';
useProxy = false;
}
</script>

{#snippet icon(platformKind:string)}
Expand Down Expand Up @@ -335,14 +353,7 @@
<button
class="tooltip ml-4 mr-2 flex items-center"
data-tip={$t('clear')}
onclick={() => {
inputRef!.value = '';
url = '';
liveInfo = undefined;
errorMessage = '';
useProxy = false;
recordingOption.useProxy = null;
}}
onclick={() => clear()}
>
<span
class="icon-[fluent--dismiss-circle-28-regular] h-6 w-6 text-gray-500 hover:text-white"
Expand Down Expand Up @@ -486,7 +497,7 @@
type="text"
class="m-0 grow resize-none appearance-none overflow-hidden bg-transparent px-0 py-4 pl-4 placeholder-gray2 outline-none focus:text-white1"
placeholder={$t('useProxyPlaceholder')}
bind:value={recordingOption.useProxy}
bind:value={proxyAddress}
/>
</label>
{/if}
Expand Down

0 comments on commit 5940e49

Please sign in to comment.