mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-12 23:24:35 +01:00
default install path in appdata
This commit is contained in:
@@ -4,10 +4,11 @@ import Tr from '../../../utils/language'
|
|||||||
import DownloadHandler from '../../../utils/download'
|
import DownloadHandler from '../../../utils/download'
|
||||||
import { unzip } from '../../../utils/zip_utils'
|
import { unzip } from '../../../utils/zip_utils'
|
||||||
import BigButton from '../common/BigButton'
|
import BigButton from '../common/BigButton'
|
||||||
|
import { dataDir } from '@tauri-apps/api/path'
|
||||||
|
|
||||||
import './Downloads.css'
|
import './Downloads.css'
|
||||||
import Divider from './Divider'
|
import Divider from './Divider'
|
||||||
import { getConfigOption } from '../../../utils/configuration'
|
import { getConfigOption, setConfigOption } from '../../../utils/configuration'
|
||||||
import { invoke } from '@tauri-apps/api'
|
import { invoke } from '@tauri-apps/api'
|
||||||
|
|
||||||
const STABLE_REPO_DOWNLOAD = 'https://github.com/Grasscutters/Grasscutter/archive/refs/heads/stable.zip'
|
const STABLE_REPO_DOWNLOAD = 'https://github.com/Grasscutters/Grasscutter/archive/refs/heads/stable.zip'
|
||||||
@@ -52,6 +53,16 @@ export default class Downloads extends React.Component<IProps, IState> {
|
|||||||
|
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
const gc_path = await getConfigOption('grasscutter_path')
|
const gc_path = await getConfigOption('grasscutter_path')
|
||||||
|
|
||||||
|
if (!gc_path || gc_path === '') {
|
||||||
|
this.setState({
|
||||||
|
grasscutter_set: false,
|
||||||
|
resources_exist: false
|
||||||
|
})
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const path = gc_path.substring(0, gc_path.lastIndexOf('\\'))
|
const path = gc_path.substring(0, gc_path.lastIndexOf('\\'))
|
||||||
|
|
||||||
if (gc_path) {
|
if (gc_path) {
|
||||||
@@ -70,6 +81,15 @@ export default class Downloads extends React.Component<IProps, IState> {
|
|||||||
const path = await getConfigOption('grasscutter_path')
|
const path = await getConfigOption('grasscutter_path')
|
||||||
let folderPath
|
let folderPath
|
||||||
|
|
||||||
|
// Set to default if not set
|
||||||
|
if (!path || path === '') {
|
||||||
|
const appdata = await dataDir()
|
||||||
|
folderPath = appdata + 'cultivation\\grasscutter'
|
||||||
|
|
||||||
|
// Early return since its formatted properly
|
||||||
|
return folderPath
|
||||||
|
}
|
||||||
|
|
||||||
if (path.includes('/')) {
|
if (path.includes('/')) {
|
||||||
folderPath = path.substring(0, path.lastIndexOf('/'))
|
folderPath = path.substring(0, path.lastIndexOf('/'))
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -87,6 +87,15 @@ async function readConfigFile() {
|
|||||||
await fs.createDir(local + 'cultivation')
|
await fs.createDir(local + 'cultivation')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const innerDirs = await fs.readDir(local + '\\cultivation')
|
||||||
|
|
||||||
|
// Create grasscutter dir for potential installation
|
||||||
|
if (!innerDirs.find((fileOrDir) => fileOrDir?.name === 'grasscutter')) {
|
||||||
|
// Create dir
|
||||||
|
await fs.createDir(local + 'cultivation\\grasscutter')
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const dataFiles = await fs.readDir(local + 'cultivation')
|
const dataFiles = await fs.readDir(local + 'cultivation')
|
||||||
|
|
||||||
// Ensure config exists
|
// Ensure config exists
|
||||||
|
|||||||
Reference in New Issue
Block a user