Skip to content

Commit

Permalink
Merge pull request #38 from Enraged-Dun-Cookie-Development-Team/master
Browse files Browse the repository at this point in the history
发布1.0.1
  • Loading branch information
phidiaLam authored Oct 6, 2023
2 parents 5c4810c + 273fa43 commit 0b2ea48
Show file tree
Hide file tree
Showing 5 changed files with 239 additions and 246 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.

6 changes: 5 additions & 1 deletion src/api/operations/updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class Updater {
}
}
}

export enum VersionStateType {
Newest = "Newest",
UpdateAvailable = "UpdateAvailable",
Unknown = "Unknown",
}
const updater = new Updater();
export default updater;
221 changes: 111 additions & 110 deletions src/components/AppTop.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div
class="app-top d-flex justify-space-between align-center w-100 pa-2"
data-tauri-drag-region
class="app-top d-flex justify-space-between align-center w-100 pa-2"
data-tauri-drag-region
>
<div class="h-100 d-flex align-center">
<v-img src="icon.png" width="40"></v-img>
Expand All @@ -10,63 +10,63 @@

<div class="h-100 no-drag">
<v-menu
v-model="search.show"
:close-on-content-click="false"
location="bottom"
transition="slide-y-transition"
v-model="search.show"
:close-on-content-click="false"
location="bottom"
transition="slide-y-transition"
>
<template #activator="{ props }">
<v-btn
icon="fas fa-magnifying-glass"
v-bind="props"
variant="text"
icon="fas fa-magnifying-glass"
v-bind="props"
variant="text"
></v-btn>
</template>
<v-card class="mx-auto" color="grey-lighten-3" min-width="400">
<v-text-field
color="grey-lighten-1"
v-model="search.searchWord"
append-inner-icon="fa fa-magnifying-glass"
autofocus
class="pa-2"
v-model="search.searchWord"
append-inner-icon="fa fa-magnifying-glass"
autofocus
clearable
density="compact"
hide-details
label="查找饼仓"
variant="outlined"
@click:append-inner="search.searching"
@update:model-value="search.searchChange"
clearable
color="grey-lighten-1"
density="compact"
hide-details
label="查找饼仓"
variant="outlined"
@click:append-inner="search.searching"
@update:model-value="search.searchChange"
></v-text-field>
</v-card>
</v-menu>
<span v-if="search.wordShow !== ''">{{ search.wordShow }}</span>
<v-menu
v-model="menuShow.show"
:close-on-content-click="false"
location="right"
transition="slide-y-transition"
v-model="menuShow.show"
:close-on-content-click="false"
location="right"
transition="slide-y-transition"
>
<template #activator="{ props }">
<v-btn
icon="fa fa-filter"
v-bind="props"
variant="text"
@click="menuShow.changeDatasourceOpen(menuShow.show)"
icon="fa fa-filter"
v-bind="props"
variant="text"
@click="menuShow.changeDatasourceOpen(menuShow.show)"
></v-btn>
</template>
<v-list density="compact">
<v-list-item
v-for="(item, i) in menuShow.datasourceList"
:key="i"
:class="
v-for="(item, i) in menuShow.datasourceList"
:key="i"
:class="
item.check ? '' : 'not'
"
:prepend-avatar="item.avatar"
:title="item.nickname"
:value="item"
class="menuShow-item"
color="primary"
@click="menuShow.changeSelectSource(item)"
:prepend-avatar="item.avatar"
:title="item.nickname"
:value="item"
class="menuShow-item"
color="primary"
@click="menuShow.changeSelectSource(item)"
>
</v-list-item>
</v-list>
Expand All @@ -75,78 +75,80 @@
<!-- right control panel -->
<div class="h-100 no-drag">
<v-btn
icon="fas fa-comments-dollar"
variant="text"
@click="donate.show = true"
icon="fas fa-comments-dollar"
variant="text"
@click="donate.show = true"
></v-btn>
<v-btn
icon="fas fa-gear"
variant="text"
@click="setting.show = true"
icon="fas fa-gear"
variant="text"
@click="setting.show = true"
></v-btn>
<v-btn
icon="fas fa-minus"
variant="text"
@click="handleWindow.minus"
icon="fas fa-minus"
variant="text"
@click="handleWindow.minus"
></v-btn>
<v-btn
:icon="winMax ? 'fas fa-minimize' : 'fas fa-maximize'"
variant="text"
@click="handleWindow.maximize"
:icon="winMax ? 'fas fa-minimize' : 'fas fa-maximize'"
variant="text"
@click="handleWindow.maximize"
></v-btn>
<v-btn
color="error"
icon="fas fa-circle-xmark "
variant="text"
@click="handleWindow.close"
color="error"
icon="fas fa-circle-xmark "
variant="text"
@click="handleWindow.close"
></v-btn>
</div>
</div>

<v-dialog
v-model="donate.show"
persistent
transition="dialog-top-transition"
width="800"
v-model="donate.show"
persistent
transition="dialog-top-transition"
width="800"
>
<donate-page @close="donate.show = false"></donate-page>
</v-dialog>

<v-dialog
v-model="setting.show"
persistent
transition="dialog-top-transition"
width="400"
v-model="setting.show"
persistent
transition="dialog-top-transition"
width="400"
>
<setting-page @close="setting.close" @checkUpdate="version.getNewestVersion" :versionState="setting.versionState"></setting-page>
<setting-page :versionState="setting.versionState" @checkUpdate="version.getNewestVersion"
@close="setting.close"></setting-page>
</v-dialog>
<v-dialog
v-model="version.show"
persistent
transition="dialog-top-transition"
width="600"
v-model="version.show"
persistent
transition="dialog-top-transition"
width="600"
>
<version-page @close="version.show = false" :versionInfo="version.version_info" :force="version.force"></version-page>
<version-page :force="version.force" :versionInfo="version.version_info"
@close="version.show = false"></version-page>
</v-dialog>
</template>

<script lang="ts" name="index" setup>
import { onMounted, reactive, ref } from "vue";
<script lang="ts" setup>
import {onMounted, reactive, ref} from "vue";
import storage from "../api/operations/localStorage";
import {
DatasourceItem,
getConfigDatasourceList,
} from "../api/resourceFetcher/datasourceList";
import { getDatasourceComb } from "../api/resourceFetcher/datasourceCombine";
} from "@/api/resourceFetcher/datasourceList";
import {getDatasourceComb} from "@/api/resourceFetcher/datasourceCombine";
import datasourceConfigOperate from "../api/operations/datasourceConfig";
import searchWordEvent from "../api/operations/searchWordEvent";
import operate from "../api/operations/operate";
import DonatePage from "./DonatePage.vue";
import SettingPage from "./SettingPage.vue";
import VersionPage from "./VersionPage.vue";
import { getVersion } from "../api/resourceFetcher/version";
import updater from "../api/operations/updater";
import { notification } from "@tauri-apps/api";
import {getVersion, DesktopVersion} from "@/api/resourceFetcher/version";
import updater, {VersionStateType} from "../api/operations/updater";
import {notification} from "@tauri-apps/api";
const winMax = ref(false);
Expand All @@ -173,16 +175,16 @@ const menuShow = reactive<{
menuShow.notOpened = false;
}
let datasourceConfig = await storage.getItem<string[]>(
"datasource-config",
"datasource-config",
);
// 打开列表
getConfigDatasourceList().then((data) => {
if (data.status == 200) {
menuShow.datasourceList = data.data.data.map(
(data: ViewDataSourceItem) => {
data.check = false;
return data;
},
(data: ViewDataSourceItem) => {
data.check = false;
return data;
},
);
if (datasourceConfig) {
let datasourceConfigUuidMap: Record<string, boolean> = {};
Expand All @@ -207,12 +209,12 @@ const menuShow = reactive<{
}
// 关闭列表
let datasourceConfig = menuShow.datasourceList
.filter((element) => {
return element.check;
})
.map((element) => {
return element.unique_id;
});
.filter((element) => {
return element.check;
})
.map((element) => {
return element.unique_id;
});
let comb_resp = await getDatasourceComb(datasourceConfig);
let comb_id = comb_resp.data.data.datasource_comb_id;
let datasourceComb = await storage.getItem<string>("datasource-comb");
Expand Down Expand Up @@ -268,46 +270,45 @@ const donate = reactive({
const setting = reactive({
show: false,
// updater setting
// updater setting
versionState: "Unknown",
close() {
setting.show = false;
setting.versionState = "Unknown";
},
});
const version = reactive({
const version = reactive<{
show: boolean,
version_info?: DesktopVersion,
force: boolean,
getNewestVersion(): void
}>({
show: false,
version_info: {},
force: false,
async getNewestVersion() {
if (setting.show) {
setting.versionState = "Newest";
}
getVersion().then((resq) => {
version.version_info = resq.data.data;
updater
.judgmentVersion(version.version_info.last_force_version).then((resq) => {
version.force = resq;
})
updater
.judgmentVersion(version.version_info.version).then((resq) => {
version.show = resq;
if (setting.show) {
setting.versionState = "UpdateAvailable";
}
})
}).catch(async (error)=>{
try {
if (setting.show) {
setting.versionState = VersionStateType.Newest;
}
const currentVersion = await getVersion()
version.version_info = currentVersion.data.data
// version.force = await updater.judgmentVersion(version.version_info.last_force_version)
version.show = await updater.judgmentVersion(version.version_info.version)
if (version.show) {
setting.versionState = VersionStateType.UpdateAvailable
}
} catch (error: any) {
console.log("Failure loading New Version")
if (!await notification.isPermissionGranted()){
if (!await notification.isPermissionGranted()) {
await notification.requestPermission()
}
notification.sendNotification({
title:"小刻出错了!",
icon:"/asserts/icon.png",
body:error.toString()
title: "小刻出错了!",
icon: "/asserts/icon.png",
body: error.toString()
})
});
}
}
});
Expand Down
Loading

0 comments on commit 0b2ea48

Please sign in to comment.