Skip to content

Commit

Permalink
add config
Browse files Browse the repository at this point in the history
  • Loading branch information
Sjj1024 committed Sep 27, 2024
1 parent f9140c6 commit 40539ac
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"removeFile": true,
"renameFile": true,
"exists": true,
"scope": ["$RESOURCE/*"]
"scope": ["$CACHE/*"]
},
"http": {
"all": true,
Expand All @@ -43,7 +43,7 @@
"protocol": {
"all": true,
"asset": true,
"assetScope": ["$RESOURCE/*"]
"assetScope": ["$CACHE/*"]
},
"shell": {
"all": false,
Expand Down
36 changes: 25 additions & 11 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
<script setup lang="ts">
import { onMounted } from 'vue'
import { cacheDir, join } from '@tauri-apps/api/path'
import { exists, BaseDirectory } from '@tauri-apps/api/fs'
const userLanguage = navigator.language
console.log('System language:', userLanguage)
let theme = localStorage.getItem('theme') || 'dark'
if (theme !== 'dark') {
document.documentElement.setAttribute('theme', 'light')
document.querySelector('html')?.classList.remove('dark')
document.querySelector('html')?.classList.add('light')
// userStore.setTheme('light')
} else {
document.documentElement.setAttribute('theme', 'dark')
document.querySelector('html')?.classList.remove('light')
document.querySelector('html')?.classList.add('dark')
// userStore.setTheme('dark')
const initEnv = async () => {
// checkout appdata dir exists
const dataDir = await cacheDir()
const existRes = await exists(dataDir)
console.log('App data dir exists:', existRes)
}
onMounted(() => {
// initEnv()
let theme = localStorage.getItem('theme') || 'dark'
if (theme !== 'dark') {
document.documentElement.setAttribute('theme', 'light')
document.querySelector('html')?.classList.remove('dark')
document.querySelector('html')?.classList.add('light')
// userStore.setTheme('light')
} else {
document.documentElement.setAttribute('theme', 'dark')
document.querySelector('html')?.classList.remove('light')
document.querySelector('html')?.classList.add('dark')
// userStore.setTheme('dark')
}
})
</script>

<template>
Expand Down
9 changes: 5 additions & 4 deletions src/pages/edit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,9 @@ import type { ComponentSize, FormInstance, FormRules } from 'element-plus'
import githubApi from '@/apis/github'
import { ElMessage, ElMessageBox } from 'element-plus'
import { usePakeStore } from '@/store'
import { writeBinaryFile, BaseDirectory } from '@tauri-apps/api/fs'
import { resourceDir, join } from '@tauri-apps/api/path'
import { writeBinaryFile, BaseDirectory, exists } from '@tauri-apps/api/fs'
import { cacheDir, join } from '@tauri-apps/api/path'
import { convertFileSrc } from '@tauri-apps/api/tauri'
import { open } from '@tauri-apps/api/dialog'
import { ArrowLeft } from '@element-plus/icons-vue'
const router = useRouter()
Expand Down Expand Up @@ -316,8 +315,10 @@ const saveImage = async (fileName: string, base64: string) => {
// save file
const imageData = new Uint8Array(imageArrayBuffer)
// 获取应用数据目录
const appDataPath = await resourceDir()
const appDataPath = await cacheDir()
console.log('appDataPath------', appDataPath)
// const pathExist = await exists(appDataPath)
// console.log('pathExist---', pathExist)
// 拼接文件保存路径
const savePath = `${appDataPath}${fileName}`
// 将图片保存到应用数据目录
Expand Down

0 comments on commit 40539ac

Please sign in to comment.