Open in Google Play Console deep-links the app: Play developer id per credential profile (accounts play-developer, desktop Accounts), shared playAppUrl builder for desktop, CLI and watch; developer chooser instead of the console root

This commit is contained in:
CRTkafa 2026-10-23 09:20:35 +08:00
parent 7c769c18f4
commit 4a74989a95
33 changed files with 311 additions and 40 deletions

View file

@ -803,7 +803,11 @@ pub fn project_set_accounts(window: WebviewWindow, state: State<'_, AppState>, i
pub fn accounts_list(window: WebviewWindow, state: State<'_, AppState>) -> Res<Vec<Account>> {
guard(&window)?;
sync_machine(&state)?;
Ok(saved(&state)?.accounts.clone())
let mut out = saved(&state)?.accounts.clone();
for a in out.iter_mut().filter(|a| a.kind == accounts::AccountKind::Play) {
a.developer_id = a.profile.as_deref().and_then(|p| state.profiles.play_developer_id(p));
}
Ok(out)
}
fn check_studio(state: &AppState, studio: &Option<String>) -> Res<()> {
@ -834,7 +838,7 @@ fn add_account(state: &AppState, label: &str, secret: Secret, studio: Option<Str
}
let id = profiles::account_id(secret.kind(), &profile);
let id = if st.accounts.iter().any(|a| a.id == id) { store::new_id()? } else { id };
let acc = Account { id, label, kind: secret.kind(), created: store::now_iso(), studio, profile: Some(profile) };
let acc = Account { id, label, kind: secret.kind(), created: store::now_iso(), studio, profile: Some(profile), developer_id: None };
st.accounts.push(acc.clone());
persist(state, &st)?;
Ok(acc)
@ -1135,6 +1139,23 @@ pub fn account_update(window: WebviewWindow, state: State<'_, AppState>, id: Str
Ok(out)
}
/// Sets or clears the Play developer account id of a Play account (PLAY_DEVELOPER_ID in its credential profile, the
/// same field `storebound accounts play-developer` writes): Play Console links then open each app's own page.
#[tauri::command]
pub fn account_set_play_developer(window: WebviewWindow, state: State<'_, AppState>, id: String, developer_id: Option<String>) -> Res<Account> {
guard(&window)?;
let st = saved(&state)?;
let mut a = st.accounts.iter().find(|a| a.id == id).cloned().ok_or_else(|| Fail::host("unknown account"))?;
if a.kind != accounts::AccountKind::Play {
return Err(Fail::host("a Play account only"));
}
let profile = a.profile.clone().ok_or_else(|| Fail::host("this account has no credential profile yet"))?;
let v = developer_id.as_deref().map(str::trim).filter(|v| !v.is_empty());
state.profiles.set_play_developer_id(&profile, v).map_err(Fail::host)?;
a.developer_id = state.profiles.play_developer_id(&profile);
Ok(a)
}
/// Does the account's key work, and can it see apps (sidecar `account.check`). Not cached: it is a live answer.
#[tauri::command]
pub async fn account_check(window: WebviewWindow, app: AppHandle, state: State<'_, AppState>, id: String, job: Option<String>) -> Res<Value> {