✨ add apis
This commit is contained in:
@@ -6,6 +6,7 @@ import {useWebSocketStore} from "@/store/modules/websocketStore.ts";
|
||||
import {useUpscaleStore} from "@/store/modules/upscaleStore.ts";
|
||||
import {useMenuStore} from "@/store/modules/menuStore.ts";
|
||||
import {useUploadStore} from "@/store/modules/uploadStore.ts";
|
||||
import {useImageStore} from "@/store/modules/imageStore.ts";
|
||||
|
||||
export default function useStore() {
|
||||
return {
|
||||
@@ -17,5 +18,6 @@ export default function useStore() {
|
||||
upscale: useUpscaleStore(),
|
||||
menu: useMenuStore(),
|
||||
upload: useUploadStore(),
|
||||
image: useImageStore(),
|
||||
};
|
||||
}
|
||||
|
||||
52
src/store/modules/imageStore.ts
Normal file
52
src/store/modules/imageStore.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import {ImageList} from "@/types/image";
|
||||
|
||||
export const useImageStore = defineStore(
|
||||
'image',
|
||||
() => {
|
||||
const selected = ref<number[]>([]);
|
||||
const tabActiveKey = ref<string>("-1");
|
||||
const tabMap = reactive({
|
||||
"-1": "全部相册",
|
||||
"0": "我的相册",
|
||||
"1": "我的分享",
|
||||
"2": "我的收藏",
|
||||
});
|
||||
const homeTabActiveKey = ref<string>("all");
|
||||
const homeTabMap = reactive({
|
||||
"all": "全部",
|
||||
"video": "视频",
|
||||
"gif": "动图",
|
||||
"screenshot": "截图",
|
||||
});
|
||||
|
||||
/**
|
||||
* 统计图片总数
|
||||
* @param imageList 图片列表数据
|
||||
* @returns 图片总数
|
||||
*/
|
||||
function countTotalImages(imageList: ImageList): number {
|
||||
if (!imageList) {
|
||||
return 0;
|
||||
}
|
||||
return imageList.reduce((total, record) => total + record.list.length, 0);
|
||||
}
|
||||
|
||||
return {
|
||||
selected,
|
||||
tabActiveKey,
|
||||
tabMap,
|
||||
homeTabMap,
|
||||
homeTabActiveKey,
|
||||
countTotalImages
|
||||
};
|
||||
},
|
||||
{
|
||||
// 开启数据持久化
|
||||
persistedState: {
|
||||
persist: true,
|
||||
storage: localStorage,
|
||||
key: 'image',
|
||||
includePaths: ["tabActiveKey", "tabMap", "homeTabActiveKey", "homeTabMap"],
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -84,7 +84,13 @@ export const useAuthStore = defineStore(
|
||||
message.success(t('login.loginSuccess'));
|
||||
window.removeEventListener("message", messageHandler);
|
||||
setTimeout(() => {
|
||||
router.push('/main/photo/all');
|
||||
const currentUrl = new URL(window.location.href);
|
||||
const redirect = currentUrl.searchParams.get('redirect');
|
||||
if (redirect) {
|
||||
router.push(redirect);
|
||||
} else {
|
||||
router.push('/main/photo/all');
|
||||
}
|
||||
}, 1000);
|
||||
} else {
|
||||
message.error(t('login.loginError'));
|
||||
|
||||
Reference in New Issue
Block a user