feat:add mobile views

This commit is contained in:
jiangrui
2025-03-03 18:06:19 +08:00
parent 4cd71a72e5
commit 03509eb723
20 changed files with 1346 additions and 40 deletions

View File

@@ -0,0 +1,147 @@
<template>
<div class="movie-wall">
<div v-for="movie in doubanStore.hotList" :key="movie.id" class="movie-item">
<div class="movie-poster">
<el-image
class="movie-poster-img"
:src="movie.cover"
fit="cover"
lazy
:alt="movie.title"
hide-on-click-modal
:preview-src-list="[movie.cover]"
/>
<div class="movie-rate">
{{ movie.rate }}
</div>
<div class="movie-poster-hover" @click="searchMovie(movie.title)">
<div class="movie-search">
<el-icon class="search_icon" size="28px"><Search /></el-icon>
</div>
</div>
</div>
<div class="movie-info">
<el-link :href="movie.url" target="_blank" :underline="false" class="movie-title">{{
movie.title
}}</el-link>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { computed, watch } from "vue";
import { useRouter, useRoute } from "vue-router";
import { useDoubanStore } from "@/stores/douban";
interface CurrentParams {
type: string;
tag?: string;
}
const router = useRouter();
const route = useRoute();
const routeParams = computed((): CurrentParams => ({ ...route.query }) as unknown as CurrentParams);
const doubanStore = useDoubanStore();
if (routeParams.value) {
doubanStore.setCurrentParams(routeParams.value);
}
watch(
() => routeParams.value,
() => {
console.log(routeParams.value);
doubanStore.setCurrentParams(routeParams.value);
}
);
const searchMovie = (title: string) => {
router.push({ path: "/resource", query: { keyword: title } });
};
</script>
<style scoped>
.movie-wall {
display: grid;
grid-template-columns: repeat(auto-fill, 48%);
grid-row-gap: 15px;
justify-content: space-between;
padding: 15px;
}
.movie-item {
overflow: hidden; /* 确保内容不会超出卡片 */
text-align: center;
background-color: #f9f9f9; /* 可选:设置背景颜色 */
box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.12); /* 可选:设置阴影效果 */
border-radius: 15px; /* 设置图片圆角 */
box-sizing: border-box;
padding-bottom: 0px;
position: relative;
padding: 15px;
padding-bottom: 0;
}
.movie-poster-img {
width: 100%;
height: 280px;
object-fit: cover; /* 确保图片使用cover模式 */
border-radius: 15px; /* 设置图片圆角 */
overflow: hidden;
}
.movie-info {
/* margin-top: 8px; */
.movie-title {
font-size: 24px;
font-weight: bold;
padding: 10px 0;
}
}
.movie-poster {
width: 100%;
height: 280px;
position: relative;
overflow: hidden;
border-radius: 15px;
box-sizing: border-box;
padding: 0;
margin: 0;
overflow: hidden;
}
.movie-poster-hover {
opacity: 0; /* 默认情况下隐藏 */
transition: opacity 0.3s ease; /* 添加过渡效果 */
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
/* height: 100%; */
background-color: rgba(0, 0, 0, 0.5);
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
}
.movie-poster:hover .movie-poster-hover {
opacity: 1; /* 鼠标移入时显示 */
}
.movie-rate {
position: absolute;
top: 10px;
right: 10px;
background-color: rgba(88, 83, 250, 0.8);
color: white;
padding: 0px 8px;
border-radius: 5px;
font-size: 20px;
}
.movie-search {
color: white;
border-radius: 5px;
font-size: 14px;
cursor: pointer;
}
</style>

View File

@@ -0,0 +1,143 @@
<template>
<div class="mobile-pc">
<van-search
v-model="keyword"
shape="round"
show-action
class="search-input"
placeholder="请输入搜索关键词或输入链接直接解析"
@search="handleSearch"
>
<template #action>
<van-icon name="contact-o" @click="logout" />
</template>
</van-search>
<div class="content">
<router-view />
</div>
</div>
<div v-if="resourcStore.loading" class="page-loading" @touchmove.prevent>
<van-loading text-color="#fff">资源搜索中...</van-loading>
</div>
<van-back-top />
<van-tabbar route>
<van-tabbar-item replace to="/resource" icon="search"></van-tabbar-item>
<van-tabbar-item replace to="/douban" icon="play-circle-o"></van-tabbar-item>
<van-tabbar-item replace to="/setting" icon="setting"></van-tabbar-item>
</van-tabbar>
<!-- <login v-else /> -->
</template>
<script setup lang="ts">
import { useResourceStore } from "@/stores/resource";
// import { useStore } from "@/stores/index";
import { useUserSettingStore } from "@/stores/userSetting";
import { computed, ref, watch } from "vue";
import { useRoute, useRouter } from "vue-router";
import { showConfirmDialog } from "vant";
// const store = useStore();
const route = useRoute();
const router = useRouter();
const resourcStore = useResourceStore();
const settingStore = useUserSettingStore();
settingStore.getSettings();
const keyword = ref("");
const routeKeyword = computed(() => route.query.keyword as string);
const logout = () => {
showConfirmDialog({
title: "退出登录",
message: "是否确定退出登录?",
}).then(() => {
// on confirm
localStorage.removeItem("token");
router.push({ path: "/login" });
});
};
const handleSearch = async () => {
// 如果搜索内容是一个https的链接则尝试解析链接
if (keyword.value.startsWith("http")) {
resourcStore.parsingCloudLink(keyword.value);
return;
}
if (!keyword.value.trim()) {
return;
}
console.log(route.path);
if (route.path !== "/resource") {
router.push({ path: "/resource" });
}
await resourcStore.searchResources(keyword.value);
};
watch(
() => routeKeyword.value,
() => {
if (routeKeyword.value) {
console.log("获取路由参数", routeKeyword.value);
keyword.value = routeKeyword.value;
handleSearch();
} else {
keyword.value = "";
}
}
);
</script>
<style scoped lang="scss">
.home-pc {
// padding: 20px;
min-width: 1000px;
height: 100vh;
overflow: hidden;
margin: 0 auto;
}
.home-header {
height: auto;
position: sticky;
top: 0;
z-index: 10;
background-color: rgba(231, 235, 239, 0.7) !important;
backdrop-filter: blur(8px);
-webkit-backdrop-filter: blur(8px);
border-radius: 0 0 5px 5px;
}
.home-main {
width: 1000px;
height: 100vh;
overflow: auto;
}
.home-main-main {
padding: 10px 15px;
}
.home-aside {
width: 300px;
}
.search-input {
background-color: rgba(231, 235, 239, 0.7) !important;
backdrop-filter: blur(8px);
-webkit-backdrop-filter: blur(8px);
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 999;
}
.page-loading {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
z-index: 999;
display: flex;
justify-content: center;
align-items: center;
}
.content {
padding-top: 120px;
padding-bottom: 100px;
}
</style>

View File

@@ -0,0 +1,113 @@
<template>
<div class="login-container">
<div class="login-form">
<div class="login-header">
<img :src="logo" alt="logo" class="logo" />
<div class="name">Cloud Saver</div>
</div>
<van-form @submit="handleLogin">
<van-cell-group inset class="login-form-group">
<van-field
v-model="loginForm.username"
name="用户名"
label="用户名"
placeholder="用户名"
:rules="[{ required: true, message: '请填写用户名' }]"
/>
<van-field
v-model="loginForm.password"
type="password"
name="密码"
label="密码"
placeholder="密码"
:rules="[{ required: true, message: '请填写密码' }]"
/>
</van-cell-group>
<div style="margin: 16px">
<van-button round block type="primary" native-type="submit"> 登录 </van-button>
</div>
</van-form>
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from "vue";
import logo from "@/assets/images/logo.png";
import { userApi } from "@/api/user";
import router from "@/router";
import { showNotify } from "vant";
const loginForm = ref({
username: "",
password: "",
});
const handleLogin = async () => {
try {
const res = await userApi.login(loginForm.value);
console.log(res);
if (res.code === 0) {
const { token } = res.data;
localStorage.setItem("token", token);
// 路由跳转首页
router.push("/");
} else {
showNotify({
message: res.message,
duration: 2000,
type: "danger",
});
}
} catch (error) {
showNotify({
message: "登录失败",
duration: 2000,
type: "danger",
});
}
};
</script>
<style lang="scss" scoped>
.login-container {
padding: 0;
background-color: #fff;
width: 100%;
height: 100vh;
background: url("../../assets//images//mobile-login-bg.png") no-repeat;
background-size: 100% auto;
.login-header {
width: 100%;
display: flex;
justify-content: center;
align-items: center;
margin-bottom: 38px;
.logo {
width: 50px;
height: auto;
margin-right: 18px;
}
.name {
font-size: 50px;
font-weight: 700;
letter-spacing: 0px;
line-height: 65.64px;
color: rgba(2, 46, 87, 1);
}
}
.login-form {
height: 60%;
width: 100%;
position: absolute;
left: 0;
bottom: 0;
background-color: #fff;
border-radius: 20px 20px 0 0;
box-sizing: border-box;
padding-top: 30px;
.login-form-group {
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
margin-bottom: 15px;
}
}
}
</style>

View File

@@ -0,0 +1,246 @@
<template>
<div ref="content" class="resource-list">
<div :class="{ 'resource-list__header': true }">
<div class="header_left">
<div class="refresh_btn" @click="refreshResources">
<el-icon class="type_icon" size="20px"><Refresh /></el-icon>最新资源<span
class="item-count"
>(上次刷新时间{{ resourceStore.lastUpdateTime }})</span
>
</div>
</div>
</div>
<van-tabs v-model:active="currentTab">
<van-tab
v-for="item in resourceStore.resources"
:key="item.id"
:name="item.id"
:title="item.channelInfo.name"
>
<ResourceCard
:current-channel-id="currentTab"
@save="handleSave"
@search-moviefor-tag="searchMovieforTag"
/>
</van-tab>
</van-tabs>
<el-dialog
v-if="currentResource"
v-model="saveDialogVisible"
width="100%"
:title="saveDialogMap[saveDialogStep].title"
>
<template #header="{ titleId }">
<div class="my-header">
<div :id="titleId">
<el-tag
:type="resourceStore.tagColor[currentResource.cloudType as keyof TagColor]"
effect="dark"
round
>
{{ currentResource.cloudType }}
</el-tag>
{{ saveDialogMap[saveDialogStep].title }}
<span
v-if="resourceStore.shareInfo.fileSize && saveDialogStep === 1"
style="font-weight: bold"
>
({{ formattedFileSize(resourceStore.shareInfo.fileSize || 0) }})
</span>
</div>
</div>
</template>
<div v-loading="resourceStore.loadTree">
<resource-select
v-if="saveDialogVisible && saveDialogStep === 1"
:cloud-type="currentResource.cloudType"
/>
<folder-select
v-if="saveDialogVisible && saveDialogStep === 2"
:cloud-type="currentResource.cloudType"
@select="handleFolderSelect"
@close="saveDialogVisible = false"
/>
</div>
<div class="dialog-footer">
<el-button @click="saveDialogVisible = false">取消</el-button>
<el-button type="primary" @click="handleConfirmClick">{{
saveDialogMap[saveDialogStep].buttonText
}}</el-button>
</div>
</el-dialog>
</div>
</template>
<script setup lang="ts">
import { ref, watch, onMounted, onUnmounted } from "vue";
import { useResourceStore } from "@/stores/resource";
// import { useUserSettingStore } from "@/stores/userSetting";
import FolderSelect from "@/components/mobile/FolderSelect.vue";
import ResourceSelect from "@/components/mobile/ResourceSelect.vue";
import { formattedFileSize } from "@/utils/index";
import type { ResourceItem, TagColor } from "@/types";
import ResourceCard from "@/components/mobile/ResourceCard.vue";
import { useRouter } from "vue-router";
import { ElMessage } from "element-plus";
const router = useRouter();
const resourceStore = useResourceStore();
// const userStore = useUserSettingStore();
const saveDialogVisible = ref(false);
const currentResource = ref<ResourceItem | null>(null);
const currentFolderId = ref<string | null>(null);
const saveDialogStep = ref<1 | 2>(1);
const currentTab = ref<string>("");
watch(
() => resourceStore.resources,
() => {
if (resourceStore.resources.length > 0) {
currentTab.value = resourceStore.resources[0].id;
}
}
);
const refreshResources = async () => {
resourceStore.searchResources("", false);
};
const saveDialogMap = {
1: {
title: "选择资源",
buttonText: "下一步",
},
2: {
title: "选择保存目录",
buttonText: "保存",
},
};
const handleSave = async (resource: ResourceItem) => {
currentResource.value = resource;
saveDialogVisible.value = true;
saveDialogStep.value = 1;
if (!(await resourceStore.getResourceListAndSelect(currentResource.value))) {
saveDialogVisible.value = false;
}
};
const handleFolderSelect = async (folderId: string) => {
if (!currentResource.value) return;
currentFolderId.value = folderId;
};
const handleConfirmClick = async () => {
if (saveDialogStep.value === 1) {
if (resourceStore.resourceSelect.length === 0) {
ElMessage.warning("请选择要保存的资源");
return;
}
saveDialogStep.value = 2;
} else {
handleSaveBtnClick();
}
};
const handleSaveBtnClick = async () => {
if (!currentResource.value || !currentFolderId.value) return;
saveDialogVisible.value = false;
await resourceStore.saveResource(currentResource.value, currentFolderId.value);
};
// 添加加载更多处理函数
const handleLoadMore = (channelId: string) => {
resourceStore.searchResources("", true, channelId);
};
const searchMovieforTag = (tag: string) => {
router.push({ path: "/resource", query: { keyword: tag } });
};
const doScroll = () => {
const scrollHeight = document.documentElement.scrollHeight; // 可滚动区域的高
const scrollTop = document.documentElement.scrollTop; // 已经滚动区域的高
const clientHeight = document.documentElement.clientHeight; // 可视区高度
if (clientHeight + scrollTop >= scrollHeight) {
handleLoadMore(currentTab.value);
}
};
onMounted(() => {
window.addEventListener("scroll", doScroll);
});
onUnmounted(() => {
window.removeEventListener("scroll", doScroll);
});
</script>
<style scoped>
.resource-list {
position: relative;
}
.resource-list__header {
height: 52px;
background-color: var(--theme-other_background);
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 10px;
box-sizing: border-box;
border-radius: 15px;
padding: 0 15px;
}
.header_right {
cursor: pointer;
}
.refresh_btn {
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
padding: 0 15px;
.item-count {
color: #909399;
font-size: 0.9em;
}
}
.dialog-footer {
display: flex;
align-items: center;
justify-content: flex-end;
}
.group-header {
display: flex;
align-items: center;
gap: 8px;
}
.item-count {
color: #909399;
font-size: 0.9em;
}
:deep(.el-table__expand-column) {
.cell {
padding: 0 !important;
}
}
:deep(.el-table__expanded-cell) {
padding: 20px !important;
}
:deep(.el-table__expand-icon) {
height: 23px;
line-height: 23px;
}
.load-more {
display: flex;
justify-content: center;
padding: 16px 0;
}
</style>

View File

@@ -0,0 +1,182 @@
<template>
<div class="settings">
<el-card v-if="settingStore.globalSetting" class="setting-card">
<div class="card-title">项目配置</div>
<div class="section">
<div class="form-group">
<label for="proxyDomain">代理ip:</label>
<el-input
id="proxyDomain"
v-model="globalSetting.httpProxyHost"
class="form-input"
type="text"
placeholder="127.0.0.1"
/>
</div>
<div class="form-group">
<label for="proxyPort">代理端口:</label>
<el-input
id="proxyPort"
v-model="globalSetting.httpProxyPort"
class="form-input"
type="text"
placeholder="7890"
/>
</div>
<div class="form-group">
<label for="AdminUserCode">管理员注册码:</label>
<el-input-number
id="AdminUserCode"
v-model="globalSetting.AdminUserCode"
class="form-input"
type="text"
:controls="false"
:precision="0"
placeholder="设置管理员注册码"
/>
</div>
<div class="form-group">
<label for="CommonUserCode">普通用户注册码:</label>
<el-input-number
id="CommonUserCode"
v-model="globalSetting.CommonUserCode"
class="form-input"
type="text"
:precision="0"
:controls="false"
placeholder="设置普通用户注册码"
/>
</div>
</div>
<div class="section">
<div class="form-group">
<label for="isProxyEnabled">启用代理:</label>
<el-switch v-model="globalSetting.isProxyEnabled" @change="saveSettings" />
</div>
</div>
</el-card>
<el-card class="setting-card">
<div class="card-title">用户配置</div>
<div class="section">
<div class="form-group">
<label for="cookie115">115网盘Cookie:</label>
<el-input
id="cookie115"
v-model="settingStore.userSettings.cloud115Cookie"
class="form-input"
type="text"
/>
</div>
<div class="form-group">
<label for="cookieQuark">夸克网盘Cookie:</label>
<el-input
id="cookieQuark"
v-model="settingStore.userSettings.quarkCookie"
class="form-input"
type="text"
/>
</div>
</div>
<div class="user-setting-tips">
<h3>帮助</h3>
<div>
<el-link
target="_blank"
href="https://alist.nn.ci/zh/guide/drivers/115.html#cookie%E8%8E%B7%E5%8F%96%E6%96%B9%E5%BC%8F"
>如何获取115网盘cookie</el-link
>
</div>
<div>
<el-link target="_blank" href="https://alist.nn.ci/zh/guide/drivers/quark.html#cookie"
>如何获取夸克网盘cookie</el-link
>
</div>
</div>
</el-card>
<van-button round block type="primary" @click="saveSettings"> 保存设置 </van-button>
</div>
</template>
<script setup lang="ts">
import { useUserSettingStore } from "@/stores/userSetting";
import { computed } from "vue";
const settingStore = useUserSettingStore();
const globalSetting = computed(
() =>
settingStore.globalSetting || {
httpProxyHost: "127.0.1",
httpProxyPort: "7890",
isProxyEnabled: false,
AdminUserCode: 230713,
CommonUserCode: 9527,
}
);
settingStore.getSettings();
const saveSettings = () => {
settingStore.saveSettings();
// Add your save logic here
};
</script>
<style scoped lang="scss">
.settings {
padding: 10px;
}
.setting-card {
margin-bottom: 20px;
border-radius: 15px;
padding: 0px;
}
.card-title {
font-size: 32px;
}
.section {
margin-bottom: 20px;
display: flex;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
&:last-child {
margin-bottom: 0;
}
}
.form-group {
margin-bottom: 10px;
width: 48%;
}
.form-input {
text-align: left;
width: 100%;
}
::v-deep .el-input__inner {
text-align: left;
}
label {
display: block;
margin-bottom: 5px;
}
input {
width: 100%;
padding: 8px;
box-sizing: border-box;
}
button {
padding: 10px 20px;
background-color: #007bff;
color: white;
border: none;
cursor: pointer;
}
button:hover {
background-color: #0056b3;
}
</style>