inital commit
21
.gitignore
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
node_modules
|
||||||
|
|
||||||
|
# Output
|
||||||
|
.output
|
||||||
|
.vercel
|
||||||
|
/.svelte-kit
|
||||||
|
/build
|
||||||
|
|
||||||
|
# OS
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# Env
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
!.env.example
|
||||||
|
!.env.test
|
||||||
|
|
||||||
|
# Vite
|
||||||
|
vite.config.js.timestamp-*
|
||||||
|
vite.config.ts.timestamp-*
|
4
.prettierignore
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# Package Managers
|
||||||
|
package-lock.json
|
||||||
|
pnpm-lock.yaml
|
||||||
|
yarn.lock
|
8
.prettierrc
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"useTabs": true,
|
||||||
|
"singleQuote": true,
|
||||||
|
"trailingComma": "none",
|
||||||
|
"printWidth": 100,
|
||||||
|
"plugins": ["prettier-plugin-svelte"],
|
||||||
|
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
|
||||||
|
}
|
38
README.md
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
# create-svelte
|
||||||
|
|
||||||
|
Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/main/packages/create-svelte).
|
||||||
|
|
||||||
|
## Creating a project
|
||||||
|
|
||||||
|
If you're seeing this, you've probably already done this step. Congrats!
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# create a new project in the current directory
|
||||||
|
npm create svelte@latest
|
||||||
|
|
||||||
|
# create a new project in my-app
|
||||||
|
npm create svelte@latest my-app
|
||||||
|
```
|
||||||
|
|
||||||
|
## Developing
|
||||||
|
|
||||||
|
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run dev
|
||||||
|
|
||||||
|
# or start the server and open the app in a new browser tab
|
||||||
|
npm run dev -- --open
|
||||||
|
```
|
||||||
|
|
||||||
|
## Building
|
||||||
|
|
||||||
|
To create a production version of your app:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
You can preview the production build with `npm run preview`.
|
||||||
|
|
||||||
|
> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
|
33
eslint.config.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
import js from '@eslint/js';
|
||||||
|
import ts from 'typescript-eslint';
|
||||||
|
import svelte from 'eslint-plugin-svelte';
|
||||||
|
import prettier from 'eslint-config-prettier';
|
||||||
|
import globals from 'globals';
|
||||||
|
|
||||||
|
/** @type {import('eslint').Linter.FlatConfig[]} */
|
||||||
|
export default [
|
||||||
|
js.configs.recommended,
|
||||||
|
...ts.configs.recommended,
|
||||||
|
...svelte.configs['flat/recommended'],
|
||||||
|
prettier,
|
||||||
|
...svelte.configs['flat/prettier'],
|
||||||
|
{
|
||||||
|
languageOptions: {
|
||||||
|
globals: {
|
||||||
|
...globals.browser,
|
||||||
|
...globals.node
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ['**/*.svelte'],
|
||||||
|
languageOptions: {
|
||||||
|
parserOptions: {
|
||||||
|
parser: ts.parser
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ignores: ['build/', '.svelte-kit/', 'dist/']
|
||||||
|
}
|
||||||
|
];
|
4564
package-lock.json
generated
Normal file
42
package.json
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
{
|
||||||
|
"name": "fanslysync-desktop",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"dev": "vite dev",
|
||||||
|
"build": "vite build",
|
||||||
|
"preview": "vite preview",
|
||||||
|
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
||||||
|
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
||||||
|
"lint": "prettier --check . && eslint .",
|
||||||
|
"format": "prettier --write .",
|
||||||
|
"tauri": "tauri"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@sveltejs/adapter-auto": "^3.0.0",
|
||||||
|
"@sveltejs/adapter-static": "^3.0.2",
|
||||||
|
"@sveltejs/kit": "^2.0.0",
|
||||||
|
"@sveltejs/vite-plugin-svelte": "^3.0.0",
|
||||||
|
"@tauri-apps/cli": "^1.6.0",
|
||||||
|
"@types/eslint": "^8.56.7",
|
||||||
|
"autoprefixer": "^10.4.19",
|
||||||
|
"eslint": "^9.0.0",
|
||||||
|
"eslint-config-prettier": "^9.1.0",
|
||||||
|
"eslint-plugin-svelte": "^2.36.0",
|
||||||
|
"globals": "^15.0.0",
|
||||||
|
"postcss": "^8.4.39",
|
||||||
|
"prettier": "^3.1.1",
|
||||||
|
"prettier-plugin-svelte": "^3.1.2",
|
||||||
|
"svelte": "^4.2.7",
|
||||||
|
"svelte-check": "^3.6.0",
|
||||||
|
"tailwindcss": "^3.4.6",
|
||||||
|
"tslib": "^2.4.1",
|
||||||
|
"typescript": "^5.0.0",
|
||||||
|
"typescript-eslint": "^8.0.0-alpha.20",
|
||||||
|
"vite": "^5.0.3"
|
||||||
|
},
|
||||||
|
"type": "module",
|
||||||
|
"dependencies": {
|
||||||
|
"@tauri-apps/api": "^1.6.0"
|
||||||
|
}
|
||||||
|
}
|
6
postcss.config.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
export default {
|
||||||
|
plugins: {
|
||||||
|
tailwindcss: {},
|
||||||
|
autoprefixer: {},
|
||||||
|
},
|
||||||
|
}
|
3
src-tauri/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Generated by Cargo
|
||||||
|
# will have compiled files and executables
|
||||||
|
/target/
|
5313
src-tauri/Cargo.lock
generated
Normal file
31
src-tauri/Cargo.toml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
[package]
|
||||||
|
name = "app"
|
||||||
|
version = "0.1.0"
|
||||||
|
description = "A Tauri App"
|
||||||
|
authors = ["you"]
|
||||||
|
license = ""
|
||||||
|
repository = ""
|
||||||
|
default-run = "app"
|
||||||
|
edition = "2021"
|
||||||
|
rust-version = "1.60"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
tauri-build = { version = "1.5.3", features = [] }
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
serde_json = "1.0"
|
||||||
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
tauri = { version = "1.7.0", features = [ "os-all", "notification-all", "dialog-confirm", "clipboard-all", "dialog-message", "dialog-ask"] }
|
||||||
|
dirs = "5.0.1"
|
||||||
|
reqwest = { version = "0.11.18", features = ["json"] }
|
||||||
|
lazy_static = "1.5.0"
|
||||||
|
tokio = { version = "1.29.1", features = ["full"] }
|
||||||
|
tokio-macros = "2.3.0"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
# this feature is used for production builds or when `devPath` points to the filesystem and the built-in dev server is disabled.
|
||||||
|
# If you use cargo directly instead of tauri's cli you can use this feature flag to switch between tauri's `dev` and `build` modes.
|
||||||
|
# DO NOT REMOVE!!
|
||||||
|
custom-protocol = [ "tauri/custom-protocol" ]
|
3
src-tauri/build.rs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fn main() {
|
||||||
|
tauri_build::build()
|
||||||
|
}
|
BIN
src-tauri/icons/128x128.png
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
src-tauri/icons/128x128@2x.png
Normal file
After Width: | Height: | Size: 7.6 KiB |
BIN
src-tauri/icons/32x32.png
Normal file
After Width: | Height: | Size: 1011 B |
BIN
src-tauri/icons/Square107x107Logo.png
Normal file
After Width: | Height: | Size: 3.3 KiB |
BIN
src-tauri/icons/Square142x142Logo.png
Normal file
After Width: | Height: | Size: 4.2 KiB |
BIN
src-tauri/icons/Square150x150Logo.png
Normal file
After Width: | Height: | Size: 4.4 KiB |
BIN
src-tauri/icons/Square284x284Logo.png
Normal file
After Width: | Height: | Size: 8.7 KiB |
BIN
src-tauri/icons/Square30x30Logo.png
Normal file
After Width: | Height: | Size: 957 B |
BIN
src-tauri/icons/Square310x310Logo.png
Normal file
After Width: | Height: | Size: 9.3 KiB |
BIN
src-tauri/icons/Square44x44Logo.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
src-tauri/icons/Square71x71Logo.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
src-tauri/icons/Square89x89Logo.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
src-tauri/icons/StoreLogo.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
src-tauri/icons/icon.icns
Normal file
BIN
src-tauri/icons/icon.ico
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
src-tauri/icons/icon.png
Normal file
After Width: | Height: | Size: 12 KiB |
43
src-tauri/src/commands/config/mod.rs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
use crate::handlers::config::{get_config_path, Config};
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn init_config() -> Result<(), String> {
|
||||||
|
println!("[commands::config::init_config] Initializing config...");
|
||||||
|
let config_path = get_config_path().map_err(|e| e.to_string())?;
|
||||||
|
|
||||||
|
println!(
|
||||||
|
"[commands::config::init_config] Config path: {}",
|
||||||
|
config_path.display()
|
||||||
|
);
|
||||||
|
|
||||||
|
Config::load_or_create(&config_path).map_err(|e| e.to_string())?;
|
||||||
|
println!("[commands::config::init_config] Config initialized successfully");
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn get_config() -> Result<Config, String> {
|
||||||
|
let config_path = get_config_path().map_err(|e| e.to_string())?;
|
||||||
|
let config = Config::load_or_create(&config_path).map_err(|e| e.to_string())?;
|
||||||
|
|
||||||
|
println!(
|
||||||
|
"[commands::config::get_config] Config loaded successfully: {:?} from path: {}",
|
||||||
|
config,
|
||||||
|
config_path.display()
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(config)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn save_config(config: Config) -> Result<(), String> {
|
||||||
|
let config_path = get_config_path().map_err(|e| e.to_string())?;
|
||||||
|
println!(
|
||||||
|
"[commands::config::save_config] Saving config: {:?} to path: {}",
|
||||||
|
config,
|
||||||
|
config_path.display()
|
||||||
|
);
|
||||||
|
|
||||||
|
config.save(&config_path).map_err(|e| e.to_string())?;
|
||||||
|
Ok(())
|
||||||
|
}
|
37
src-tauri/src/commands/fansly/mod.rs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
use crate::{
|
||||||
|
handlers::fansly::Fansly,
|
||||||
|
structs::{FanslyAccountResponse, FanslyBaseResponse, SyncDataResponse},
|
||||||
|
};
|
||||||
|
use lazy_static::lazy_static;
|
||||||
|
use tokio::sync::Mutex;
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
static ref FANSLY: Mutex<Fansly> = Mutex::new(Fansly::new(None));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn fansly_set_token(token: Option<String>) {
|
||||||
|
FANSLY.lock().await.set_token(token);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn fansly_get_me() -> Result<FanslyBaseResponse<FanslyAccountResponse>, String> {
|
||||||
|
let fansly = FANSLY.lock().await;
|
||||||
|
let response = fansly.get_profile().await;
|
||||||
|
|
||||||
|
match response {
|
||||||
|
Ok(response) => Ok(response),
|
||||||
|
Err(e) => Err(e.to_string()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn fansly_sync() -> Result<SyncDataResponse, String> {
|
||||||
|
let fansly = FANSLY.lock().await;
|
||||||
|
let response = fansly.sync().await;
|
||||||
|
|
||||||
|
match response {
|
||||||
|
Ok(response) => Ok(response),
|
||||||
|
Err(e) => Err(e.to_string()),
|
||||||
|
}
|
||||||
|
}
|
3
src-tauri/src/commands/mod.rs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
pub mod config;
|
||||||
|
pub mod fansly;
|
||||||
|
pub mod utils;
|
4
src-tauri/src/commands/utils/mod.rs
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#[tauri::command]
|
||||||
|
pub fn quit(code: i32) {
|
||||||
|
std::process::exit(code);
|
||||||
|
}
|
105
src-tauri/src/handlers/config/mod.rs
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use std::fs::{self, File};
|
||||||
|
use std::io::{self, Write};
|
||||||
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
|
use crate::structs::{FanslyFollowersResponse, Subscription};
|
||||||
|
|
||||||
|
const CURRENT_VERSION: i32 = 1; // Set the current version of the config
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
pub struct SyncData {
|
||||||
|
pub followers: Vec<FanslyFollowersResponse>,
|
||||||
|
pub subscribers: Vec<Subscription>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
pub struct Config {
|
||||||
|
pub version: i32, // Add a version field to the config (1, 2, 3, etc.)
|
||||||
|
pub is_first_run: bool,
|
||||||
|
pub fansly_token: String,
|
||||||
|
pub sync_interval: u64,
|
||||||
|
pub last_sync: u64,
|
||||||
|
pub last_sync_data: SyncData,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Config {
|
||||||
|
fn default() -> Self {
|
||||||
|
Config {
|
||||||
|
version: CURRENT_VERSION, // Version is set to CURRENT_VERSION by default
|
||||||
|
is_first_run: true, // First run is set to true by default
|
||||||
|
fansly_token: String::new(), // Fansly token is stored as a string
|
||||||
|
sync_interval: 1, // Every hour - sync interval is interpreted as hours
|
||||||
|
last_sync: 0, // Last sync time is stored as a UNIX timestamp
|
||||||
|
last_sync_data: SyncData {
|
||||||
|
followers: Vec::new(),
|
||||||
|
subscribers: Vec::new(),
|
||||||
|
}, // Last sync data is stored as a list of followers and subscribers
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Config {
|
||||||
|
pub fn load_or_create(path: &Path) -> io::Result<Self> {
|
||||||
|
if path.exists() {
|
||||||
|
let mut config: Self = serde_json::from_str(std::fs::read_to_string(path)?.as_str())
|
||||||
|
.map_err(|e| {
|
||||||
|
io::Error::new(
|
||||||
|
io::ErrorKind::InvalidData,
|
||||||
|
format!("Could not parse config file: {}", e),
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
if config.version != CURRENT_VERSION {
|
||||||
|
config = config.migrate()?;
|
||||||
|
config.save(path)?;
|
||||||
|
}
|
||||||
|
Ok(config)
|
||||||
|
} else {
|
||||||
|
let saved_config = Config::default().save(path);
|
||||||
|
saved_config
|
||||||
|
.and_then(|_| Config::load_or_create(path))
|
||||||
|
.or_else(|e| Err(e))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn migrate(mut self) -> io::Result<Self> {
|
||||||
|
while self.version < CURRENT_VERSION {
|
||||||
|
self = match self.version {
|
||||||
|
1 => {
|
||||||
|
// If we're on version 1, migrate to version 2 (not implemented)
|
||||||
|
self.version += 1;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
// If we don't have a migration path, return an error
|
||||||
|
return Err(io::Error::new(
|
||||||
|
io::ErrorKind::InvalidData,
|
||||||
|
format!("No migration path for version {}", self.version),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
Ok(self)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn save(&self, path: &Path) -> io::Result<()> {
|
||||||
|
let mut file = File::create(path)?;
|
||||||
|
file.write_all(serde_json::to_string_pretty(self).unwrap().as_bytes())?;
|
||||||
|
|
||||||
|
// Return the saved config
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_config_path() -> io::Result<PathBuf> {
|
||||||
|
let mut config_dir = dirs::config_dir().ok_or_else(|| {
|
||||||
|
io::Error::new(
|
||||||
|
io::ErrorKind::NotFound,
|
||||||
|
"Could not determine user's config directory",
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
config_dir.push("FanslySync");
|
||||||
|
fs::create_dir_all(&config_dir)?;
|
||||||
|
config_dir.push("config.json");
|
||||||
|
Ok(config_dir)
|
||||||
|
}
|
254
src-tauri/src/handlers/fansly/mod.rs
Normal file
@ -0,0 +1,254 @@
|
|||||||
|
// Create a simple module for handling the Fansly API, using reqwest to make requests to the API.
|
||||||
|
// This module will contain a struct Fansly, which will have a method to get the user's profile information.
|
||||||
|
use crate::structs::{
|
||||||
|
FanslyAccountResponse, FanslyBaseResponse, FanslyBaseResponseList, FanslyFollowersResponse,
|
||||||
|
FanslySubscriptionsResponse, Subscription, SyncDataResponse,
|
||||||
|
};
|
||||||
|
use reqwest::header::{HeaderMap, HeaderValue, USER_AGENT};
|
||||||
|
|
||||||
|
pub struct Fansly {
|
||||||
|
client: reqwest::Client,
|
||||||
|
token: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Fansly {
|
||||||
|
pub fn new(token: Option<String>) -> Self {
|
||||||
|
let mut headers = HeaderMap::new();
|
||||||
|
|
||||||
|
// Set the user agent to the FanslySync/0.1.0 tanner@fanslycreatorbot.com
|
||||||
|
headers.insert(
|
||||||
|
USER_AGENT,
|
||||||
|
HeaderValue::from_static("FanslySync/0.1.0 tanner@fanslycreatorbot.com"),
|
||||||
|
);
|
||||||
|
|
||||||
|
// If we have a token, add it to the headers\
|
||||||
|
if let Some(token) = &token {
|
||||||
|
headers.insert(
|
||||||
|
"Authorization",
|
||||||
|
HeaderValue::from_str(&format!("{}", token)).unwrap(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set our default base url to https://apiv3.fansly.com/api/v1/
|
||||||
|
let client = reqwest::Client::builder()
|
||||||
|
.default_headers(headers)
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
Self { client, token }
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper function to set our token on the fly
|
||||||
|
pub fn set_token(&mut self, token: Option<String>) {
|
||||||
|
self.token = token;
|
||||||
|
|
||||||
|
// Re-create the client with the new token (if it exists)
|
||||||
|
let mut headers = HeaderMap::new();
|
||||||
|
|
||||||
|
headers.insert(
|
||||||
|
USER_AGENT,
|
||||||
|
HeaderValue::from_static("FanslySync/0.1.0 tanner@fanslycreatorbot.com"),
|
||||||
|
);
|
||||||
|
|
||||||
|
// If we have a token, add it to the headers
|
||||||
|
if let Some(token) = &self.token {
|
||||||
|
headers.insert(
|
||||||
|
"Authorization",
|
||||||
|
HeaderValue::from_str(&format!("{}", token)).unwrap(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
self.client = reqwest::Client::builder()
|
||||||
|
.default_headers(headers)
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get_profile(
|
||||||
|
&self,
|
||||||
|
) -> Result<FanslyBaseResponse<FanslyAccountResponse>, reqwest::Error> {
|
||||||
|
let response = self
|
||||||
|
.client
|
||||||
|
.get("https://apiv3.fansly.com/api/v1/account/me")
|
||||||
|
.send()
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
if !response.status().is_success() {
|
||||||
|
eprintln!("[sync::process::get_profile] No successful response from API. Setting error state.");
|
||||||
|
return Err(response.error_for_status().unwrap_err());
|
||||||
|
} else {
|
||||||
|
println!("[sync::process::get_profile] Got successful response from API.");
|
||||||
|
}
|
||||||
|
|
||||||
|
let profile: FanslyBaseResponse<FanslyAccountResponse> = response.json().await?;
|
||||||
|
Ok(profile)
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn fetch_followers(
|
||||||
|
&self,
|
||||||
|
account_id: &str,
|
||||||
|
auth_token: &str,
|
||||||
|
offset: u32,
|
||||||
|
) -> Result<FanslyBaseResponseList<FanslyFollowersResponse>, reqwest::Error> {
|
||||||
|
let url = format!("https://apiv3.fansly.com/api/v1/account/{}/followers?ngsw-bypass=true&limit=100&offset={}", account_id, offset);
|
||||||
|
|
||||||
|
let mut headers = reqwest::header::HeaderMap::new();
|
||||||
|
headers.insert(
|
||||||
|
reqwest::header::AUTHORIZATION,
|
||||||
|
format!("{}", auth_token).parse().unwrap(),
|
||||||
|
);
|
||||||
|
headers.insert(
|
||||||
|
reqwest::header::USER_AGENT,
|
||||||
|
"FanslySync/1.0.0 (tanner@teamhydra.dev)".parse().unwrap(),
|
||||||
|
);
|
||||||
|
|
||||||
|
headers.insert(
|
||||||
|
reqwest::header::CONTENT_TYPE,
|
||||||
|
"application/json".parse().unwrap(),
|
||||||
|
);
|
||||||
|
|
||||||
|
let response = self.client.get(url).headers(headers).send().await?;
|
||||||
|
|
||||||
|
if !response.status().is_success() {
|
||||||
|
eprintln!("[sync::process::fetch_followers] No successful response from API. Setting error state.");
|
||||||
|
return Err(response.error_for_status().unwrap_err());
|
||||||
|
}
|
||||||
|
|
||||||
|
let followers: FanslyBaseResponseList<FanslyFollowersResponse> = response.json().await?;
|
||||||
|
println!(
|
||||||
|
"[sync::process::fetch_followers] Got {} followers from API.",
|
||||||
|
followers.response.len()
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(followers)
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn fetch_subscribers(
|
||||||
|
&self,
|
||||||
|
auth_token: &str,
|
||||||
|
offset: u32,
|
||||||
|
) -> Result<Vec<Subscription>, reqwest::Error> {
|
||||||
|
let url = format!("https://apiv3.fansly.com/api/v1/subscribers?status=3,4&limit=100&offset={}&ngsw-bypass=true", offset);
|
||||||
|
|
||||||
|
let mut headers = reqwest::header::HeaderMap::new();
|
||||||
|
headers.insert(
|
||||||
|
reqwest::header::AUTHORIZATION,
|
||||||
|
format!("{}", auth_token).parse().unwrap(),
|
||||||
|
);
|
||||||
|
headers.insert(
|
||||||
|
reqwest::header::USER_AGENT,
|
||||||
|
"FanslySync/1.0.0 (sticks@teamhydra.dev)".parse().unwrap(),
|
||||||
|
);
|
||||||
|
headers.insert(
|
||||||
|
reqwest::header::CONTENT_TYPE,
|
||||||
|
"application/json".parse().unwrap(),
|
||||||
|
);
|
||||||
|
|
||||||
|
let response = self.client.get(url).headers(headers).send().await?;
|
||||||
|
|
||||||
|
if !response.status().is_success() {
|
||||||
|
eprintln!("[fanslySyncExt] No successful response from API. Setting error state.");
|
||||||
|
let error = response.error_for_status().unwrap_err();
|
||||||
|
return Err(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
let subscriptions: FanslyBaseResponse<FanslySubscriptionsResponse> =
|
||||||
|
response.json().await?;
|
||||||
|
println!(
|
||||||
|
"[fanslySyncExt] Got {} subscriptions from API.",
|
||||||
|
subscriptions.response.subscriptions.len()
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(subscriptions.response.subscriptions)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn sync(&self) -> Result<SyncDataResponse, String> {
|
||||||
|
// Fetch profile
|
||||||
|
println!("[sync::process] Fetching profile...");
|
||||||
|
let profile = self.get_profile().await.map_err(|e| e.to_string())?;
|
||||||
|
|
||||||
|
if !profile.success {
|
||||||
|
return Err("Failed to fetch profile".to_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
println!("[sync::process] Profile retrieved successfully.");
|
||||||
|
|
||||||
|
let account = profile.response.account;
|
||||||
|
let total_followers = account.follow_count;
|
||||||
|
let total_subscribers = account.subscriber_count;
|
||||||
|
|
||||||
|
println!(
|
||||||
|
"[sync::process] Account {} has {} followers and {} subscribers. Starting sync...",
|
||||||
|
account.id, total_followers, total_subscribers
|
||||||
|
);
|
||||||
|
|
||||||
|
let mut followers: Vec<FanslyFollowersResponse> = Vec::new();
|
||||||
|
let mut subscribers: Vec<Subscription> = Vec::new();
|
||||||
|
|
||||||
|
println!("[sync::process] Fetching followers and subscribers...");
|
||||||
|
|
||||||
|
// Fetch followers until we have all of them
|
||||||
|
let mut offset = 0;
|
||||||
|
let mut total_requests = 0;
|
||||||
|
while followers.len() < total_followers as usize {
|
||||||
|
println!(
|
||||||
|
"[sync::process] Fetching followers for account {} with offset {} (total: {})",
|
||||||
|
account.id, offset, total_followers
|
||||||
|
);
|
||||||
|
let response = self
|
||||||
|
.fetch_followers(&account.id, &self.token.as_ref().unwrap(), offset)
|
||||||
|
.await
|
||||||
|
.map_err(|e| e.to_string())?;
|
||||||
|
|
||||||
|
println!(
|
||||||
|
"[sync::process] Got {} followers from API.",
|
||||||
|
response.response.len()
|
||||||
|
);
|
||||||
|
followers.extend(response.response);
|
||||||
|
offset += 100;
|
||||||
|
total_requests += 1;
|
||||||
|
|
||||||
|
// Every 10 requests, sleep for a bit to avoid rate limiting
|
||||||
|
if total_requests % 10 == 0 {
|
||||||
|
tokio::time::sleep(tokio::time::Duration::from_secs(5)).await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch subscribers until we have all of them
|
||||||
|
offset = 0;
|
||||||
|
while subscribers.len() < total_subscribers as usize {
|
||||||
|
println!(
|
||||||
|
"[sync::process] Fetching subscribers with offset {} for account {} (total: {})",
|
||||||
|
offset, account.id, total_subscribers
|
||||||
|
);
|
||||||
|
|
||||||
|
let response = self
|
||||||
|
.fetch_subscribers(&self.token.as_ref().unwrap(), offset)
|
||||||
|
.await
|
||||||
|
.map_err(|e| e.to_string())?;
|
||||||
|
|
||||||
|
subscribers.extend(response);
|
||||||
|
offset += 100;
|
||||||
|
total_requests += 1;
|
||||||
|
|
||||||
|
// Every 10 requests, sleep for a bit to avoid rate limiting
|
||||||
|
if total_requests % 10 == 0 {
|
||||||
|
tokio::time::sleep(tokio::time::Duration::from_secs(5)).await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
println!(
|
||||||
|
"[sync::process] Got {} followers and {} subscribers from API.",
|
||||||
|
followers.len(),
|
||||||
|
subscribers.len()
|
||||||
|
);
|
||||||
|
|
||||||
|
println!("[sync::process] Sync complete.");
|
||||||
|
|
||||||
|
// Return JSON of what we fetched
|
||||||
|
Ok(SyncDataResponse {
|
||||||
|
followers,
|
||||||
|
subscribers,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
2
src-tauri/src/handlers/mod.rs
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
pub mod config;
|
||||||
|
pub mod fansly;
|
26
src-tauri/src/main.rs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
||||||
|
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||||
|
|
||||||
|
mod commands;
|
||||||
|
mod handlers;
|
||||||
|
mod structs;
|
||||||
|
|
||||||
|
use commands::config::{get_config, init_config, save_config};
|
||||||
|
use commands::fansly::{fansly_get_me, fansly_set_token, fansly_sync};
|
||||||
|
use commands::utils::quit;
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() {
|
||||||
|
tauri::Builder::default()
|
||||||
|
.invoke_handler(tauri::generate_handler![
|
||||||
|
init_config,
|
||||||
|
get_config,
|
||||||
|
save_config,
|
||||||
|
quit,
|
||||||
|
fansly_set_token,
|
||||||
|
fansly_get_me,
|
||||||
|
fansly_sync
|
||||||
|
])
|
||||||
|
.run(tauri::generate_context!())
|
||||||
|
.expect("error while running tauri application");
|
||||||
|
}
|
196
src-tauri/src/structs/mod.rs
Normal file
@ -0,0 +1,196 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use serde_json::Value;
|
||||||
|
|
||||||
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
|
pub struct SyncDataResponse {
|
||||||
|
pub followers: Vec<FanslyFollowersResponse>,
|
||||||
|
pub subscribers: Vec<Subscription>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct FanslyBaseResponse<T> {
|
||||||
|
pub success: bool,
|
||||||
|
pub response: T,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct FanslyBaseResponseList<T> {
|
||||||
|
pub success: bool,
|
||||||
|
pub response: Vec<T>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct FanslyFollowersResponse {
|
||||||
|
pub follower_id: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct FanslySubscriptionsResponse {
|
||||||
|
pub stats: SubscriptionsStats,
|
||||||
|
pub subscriptions: Vec<Subscription>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct SubscriptionsStats {
|
||||||
|
pub total_active: i64,
|
||||||
|
pub total_expired: i64,
|
||||||
|
pub total: i64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct Subscription {
|
||||||
|
pub id: String,
|
||||||
|
pub history_id: String,
|
||||||
|
pub subscriber_id: String,
|
||||||
|
pub subscription_tier_id: String,
|
||||||
|
pub subscription_tier_name: String,
|
||||||
|
pub subscription_tier_color: String,
|
||||||
|
pub plan_id: String,
|
||||||
|
pub promo_id: Option<String>,
|
||||||
|
pub gift_code_id: Value,
|
||||||
|
pub payment_method_id: String,
|
||||||
|
pub status: i64,
|
||||||
|
pub price: i64,
|
||||||
|
pub renew_price: i64,
|
||||||
|
pub renew_correlation_id: String,
|
||||||
|
pub auto_renew: i64,
|
||||||
|
pub billing_cycle: i64,
|
||||||
|
pub duration: i64,
|
||||||
|
pub renew_date: i64,
|
||||||
|
pub version: i64,
|
||||||
|
pub created_at: i64,
|
||||||
|
pub updated_at: i64,
|
||||||
|
pub ends_at: i64,
|
||||||
|
pub promo_price: Value,
|
||||||
|
pub promo_duration: Value,
|
||||||
|
pub promo_status: Value,
|
||||||
|
pub promo_starts_at: Value,
|
||||||
|
pub promo_ends_at: Value,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct FanslyAccountResponse {
|
||||||
|
pub account: Account,
|
||||||
|
pub correlation_id: String,
|
||||||
|
pub check_token: Value,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct Account {
|
||||||
|
pub id: String,
|
||||||
|
pub email: String,
|
||||||
|
pub username: String,
|
||||||
|
pub display_name: String,
|
||||||
|
pub flags: i64,
|
||||||
|
pub version: i64,
|
||||||
|
pub created_at: i64,
|
||||||
|
pub follow_count: i64,
|
||||||
|
pub subscriber_count: i64,
|
||||||
|
pub permissions: Permissions,
|
||||||
|
pub timeline_stats: TimelineStats,
|
||||||
|
pub profile_access_flags: i64,
|
||||||
|
pub profile_flags: i64,
|
||||||
|
pub about: String,
|
||||||
|
pub location: String,
|
||||||
|
pub profile_socials: Vec<Value>,
|
||||||
|
pub status_id: i64,
|
||||||
|
pub last_seen_at: i64,
|
||||||
|
pub post_likes: i64,
|
||||||
|
pub main_wallet: MainWallet,
|
||||||
|
pub streaming: Streaming,
|
||||||
|
pub account_media_likes: i64,
|
||||||
|
pub earnings_wallet: EarningsWallet,
|
||||||
|
pub subscription_tiers: Vec<SubscriptionTier>,
|
||||||
|
pub profile_access: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct Permissions {
|
||||||
|
pub account_permission_flags: AccountPermissionFlags,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct AccountPermissionFlags {
|
||||||
|
pub flags: i64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct TimelineStats {
|
||||||
|
pub account_id: String,
|
||||||
|
pub image_count: i64,
|
||||||
|
pub video_count: i64,
|
||||||
|
pub bundle_count: i64,
|
||||||
|
pub bundle_image_count: i64,
|
||||||
|
pub bundle_video_count: i64,
|
||||||
|
pub fetched_at: i64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct MainWallet {
|
||||||
|
pub id: String,
|
||||||
|
pub account_id: String,
|
||||||
|
pub balance: i64,
|
||||||
|
#[serde(rename = "type")]
|
||||||
|
pub type_field: i64,
|
||||||
|
pub wallet_version: i64,
|
||||||
|
pub flags: i64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct Streaming {
|
||||||
|
pub account_id: String,
|
||||||
|
pub channel: Value,
|
||||||
|
pub enabled: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct EarningsWallet {
|
||||||
|
pub id: String,
|
||||||
|
pub account_id: String,
|
||||||
|
pub balance: i64,
|
||||||
|
#[serde(rename = "type")]
|
||||||
|
pub type_field: i64,
|
||||||
|
pub wallet_version: i64,
|
||||||
|
pub flags: i64,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct SubscriptionTier {
|
||||||
|
pub id: String,
|
||||||
|
pub account_id: String,
|
||||||
|
pub name: String,
|
||||||
|
pub color: String,
|
||||||
|
pub pos: i64,
|
||||||
|
pub price: i64,
|
||||||
|
pub max_subscribers: i64,
|
||||||
|
pub subscription_benefits: Vec<String>,
|
||||||
|
pub included_tier_ids: Vec<Value>,
|
||||||
|
pub plans: Vec<Plan>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct Plan {
|
||||||
|
pub id: String,
|
||||||
|
pub status: i64,
|
||||||
|
pub billing_cycle: i64,
|
||||||
|
pub price: i64,
|
||||||
|
pub use_amounts: i64,
|
||||||
|
pub promos: Vec<Value>,
|
||||||
|
pub uses: i64,
|
||||||
|
}
|
89
src-tauri/tauri.conf.json
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
{
|
||||||
|
"$schema": "../node_modules/@tauri-apps/cli/schema.json",
|
||||||
|
"build": {
|
||||||
|
"beforeBuildCommand": "npm run build",
|
||||||
|
"beforeDevCommand": "npm run dev",
|
||||||
|
"devPath": "http://localhost:5173",
|
||||||
|
"distDir": "../build"
|
||||||
|
},
|
||||||
|
"package": {
|
||||||
|
"productName": "fanslysync-desktop",
|
||||||
|
"version": "0.1.0"
|
||||||
|
},
|
||||||
|
"tauri": {
|
||||||
|
"allowlist": {
|
||||||
|
"clipboard": {
|
||||||
|
"all": true,
|
||||||
|
"readText": false,
|
||||||
|
"writeText": false
|
||||||
|
},
|
||||||
|
"dialog": {
|
||||||
|
"all": false,
|
||||||
|
"ask": true,
|
||||||
|
"confirm": true,
|
||||||
|
"message": true,
|
||||||
|
"open": false,
|
||||||
|
"save": false
|
||||||
|
},
|
||||||
|
"notification": {
|
||||||
|
"all": true
|
||||||
|
},
|
||||||
|
"os": {
|
||||||
|
"all": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"bundle": {
|
||||||
|
"active": true,
|
||||||
|
"category": "DeveloperTool",
|
||||||
|
"copyright": "",
|
||||||
|
"deb": {
|
||||||
|
"depends": []
|
||||||
|
},
|
||||||
|
"externalBin": [],
|
||||||
|
"icon": [
|
||||||
|
"icons/32x32.png",
|
||||||
|
"icons/128x128.png",
|
||||||
|
"icons/128x128@2x.png",
|
||||||
|
"icons/icon.icns",
|
||||||
|
"icons/icon.ico"
|
||||||
|
],
|
||||||
|
"identifier": "com.fanslycreatorbot.fanslysync",
|
||||||
|
"longDescription": "",
|
||||||
|
"macOS": {
|
||||||
|
"entitlements": null,
|
||||||
|
"exceptionDomain": "",
|
||||||
|
"frameworks": [],
|
||||||
|
"providerShortName": null,
|
||||||
|
"signingIdentity": null
|
||||||
|
},
|
||||||
|
"resources": [],
|
||||||
|
"shortDescription": "",
|
||||||
|
"targets": "all",
|
||||||
|
"windows": {
|
||||||
|
"certificateThumbprint": null,
|
||||||
|
"digestAlgorithm": "sha256",
|
||||||
|
"timestampUrl": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"security": {
|
||||||
|
"csp": null
|
||||||
|
},
|
||||||
|
"updater": {
|
||||||
|
"active": true,
|
||||||
|
"endpoints": [
|
||||||
|
"https://cdn.crabnebula.app/update/fansly-creator-bot/fansly-sync/{{target}}-{{arch}}/{{current_version}}"
|
||||||
|
],
|
||||||
|
"dialog": true,
|
||||||
|
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDJFODZGRDI4NjBFMDQ1RUMKUldUc1JlQmdLUDJHTGdRdSt6dWFISXE0MThsa0tvUDA2RWdMSStjQ0J6NVBhdmU4ajRMMms4a1cK"
|
||||||
|
},
|
||||||
|
"windows": [
|
||||||
|
{
|
||||||
|
"fullscreen": false,
|
||||||
|
"height": 650,
|
||||||
|
"resizable": false,
|
||||||
|
"title": "FanslySync",
|
||||||
|
"width": 600
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
3
src/app.css
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
@tailwind base;
|
||||||
|
@tailwind components;
|
||||||
|
@tailwind utilities;
|
13
src/app.d.ts
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// See https://kit.svelte.dev/docs/types#app
|
||||||
|
// for information about these interfaces
|
||||||
|
declare global {
|
||||||
|
namespace App {
|
||||||
|
// interface Error {}
|
||||||
|
// interface Locals {}
|
||||||
|
// interface PageData {}
|
||||||
|
// interface PageState {}
|
||||||
|
// interface Platform {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export {};
|
12
src/app.html
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
%sveltekit.head%
|
||||||
|
</head>
|
||||||
|
<body data-sveltekit-preload-data="hover">
|
||||||
|
<div style="display: contents">%sveltekit.body%</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
1
src/lib/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
// place files you want to import through the `$lib` alias in this folder.
|
255
src/lib/types.ts
Normal file
@ -0,0 +1,255 @@
|
|||||||
|
export type Config = {
|
||||||
|
version: number;
|
||||||
|
is_first_run: boolean;
|
||||||
|
fansly_token: string;
|
||||||
|
sync_interval: number;
|
||||||
|
last_sync: number;
|
||||||
|
last_sync_data: SyncData;
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface SyncData {
|
||||||
|
followers: Follower[];
|
||||||
|
subscribers: Subscriber[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Subscriber {
|
||||||
|
id: string;
|
||||||
|
historyId: string;
|
||||||
|
subscriberId: string;
|
||||||
|
subscriptionTierId: string;
|
||||||
|
subscriptionTierName: string;
|
||||||
|
subscriptionTierColor: string;
|
||||||
|
planId: string;
|
||||||
|
promoId: null | string;
|
||||||
|
giftCodeId: null | string;
|
||||||
|
paymentMethodId: string;
|
||||||
|
status: number;
|
||||||
|
price: number;
|
||||||
|
renewPrice: number;
|
||||||
|
renewCorrelationId: string;
|
||||||
|
autoRenew: number;
|
||||||
|
billingCycle: number;
|
||||||
|
duration: number;
|
||||||
|
renewDate: number;
|
||||||
|
version: number;
|
||||||
|
createdAt: number;
|
||||||
|
updatedAt: number;
|
||||||
|
endsAt: number;
|
||||||
|
promoPrice: null | number;
|
||||||
|
promoDuration: null | number;
|
||||||
|
promoStatus: null | number;
|
||||||
|
promoStartsAt: null | number;
|
||||||
|
promoEndsAt: null | number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Follower {
|
||||||
|
followerId: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AccountInfoResponse {
|
||||||
|
success: boolean;
|
||||||
|
response: AccountInfo[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AccountInfo {
|
||||||
|
id: string;
|
||||||
|
username: string;
|
||||||
|
displayName: string;
|
||||||
|
flags: number;
|
||||||
|
version: number;
|
||||||
|
createdAt: number;
|
||||||
|
followCount: number;
|
||||||
|
subscriberCount: number;
|
||||||
|
permissions: Permissions;
|
||||||
|
profileAccessFlags: number;
|
||||||
|
profileFlags: number;
|
||||||
|
about: string;
|
||||||
|
location: string;
|
||||||
|
profileSocials: ProfileSocial[];
|
||||||
|
pinnedPosts: PinnedPost[];
|
||||||
|
walls: Wall[];
|
||||||
|
timelineStats: TimelineStats;
|
||||||
|
statusId: number;
|
||||||
|
lastSeenAt: number;
|
||||||
|
mediaStoryState: MediaStoryState;
|
||||||
|
accountMediaLikes: number;
|
||||||
|
avatar: Avatar;
|
||||||
|
banner: Avatar;
|
||||||
|
postLikes: number;
|
||||||
|
streaming: Streaming;
|
||||||
|
subscriptionTiers: SubscriptionTier[];
|
||||||
|
profileAccess: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SubscriptionTier {
|
||||||
|
id: string;
|
||||||
|
accountId: string;
|
||||||
|
name: string;
|
||||||
|
color: string;
|
||||||
|
pos: number;
|
||||||
|
price: number;
|
||||||
|
maxSubscribers: number;
|
||||||
|
subscriptionBenefits: string[];
|
||||||
|
includedTierIds: string[];
|
||||||
|
plans: Plan[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Plan {
|
||||||
|
id: string;
|
||||||
|
status: number;
|
||||||
|
billingCycle: number;
|
||||||
|
price: number;
|
||||||
|
useAmounts: number;
|
||||||
|
promos: Promo[];
|
||||||
|
uses: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Promo {
|
||||||
|
id: string;
|
||||||
|
status: number;
|
||||||
|
price: number;
|
||||||
|
duration: number;
|
||||||
|
maxUses: number;
|
||||||
|
maxUsesBefore?: unknown;
|
||||||
|
newSubscribersOnly: number;
|
||||||
|
startsAt: number;
|
||||||
|
endsAt: number;
|
||||||
|
uses: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Streaming {
|
||||||
|
accountId: string;
|
||||||
|
channel: Channel;
|
||||||
|
enabled: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Channel {
|
||||||
|
id: string;
|
||||||
|
accountId: string;
|
||||||
|
playbackUrl: string;
|
||||||
|
chatRoomId: string;
|
||||||
|
status: number;
|
||||||
|
version: number;
|
||||||
|
createdAt: number;
|
||||||
|
updatedAt?: unknown;
|
||||||
|
stream: Stream;
|
||||||
|
arn?: unknown;
|
||||||
|
ingestEndpoint?: unknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Stream {
|
||||||
|
id: string;
|
||||||
|
historyId: string;
|
||||||
|
channelId: string;
|
||||||
|
accountId: string;
|
||||||
|
title: string;
|
||||||
|
status: number;
|
||||||
|
viewerCount: number;
|
||||||
|
version: number;
|
||||||
|
createdAt: number;
|
||||||
|
updatedAt?: unknown;
|
||||||
|
lastFetchedAt: number;
|
||||||
|
startedAt: number;
|
||||||
|
permissions: Permissions2;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Permissions2 {
|
||||||
|
permissionFlags: PermissionFlag[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface PermissionFlag {
|
||||||
|
id: string;
|
||||||
|
streamId: string;
|
||||||
|
type: number;
|
||||||
|
flags: number;
|
||||||
|
price: number;
|
||||||
|
metadata: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Avatar {
|
||||||
|
id: string;
|
||||||
|
type: number;
|
||||||
|
status: number;
|
||||||
|
accountId: string;
|
||||||
|
mimetype: string;
|
||||||
|
flags: number;
|
||||||
|
location: string;
|
||||||
|
width: number;
|
||||||
|
height: number;
|
||||||
|
metadata: string;
|
||||||
|
updatedAt: number;
|
||||||
|
createdAt: number;
|
||||||
|
variants: Variant[];
|
||||||
|
variantHash: VariantHash;
|
||||||
|
locations: Location[];
|
||||||
|
}
|
||||||
|
|
||||||
|
type VariantHash = unknown;
|
||||||
|
|
||||||
|
interface Variant {
|
||||||
|
id: string;
|
||||||
|
type: number;
|
||||||
|
status: number;
|
||||||
|
mimetype: string;
|
||||||
|
flags: number;
|
||||||
|
location: string;
|
||||||
|
width: number;
|
||||||
|
height: number;
|
||||||
|
metadata: string;
|
||||||
|
updatedAt: number;
|
||||||
|
locations: Location[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Location {
|
||||||
|
locationId: string;
|
||||||
|
location: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MediaStoryState {
|
||||||
|
accountId: string;
|
||||||
|
status: number;
|
||||||
|
storyCount: number;
|
||||||
|
version: number;
|
||||||
|
createdAt: number;
|
||||||
|
updatedAt: number;
|
||||||
|
hasActiveStories: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TimelineStats {
|
||||||
|
accountId: string;
|
||||||
|
imageCount: number;
|
||||||
|
videoCount: number;
|
||||||
|
bundleCount: number;
|
||||||
|
bundleImageCount: number;
|
||||||
|
bundleVideoCount: number;
|
||||||
|
fetchedAt: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Wall {
|
||||||
|
id: string;
|
||||||
|
accountId: string;
|
||||||
|
pos: number;
|
||||||
|
name: string;
|
||||||
|
description: string;
|
||||||
|
metadata: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface PinnedPost {
|
||||||
|
postId: string;
|
||||||
|
accountId: string;
|
||||||
|
pos: number;
|
||||||
|
createdAt: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ProfileSocial {
|
||||||
|
providerId: string;
|
||||||
|
handle: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Permissions {
|
||||||
|
accountPermissionFlags: AccountPermissionFlags;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface AccountPermissionFlags {
|
||||||
|
flags: number;
|
||||||
|
}
|
9
src/lib/utils.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
export const awaiter = async <T>(promise: Promise<T>): Promise<[T | null, any | null]> => {
|
||||||
|
try {
|
||||||
|
const data: T = await promise;
|
||||||
|
return [data, null];
|
||||||
|
} catch (err) {
|
||||||
|
return [null, err];
|
||||||
|
}
|
||||||
|
};
|
5
src/routes/+layout.svelte
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<script>
|
||||||
|
import '../app.css';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<slot />
|
2
src/routes/+layout.ts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export const prerender = true;
|
||||||
|
export const ssr = false;
|
98
src/routes/+page.svelte
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
let status = 'Initializing...';
|
||||||
|
import { invoke } from '@tauri-apps/api/tauri';
|
||||||
|
import { dialog, clipboard } from '@tauri-apps/api';
|
||||||
|
import { awaiter } from '$lib/utils';
|
||||||
|
import { onMount } from 'svelte';
|
||||||
|
import type { Config } from '$lib/types';
|
||||||
|
import { isPermissionGranted, requestPermission } from '@tauri-apps/api/notification';
|
||||||
|
|
||||||
|
onMount(async () => {
|
||||||
|
const [_, configInitError] = await awaiter(invoke('init_config'));
|
||||||
|
|
||||||
|
if (configInitError) {
|
||||||
|
status = 'Failed to initialize configuration';
|
||||||
|
await dialog.message(
|
||||||
|
`Something went wrong while initializing the configuration. We've copied the error to your clipboard. Please contact us.\n\nError: ${configInitError}\n\nThe application will now close.`,
|
||||||
|
{ title: 'FanslySync | Initialization Error', type: 'error' }
|
||||||
|
);
|
||||||
|
|
||||||
|
await clipboard.writeText(configInitError);
|
||||||
|
invoke('quit', { code: 1 });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const [config, configError] = await awaiter(invoke('get_config') as Promise<Config>);
|
||||||
|
|
||||||
|
if (configError || !config || config === null) {
|
||||||
|
status = 'Failed to get configuration';
|
||||||
|
await dialog.message(
|
||||||
|
`Something went wrong while getting the configuration. We've copied the error to your clipboard. Please contact us.\n\nError: ${configError ?? 'Config was null'}\n\nThe application will now close.`,
|
||||||
|
{ title: 'FanslySync | Configuration Error', type: 'error' }
|
||||||
|
);
|
||||||
|
|
||||||
|
await clipboard.writeText(configError);
|
||||||
|
invoke('quit', { code: 1 });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const permissionGranted = await isPermissionGranted();
|
||||||
|
if (!permissionGranted) {
|
||||||
|
let result = await requestPermission();
|
||||||
|
if (result !== 'granted') {
|
||||||
|
status = 'Notification permission denied';
|
||||||
|
await dialog.message(
|
||||||
|
`FanslySync requires notification permissions to function properly. Please enable notifications and restart the application.`,
|
||||||
|
{ title: 'FanslySync | Notification Permission Error', type: 'error' }
|
||||||
|
);
|
||||||
|
|
||||||
|
invoke('quit', { code: 1 });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
status = 'Initialization complete!';
|
||||||
|
// Wait 1000ms before redirecting to /setup or /home
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||||
|
|
||||||
|
if (config.is_first_run) {
|
||||||
|
// Navigate to /setup
|
||||||
|
window.location.href = '/setup';
|
||||||
|
} else {
|
||||||
|
// todo: set jwt for future requests
|
||||||
|
await invoke('fansly_set_token', { token: config.fansly_token });
|
||||||
|
window.location.href = '/home';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="container bg-zinc-800 w-screen h-screen">
|
||||||
|
<!-- Centered loading spinner -->
|
||||||
|
<div class="flex flex-col justify-center items-center h-screen">
|
||||||
|
<img src="/fanslySync.png" alt="FanslySync Logo" class="w-24 h-24" />
|
||||||
|
<h1 class="text-2xl font-bold mt-2 text-white">FanslySync</h1>
|
||||||
|
<p class="text-gray-400 mb-3">
|
||||||
|
{status}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div role="status">
|
||||||
|
<svg
|
||||||
|
aria-hidden="true"
|
||||||
|
class="w-14 h-14 text-gray-200 animate-spin dark:text-gray-600 fill-[#209CEE]"
|
||||||
|
viewBox="0 0 100 101"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
|
||||||
|
fill="currentColor"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
|
||||||
|
fill="currentFill"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
<span class="sr-only">Loading...</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
299
src/routes/home/+page.svelte
Normal file
@ -0,0 +1,299 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { invoke } from '@tauri-apps/api/tauri';
|
||||||
|
import { awaiter } from '$lib/utils';
|
||||||
|
import { onMount } from 'svelte';
|
||||||
|
import type { Config, SyncData } from '$lib/types';
|
||||||
|
import { clipboard, dialog } from '@tauri-apps/api';
|
||||||
|
import { slide } from 'svelte/transition';
|
||||||
|
import { sendNotification } from '@tauri-apps/api/notification';
|
||||||
|
import { platform } from '@tauri-apps/api/os';
|
||||||
|
|
||||||
|
let loadingSync = true;
|
||||||
|
let syncing = false;
|
||||||
|
let syncState = {
|
||||||
|
show: false,
|
||||||
|
syncing: false,
|
||||||
|
error: false,
|
||||||
|
success: false,
|
||||||
|
message: ''
|
||||||
|
};
|
||||||
|
|
||||||
|
let config: Config | null = null;
|
||||||
|
|
||||||
|
onMount(async () => {
|
||||||
|
const [configData, configError] = await awaiter(invoke('get_config') as Promise<Config>);
|
||||||
|
|
||||||
|
if (configError || !configData) {
|
||||||
|
await dialog.message(
|
||||||
|
`Something went wrong while getting the configuration. We've copied the error to your clipboard. Please report this issue on GitHub.\n\nError: ${configError ?? 'Config was null'}\n\nThe application will now close.`,
|
||||||
|
{ title: 'FanslySync | Configuration Error', type: 'error' }
|
||||||
|
);
|
||||||
|
|
||||||
|
await clipboard.writeText(configError);
|
||||||
|
invoke('quit', { code: 1 });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
config = configData;
|
||||||
|
loadingSync = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
async function syncNow() {
|
||||||
|
syncState.error = false;
|
||||||
|
syncState.success = false;
|
||||||
|
syncState.syncing = true;
|
||||||
|
syncState.show = true;
|
||||||
|
|
||||||
|
const [syncData, syncError] = await awaiter(invoke('fansly_sync') as Promise<SyncData>);
|
||||||
|
console.log(syncData, syncError);
|
||||||
|
|
||||||
|
if (syncError || syncData === null) {
|
||||||
|
syncState.syncing = false;
|
||||||
|
syncState.error = true;
|
||||||
|
syncState.message = syncError ?? 'Sync data was null';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the last sync as unix timestamp
|
||||||
|
config!.last_sync = Date.now();
|
||||||
|
config!.last_sync_data = syncData!;
|
||||||
|
|
||||||
|
const [saveConfigData, saveConfigError] = await awaiter(
|
||||||
|
invoke('save_config', { config }) as Promise<boolean>
|
||||||
|
);
|
||||||
|
if (saveConfigError) {
|
||||||
|
syncState.syncing = false;
|
||||||
|
syncState.error = true;
|
||||||
|
syncState.message = saveConfigError ?? 'Save config data was null';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
syncState.syncing = false;
|
||||||
|
syncState.success = true;
|
||||||
|
|
||||||
|
const platformName = await platform();
|
||||||
|
let soundName;
|
||||||
|
|
||||||
|
if (platformName === 'win32') {
|
||||||
|
soundName = 'ms-winsoundevent:Notification.Default';
|
||||||
|
} else if (platformName === 'darwin') {
|
||||||
|
soundName = 'Ping';
|
||||||
|
} else {
|
||||||
|
soundName = 'completion-sucess';
|
||||||
|
}
|
||||||
|
|
||||||
|
await sendNotification({
|
||||||
|
title: 'FanslySync: Sync Successful!',
|
||||||
|
body: 'Data synced successfully. Please look at the app for more details.',
|
||||||
|
sound: soundName
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="container bg-zinc-800 w-screen h-screen">
|
||||||
|
<!-- Top header, Bambu Connect at the left side, settings icon on the right -->
|
||||||
|
<div class="flex justify-between items-center h-16 px-4 bg-zinc-900">
|
||||||
|
<div class="flex items-center">
|
||||||
|
<img src="/fanslySync.png" alt="FanslySynct" class="w-8 h-8" />
|
||||||
|
<h1 class="text-2xl font-bold text-gray-200 ml-2">FanslySync</h1>
|
||||||
|
<span class="text-gray-400 ml-2">v0.1.0</span>
|
||||||
|
</div>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
fill="none"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke="currentColor"
|
||||||
|
class="w-6 h-6 text-white hidden"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
d="M9.594 3.94c.09-.542.56-.94 1.11-.94h2.593c.55 0 1.02.398 1.11.94l.213 1.281c.063.374.313.686.645.87.074.04.147.083.22.127.325.196.72.257 1.075.124l1.217-.456a1.125 1.125 0 0 1 1.37.49l1.296 2.247a1.125 1.125 0 0 1-.26 1.431l-1.003.827c-.293.241-.438.613-.43.992a7.723 7.723 0 0 1 0 .255c-.008.378.137.75.43.991l1.004.827c.424.35.534.955.26 1.43l-1.298 2.247a1.125 1.125 0 0 1-1.369.491l-1.217-.456c-.355-.133-.75-.072-1.076.124a6.47 6.47 0 0 1-.22.128c-.331.183-.581.495-.644.869l-.213 1.281c-.09.543-.56.94-1.11.94h-2.594c-.55 0-1.019-.398-1.11-.94l-.213-1.281c-.062-.374-.312-.686-.644-.87a6.52 6.52 0 0 1-.22-.127c-.325-.196-.72-.257-1.076-.124l-1.217.456a1.125 1.125 0 0 1-1.369-.49l-1.297-2.247a1.125 1.125 0 0 1 .26-1.431l1.004-.827c.292-.24.437-.613.43-.991a6.932 6.932 0 0 1 0-.255c.007-.38-.138-.751-.43-.992l-1.004-.827a1.125 1.125 0 0 1-.26-1.43l1.297-2.247a1.125 1.125 0 0 1 1.37-.491l1.216.456c.356.133.751.072 1.076-.124.072-.044.146-.086.22-.128.332-.183.582-.495.644-.869l.214-1.28Z"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Sync container -->
|
||||||
|
<div class="flex flex-col mt-4 px-3">
|
||||||
|
<h2 class="text-2xl font-bold text-gray-200">Sync</h2>
|
||||||
|
<p class="text-gray-400 mt-1">Manage automatic sync options and manual sync here.</p>
|
||||||
|
<div class="flex flex-wrap mt-2 rounded-lg">
|
||||||
|
{#if loadingSync}
|
||||||
|
<div class="flex flex-col items-center justify-center">
|
||||||
|
<div role="status" class="mb-2">
|
||||||
|
<svg
|
||||||
|
aria-hidden="true"
|
||||||
|
class="w-14 h-14 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600"
|
||||||
|
viewBox="0 0 100 101"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
|
||||||
|
fill="currentColor"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
|
||||||
|
fill="currentFill"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
<span class="sr-only">Loading...</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p class="text-gray-400 animate-pulse">Loading sync options, one moment...</p>
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
|
<div class="flex flex-col gap-y-2 justify-start">
|
||||||
|
<!-- Automatic sync card -->
|
||||||
|
<div class="relative">
|
||||||
|
<div class="bg-zinc-700 p-4 rounded-lg">
|
||||||
|
<h1 class="text-xl font-bold text-gray-200">Automatic Sync</h1>
|
||||||
|
<p class="text-gray-400 mt-1">
|
||||||
|
Sync content automatically every {config?.sync_interval} hours. Please ensure you have
|
||||||
|
a stable internet connection.
|
||||||
|
</p>
|
||||||
|
<div class="flex mt-2">
|
||||||
|
<button
|
||||||
|
class="bg-blue-600 text-white px-4 py-2 rounded-lg w-full"
|
||||||
|
on:click={() => console.log('Automatic sync clicked')}
|
||||||
|
>
|
||||||
|
Enable
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="absolute top-0 left-0 right-0 bottom-0 bg-white/30 backdrop-blur-sm flex flex-col justify-center items-center rounded-lg"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
fill="none"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke="currentColor"
|
||||||
|
class="size-10 text-blue-400"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
d="m11.25 11.25.041-.02a.75.75 0 0 1 1.063.852l-.708 2.836a.75.75 0 0 0 1.063.853l.041-.021M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9-3.75h.008v.008H12V8.25Z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
<h1 class="text-xl font-bold text-gray-200 ml-2">Automatic Sync is coming soon!</h1>
|
||||||
|
<p class="text-white mt-1">Stay tuned for updates.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Manual sync card -->
|
||||||
|
<div class=" bg-zinc-700 p-4 rounded-lg">
|
||||||
|
<h1 class="text-xl font-bold text-gray-200">Manual Sync</h1>
|
||||||
|
<p class="text-gray-400 mt-1">
|
||||||
|
Trigger a manual sync now, instead of waiting for an automatic sync.
|
||||||
|
</p>
|
||||||
|
<div class="flex mt-2">
|
||||||
|
<button
|
||||||
|
class="bg-blue-600 text-white px-4 py-2 rounded-lg w-full disabled:opacity-50 disabled:cursor-not-allowed hover:bg-blue-700 transition-all duration-200 ease-in-out"
|
||||||
|
on:click={syncNow}
|
||||||
|
disabled={syncState.syncing}
|
||||||
|
>
|
||||||
|
{syncState.syncing ? 'Syncing...' : 'Sync Now'}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Create a Little bar that animates up when a sync is running -->
|
||||||
|
{#if syncState.show}
|
||||||
|
<div
|
||||||
|
class={`fixed bottom-0 left-0 right-0 text-white p-4
|
||||||
|
${syncState.syncing ? 'bg-blue-500' : syncState.success ? 'bg-green-500' : 'bg-red-500'}
|
||||||
|
|
||||||
|
`}
|
||||||
|
transition:slide={{ duration: 500 }}
|
||||||
|
>
|
||||||
|
<div class="flex items-center">
|
||||||
|
{#if !syncState.success && !syncState.error}
|
||||||
|
<!-- Add loading spinner -->
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
fill="none"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke="currentColor"
|
||||||
|
class="size-6 mr-2 animate-spin"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0 3.181 3.183a8.25 8.25 0 0 0 13.803-3.7M4.031 9.865a8.25 8.25 0 0 1 13.803-3.7l3.181 3.182m0-4.991v4.99"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
<!-- Add Syncing title and status subtitle below it -->
|
||||||
|
<div class="flex flex-col">
|
||||||
|
<h1 class="text-lg font-bold">Syncing...</h1>
|
||||||
|
<p class="text-sm">
|
||||||
|
Please wait while we sync your followers and subscriber data. This can take awhile on
|
||||||
|
some connections.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
{:else if syncState.success}
|
||||||
|
<!-- Add Success title and status subtitle below it -->
|
||||||
|
<div class="flex flex-col">
|
||||||
|
<h1 class="text-lg font-bold">Sync Successful!</h1>
|
||||||
|
<p class="text-sm">
|
||||||
|
Data synced successfully. Please run the import with the following link {syncState.message}
|
||||||
|
to import the data.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Add copy and close button -->
|
||||||
|
<div class="flex items-center ml-auto">
|
||||||
|
<button
|
||||||
|
class="bg-white text-blue-600 px-2 py-1 rounded-lg"
|
||||||
|
on:click={() => {
|
||||||
|
clipboard.writeText(syncState.message);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Copy
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
class="bg-white text-blue-600 px-2 py-1 rounded-lg ml-2"
|
||||||
|
on:click={() => {
|
||||||
|
syncState.show = false;
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Close
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
|
<!-- Add Error title and status subtitle below it -->
|
||||||
|
<div class="flex flex-col">
|
||||||
|
<h1 class="text-lg font-bold">Sync Failed!</h1>
|
||||||
|
<p class="text-sm">
|
||||||
|
An error occurred while syncing your data. Details: {syncState.message}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Add close button -->
|
||||||
|
<button
|
||||||
|
class="bg-white text-blue-600 px-2 py-1 rounded-lg ml-auto"
|
||||||
|
on:click={() => {
|
||||||
|
syncState.show = false;
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Close
|
||||||
|
</button>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</div>
|
266
src/routes/setup/+page.svelte
Normal file
@ -0,0 +1,266 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
let loading = true;
|
||||||
|
let errored = false;
|
||||||
|
let step = 0;
|
||||||
|
let status = 'Contacting Fansly and checking account...';
|
||||||
|
|
||||||
|
let fanslyToken = '';
|
||||||
|
let validationErrors = {
|
||||||
|
fanslyToken: ''
|
||||||
|
};
|
||||||
|
|
||||||
|
import { invoke } from '@tauri-apps/api/tauri';
|
||||||
|
import { dialog, clipboard } from '@tauri-apps/api';
|
||||||
|
import { awaiter } from '$lib/utils';
|
||||||
|
import { onMount } from 'svelte';
|
||||||
|
import type { AccountInfo, Config } from '$lib/types';
|
||||||
|
import NoWorkResult from 'postcss/lib/no-work-result';
|
||||||
|
|
||||||
|
onMount(async () => {
|
||||||
|
const [config, configError] = await awaiter(invoke('get_config'));
|
||||||
|
|
||||||
|
if (configError) {
|
||||||
|
await dialog.message(
|
||||||
|
`Something went wrong while getting the configuration. We've copied the error to your clipboard. Please report this issue on GitHub.\n\nError: ${configError}\n\nThe application will now close.`,
|
||||||
|
{ title: 'BambuConnect | Configuration Error', type: 'error' }
|
||||||
|
);
|
||||||
|
|
||||||
|
await clipboard.writeText(configError);
|
||||||
|
invoke('quit', { code: 1 });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
loading = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
async function loginToFanslyAndFetchData() {
|
||||||
|
const [config, configError] = (await awaiter(invoke('get_config'))) as [Config, any | null];
|
||||||
|
|
||||||
|
if (configError) {
|
||||||
|
await dialog.message(
|
||||||
|
`Something went wrong while getting the configuration. We've copied the error to your clipboard. Please report this issue on GitHub.\n\nError: ${configError}\n\nThe application will now close.`,
|
||||||
|
{ title: 'BambuConnect | Configuration Error', type: 'error' }
|
||||||
|
);
|
||||||
|
|
||||||
|
await clipboard.writeText(configError);
|
||||||
|
invoke('quit', { code: 1 });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await invoke('fansly_set_token', { token: fanslyToken });
|
||||||
|
const [me, error] = (await awaiter(invoke('fansly_get_me'))) as [
|
||||||
|
{
|
||||||
|
success: boolean;
|
||||||
|
response: AccountInfo;
|
||||||
|
},
|
||||||
|
any | null
|
||||||
|
];
|
||||||
|
|
||||||
|
if (me === null) {
|
||||||
|
console.error(`Failed to authenticate with Fansly. Error: ${error}`);
|
||||||
|
step = 1;
|
||||||
|
validationErrors.fanslyToken =
|
||||||
|
'We could not authenticate with Fansly. Please check your token and try again.';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!me.success) {
|
||||||
|
console.error(`Failed to authenticate with Fansly. Error: ${me.response}`);
|
||||||
|
step = 1;
|
||||||
|
validationErrors.fanslyToken =
|
||||||
|
'We could not authenticate with Fansly. Please check your token and try again.';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
status = 'Finishing up...';
|
||||||
|
|
||||||
|
console.log('fanslyToken', fanslyToken);
|
||||||
|
config.fansly_token = fanslyToken;
|
||||||
|
config.is_first_run = false;
|
||||||
|
await invoke('save_config', { config });
|
||||||
|
step = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateLoginForm() {
|
||||||
|
let hasErrors = false;
|
||||||
|
|
||||||
|
if (fanslyToken === '') {
|
||||||
|
validationErrors.fanslyToken = 'Please enter your Fansly token.';
|
||||||
|
hasErrors = true;
|
||||||
|
} else {
|
||||||
|
validationErrors.fanslyToken = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasErrors) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
step = 2;
|
||||||
|
loginToFanslyAndFetchData();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="container bg-zinc-800 w-screen h-screen">
|
||||||
|
<!-- Centered loading spinner -->
|
||||||
|
<div class="flex flex-col justify-center items-center h-screen">
|
||||||
|
{#if loading}
|
||||||
|
<div role="status">
|
||||||
|
<svg
|
||||||
|
aria-hidden="true"
|
||||||
|
class="w-14 h-14 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600"
|
||||||
|
viewBox="0 0 100 101"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
|
||||||
|
fill="currentColor"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
|
||||||
|
fill="currentFill"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
<span class="sr-only">Loading...</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h1 class="text-2xl font-bold mt-2 text-white">Setup is loading...</h1>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if errored}
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
fill="none"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke="currentColor"
|
||||||
|
class="w-12 h-12 text-red-500 dark:text-red-400"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
d="M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126ZM12 15.75h.007v.008H12v-.008Z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
<h1 class="text-2xl font-bold mt-2 text-white">Oops!</h1>
|
||||||
|
<p class="text-red-500 mt-2 max-w-[30em]">
|
||||||
|
An error was encountered while initializing the setup, please try closing and reopening
|
||||||
|
FanslySync.
|
||||||
|
</p>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if !loading && !errored}
|
||||||
|
{#if step === 0}
|
||||||
|
<h1 class="text-2xl font-bold mt-2 text-white">Welcome to FanslySync!</h1>
|
||||||
|
<p class="text-gray-200 break-words max-w-[30em]">
|
||||||
|
Because this is your first time running FanslySync, we need to set up the connection to
|
||||||
|
your Fansly account. Click the button below to get started.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
{#if errored}
|
||||||
|
<p class="text-red-500 mt-2">
|
||||||
|
An error occurred while initializing the setup. Please try again.
|
||||||
|
</p>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if !loading}
|
||||||
|
<button
|
||||||
|
on:click={() => {
|
||||||
|
step = 1;
|
||||||
|
}}
|
||||||
|
class="mt-4 bg-blue-600 text-white px-4 py-2 rounded-md hover:bg-blue-700 transition-all duration-200 ease-in-out"
|
||||||
|
>
|
||||||
|
Begin Setup
|
||||||
|
</button>
|
||||||
|
{/if}
|
||||||
|
{:else if step === 1}
|
||||||
|
<h1 class="text-2xl font-bold mt-2 text-white">Authenticate with Fansly</h1>
|
||||||
|
<p class="text-gray-200 break-words max-w-[30em]">
|
||||||
|
To establish a secure connection with Fansly, we require your Fansly Authentication Token.
|
||||||
|
We do not transmit this token to our servers and it is only used to authenticate with
|
||||||
|
Fansly and fetch data locally. <br /> <br />
|
||||||
|
For more information on how to get your Fansly Authentication Token, please visit our documentation,
|
||||||
|
or join our Discord server if you need help or have any questions.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<label for="username" class="text-gray-200 mt-4"> Fansly Authentication Token </label>
|
||||||
|
<input
|
||||||
|
id="fanslyToken"
|
||||||
|
class="w-full bg-zinc-700 text-gray-200 px-4 py-2 rounded-md mt-2 max-w-96"
|
||||||
|
type="text"
|
||||||
|
autocomplete="current-password"
|
||||||
|
bind:value={fanslyToken}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{#if validationErrors.fanslyToken !== ''}
|
||||||
|
<p class="text-red-500 mt-2">{validationErrors.fanslyToken}</p>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if !loading}
|
||||||
|
<button
|
||||||
|
on:click={validateLoginForm}
|
||||||
|
class="mt-4 bg-blue-600 text-white px-4 py-2 rounded-md hover:bg-blue-700 transition-all duration-200 ease-in-out"
|
||||||
|
>
|
||||||
|
Authenticate and setup connection
|
||||||
|
</button>
|
||||||
|
{/if}
|
||||||
|
{:else if step == 2}
|
||||||
|
<div role="status">
|
||||||
|
<svg
|
||||||
|
aria-hidden="true"
|
||||||
|
class="w-14 h-14 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600"
|
||||||
|
viewBox="0 0 100 101"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
|
||||||
|
fill="currentColor"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
|
||||||
|
fill="currentFill"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
<span class="sr-only">Loading...</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h1 class="text-2xl font-bold mt-2 text-white">We are working our magic!</h1>
|
||||||
|
<p class="text-gray-200 break-words max-w-[30em]">
|
||||||
|
We are now authenticating with Fansly and fetching your data. This may take a few moments.
|
||||||
|
</p>
|
||||||
|
<p class="text-gray-200 break-words max-w-[30em]">
|
||||||
|
{status}
|
||||||
|
</p>
|
||||||
|
{:else if step === 3}
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
fill="none"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke="currentColor"
|
||||||
|
class="w-12 h-12 text-green-500 dark:text-green-400"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
d="M9 12.75 11.25 15 15 9.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
<h1 class="text-2xl font-bold mt-2 text-white">Setup Complete!</h1>
|
||||||
|
<p class="text-gray-200 break-words max-w-[30em]">
|
||||||
|
You're all set! FanslySync is now connected to your Fansly account and is ready to use.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<button
|
||||||
|
on:click={() => {
|
||||||
|
window.location.href = '/home';
|
||||||
|
}}
|
||||||
|
class="mt-4 bg-blue-600 text-white px-4 py-2 rounded-md hover:bg-blue-700 transition-all duration-200 ease-in-out"
|
||||||
|
>
|
||||||
|
Finish
|
||||||
|
</button>
|
||||||
|
{/if}
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</div>
|
BIN
static/fanslySync.png
Normal file
After Width: | Height: | Size: 19 KiB |
18
svelte.config.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import adapter from '@sveltejs/adapter-static';
|
||||||
|
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
||||||
|
|
||||||
|
/** @type {import('@sveltejs/kit').Config} */
|
||||||
|
const config = {
|
||||||
|
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
|
||||||
|
// for more information about preprocessors
|
||||||
|
preprocess: vitePreprocess(),
|
||||||
|
|
||||||
|
kit: {
|
||||||
|
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
|
||||||
|
// If your environment is not supported, or you settled on a specific environment, switch out the adapter.
|
||||||
|
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
|
||||||
|
adapter: adapter()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default config;
|
8
tailwind.config.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/** @type {import('tailwindcss').Config} */
|
||||||
|
export default {
|
||||||
|
content: ['./src/**/*.{html,js,svelte,ts}'],
|
||||||
|
theme: {
|
||||||
|
extend: {}
|
||||||
|
},
|
||||||
|
plugins: []
|
||||||
|
};
|
19
tsconfig.json
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"extends": "./.svelte-kit/tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"allowJs": true,
|
||||||
|
"checkJs": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"sourceMap": true,
|
||||||
|
"strict": true,
|
||||||
|
"moduleResolution": "bundler"
|
||||||
|
}
|
||||||
|
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
|
||||||
|
// except $lib which is handled by https://kit.svelte.dev/docs/configuration#files
|
||||||
|
//
|
||||||
|
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
|
||||||
|
// from the referenced tsconfig.json - TypeScript does not merge them in
|
||||||
|
}
|
6
vite.config.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import { sveltekit } from '@sveltejs/kit/vite';
|
||||||
|
import { defineConfig } from 'vite';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [sveltekit()]
|
||||||
|
});
|