mirror of
https://github.com/ialley-workshop-open/uni-halo.git
synced 2026-07-27 04:20:43 +08:00
Compare commits
38 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9ab013562d | |||
| a8bd121deb | |||
| 476a1ec48e | |||
| 31ade9908a | |||
| 5606e8c59f | |||
| 61d3b22fdb | |||
| c05aa5253c | |||
| 0b599dcced | |||
| 623e3fa59a | |||
| 1075f588fa | |||
| c0d8cb2c3b | |||
| 9c6a054b12 | |||
| 6a05f664ba | |||
| 9c4d2242ae | |||
| eac027c116 | |||
| 3a08008192 | |||
| 7daf93d51f | |||
| 409be28deb | |||
| 97e358e41f | |||
| c17e668afe | |||
| 4611932ad8 | |||
| 452d021816 | |||
| d71022c224 | |||
| d521a641de | |||
| 4246d8cdcb | |||
| 6989fd8ddc | |||
| 742b51a23e | |||
| bc541a3ef6 | |||
| 67fc682164 | |||
| b43dd7e5a7 | |||
| e29ccf65c5 | |||
| 91553fc053 | |||
| 22f57b7860 | |||
| 2a25727c0b | |||
| eb69ae4af6 | |||
| 2fd83a7814 | |||
| 8963ba1921 | |||
| 051c72b584 |
@@ -2,8 +2,3 @@ node_modules/
|
||||
unpackage/
|
||||
package-lock.json
|
||||
.idea
|
||||
|
||||
config/halo.config.js
|
||||
config/love.config.js
|
||||
config/token.config.js
|
||||
config/plugins.config.js
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script>
|
||||
import HaloTokenConfig from '@/config/token.config.js';
|
||||
import HaloTokenConfig from '@/config/uhalo.config.js';
|
||||
|
||||
// app升级检测(搭配:https://ext.dcloud.net.cn/plugin?id=4470 升级中心)
|
||||
import CheckAppUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update';
|
||||
|
||||
+65
-8
@@ -1,7 +1,9 @@
|
||||
/**
|
||||
* 所有的接口
|
||||
*/
|
||||
import HaloTokenConfig from '@/config/token.config.js'
|
||||
import {
|
||||
getPersonalToken
|
||||
} from '@/utils/token.js'
|
||||
import HttpHandler from '@/common/http/request.js'
|
||||
import qs from 'qs'
|
||||
|
||||
@@ -35,7 +37,8 @@ export default {
|
||||
* @param {Object} params 数据
|
||||
*/
|
||||
getPostListByKeyword: (params) => {
|
||||
return HttpHandler.Get(`/apis/api.halo.run/v1alpha1/indices/post`, params)
|
||||
// return HttpHandler.Get(`/apis/api.halo.run/v1alpha1/indices/post`, params)
|
||||
return HttpHandler.Post(`/apis/api.halo.run/v1alpha1/indices/-/search`, params)
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -50,7 +53,7 @@ export default {
|
||||
encode: false,
|
||||
arrayFormat: 'repeat'
|
||||
})
|
||||
return HttpHandler.Get(`/apis/api.content.halo.run/v1alpha1/categories?${param}`,{})
|
||||
return HttpHandler.Get(`/apis/api.content.halo.run/v1alpha1/categories?${param}`, {})
|
||||
},
|
||||
/**
|
||||
* 查询分类下的文章
|
||||
@@ -111,7 +114,19 @@ export default {
|
||||
getMomentList: (params) => {
|
||||
return HttpHandler.Get(`/apis/moment.halo.run/v1alpha1/moments`, params, {
|
||||
custom: {
|
||||
systemToken: HaloTokenConfig.systemToken
|
||||
personalToken: getPersonalToken()
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取瞬间详情
|
||||
* @param {String} name 瞬间id
|
||||
*/
|
||||
getMomentByName: (name) => {
|
||||
return HttpHandler.Get(`/apis/moment.halo.run/v1alpha1/moments/${name}`, {}, {
|
||||
custom: {
|
||||
personalToken: getPersonalToken()
|
||||
}
|
||||
})
|
||||
},
|
||||
@@ -130,7 +145,7 @@ export default {
|
||||
getPhotoGroupList: (params) => {
|
||||
return HttpHandler.Get(`/apis/core.halo.run/v1alpha1/photogroups`, params, {
|
||||
custom: {
|
||||
systemToken: HaloTokenConfig.systemToken
|
||||
personalToken: getPersonalToken()
|
||||
}
|
||||
})
|
||||
},
|
||||
@@ -142,7 +157,7 @@ export default {
|
||||
getPhotoListByGroupName: (params) => {
|
||||
return HttpHandler.Get(`/apis/console.api.photo.halo.run/v1alpha1/photos`, params, {
|
||||
custom: {
|
||||
systemToken: HaloTokenConfig.systemToken
|
||||
personalToken: getPersonalToken()
|
||||
}
|
||||
})
|
||||
},
|
||||
@@ -153,7 +168,7 @@ export default {
|
||||
getFriendLinkGroupList: (params) => {
|
||||
return HttpHandler.Get(`/apis/core.halo.run/v1alpha1/linkgroups`, params, {
|
||||
custom: {
|
||||
systemToken: HaloTokenConfig.systemToken
|
||||
personalToken: getPersonalToken()
|
||||
}
|
||||
})
|
||||
},
|
||||
@@ -194,6 +209,7 @@ export default {
|
||||
return HttpHandler.Get(`/apis/tools.muyin.site/v1alpha1/restrict-read/create`, null, {
|
||||
header: {
|
||||
'Authorization': getAppConfigs().pluginConfig.toolsPlugin?.Authorization,
|
||||
'Wechat-Session-Id': uni.getStorageSync('openid'),
|
||||
}
|
||||
})
|
||||
},
|
||||
@@ -229,6 +245,47 @@ export default {
|
||||
*/
|
||||
submitUpvote(data) {
|
||||
return HttpHandler.Post(`/apis/api.halo.run/v1alpha1/trackers/upvote`, data, {})
|
||||
}
|
||||
},
|
||||
|
||||
//----------- 投票 -----------------
|
||||
/**
|
||||
* 获取投票列表
|
||||
*/
|
||||
getVoteList: (params) => {
|
||||
return HttpHandler.Get(`/apis/api.vote.kunkunyu.com/v1alpha1/votes`, params)
|
||||
},
|
||||
/**
|
||||
* 获取投票详情
|
||||
* @param {String} name id
|
||||
*/
|
||||
getVoteDetail: (name) => {
|
||||
return HttpHandler.Get(`/apis/api.vote.kunkunyu.com/v1alpha1/votes/${name}/detail`, {})
|
||||
},
|
||||
/**
|
||||
* 获取投票用户列表
|
||||
* @param {String} name id
|
||||
*/
|
||||
getVoteUserList: (name) => {
|
||||
return HttpHandler.Get(`/apis/api.vote.kunkunyu.com/v1alpha1/votes/${name}/user-list`, {})
|
||||
},
|
||||
/**
|
||||
* 提交投票
|
||||
* @param {String} name id
|
||||
* @param {Object} { voteData:["选项ID"] } 提交的数据
|
||||
* @param {Boolean} canAnonymously 是否匿名 默认匿名
|
||||
*/
|
||||
submitVote: (name, data, canAnonymously = true) => {
|
||||
return HttpHandler.Post(`/apis/api.vote.kunkunyu.com/v1alpha1/votes/${name}/submit`, data, {
|
||||
custom: {
|
||||
personalToken: canAnonymously ? undefined : getPersonalToken()
|
||||
}
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 检查是否安装启用插件
|
||||
* @param {String} name 插件id
|
||||
*/
|
||||
checkPluginAvailable: (name) => {
|
||||
return HttpHandler.Get(`/apis/api.plugin.halo.run/v1alpha1/plugins/${name}/available`, {})
|
||||
},
|
||||
}
|
||||
@@ -10,7 +10,7 @@
|
||||
* 修改时间:
|
||||
*/
|
||||
|
||||
import HaloTokenConfig from '@/config/token.config.js'
|
||||
import HaloTokenConfig from '@/config/uhalo.config.js'
|
||||
import {
|
||||
setInterceptors
|
||||
} from "./interceptors.js";
|
||||
|
||||
+14
-30
@@ -9,13 +9,7 @@
|
||||
* 修改人员:
|
||||
* 修改时间:
|
||||
*/
|
||||
import {
|
||||
getAdminAccessToken
|
||||
} from "@/utils/auth.js";
|
||||
import {
|
||||
delCache,
|
||||
setCache
|
||||
} from "@/utils/storage";
|
||||
import {delCache, setCache} from "@/utils/storage";
|
||||
|
||||
const getCategoryNameByUrl = (url) => {
|
||||
const reg = '(?<=/api/content/categories/).+(?=/posts)'
|
||||
@@ -37,9 +31,7 @@ const showCategoryInputPasswordModal = (response, category) => {
|
||||
// TODO 这里如果没有输入密码点击确认应该阻止窗口关闭,但是没找到方法
|
||||
if (!res.content) {
|
||||
uni.showToast({
|
||||
title: '提示:请输入密码',
|
||||
icon: 'none',
|
||||
success: () => {
|
||||
title: '提示:请输入密码', icon: 'none', success: () => {
|
||||
setTimeout(() => {
|
||||
showCategoryInputPasswordModal(response, category);
|
||||
}, 800)
|
||||
@@ -56,14 +48,14 @@ const showCategoryInputPasswordModal = (response, category) => {
|
||||
uni.reLaunch({
|
||||
url: '/pages/tabbar/category/category'
|
||||
});
|
||||
} else if (res.cancel) {}
|
||||
} else if (res.cancel) {
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export const setInterceptors = (http) => {
|
||||
http.interceptors.request.use(
|
||||
(config) => {
|
||||
http.interceptors.request.use((config) => {
|
||||
console.log("config", config)
|
||||
|
||||
// 可使用async await 做异步操作
|
||||
@@ -71,19 +63,16 @@ export const setInterceptors = (http) => {
|
||||
...config.header
|
||||
// ... 可以直接加参数
|
||||
};
|
||||
if (config.custom.systemToken) {
|
||||
config.header['Authorization'] = `Bearer ${config.custom.systemToken}`
|
||||
if (config.custom.personalToken) {
|
||||
config.header['Authorization'] = `Bearer ${config.custom.personalToken}`
|
||||
}
|
||||
return config;
|
||||
},
|
||||
(config) => {
|
||||
}, (config) => {
|
||||
// 可使用async await 做异步操作
|
||||
return Promise.reject(config);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
http.interceptors.response.use(
|
||||
(response) => {
|
||||
http.interceptors.response.use((response) => {
|
||||
/* 对响应成功做点什么 可使用async await 做异步操作*/
|
||||
// if (response.data.code !== 200) { // 服务端返回的状态码不等于200,则reject()
|
||||
// return Promise.reject(response) // return Promise.reject 可使promise状态进入catch
|
||||
@@ -96,13 +85,11 @@ export const setInterceptors = (http) => {
|
||||
} else {
|
||||
return Promise.reject(response);
|
||||
}
|
||||
},
|
||||
(response) => {
|
||||
}, (response) => {
|
||||
/* 对响应错误做点什么 (statusCode !== 200)*/
|
||||
if (!response.data) {
|
||||
return Promise.reject({
|
||||
status: 500,
|
||||
message: 'API接口服务异常!'
|
||||
status: 500, message: 'API接口服务异常!'
|
||||
})
|
||||
} else if (response.data.status == 401) {
|
||||
uni.$tm.toast(response.data.message);
|
||||
@@ -111,9 +98,7 @@ export const setInterceptors = (http) => {
|
||||
const category = getCategoryNameByUrl(response.config.url)
|
||||
delCache('APP_CATEGORY_PWD_' + category);
|
||||
uni.showToast({
|
||||
title: '提示:密码不正确',
|
||||
icon: 'none',
|
||||
success: () => {
|
||||
title: '提示:密码不正确', icon: 'none', success: () => {
|
||||
setTimeout(() => {
|
||||
showCategoryInputPasswordModal(response, category);
|
||||
}, 800)
|
||||
@@ -152,6 +137,5 @@ export const setInterceptors = (http) => {
|
||||
return Promise.reject(response.data);
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
});
|
||||
};
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
import {getAppConfigs} from '@/config/index.js'
|
||||
import HaloTokenConfig from '@/config/token.config.js'
|
||||
import HaloTokenConfig from '@/config/uhalo.config.js'
|
||||
import utils from '@/utils/index.js'
|
||||
|
||||
export default {
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* 功能:插件检查
|
||||
*/
|
||||
import {
|
||||
NeedPluginIds,
|
||||
NeedPlugins,
|
||||
checkNeedPluginAvailable
|
||||
} from "@/utils/plugin.js"
|
||||
|
||||
const HaloPluginAvailableMixin = {
|
||||
data() {
|
||||
return {
|
||||
NeedPluginIds,
|
||||
NeedPlugins,
|
||||
uniHaloPluginAvailableError: "",
|
||||
uniHaloPluginAvailable: true,
|
||||
uniHaloPluginPageClass: "",
|
||||
uniHaloPluginId: "", // 当前需要的插件
|
||||
uniHaloPluginInfo: "" // 当前插件信息
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
uniHaloPluginAvailable: {
|
||||
immediate: true,
|
||||
handler(val) {
|
||||
if (val) {
|
||||
this.uniHaloPluginPageClass = ""
|
||||
} else {
|
||||
this.uniHaloPluginPageClass = "box-border items-center justify-center"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
/** 设置插件ID */
|
||||
setPluginId(pluginId) {
|
||||
this.uniHaloPluginId = pluginId
|
||||
this.uniHaloPluginInfo = NeedPlugins.get(pluginId)
|
||||
},
|
||||
/** 检查插件状态 */
|
||||
async checkPluginAvailable(pluginId) {
|
||||
pluginId = pluginId ?? this.uniHaloPluginId
|
||||
if (!pluginId) return false;
|
||||
const available = await checkNeedPluginAvailable(pluginId)
|
||||
this.uniHaloPluginAvailable = available
|
||||
return available
|
||||
},
|
||||
/** 设置错误信息 */
|
||||
setPluginError(text) {
|
||||
this.uniHaloPluginAvailableError = text
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export default HaloPluginAvailableMixin;
|
||||
@@ -172,3 +172,178 @@
|
||||
}
|
||||
|
||||
/* 文本省略样式 结束 */
|
||||
|
||||
.box-border{
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
// 定义尺寸变量(单位:rpx)
|
||||
$spacing-sizes: (
|
||||
0: 0,
|
||||
2: 4rpx,
|
||||
4: 8rpx,
|
||||
8: 16rpx,
|
||||
12: 24rpx,
|
||||
24: 48rpx,
|
||||
48: 96rpx
|
||||
);
|
||||
|
||||
// 内边距类
|
||||
@each $name, $size in $spacing-sizes {
|
||||
// 全方向内边距:p-{size}
|
||||
.uh-p-#{$name} {
|
||||
padding: $size !important;
|
||||
}
|
||||
|
||||
// 水平方向内边距:px-{size}
|
||||
.uh-px-#{$name} {
|
||||
padding-left: $size !important;
|
||||
padding-right: $size !important;
|
||||
}
|
||||
|
||||
// 垂直方向内边距:py-{size}
|
||||
.uh-py-#{$name} {
|
||||
padding-top: $size !important;
|
||||
padding-bottom: $size !important;
|
||||
}
|
||||
|
||||
// 上内边距:pt-{size}
|
||||
.uh-pt-#{$name} {
|
||||
padding-top: $size !important;
|
||||
}
|
||||
|
||||
// 右内边距:pr-{size}
|
||||
.uh-pr-#{$name} {
|
||||
padding-right: $size !important;
|
||||
}
|
||||
|
||||
// 下内边距:pb-{size}
|
||||
.uh-pb-#{$name} {
|
||||
padding-bottom: $size !important;
|
||||
}
|
||||
|
||||
// 左内边距:pl-{size}
|
||||
.uh-pl-#{$name} {
|
||||
padding-left: $size !important;
|
||||
}
|
||||
}
|
||||
|
||||
//外边距工具类
|
||||
@each $name, $size in $spacing-sizes {
|
||||
// 全方向外边距:m-{size}
|
||||
.uh-m-#{$name} {
|
||||
margin: $size !important;
|
||||
}
|
||||
|
||||
// 水平方向外边距:mx-{size}
|
||||
.uh-mx-#{$name} {
|
||||
margin-left: $size !important;
|
||||
margin-right: $size !important;
|
||||
}
|
||||
|
||||
// 垂直方向外边距:my-{size}
|
||||
.uh-my-#{$name} {
|
||||
margin-top: $size !important;
|
||||
margin-bottom: $size !important;
|
||||
}
|
||||
|
||||
// 上外边距:mt-{size}
|
||||
.uh-mt-#{$name} {
|
||||
margin-top: $size !important;
|
||||
}
|
||||
|
||||
// 右外边距:mr-{size}
|
||||
.uh-mr-#{$name} {
|
||||
margin-right: $size !important;
|
||||
}
|
||||
|
||||
// 下外边距:mb-{size}
|
||||
.uh-mb-#{$name} {
|
||||
margin-bottom: $size !important;
|
||||
}
|
||||
|
||||
// 左外边距:ml-{size}
|
||||
.uh-ml-#{$name} {
|
||||
margin-left: $size !important;
|
||||
}
|
||||
}
|
||||
|
||||
// gap 类
|
||||
@each $name, $size in $spacing-sizes {
|
||||
// 全方向gap:gap-{size}
|
||||
.uh-gap-#{$name} {
|
||||
gap: $size !important;
|
||||
}
|
||||
|
||||
// 水平方向gap:gap-x-{size}
|
||||
.uh-gap-x-#{$name} {
|
||||
column-gap: $size !important;
|
||||
}
|
||||
|
||||
// 垂直方向gap:gap-y-{size}
|
||||
.uh-gap-y-#{$name} {
|
||||
row-gap: $size !important;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.w-full {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.h-full {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.flex {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.flex-col {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.flex-1 {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.flex-shrink-0 {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.items-center {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.items-start {
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.items-end {
|
||||
align-items: flex-end;
|
||||
}
|
||||
|
||||
.justify-between {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.justify-around {
|
||||
justify-content: space-around;
|
||||
}
|
||||
|
||||
.justify-end {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.justify-start {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.justify-center {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.text-break {
|
||||
overflow-wrap: break-word;
|
||||
word-break: break-all;
|
||||
}
|
||||
@@ -66,7 +66,7 @@
|
||||
display: flex;
|
||||
box-sizing: border-box;
|
||||
margin: 0 24rpx;
|
||||
padding: 24rpx;
|
||||
padding:22rpx 24rpx;
|
||||
border-radius: 12rpx;
|
||||
background-color: #ffff;
|
||||
box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.03);
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
<template>
|
||||
<view class="article-min-card" :class="[globalAppSettings.layout.cardType]" @click="fnClickEvent('card')">
|
||||
<view class="article-min-card" @click="fnClickEvent('card')">
|
||||
<view class="left">
|
||||
<cache-image class="thumbnail" radius="6rpx" :url="$utils.checkThumbnailUrl(article.thumbnail)" :fileMd5="$utils.checkThumbnailUrl(article.thumbnail)" mode="aspectFill"></cache-image>
|
||||
<cache-image class="thumbnail" radius="6rpx" :url="$utils.checkThumbnailUrl(article.spec.cover)" :fileMd5="article.spec.cover"
|
||||
mode="aspectFill"></cache-image>
|
||||
</view>
|
||||
<view class="right">
|
||||
<view class="title text-overflow">{{ article.title }}</view>
|
||||
<view class="content text-overflow">{{ article.summary }}</view>
|
||||
<view class="title text-overflow">{{ article.spec.title }}</view>
|
||||
<view class="content text-overflow">{{ article.status.excerpt }}</view>
|
||||
<view class="foot">
|
||||
<view class="create-time">
|
||||
<!-- <text class="icon iconfont icon-clock"></text> -->
|
||||
<text class="time-label">发布时间:</text>
|
||||
{{ { d: article.createTime, f: 'yyyy-MM-dd' } | formatTime }}
|
||||
{{ {d: article.spec.publishTime, f: 'yyyy-MM-dd'} | formatTime }}
|
||||
</view>
|
||||
<view class="visits">
|
||||
<!-- <text class="icon iconfont icon-eye"></text> -->
|
||||
浏览
|
||||
<text class="number">{{ article.visits }}</text>
|
||||
<text class="number">{{ article.stats.visit }}</text>
|
||||
次
|
||||
</view>
|
||||
</view>
|
||||
@@ -24,12 +23,13 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
export default {
|
||||
name: 'article-min-card',
|
||||
props: {
|
||||
article: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
default: () => {
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -37,11 +37,11 @@
|
||||
this.$emit('on-click', this.article);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.article-min-card {
|
||||
.article-min-card {
|
||||
display: flex;
|
||||
box-sizing: border-box;
|
||||
border-radius: 12rpx;
|
||||
@@ -52,7 +52,8 @@
|
||||
padding: 16rpx;
|
||||
box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.03);
|
||||
|
||||
&.lr_image_text {}
|
||||
&.lr_image_text {
|
||||
}
|
||||
|
||||
&.lr_text_image {
|
||||
.left {
|
||||
@@ -216,5 +217,6 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,569 @@
|
||||
<template>
|
||||
<view class="vote-card" :class="[loading]">
|
||||
<view v-if="loading !=='success'" class="vote-error" @click="fnGetData()">
|
||||
{{loadingText}}
|
||||
</view>
|
||||
<template v-else>
|
||||
<view class="vote-card-head flex flex-col">
|
||||
<view class="flex justify-between">
|
||||
<view class="flex">
|
||||
<tm-tags color="orange" style="min-width:40rpx;" :shadow="0" rounded size="s"
|
||||
model="fill">{{ index + 1 }}</tm-tags>
|
||||
<tm-tags color="light-blue" :shadow="0" rounded size="s"
|
||||
model="fill">{{ vote.spec._uh_type }}</tm-tags>
|
||||
<tm-tags :color="vote.spec._uh_state.color" size="s" rounded :shadow="0"
|
||||
model="fill">{{vote.spec._uh_state.state}}</tm-tags>
|
||||
</view>
|
||||
<view class="flex-shrink">
|
||||
<tm-button theme="light-blue" :shadow="0" dense size="s"
|
||||
@click="handleToVoteDetail(vote)">查看投票详情</tm-button>
|
||||
</view>
|
||||
</view>
|
||||
<view class="title">
|
||||
{{ vote.spec.title }}
|
||||
</view>
|
||||
</view>
|
||||
<view class="vote-card-body">
|
||||
|
||||
<view v-if="vote.spec.remark" class="remark text-size-s">
|
||||
{{vote.spec.remark}}
|
||||
</view>
|
||||
|
||||
<template>
|
||||
<!-- 单选 -->
|
||||
<view v-if="vote.spec.type==='single'" class="single">
|
||||
<view class="w-full flex flex-col uh-gap-8">
|
||||
<template v-if="vote.spec.isVoted || vote.spec.hasEnded">
|
||||
<view v-for="(option,optionIndex) in vote.spec.options" :key="optionIndex"
|
||||
class="is-voted-item" :class="[option.checked?'selected':'']" :style="{
|
||||
'--percent': option._uh_percent + '%'
|
||||
}">
|
||||
<view class="is-voted-item-content flex w-full flex-between uh-gap-4">
|
||||
<view class="text-align-left flex-1 text-break">
|
||||
{{option.title }}
|
||||
</view>
|
||||
<view class="flex-shrink ">
|
||||
{{option._uh_percent }}%
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view v-for="(option,optionIndex) in vote.spec.options" :key="optionIndex"
|
||||
class="vote-select-option flex-1 w-full text-break"
|
||||
:class="[option.checked?'light-blue':'grey-lighten-3']"
|
||||
@click="handleSelectSingleOption(option)">
|
||||
{{option.title }}
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 多选 -->
|
||||
<view v-else-if="vote.spec.type==='multiple'" class="multiple">
|
||||
<view class="w-full flex flex-col uh-gap-8">
|
||||
<template v-if="vote.spec.isVoted || vote.spec.hasEnded">
|
||||
<view v-for="(option,optionIndex) in vote.spec.options" :key="optionIndex"
|
||||
class="is-voted-item" :class="[option.checked?'selected':'']" :style="{
|
||||
'--percent': option._uh_percent + '%'
|
||||
}">
|
||||
<view class="is-voted-item-content flex w-full flex-between uh-gap-4">
|
||||
<view class="text-align-left flex-1 text-break">
|
||||
{{option.title }}
|
||||
</view>
|
||||
<view class="flex-shrink ">
|
||||
{{option._uh_percent }}%
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view v-for="(option,optionIndex) in vote.spec.options" :key="optionIndex"
|
||||
class="vote-select-option flex-1 w-full text-break"
|
||||
:class="[option.checked?'light-blue':'grey-lighten-3']"
|
||||
@click="handleSelectCheckboxOption(option)">
|
||||
{{option.title }}
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- PK -->
|
||||
<view v-else-if="vote.spec.type==='pk'" class="pk">
|
||||
<view class="pk-container">
|
||||
<view class="radio-item" v-for="(option,optionIndex) in vote.spec.options"
|
||||
:key="optionIndex" :class="[optionIndex==0?'radio-left':'radio-right']"
|
||||
:style="{width:option._uh_percent + '%'}">
|
||||
<view class="option-item"
|
||||
:class="[optionIndex==0?'option-item-left':'option-item-right']">
|
||||
{{option._uh_percent }}%
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="option-foot w-full flex flex-between uh-mt-12">
|
||||
<view class="w-full flex flex-col uh-gap-8">
|
||||
<template v-if="vote.spec.isVoted || vote.spec.hasEnded">
|
||||
<view v-for="(option,optionIndex) in vote.spec.options" :key="optionIndex"
|
||||
class="is-voted-item" :class="[option.checked?'selected':'']" :style="{
|
||||
'--percent': option._uh_percent + '%'
|
||||
}">
|
||||
<view class="is-voted-item-content flex w-full flex-between uh-gap-4">
|
||||
<view class="text-align-left flex-1 text-break">
|
||||
{{option.title }}
|
||||
</view>
|
||||
<view class="flex-shrink ">
|
||||
{{option._uh_percent }}%
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view v-for="(option,optionIndex) in vote.spec.options" :key="optionIndex"
|
||||
class="vote-select-option flex-1 w-full text-break"
|
||||
:class="[option.checked?'light-blue':'grey-lighten-3']"
|
||||
@click="handleSelectSingleOption(option)">
|
||||
选项{{ optionIndex+1}}:{{option.title }}
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
<view class="vote-card-foot flex flex-between">
|
||||
<view class="left flex">
|
||||
<tm-tags v-if="vote.spec.timeLimit==='permanent'" color="grey-darken-2" rounded size="s"
|
||||
model="text">结束:永久有效 </tm-tags>
|
||||
<tm-tags v-else color="grey-darken-2" rounded size="s" model="text">
|
||||
<template
|
||||
v-if="vote.spec._state=='未开始'">开始:{{ {d: vote.spec.startDate, f: 'yyyy-MM-dd HH:mm'} | formatTime }}
|
||||
</template>
|
||||
<template v-else>结束:{{ {d: vote.spec.endDate, f: 'yyyy-MM-dd HH:mm'} | formatTime }}
|
||||
</template>
|
||||
</tm-tags>
|
||||
</view>
|
||||
|
||||
<view class="right flex flex-end">
|
||||
<tm-tags color="grey-darken-2" rounded size="s" model="text">{{ vote.stats.voteCount }}
|
||||
人已参与</tm-tags>
|
||||
<tm-tags v-if="vote.spec.isVoted" color="blue" rounded size="s" model="text">已投票</tm-tags>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="submitForm.voteData.length!==0" class="box-border uh-mt-12 w-full uh-px-2">
|
||||
<tm-button v-if="fnCalcIsVoted()" theme="white" text :block="true" class="w-full">您已参与投票</tm-button>
|
||||
<tm-button v-else-if="vote.spec._uh_state.state==='未开始'" theme="orange" text class="w-full" :height="72"
|
||||
:block="true" @click="handleSubmitTip('投票未开始')">投票未开始</tm-button>
|
||||
<tm-button v-else-if="vote.spec._uh_state.state==='已结束'" theme="red" text class="w-full" :height="72"
|
||||
:block="true" @click="handleSubmitTip('投票已结束')">投票已结束</tm-button>
|
||||
<tm-button v-else-if="!vote.spec.canAnonymously" theme="red" :shadow="0" class="w-full" :height="72"
|
||||
text :block="true" @click="handleSubmit()">不支持匿名投票</tm-button>
|
||||
<tm-button v-else-if="submitForm.voteData.length===0" theme="white" text class="w-full" :height="72"
|
||||
:block="true" @click="handleSubmitTip('请选择选项')">提交投票(请选择选项)</tm-button>
|
||||
<tm-button v-else theme="light-blue" class="w-full" :height="72" :block="true" :loading="submitLoading"
|
||||
:disabled="submitLoading" @click="handleSubmit()">提交投票</tm-button>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
|
||||
import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue';
|
||||
import {
|
||||
VOTE_TYPES,
|
||||
calcVoteState,
|
||||
calcVotePercent,
|
||||
voteCacheUtil
|
||||
} from '@/utils/vote.js'
|
||||
|
||||
export default {
|
||||
name: "ArticleVote",
|
||||
components: {
|
||||
tmButton,
|
||||
tmTags
|
||||
},
|
||||
props: {
|
||||
voteId: {
|
||||
type: String,
|
||||
default: ""
|
||||
},
|
||||
index: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
article: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: "loading",
|
||||
loadingText: "加载中,请稍等...",
|
||||
detail: null,
|
||||
vote: null,
|
||||
submitForm: {
|
||||
voteData: []
|
||||
},
|
||||
submitLoading: false
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.fnGetData();
|
||||
},
|
||||
methods: {
|
||||
fnGetData() {
|
||||
this.loadingText = "加载中,请稍等...";
|
||||
this.loading = "loading";
|
||||
this.$httpApi.v2
|
||||
.getVoteDetail(this.voteId)
|
||||
.then(res => {
|
||||
this.pageTitle = "投票详情" + `(${VOTE_TYPES[res.vote.spec.type]})`
|
||||
|
||||
const tempVoteRes = res;
|
||||
|
||||
tempVoteRes.vote.spec.isVoted = this.fnCalcIsVoted()
|
||||
tempVoteRes.vote.spec.disabled = this.fnCalcIsVoted()
|
||||
tempVoteRes.vote.spec._uh_state = calcVoteState(tempVoteRes.vote)
|
||||
tempVoteRes.vote.spec._uh_type = VOTE_TYPES[tempVoteRes.vote.spec.type]
|
||||
|
||||
tempVoteRes.vote.spec.options.map((option, index) => {
|
||||
option.value = option.id
|
||||
option.label = option.title
|
||||
option.isVoted = this.fnCalcIsVoted()
|
||||
option.checked = this.fnCalcIsChecked(option)
|
||||
option._uh_percent = calcVotePercent(tempVoteRes.vote, option);
|
||||
option.dataStr = JSON.stringify(option)
|
||||
|
||||
return option
|
||||
})
|
||||
|
||||
this.vote = tempVoteRes.vote
|
||||
this.detail = tempVoteRes;
|
||||
|
||||
setTimeout(() => {
|
||||
this.loading = 'success';
|
||||
}, 200);
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
this.loading = 'error';
|
||||
this.loadingText = "投票内容加载失败,点击重试"
|
||||
})
|
||||
},
|
||||
|
||||
fnCalcIsVoted() {
|
||||
return voteCacheUtil.has(this.voteId)
|
||||
},
|
||||
fnCalcIsChecked(option) {
|
||||
const data = voteCacheUtil.get(this.voteId)
|
||||
if (!data) return false;
|
||||
const checked = data.selected.includes(option.id)
|
||||
return checked
|
||||
},
|
||||
formatJsonStr(jsonStr) {
|
||||
return jsonStr ? JSON.parse(jsonStr) : {}
|
||||
},
|
||||
handleSubmitTip(text) {
|
||||
uni.showToast({
|
||||
icon: "none",
|
||||
title: text
|
||||
})
|
||||
},
|
||||
handleSubmit() {
|
||||
if (!this.vote.spec.canAnonymously) {
|
||||
uni.showModal({
|
||||
icon: "none",
|
||||
title: "提示",
|
||||
content: "该投票不支持匿名,请到博主的 网站端 进行投票!",
|
||||
cancelColor: "#666666",
|
||||
cancelText: "关闭",
|
||||
confirmText: "复制地址",
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
console.log("this.article", this.article)
|
||||
const articleUrl = this.$baseApiUrl + (this.article?.status?.permalink ?? "")
|
||||
this.$utils.copyText(articleUrl, "原文地址复制成功")
|
||||
}
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
uni.showLoading({
|
||||
title: "正在保存..."
|
||||
})
|
||||
this.submitLoading = true
|
||||
this.$httpApi.v2
|
||||
.submitVote(this.voteId, this.submitForm, this.vote.spec.canAnonymously)
|
||||
.then(res => {
|
||||
uni.showToast({
|
||||
icon: "none",
|
||||
title: "提交成功"
|
||||
})
|
||||
|
||||
voteCacheUtil.set(this.voteId, {
|
||||
selected: [...this.submitForm.voteData],
|
||||
data: this.vote
|
||||
})
|
||||
|
||||
this.fnGetData()
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
uni.showToast({
|
||||
icon: "none",
|
||||
title: "提交失败,请重试"
|
||||
})
|
||||
}).finally(() => {
|
||||
this.submitLoading = false
|
||||
})
|
||||
},
|
||||
|
||||
handleSelectSingleOption(option) {
|
||||
if (this.vote.spec._uh_state.state == '未开始') {
|
||||
this.showToast(`投票未开始`)
|
||||
return
|
||||
}
|
||||
if (this.vote.spec.hasEnded) return
|
||||
if (this.vote.spec.disabled) return
|
||||
this.vote.spec.options.map(item => {
|
||||
if (option.id == item.id) {
|
||||
item.checked = true
|
||||
} else {
|
||||
item.checked = false
|
||||
}
|
||||
})
|
||||
this.submitForm.voteData = this.vote.spec.options.filter(x => x.checked).map(item => item.id)
|
||||
},
|
||||
|
||||
handleSelectCheckboxOption(option) {
|
||||
if (this.vote.spec._uh_state.state == '未开始') {
|
||||
this.showToast(`投票未开始`)
|
||||
return
|
||||
}
|
||||
|
||||
if (this.vote.spec.hasEnded) return
|
||||
if (this.vote.spec.disabled) return
|
||||
|
||||
const checkedList = this.vote.spec.options.filter(x => x.checked && x.id != option.id)
|
||||
|
||||
if (this.vote.spec.type === 'multiple' && checkedList.length >= this.vote.spec.maxVotes) {
|
||||
this.showToast(`最多选择 ${this.vote.spec.maxVotes} 项`)
|
||||
return
|
||||
}
|
||||
|
||||
this.vote.spec.options.map(item => {
|
||||
if (option.id == item.id) {
|
||||
item.checked = !item.checked
|
||||
}
|
||||
})
|
||||
this.submitForm.voteData = this.vote.spec.options.filter(x => x.checked).map(item => item.id)
|
||||
},
|
||||
handleToVoteDetail(vote) {
|
||||
uni.navigateTo({
|
||||
url: `/pagesA/vote-detail/vote-detail?name=${vote.metadata.name}`
|
||||
});
|
||||
},
|
||||
showToast(content) {
|
||||
uni.showToast({
|
||||
icon: "none",
|
||||
title: content,
|
||||
mask: true
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.w-full {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.wp-50 {
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.vote-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
padding: 24rpx;
|
||||
border-radius: 12rpx;
|
||||
background-color: #ffff;
|
||||
overflow: hidden;
|
||||
margin-bottom: 12rpx;
|
||||
border: 1px solid #eee;
|
||||
|
||||
&.error {
|
||||
padding: 0;
|
||||
border-style: dashed;
|
||||
border-color: #e88080;
|
||||
color: #e88080;
|
||||
background-color: rgba(232, 128, 128, 0.075);
|
||||
}
|
||||
|
||||
&.loading {
|
||||
padding: 0;
|
||||
border-style: dashed;
|
||||
border-color: rgba(3, 174, 252, 1);
|
||||
color: rgba(3, 174, 252, 1);
|
||||
background-color: rgba(3, 174, 252, 0.075);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.vote-error {
|
||||
padding: 50rpx 24rpx;
|
||||
font-size: 24rpx;
|
||||
border-radius: 12rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.vote-card-head {
|
||||
margin-bottom: 12rpx;
|
||||
|
||||
.title {
|
||||
padding: 12rpx 0;
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
.vote-card-body {
|
||||
|
||||
.remark {
|
||||
box-sizing: border-box;
|
||||
color: rgba(0, 0, 0, 0.75);
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.vote-card-foot {
|
||||
box-sizing: border-box;
|
||||
padding-top: 6px;
|
||||
margin-top: 12px;
|
||||
border-top: 2rpx solid #eee;
|
||||
|
||||
.left {}
|
||||
}
|
||||
|
||||
.is-voted-item {
|
||||
min-height: 72rpx;
|
||||
box-sizing: border-box;
|
||||
position: relative;
|
||||
border-radius: 12rpx;
|
||||
background-color: rgba(229, 229, 229, 0.75);
|
||||
font-size: 24rpx;
|
||||
overflow: hidden;
|
||||
|
||||
&::before {
|
||||
content: "";
|
||||
width: var(--percent);
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
background-color: rgba(208, 208, 208, 1);
|
||||
z-index: 0;
|
||||
border-radius: 6rpx;
|
||||
}
|
||||
|
||||
&.selected {
|
||||
background-color: rgba(3, 169, 244, 0.35);
|
||||
color: #ffffff;
|
||||
|
||||
&::before {
|
||||
background-color: rgba(3, 169, 244, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.is-voted-item-content {
|
||||
box-sizing: border-box;
|
||||
min-height: 72rpx;
|
||||
padding: 12rpx 24rpx;
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.vote-select-option {
|
||||
box-sizing: border-box;
|
||||
padding: 20rpx 24rpx;
|
||||
font-size: 24rpx;
|
||||
border-radius: 12rpx;
|
||||
transition: all 0.1s ease-in-out;
|
||||
}
|
||||
|
||||
.single {
|
||||
::v-deep {}
|
||||
}
|
||||
|
||||
.multiple {
|
||||
::v-deep {}
|
||||
}
|
||||
|
||||
.pk {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
padding: 0 12rpx;
|
||||
|
||||
::v-deep {
|
||||
|
||||
.pk-container {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.radio-item {
|
||||
flex-grow: 1;
|
||||
min-width: 30% !important;
|
||||
max-width: 70% !important;
|
||||
}
|
||||
|
||||
.radio-left {}
|
||||
|
||||
.radio-right {}
|
||||
|
||||
.option-item {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
padding: 24rpx;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
|
||||
.option-item-left {
|
||||
background: linear-gradient(90deg, #3B82F6, #60A5FA);
|
||||
color: white;
|
||||
clip-path: polygon(0 0, calc(100% - 40rpx) 0, 100% 100%, 0 100%);
|
||||
}
|
||||
|
||||
.option-item-right {
|
||||
background: linear-gradient(90deg, #F87171, #EF4444);
|
||||
color: white;
|
||||
clip-path: polygon(0 0, 100% 0, 100% 100%, 40rpx 100%);
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.option-foot {
|
||||
width: 100%;
|
||||
margin-top: 6rpx;
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
|
||||
.left {
|
||||
box-sizing: border-box;
|
||||
padding-right: 24rpx;
|
||||
}
|
||||
|
||||
.right {
|
||||
box-sizing: border-box;
|
||||
padding-left: 24rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -43,7 +43,7 @@
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
background-color: rgba(0, 0, 0, 0.25);
|
||||
backdrop-filter: blur(3rpx);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="right-hot-ttf">
|
||||
<text class="text hot-text">{{ title }}</text>
|
||||
<text class="text hot-text text-overflow-2">{{ title }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -63,7 +63,7 @@
|
||||
</view>
|
||||
<!-- 标题 -->
|
||||
<view class="Top-Title">
|
||||
<text class="text title-text">{{ item.title }}</text>
|
||||
<text class="text title-text text-overflow-2">{{ item.title }}</text>
|
||||
</view>
|
||||
<!-- 用户信息 -->
|
||||
<view v-if="false" class="Bottom-UserInfo">
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
<template>
|
||||
<tm-poup v-model="isShow" width="80vw" height="800rpx" position="center" :round="6" @change="fnOnChange">
|
||||
<view class="fulled pa-4">
|
||||
<view class="mt-24 fulled text-weight-b text-size-sm text-align-center text-overflow-2 pb-24">{{ title }}</view>
|
||||
<view class="fulled mt-2">
|
||||
<scroll-view class="fulled" scroll-y :style="{
|
||||
height: url? '600rpx': '680rpx'
|
||||
}">
|
||||
<mp-html class="evan-markdown" lazy-load :domain="markdownConfig.domain"
|
||||
:loading-img="markdownConfig.loadingGif" :scroll-table="true" :selectable="true"
|
||||
:tag-style="markdownConfig.tagStyle" :container-style="markdownConfig.containStyle"
|
||||
:content="content" :markdown="true" :showLineNumber="true" :showLanguageName="true"
|
||||
:copyByLongPress="true"/>
|
||||
</scroll-view>
|
||||
</view>
|
||||
<view v-if="url" class="fulled mt-12 flex flex-center">
|
||||
<tm-button theme="bg-gradient-light-blue-accent" size="m" @click="fnToWebview()">
|
||||
点击跳转内容链接
|
||||
</tm-button>
|
||||
</view>
|
||||
</view>
|
||||
</tm-poup>
|
||||
</template>
|
||||
|
||||
|
||||
<script>
|
||||
import tmPoup from '@/tm-vuetify/components/tm-poup/tm-poup.vue';
|
||||
import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
|
||||
import mpHtml from '@/components/mp-html/components/mp-html/mp-html.vue';
|
||||
|
||||
import MarkdownConfig from '@/common/markdown/markdown.config.js';
|
||||
|
||||
export default {
|
||||
name: 'notify-dialog',
|
||||
components: {
|
||||
tmPoup,
|
||||
tmButton,
|
||||
mpHtml
|
||||
},
|
||||
props: {
|
||||
show: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
content: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
url: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
isShow: false,
|
||||
markdownConfig: MarkdownConfig,
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.isShow = this.show;
|
||||
},
|
||||
methods: {
|
||||
fnToWebview() {
|
||||
if (this.$utils.checkIsUrl(this.url)) {
|
||||
uni.navigateTo({
|
||||
url: '/pagesC/website/website?data=' +
|
||||
JSON.stringify({
|
||||
title: this.title,
|
||||
url: encodeURIComponent(this.url)
|
||||
}),
|
||||
success: () => {
|
||||
this.fnOnChange(false)
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
fnOnChange(e) {
|
||||
this.isShow = false;
|
||||
this.$emit('on-change', e);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,200 @@
|
||||
<template>
|
||||
<view v-if="pluginInfo" class="plugin-unavailable flex flex-col flex-center"
|
||||
:class="{border:useBorder,'decoration':useDecoration}" :style="[calcCustomStyle]">
|
||||
<!-- 图标 -->
|
||||
<image class="plugin-logo" :src="pluginInfo.logo" mode="scaleToFill"></image>
|
||||
<!-- 名称 -->
|
||||
<view class="plugin-name">
|
||||
{{ pluginInfo.name }}
|
||||
</view>
|
||||
<view class="plugin-error">
|
||||
未安装/启用插件
|
||||
</view>
|
||||
<!-- 描述 -->
|
||||
<view class="plugin-desc">
|
||||
{{ pluginInfo.desc }}
|
||||
</view>
|
||||
<view v-if="errorText" class="plugin-tip">
|
||||
{{errorText}}
|
||||
</view>
|
||||
<!-- 插件地址 -->
|
||||
<view class="plugin-url">
|
||||
插件地址:{{ pluginInfo.url }}
|
||||
</view>
|
||||
<!-- 反馈按钮/复制地址 -->
|
||||
<view class="plugin-btns w-full flex-center">
|
||||
<!-- #ifndef MP-WEIXIN -->
|
||||
<tm-button theme="light-blue" :block="true" class="w-full" :height="70" @click="copy">复制地址</tm-button>
|
||||
<!-- #endif -->
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<tm-button theme="light-blue" plan text :height="70" @click="copy">复制地址</tm-button>
|
||||
<tm-button theme="light-blue" open-type="contact" :height="70">提交反馈</tm-button>
|
||||
<!-- #endif -->
|
||||
</view>
|
||||
|
||||
<view class="plugin-copyright">
|
||||
提示:请确保 Halo 博客已安装相关插件
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
NeedPluginIds,
|
||||
NeedPlugins,
|
||||
CheckNeedPluginAvailable
|
||||
} from "@/utils/plugin.js"
|
||||
import utils from '@/utils/index.js'
|
||||
|
||||
import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
|
||||
|
||||
export default {
|
||||
name: "plugin-unavailable",
|
||||
components: {
|
||||
tmButton
|
||||
},
|
||||
props: {
|
||||
pluginId: {
|
||||
type: String,
|
||||
default: ""
|
||||
},
|
||||
errorText: {
|
||||
type: String,
|
||||
default: ""
|
||||
},
|
||||
useDecoration: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
useBorder: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
customStyle: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
NeedPluginIds,
|
||||
NeedPlugins,
|
||||
pluginInfo: null,
|
||||
defaultStyle: {
|
||||
width: "80vw",
|
||||
borderRadius: "24rpx"
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
calcCustomStyle() {
|
||||
const style = this.customStyle ?? {}
|
||||
return {
|
||||
...this.defaultStyle,
|
||||
...style
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
pluginId: {
|
||||
deep: true,
|
||||
immediate: true,
|
||||
handler(newVal, oldVal) {
|
||||
this.pluginInfo = NeedPlugins.get(newVal)
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
copy() {
|
||||
utils.copyText(this.pluginInfo.url, "插件地址已复制")
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.plugin-unavailable {
|
||||
box-sizing: border-box;
|
||||
margin: auto;
|
||||
padding: 100rpx 36rpx;
|
||||
gap: 24rpx;
|
||||
font-size: 28rpx;
|
||||
|
||||
&.border {
|
||||
// border: 2rpx solid #E2E8F0;
|
||||
border: 2rpx solid #eee;
|
||||
}
|
||||
|
||||
&.decoration {
|
||||
background-color: rgba(255, 255, 255, 0.95);
|
||||
box-shadow: 0 0 12rpx rgba(226, 232, 240, 0.35);
|
||||
backdrop-filter: blur(6rpx);
|
||||
border-top: 12rpx solid rgba(3, 169, 244, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.plugin-logo {
|
||||
box-sizing: border-box;
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
border-radius: 24rpx;
|
||||
}
|
||||
|
||||
.plugin-name {
|
||||
box-sizing: border-box;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
font-size: 32rpx;
|
||||
}
|
||||
|
||||
.plugin-error {
|
||||
box-sizing: border-box;
|
||||
padding: 6rpx 16rpx;
|
||||
border-radius: 36rpx;
|
||||
background-color: rgba(255, 61, 49, 0.075);
|
||||
color: rgba(255, 61, 49, 1);
|
||||
font-size: 24rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.plugin-tip {
|
||||
box-sizing: border-box;
|
||||
padding: 10rpx 20rpx;
|
||||
border-radius: 12rpx;
|
||||
border: 2rpx dashed #f2c97d;
|
||||
color: #f0a020;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.plugin-desc {
|
||||
box-sizing: border-box;
|
||||
width: 60vw;
|
||||
font-size: 24rpx;
|
||||
text-align: center;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.plugin-url {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
padding: 16rpx 24rpx;
|
||||
border-radius: 12rpx;
|
||||
background-color: #F1F5F9;
|
||||
color: #666;
|
||||
font-size: 24rpx;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.plugin-btns {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.plugin-copyright {
|
||||
font-size: 20rpx;
|
||||
color: #999;
|
||||
transform: scale(0.9) translateY(20px);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,252 @@
|
||||
<template>
|
||||
<view class="vote-card" @click="$emit('on-click',vote)">
|
||||
<view class="vote-card-head flex">
|
||||
<view class="left flex flex-center w-full">
|
||||
<view class="flex-shrink">
|
||||
<tm-tags color="light-blue" :shadow="0" rounded size="s" model="fill">{{ vote.spec._uh_type}}</tm-tags>
|
||||
</view>
|
||||
<view class="title text-overflow">
|
||||
{{ vote.spec.title }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="vote-card-body w-full">
|
||||
<view v-if="vote.spec.remark" class="remark text-overflow-2 text-size-s">
|
||||
{{vote.spec.remark}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="vote-card-foot flex flex-between">
|
||||
<view class="left flex">
|
||||
<tm-tags :color="vote.spec._uh_state.color" size="s" rounded :shadow="0"
|
||||
model="text">{{vote.spec._uh_state.state}}</tm-tags>
|
||||
|
||||
<tm-tags v-if="vote.spec.isVoted" color="blue" rounded size="s" model="text">已投票</tm-tags>
|
||||
|
||||
<tm-tags v-if="vote.spec.timeLimit==='permanent'" color="grey-darken-2" rounded size="s"
|
||||
model="text">结束时间:永久有效 </tm-tags>
|
||||
<tm-tags v-else color="grey-darken-2" rounded size="s" model="text">
|
||||
<template
|
||||
v-if="vote.spec._uh_state.state=='未开始'">开始时间:{{ {d: vote.spec.startDate, f: 'yyyy-MM-dd HH:mm'} | formatTime }}
|
||||
</template>
|
||||
<template v-else>结束时间:{{ {d: vote.spec.endDate, f: 'yyyy-MM-dd HH:mm'} | formatTime }}
|
||||
</template>
|
||||
</tm-tags>
|
||||
</view>
|
||||
|
||||
<view v-if="false" class="right flex flex-end">
|
||||
<tm-tags v-if="false" color="grey-darken-2" rounded size="s" model="text">{{ vote.stats.voteCount }}
|
||||
人已参与</tm-tags>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import tmGroupradio from '@/tm-vuetify/components/tm-groupradio/tm-groupradio.vue';
|
||||
import tmRadio from '@/tm-vuetify/components/tm-radio/tm-radio.vue';
|
||||
import tmGroupcheckbox from '@/tm-vuetify/components/tm-groupcheckbox/tm-groupcheckbox.vue';
|
||||
import tmCheckbox from '@/tm-vuetify/components/tm-checkbox/tm-checkbox.vue';
|
||||
import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
|
||||
import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue';
|
||||
|
||||
export default {
|
||||
name: "VoteCard",
|
||||
options: {
|
||||
virtualHost: true,
|
||||
styleIsolation: 'shared'
|
||||
},
|
||||
components: {
|
||||
tmGroupradio,
|
||||
tmRadio,
|
||||
tmGroupcheckbox,
|
||||
tmCheckbox,
|
||||
tmButton,
|
||||
tmTags
|
||||
},
|
||||
props: {
|
||||
vote: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
},
|
||||
index: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
showOptions: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.w-full {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.wp-50 {
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.vote-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
margin: 0 24rpx;
|
||||
padding: 24rpx;
|
||||
border-radius: 12rpx;
|
||||
background-color: #ffff;
|
||||
box-shadow: 0rpx 2rpx 12rpx rgba(0, 0, 0, 0.035);
|
||||
overflow: hidden;
|
||||
margin-bottom: 24rpx;
|
||||
// border: 1px solid #eee;
|
||||
}
|
||||
|
||||
.vote-card-head {
|
||||
margin-bottom: 12rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
|
||||
.left {
|
||||
.title {
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.vote-card-body {
|
||||
|
||||
.remark {
|
||||
box-sizing: border-box;
|
||||
padding-top: 0;
|
||||
color: rgba(0, 0, 0, 0.75);
|
||||
margin-bottom: 12rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.vote-card-foot {
|
||||
box-sizing: border-box;
|
||||
padding-top: 6px;
|
||||
margin-top: 6px;
|
||||
border-top: 2rpx solid #F7F7F7;
|
||||
|
||||
.left {}
|
||||
}
|
||||
|
||||
|
||||
.single {
|
||||
::v-deep {
|
||||
.tm-groupradio {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12rpx 0;
|
||||
}
|
||||
|
||||
.tm-checkbox {
|
||||
box-sizing: border-box;
|
||||
display: block;
|
||||
padding: 0 12rpx;
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.tm-button-label {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.multiple {
|
||||
::v-deep {
|
||||
.tm-groupcheckbox {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12rpx 0;
|
||||
}
|
||||
|
||||
.tm-checkbox {
|
||||
box-sizing: border-box;
|
||||
display: block;
|
||||
padding: 0 12rpx;
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.tm-button-label {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.pk {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
padding: 0 12rpx;
|
||||
|
||||
::v-deep {
|
||||
.tm-groupradio {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.tm-checkbox {
|
||||
flex-grow: 1;
|
||||
min-width: 30% !important;
|
||||
max-width: 70% !important;
|
||||
}
|
||||
|
||||
.radio-item {
|
||||
position: relative;
|
||||
|
||||
.selected {
|
||||
z-index: 10;
|
||||
}
|
||||
}
|
||||
|
||||
.radio-left {}
|
||||
|
||||
.radio-right {}
|
||||
|
||||
.option-item {
|
||||
width: 100%;
|
||||
padding: 12rpx 24rpx;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
|
||||
.option-item-left {
|
||||
background: linear-gradient(90deg, #3B82F6, #60A5FA);
|
||||
color: white;
|
||||
clip-path: polygon(0 0, calc(100% - 40rpx) 0, 100% 100%, 0 100%);
|
||||
}
|
||||
|
||||
.option-item-right {
|
||||
background: linear-gradient(90deg, #F87171, #EF4444);
|
||||
color: white;
|
||||
clip-path: polygon(0 0, 100% 0, 100% 100%, 40rpx 100%);
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.option-foot {
|
||||
width: 100%;
|
||||
margin-top: 6rpx;
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
|
||||
.left {
|
||||
box-sizing: border-box;
|
||||
padding-right: 24rpx;
|
||||
}
|
||||
|
||||
.right {
|
||||
box-sizing: border-box;
|
||||
padding-left: 24rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
+37
-2
@@ -4,12 +4,47 @@ export const _AppMockJsonKey = 'APP_GLOBAL_MOCK_JSON';
|
||||
|
||||
// 默认的应用设置
|
||||
export const DefaultAppConfigs = {
|
||||
basicConfig: {
|
||||
tokenConfig: {
|
||||
personalToken: "",
|
||||
}
|
||||
},
|
||||
loveConfig: {},
|
||||
imagesConfig: {},
|
||||
authorConfig: {},
|
||||
appConfig: {},
|
||||
pluginConfig: {},
|
||||
pageConfig: {}
|
||||
pluginConfig: {
|
||||
toolsPlugin: {},
|
||||
linksSubmitPlugin: {},
|
||||
},
|
||||
pageConfig: {
|
||||
homeConfig: {
|
||||
pageTitle: "首页",
|
||||
useCategory: true,
|
||||
bannerConfig: {
|
||||
enabled: true,
|
||||
showTitle: true,
|
||||
showIndicator: true,
|
||||
height: "400rpx",
|
||||
dotPosition: "right",
|
||||
type: "post",
|
||||
list: []
|
||||
}
|
||||
},
|
||||
categoryConfig: {
|
||||
type: "list"
|
||||
},
|
||||
momentConfig: {
|
||||
useTagRandomColor: true
|
||||
}
|
||||
},
|
||||
auditConfig: {
|
||||
auditModeEnabled: false,
|
||||
auditModeData: {
|
||||
jsonUrl: "",
|
||||
jsonData: ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
import {getAppConfigs} from "@/config/index";
|
||||
|
||||
/** 配置后台管理员token */
|
||||
const HaloTokenConfig = Object.freeze({
|
||||
|
||||
/** 基础请求域名:你的Halo博客基础域名 */
|
||||
BASE_API: "",
|
||||
// BASE_API: "https://blog.xiaoxiaomo.cn",
|
||||
|
||||
|
||||
/** 管理员token */
|
||||
systemToken: getAppConfigs()?.basicConfig?.tokenConfig?.personalToken,
|
||||
/** 匿名用户token */
|
||||
anonymousToken: ``
|
||||
})
|
||||
|
||||
|
||||
export default HaloTokenConfig;
|
||||
@@ -0,0 +1,12 @@
|
||||
/** 应用基础配置 */
|
||||
const UHaloBaseConfig = Object.freeze({
|
||||
|
||||
/** 基础请求域名:你的Halo博客基础域名 */
|
||||
BASE_API: "",
|
||||
// 示例:
|
||||
// BASE_API: "https://blog.xiaoxiaomo.cn",
|
||||
|
||||
// todo:可能有其他配置
|
||||
})
|
||||
|
||||
export default UHaloBaseConfig;
|
||||
@@ -4,6 +4,7 @@ import Vue from "vue";
|
||||
// 挂载全局工具类
|
||||
import utils from "./utils/index.js";
|
||||
Vue.prototype.$utils = utils;
|
||||
uni.$utils = utils;
|
||||
|
||||
// 全局统一样式的对话框
|
||||
import Fy from '@/js_sdk/fy-showModal/index.js'
|
||||
@@ -57,7 +58,7 @@ Vue.prototype.$http = http;
|
||||
import ApiManager from '@/api/index.js'
|
||||
Vue.use(ApiManager);
|
||||
|
||||
import HaloTokenConfig from '@/config/token.config.js'
|
||||
import HaloTokenConfig from '@/config/uhalo.config.js'
|
||||
Vue.prototype.$baseApiUrl = HaloTokenConfig.BASE_API
|
||||
|
||||
// 由于微信小程序的运行机制问题,需声明如下一行,H5和APP非必填
|
||||
|
||||
+31
-16
@@ -2,8 +2,8 @@
|
||||
"name" : "uni-halo",
|
||||
"appid" : "__UNI__5748B6E",
|
||||
"description" : "uni-halo博客:基于halo开源博客系统API开发的多端博客。",
|
||||
"versionName" : "1.0.0",
|
||||
"versionCode" : 100,
|
||||
"versionName" : "2.0.8",
|
||||
"versionCode" : 208,
|
||||
"transformPx" : false,
|
||||
/* 5+App特有相关 */
|
||||
"app-plus" : {
|
||||
@@ -112,43 +112,43 @@
|
||||
}
|
||||
},
|
||||
"uniStatistics" : {
|
||||
"enable" : true
|
||||
"enable" : false
|
||||
}
|
||||
},
|
||||
/* 快应用特有相关 */
|
||||
"quickapp" : {},
|
||||
/* 小程序特有相关 */
|
||||
"mp-weixin" : {
|
||||
"appid" : "wx1bb161867082c72f",
|
||||
"appid" : "",
|
||||
"setting" : {
|
||||
"urlCheck" : false,
|
||||
"minified" : true
|
||||
},
|
||||
"usingComponents" : true,
|
||||
"uniStatistics" : {
|
||||
"enable" : true
|
||||
"enable" : false
|
||||
}
|
||||
},
|
||||
"mp-alipay" : {
|
||||
"usingComponents" : true,
|
||||
"uniStatistics" : {
|
||||
"enable" : true
|
||||
"enable" : false
|
||||
}
|
||||
},
|
||||
"mp-baidu" : {
|
||||
"usingComponents" : true,
|
||||
"uniStatistics" : {
|
||||
"enable" : true
|
||||
"enable" : false
|
||||
}
|
||||
},
|
||||
"mp-toutiao" : {
|
||||
"usingComponents" : true,
|
||||
"uniStatistics" : {
|
||||
"enable" : true
|
||||
"enable" : false
|
||||
}
|
||||
},
|
||||
"uniStatistics" : {
|
||||
"enable" : true,
|
||||
"enable" : false,
|
||||
"version" : "2"
|
||||
},
|
||||
"vueVersion" : "2",
|
||||
@@ -174,7 +174,7 @@
|
||||
}
|
||||
},
|
||||
"uniStatistics" : {
|
||||
"enable" : true
|
||||
"enable" : false
|
||||
},
|
||||
"router" : {
|
||||
"base" : "/uni-halo/",
|
||||
@@ -190,32 +190,47 @@
|
||||
"es6" : true
|
||||
},
|
||||
"uniStatistics" : {
|
||||
"enable" : true
|
||||
"enable" : false
|
||||
}
|
||||
},
|
||||
"mp-jd" : {
|
||||
"uniStatistics" : {
|
||||
"enable" : true
|
||||
"enable" : false
|
||||
}
|
||||
},
|
||||
"mp-kuaishou" : {
|
||||
"uniStatistics" : {
|
||||
"enable" : true
|
||||
"enable" : false
|
||||
}
|
||||
},
|
||||
"mp-lark" : {
|
||||
"uniStatistics" : {
|
||||
"enable" : true
|
||||
"enable" : false
|
||||
}
|
||||
},
|
||||
"quickapp-webview-huawei" : {
|
||||
"uniStatistics" : {
|
||||
"enable" : true
|
||||
"enable" : false
|
||||
}
|
||||
},
|
||||
"quickapp-webview-union" : {
|
||||
"uniStatistics" : {
|
||||
"enable" : true
|
||||
"enable" : false
|
||||
}
|
||||
},
|
||||
"app-harmony" : {
|
||||
"uniStatistics" : {
|
||||
"enable" : false
|
||||
}
|
||||
},
|
||||
"mp-harmony" : {
|
||||
"uniStatistics" : {
|
||||
"enable" : false
|
||||
}
|
||||
},
|
||||
"mp-xhs" : {
|
||||
"uniStatistics" : {
|
||||
"enable" : false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "uni-halo",
|
||||
"version": "1.0.0",
|
||||
"version": "2.0.8",
|
||||
"description": "<p align=\"center\">\r <img alt=\"logo\" src=\"https://b.925i.cn/uni_halo/uni_halo_logo.png\" width=\"120\" height=\"120\" style=\"margin-bottom: 10px;\">\r </p>\r <h3 align=\"center\" style=\"margin: 30px 0 30px;font-weight: bold;font-size:40px;\">uni-halo</h3>\r <h3 align=\"center\">uni-halo 基于Halo一款现代化的开源博客/CMS系统API开发的可多端编译应用</h3>",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
+39
@@ -266,6 +266,45 @@
|
||||
"navigationBarTitleText": "友链提交",
|
||||
"enablePullDownRefresh": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "moment-detail/moment-detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "瞬间详情",
|
||||
"enablePullDownRefresh": true,
|
||||
"app-plus": {
|
||||
"pullToRefresh": {
|
||||
"color": "#03a9f4",
|
||||
"style": "circle"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "votes/votes",
|
||||
"style": {
|
||||
"navigationBarTitleText": "投票列表",
|
||||
"enablePullDownRefresh": true,
|
||||
"app-plus": {
|
||||
"pullToRefresh": {
|
||||
"color": "#03a9f4",
|
||||
"style": "circle"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "vote-detail/vote-detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "投票详情",
|
||||
"enablePullDownRefresh": true,
|
||||
"app-plus": {
|
||||
"pullToRefresh": {
|
||||
"color": "#03a9f4",
|
||||
"style": "circle"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
+58
-8
@@ -1,18 +1,39 @@
|
||||
<template>
|
||||
<view class="app-page"></view>
|
||||
<view class="app-page flex flex-center">
|
||||
<PluginUnavailable v-if="!uniHaloPluginAvailable" :pluginId="uniHaloPluginId"
|
||||
:error-text="uniHaloPluginAvailableError" :use-border="false" :use-decoration="false" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
const homePagePath = '/pages/tabbar/home/home'
|
||||
const startPagePath = '/pagesA/start/start'
|
||||
const articleDetailPath = '/pagesA/article-detail/article-detail';
|
||||
export default {
|
||||
import pluginAvailableMixin from "@/common/mixins/pluginAvailable.js"
|
||||
import PluginUnavailable from '@/components/plugin-unavailable/plugin-unavailable.vue'
|
||||
|
||||
const homePagePath = '/pages/tabbar/home/home'
|
||||
const startPagePath = '/pagesA/start/start'
|
||||
const articleDetailPath = '/pagesA/article-detail/article-detail';
|
||||
|
||||
const _DEV_ = false
|
||||
const _DEV_TO_TYPE_ = "page"
|
||||
const _DEV_TO_PATH_ = "/pagesA/article-detail/article-detail?name=077efb85-3544-4307-b24c-537a9e53f116"
|
||||
|
||||
export default {
|
||||
mixins: [pluginAvailableMixin],
|
||||
components: {
|
||||
PluginUnavailable
|
||||
},
|
||||
computed: {
|
||||
configs() {
|
||||
return this.$tm.vx.getters().getConfigs;
|
||||
}
|
||||
},
|
||||
onLoad: function (options) {
|
||||
async onLoad(options) {
|
||||
// 检查插件
|
||||
this.setPluginId(this.NeedPluginIds.PluginUniHalo)
|
||||
this.setPluginError("阿偶,检测到当前插件没有安装或者启用,无法启动 uni-halo 哦,请联系管理员")
|
||||
if (!await this.checkPluginAvailable()) return
|
||||
|
||||
// 获取配置
|
||||
uni.$tm.vx.actions('config/fetchConfigs').then(async (res) => {
|
||||
if (options.scene) {
|
||||
if ('' !== options.scene) {
|
||||
@@ -31,8 +52,16 @@ export default {
|
||||
// #endif
|
||||
|
||||
// 获取mockjson
|
||||
if (res.basicConfig.auditModeEnabled) {
|
||||
if (res.auditConfig.auditModeEnabled) {
|
||||
if (res.auditConfig.auditModeData.jsonUrl) {
|
||||
await uni.$tm.vx.actions('config/fetchMockJson')
|
||||
} else {
|
||||
const mockJson = uni.$utils.checkJsonAndParse(res.auditConfig.auditModeData
|
||||
.jsonData)
|
||||
if (mockJson.ok) {
|
||||
uni.$tm.vx.commit('config/setMockJson', mockJson.jsonData)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 进入检查
|
||||
@@ -45,6 +74,20 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
fnCheckShowStarted() {
|
||||
// 本地开发,快速跳转页面,发布请设置 _DEV_ = false
|
||||
if (_DEV_ && _DEV_TO_PATH_) {
|
||||
if (_DEV_TO_TYPE_ == 'tabbar') {
|
||||
uni.switchTab({
|
||||
url: _DEV_TO_PATH_
|
||||
});
|
||||
} else if (_DEV_TO_TYPE_ == 'page') {
|
||||
uni.navigateTo({
|
||||
url: _DEV_TO_PATH_
|
||||
});
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if (!this.configs.appConfig.startConfig.enabled) {
|
||||
uni.switchTab({
|
||||
url: homePagePath
|
||||
@@ -82,5 +125,12 @@ export default {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.app-page {
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
}
|
||||
</style>
|
||||
@@ -84,21 +84,30 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {checkHasAdminLogin} from '@/utils/auth.js';
|
||||
import CheckAppUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update';
|
||||
import {CheckWxUpdate} from '@/utils/update.js';
|
||||
import {
|
||||
checkHasAdminLogin
|
||||
} from '@/utils/auth.js';
|
||||
import CheckAppUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update';
|
||||
import {
|
||||
CheckWxUpdate
|
||||
} from '@/utils/update.js';
|
||||
import {
|
||||
NeedPluginIds,
|
||||
NeedPlugins,
|
||||
checkNeedPluginAvailable
|
||||
} from "@/utils/plugin.js"
|
||||
|
||||
import tmGrouplist from '@/tm-vuetify/components/tm-grouplist/tm-grouplist.vue';
|
||||
import tmListitem from '@/tm-vuetify/components/tm-listitem/tm-listitem.vue';
|
||||
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
|
||||
import tmPoup from '@/tm-vuetify/components/tm-poup/tm-poup.vue';
|
||||
import tmMore from '@/tm-vuetify/components/tm-more/tm-more.vue';
|
||||
import tmFlop from '@/tm-vuetify/components/tm-flop/tm-flop.vue';
|
||||
import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
|
||||
import tmIcons from '@/tm-vuetify/components/tm-icons/tm-icons.vue';
|
||||
import wave from '@/components/wave/wave.vue';
|
||||
import tmGrouplist from '@/tm-vuetify/components/tm-grouplist/tm-grouplist.vue';
|
||||
import tmListitem from '@/tm-vuetify/components/tm-listitem/tm-listitem.vue';
|
||||
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
|
||||
import tmPoup from '@/tm-vuetify/components/tm-poup/tm-poup.vue';
|
||||
import tmMore from '@/tm-vuetify/components/tm-more/tm-more.vue';
|
||||
import tmFlop from '@/tm-vuetify/components/tm-flop/tm-flop.vue';
|
||||
import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
|
||||
import tmIcons from '@/tm-vuetify/components/tm-icons/tm-icons.vue';
|
||||
import wave from '@/components/wave/wave.vue';
|
||||
|
||||
export default {
|
||||
export default {
|
||||
components: {
|
||||
tmGrouplist,
|
||||
tmListitem,
|
||||
@@ -152,7 +161,10 @@ export default {
|
||||
},
|
||||
copyrightConfig() {
|
||||
return this.haloConfigs.basicConfig.copyrightConfig;
|
||||
}
|
||||
},
|
||||
calcAuditModeEnabled() {
|
||||
return this.haloConfigs.auditConfig.auditModeEnabled
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
haloConfigs: {
|
||||
@@ -171,19 +183,18 @@ export default {
|
||||
this.fnGetData();
|
||||
},
|
||||
methods: {
|
||||
fnGetNavList() {
|
||||
async fnGetNavList() {
|
||||
const systemInfo = uni.getSystemInfoSync();
|
||||
let _isWx = false;
|
||||
// #ifdef MP-WEIXIN
|
||||
_isWx = true;
|
||||
// #endif
|
||||
this.navList = [
|
||||
{
|
||||
this.navList = [{
|
||||
key: 'archives',
|
||||
title: this.haloConfigs.basicConfig.auditModeEnabled ? '内容归档' : '文章归档',
|
||||
title: this.calcAuditModeEnabled ? '内容归档' : '文章归档',
|
||||
leftIcon: 'halocoloricon-classify',
|
||||
leftIconColor: 'red',
|
||||
rightText: this.haloConfigs.basicConfig.auditModeEnabled ? '已归档的内容' : '已归档的文章',
|
||||
rightText: this.calcAuditModeEnabled ? '已归档的内容' : '已归档的文章',
|
||||
path: '/pagesA/archives/archives',
|
||||
isAdmin: false,
|
||||
type: 'page',
|
||||
@@ -198,6 +209,16 @@ export default {
|
||||
isAdmin: false,
|
||||
type: 'page',
|
||||
show: this.haloConfigs.loveConfig.loveEnabled
|
||||
}, {
|
||||
key: 'vote',
|
||||
title: '投票中心',
|
||||
leftIcon: 'icon-box',
|
||||
leftIconColor: 'red',
|
||||
rightText: '查看当前的投票',
|
||||
path: '/pagesA/votes/votes',
|
||||
isAdmin: false,
|
||||
type: 'page',
|
||||
show: !this.calcAuditModeEnabled
|
||||
}, {
|
||||
key: 'disclaimers',
|
||||
title: '友情链接',
|
||||
@@ -338,8 +359,7 @@ export default {
|
||||
url: '/pagesB/login/login'
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
});
|
||||
.catch(err => {});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -360,8 +380,7 @@ export default {
|
||||
this.navList.find(x => x.key == 'cache').rightText =
|
||||
uni.getStorageInfoSync().currentSize + 'KB';
|
||||
})
|
||||
.catch(err => {
|
||||
});
|
||||
.catch(err => {});
|
||||
break;
|
||||
case 'update':
|
||||
// #ifdef APP-PLUS
|
||||
@@ -396,7 +415,7 @@ export default {
|
||||
url: '/pagesC/website/website?data=' +
|
||||
JSON.stringify({
|
||||
title: item.text || this.$haloConfig.title,
|
||||
url: item.path
|
||||
url: encodeURIComponent(item.path)
|
||||
})
|
||||
});
|
||||
return;
|
||||
@@ -420,16 +439,16 @@ export default {
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.app-page {
|
||||
.app-page {
|
||||
width: 100vw;
|
||||
min-height: 100vh;
|
||||
}
|
||||
}
|
||||
|
||||
.blogger-info {
|
||||
.blogger-info {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 600rpx;
|
||||
@@ -476,9 +495,9 @@ export default {
|
||||
mix-blend-mode: screen;
|
||||
height: 100rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.profile-card {
|
||||
.profile-card {
|
||||
position: relative;
|
||||
background-color: #fff;
|
||||
overflow: hidden;
|
||||
@@ -514,20 +533,20 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
.photos-img + .photos-img {
|
||||
.photos-img+.photos-img {
|
||||
margin-left: 12rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.statistics-wrap {
|
||||
.statistics-wrap {
|
||||
box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.03);
|
||||
border-radius: 0rpx 0rpx 24rpx 24rpx;
|
||||
overflow: hidden;
|
||||
|
||||
.statistics {
|
||||
&.has-solid {
|
||||
.item + .item {
|
||||
.item+.item {
|
||||
border-left: 2rpx solid #fafafa;
|
||||
}
|
||||
}
|
||||
@@ -546,9 +565,9 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.quick-nav {
|
||||
.quick-nav {
|
||||
background-color: #fff;
|
||||
box-sizing: border-box;
|
||||
box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.03);
|
||||
@@ -561,18 +580,18 @@ export default {
|
||||
border-radius: 50%;
|
||||
font-size: 80rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.nav-wrap {
|
||||
.nav-wrap {
|
||||
box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.03);
|
||||
background-color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
.copyright {
|
||||
.copyright {
|
||||
color: #c0c4c7;
|
||||
}
|
||||
}
|
||||
|
||||
.right-value-btn {
|
||||
.right-value-btn {
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
padding: 0;
|
||||
@@ -587,5 +606,5 @@ export default {
|
||||
border-radius: 0;
|
||||
transform: initial;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,37 +1,67 @@
|
||||
<template>
|
||||
<view class="app-page">
|
||||
|
||||
<view class="app-page" :style="{
|
||||
padding:calcShowType==='list-post'? 0 : '24rpx 0'
|
||||
}">
|
||||
<view v-if="loading !== 'success'" class="loading-wrap">
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
</view>
|
||||
<!-- 内容区域 -->
|
||||
<view v-else class="app-page-content">
|
||||
<view v-else class="app-page-content" :class="[calcShowType==='list-post'?'list-post':'']">
|
||||
<view v-if="dataList.length === 0" class="content-empty flex flex-center" style="height: 70vh;">
|
||||
<!-- 空布局 -->
|
||||
<tm-empty icon="icon-shiliangzhinengduixiang-" label="暂无数据"></tm-empty>
|
||||
</view>
|
||||
<block v-else>
|
||||
<block v-if="calcAuditModeEnabled || calcShowType==='list'">
|
||||
<tm-translate v-for="(item, index) in dataList" :key="index"
|
||||
style="box-sizing: border-box;width: 50%;padding: 0 8rpx;" animation-name="fadeUp"
|
||||
:wait="calcAniWait(index)">
|
||||
<view class="catgory-card" :style="{backgroundImage:`url(${item.spec.cover})`}">
|
||||
<view class="content" @click="handleToCategory(item)">
|
||||
<view style="font-size: 32rpx;color: #ffffff;">{{ item.spec.displayName }}</view>
|
||||
<view v-if="!haloConfigs.basicConfig.auditModeEnabled" style="font-size: 24rpx;color: #ffffff;margin-top: 6rpx;">
|
||||
<view v-if="!calcAuditModeEnabled"
|
||||
style="font-size: 24rpx;color: #ffffff;margin-top: 6rpx;">
|
||||
共 {{ item.postCount }} 篇文章
|
||||
</view>
|
||||
<view v-else style="font-size: 24rpx;color: #ffffff;margin-top: 6rpx;">
|
||||
共 {{ item.postCount }} 篇内容
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</tm-translate>
|
||||
<tm-flotbutton @click="fnToTopPage" size="m" color="light-blue"
|
||||
icon="icon-angle-up"></tm-flotbutton>
|
||||
<view class="load-text">{{ loadMoreText }}</view>
|
||||
</block>
|
||||
<view v-else-if="calcShowType==='list-post'" class="fulled flex" style="min-height:100vh">
|
||||
<view class="bg-white" :style="{height: '100%'}">
|
||||
<tm-sliderNav :list="categoryList" bg-color="white" color="light-blue" rang-key="displayName"
|
||||
@change="fnOnCategoryChange"></tm-sliderNav>
|
||||
</view>
|
||||
<scroll-view class="right-content pt-12 pb-12" :scroll-y="true" :scroll-top="scrollTop"
|
||||
:scroll-with-animation="true" :refresher-enabled="true" :refresher-triggered="triggered"
|
||||
:refresher-threshold="60" refresher-background="#fafafa"
|
||||
@refresherrefresh="fnGetPostByCategory(true)" @scrolltolower="fnGetPostByCategory(false)"
|
||||
@scroll="fnOnScroll" @touchmove.stop @touchstart="fnOnTouchStart" @touchend="fnOnTouchEnd"
|
||||
@touchcancel="fnOnTouchEnd">
|
||||
<view v-if="postList.length === 0" class="article-empty flex flex-center">
|
||||
<tm-empty :size="120" icon="icon-shiliangzhinengduixiang-" label="该分类下暂无文章~"></tm-empty>
|
||||
</view>
|
||||
<block v-else>
|
||||
<block v-for="(post, index) in postList" :key="post.spec.publishTime">
|
||||
<tm-translate animation-name="fadeUp" :wait="calcAniWait(index)">
|
||||
<article-min-card :article="post" @on-click="fnToArticleDetail"></article-min-card>
|
||||
</tm-translate>
|
||||
</block>
|
||||
<view class="load-text">{{ loadMoreText }}</view>
|
||||
</block>
|
||||
</scroll-view>
|
||||
</view>
|
||||
|
||||
<view class="flot-buttons">
|
||||
<tm-button @click="fnScrollTop" size="m" :fab="true" theme="light-blue"
|
||||
icon="icon-angle-up"></tm-button>
|
||||
<tm-button v-if="!calcAuditModeEnabled" @click="fnChangeShowType" size="m" :fab="true" theme="light-blue"
|
||||
:icon="calcShowType==='list'?'icon-align-left':'icon-all'"></tm-button>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
@@ -39,20 +69,27 @@
|
||||
|
||||
<script>
|
||||
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
|
||||
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
|
||||
import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
|
||||
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
|
||||
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
|
||||
|
||||
import MarkdownConfig from '@/common/markdown/markdown.config.js';
|
||||
import mpHtml from '@/components/mp-html/components/mp-html/mp-html.vue';
|
||||
import tmFlowLayout from '@/tm-vuetify/components/tm-flowLayout/tm-flowLayout.vue';
|
||||
import tmSliderNav from '@/tm-vuetify/components/tm-sliderNav/tm-sliderNav.vue';
|
||||
import ArticleMinCard from '@/components/article-min-card/article-min-card.vue';
|
||||
|
||||
|
||||
export default {
|
||||
components: {
|
||||
tmSkeleton,
|
||||
tmFlotbutton,
|
||||
tmButton,
|
||||
tmTranslate,
|
||||
tmEmpty,
|
||||
mpHtml
|
||||
mpHtml,
|
||||
tmFlowLayout,
|
||||
tmSliderNav,
|
||||
ArticleMinCard
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -60,33 +97,65 @@ export default {
|
||||
loading: 'loading',
|
||||
queryParams: {
|
||||
size: 20,
|
||||
page: 1
|
||||
page: 1,
|
||||
fieldSelector: ['spec.hideFromList=false']
|
||||
},
|
||||
hasNext: false,
|
||||
dataList: [],
|
||||
categoryList: [],
|
||||
isLoadMore: false,
|
||||
loadMoreText: '加载中...'
|
||||
loadMoreText: '加载中...',
|
||||
currentCategoryConfig: {
|
||||
type: "list"
|
||||
},
|
||||
currentCategoryName: "",
|
||||
postQueryParams: {
|
||||
size: 10,
|
||||
page: 0,
|
||||
},
|
||||
postList: [],
|
||||
triggered: false,
|
||||
scrollTop: 0,
|
||||
tempScrollTop: 0,
|
||||
scrollTimeout: null,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
haloConfigs() {
|
||||
return this.$tm.vx.getters().getConfigs;
|
||||
},
|
||||
calcAuditModeEnabled() {
|
||||
return this.haloConfigs.auditConfig.auditModeEnabled
|
||||
},
|
||||
mockJson() {
|
||||
return this.$tm.vx.getters().getMockJson;
|
||||
},
|
||||
categoryConfig() {
|
||||
return this.haloConfigs.pageConfig.categoryConfig
|
||||
},
|
||||
calcShowType() {
|
||||
return this.currentCategoryConfig.type
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.fnGetData();
|
||||
watch: {
|
||||
categoryConfig: {
|
||||
deep: true,
|
||||
immediate: true,
|
||||
handler(newVal) {
|
||||
console.log("执行了", newVal)
|
||||
if (!newVal) return;
|
||||
this.currentCategoryConfig = newVal
|
||||
this.handleInitPage()
|
||||
},
|
||||
}
|
||||
},
|
||||
onPullDownRefresh() {
|
||||
this.isLoadMore = false;
|
||||
this.queryParams.page = 0;
|
||||
this.fnGetData();
|
||||
},
|
||||
|
||||
onReachBottom(e) {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '没有更多数据了'
|
||||
@@ -94,7 +163,12 @@ export default {
|
||||
return
|
||||
}
|
||||
if (this.hasNext) {
|
||||
if (this.calcShowType === 'list') {
|
||||
|
||||
this.queryParams.page += 1;
|
||||
} else {
|
||||
this.postQueryParams.page += 1;
|
||||
}
|
||||
this.isLoadMore = true;
|
||||
this.fnGetData();
|
||||
} else {
|
||||
@@ -105,8 +179,37 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
fnChangeShowType() {
|
||||
if (this.calcShowType === 'list-post') {
|
||||
this.currentCategoryConfig.type = 'list'
|
||||
} else {
|
||||
this.currentCategoryConfig.type = 'list-post'
|
||||
}
|
||||
this.handleInitPage();
|
||||
},
|
||||
handleResetInit() {
|
||||
this.postList = []
|
||||
this.dataList = []
|
||||
this.categoryList = []
|
||||
this.queryParams.page = 0;
|
||||
this.postQueryParams.page = 0;
|
||||
this.hasNext = false
|
||||
this.isLoadMore = false
|
||||
this.loadMoreText = '加载中...'
|
||||
this.currentCategoryName = ""
|
||||
this.triggered = false
|
||||
this.fnResetSetAniWaitIndex()
|
||||
},
|
||||
handleInitPage() {
|
||||
this.handleResetInit()
|
||||
if (this.calcShowType === 'list-post') {
|
||||
this.queryParams.size = 99999
|
||||
}
|
||||
this.fnGetData();
|
||||
},
|
||||
fnGetData() {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
this.categoryConfig.type = "list"
|
||||
this.dataList = this.mockJson.category.list.map((item) => {
|
||||
return {
|
||||
metadata: {
|
||||
@@ -139,7 +242,7 @@ export default {
|
||||
.then(res => {
|
||||
console.log('请求结果:');
|
||||
console.log(res);
|
||||
|
||||
if (this.calcShowType === 'list') {
|
||||
this.loading = 'success';
|
||||
this.loadMoreText = res.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
|
||||
// 处理数据
|
||||
@@ -155,6 +258,22 @@ export default {
|
||||
} else {
|
||||
this.dataList = tempItems;
|
||||
}
|
||||
} else {
|
||||
this.dataList = res.items
|
||||
this.categoryList = res.items.map(item => {
|
||||
return {
|
||||
displayName: item.spec.displayName,
|
||||
name: item.metadata.name,
|
||||
...item,
|
||||
}
|
||||
})
|
||||
this.triggered = false;
|
||||
this.loading = 'success';
|
||||
if (this.dataList.length !== 0) {
|
||||
this.currentCategoryName = this.dataList[0].metadata.name;
|
||||
this.fnGetPostByCategory()
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
@@ -175,12 +294,90 @@ export default {
|
||||
})
|
||||
},
|
||||
handleToCategory(data) {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
return;
|
||||
}
|
||||
uni.navigateTo({
|
||||
url: `/pagesA/category-detail/category-detail?name=${data.metadata.name}&title=${data.spec.displayName}`
|
||||
})
|
||||
},
|
||||
fnGetPostByCategory(isPulldownRefresh = true, triggered = true) {
|
||||
if (!isPulldownRefresh) {
|
||||
if (this.hasNext) {
|
||||
this.postQueryParams.page += 1;
|
||||
} else {
|
||||
return uni.showToast({
|
||||
icon: 'none',
|
||||
title: '没有更多数据了'
|
||||
});
|
||||
}
|
||||
} else {
|
||||
this.postQueryParams.page = 0;
|
||||
if (triggered) {
|
||||
this.triggered = true;
|
||||
}
|
||||
}
|
||||
|
||||
this.$httpApi.v2
|
||||
.getCategoryPostList(this.currentCategoryName, this.postQueryParams)
|
||||
.then(res => {
|
||||
this.hasNext = res.hasNext;
|
||||
|
||||
if (!isPulldownRefresh) {
|
||||
this.postList = this.postList.concat(res.items);
|
||||
} else {
|
||||
this.postList = res.items;
|
||||
}
|
||||
this.loadMoreText = res.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
|
||||
})
|
||||
.catch(err => {
|
||||
this.loadMoreText = '加载失败!';
|
||||
})
|
||||
.finally(() => {
|
||||
this.triggered = false;
|
||||
});
|
||||
},
|
||||
|
||||
fnOnCategoryChange(e) {
|
||||
this.fnResetSetAniWaitIndex();
|
||||
this.currentCategoryName = this.dataList[e].metadata.name;
|
||||
this.fnToTopScroll();
|
||||
this.postList = [];
|
||||
this.fnGetPostByCategory();
|
||||
},
|
||||
|
||||
fnOnScroll(e) {
|
||||
this.tempScrollTop = e.detail.scrollTop;
|
||||
},
|
||||
fnToTopScroll() {
|
||||
uni.pageScrollTo({
|
||||
scrollTop: 0,
|
||||
duration: 500
|
||||
});
|
||||
this.scrollTop = 0;
|
||||
this.tempScrollTop = 0;
|
||||
},
|
||||
fnOnTouchStart() {
|
||||
clearTimeout(this.scrollTimeout);
|
||||
},
|
||||
fnOnTouchEnd() {
|
||||
this.scrollTimeout = setTimeout(() => {
|
||||
this.scrollTop = this.tempScrollTop;
|
||||
}, 500);
|
||||
},
|
||||
//跳转文章详情
|
||||
fnToArticleDetail(post) {
|
||||
uni.navigateTo({
|
||||
url: '/pagesA/article-detail/article-detail?name=' + post.metadata.name,
|
||||
animationType: 'slide-in-right'
|
||||
});
|
||||
},
|
||||
fnScrollTop() {
|
||||
if (this.calcShowType === 'list') {
|
||||
this.fnToTopPage()
|
||||
} else {
|
||||
this.fnToTopScroll()
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -212,8 +409,14 @@ export default {
|
||||
flex-wrap: wrap;
|
||||
padding: 0 12rpx;
|
||||
gap: 20rpx 0;
|
||||
|
||||
&.list-post {
|
||||
padding: 0;
|
||||
gap: 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.catgory-card {
|
||||
width: 100%;
|
||||
height: 200rpx;
|
||||
@@ -236,6 +439,7 @@ export default {
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: rgba(0, 0, 0, 0.15);
|
||||
backdrop-filter: blur(3rpx);
|
||||
z-index: 1;
|
||||
}
|
||||
}
|
||||
@@ -255,4 +459,14 @@ export default {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.flot-buttons {
|
||||
position: fixed;
|
||||
bottom: 100rpx;
|
||||
right: 32rpx;
|
||||
flex-direction: column;
|
||||
display: flex;
|
||||
gap: 6rpx;
|
||||
z-index: 999;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,21 +1,30 @@
|
||||
<template>
|
||||
<view class="app-page">
|
||||
<view class="app-page" :class="[uniHaloPluginPageClass]">
|
||||
<PluginUnavailable v-if="!uniHaloPluginAvailable" :pluginId="uniHaloPluginId"
|
||||
:error-text="uniHaloPluginAvailableError" />
|
||||
<template v-else>
|
||||
<!-- 顶部切换 -->
|
||||
<view class="e-fixed" v-if="category.list.length > 0">
|
||||
<tm-tabs color="light-blue" v-model="category.activeIndex" range-key="displayName" :list="category.list"
|
||||
align="left" @change="fnOnCategoryChange"></tm-tabs>
|
||||
<tm-tabs color="light-blue" :shadow="0" v-model="category.activeIndex" range-key="displayName"
|
||||
:list="category.list" align="left" @change="fnOnCategoryChange($event, false)"></tm-tabs>
|
||||
</view>
|
||||
<!-- 占位区域 -->
|
||||
<view v-if="category.list.length > 0" style="width: 100vw;height: 90rpx;"></view>
|
||||
<!-- 加载区域 -->
|
||||
<view v-if="loading !== 'success'" class="loading-wrap">
|
||||
<view v-if="loading == 'loading'" class="loading-wrap">
|
||||
<tm-skeleton model="card"></tm-skeleton>
|
||||
<tm-skeleton model="card"></tm-skeleton>
|
||||
<tm-skeleton model="card"></tm-skeleton>
|
||||
<tm-skeleton model="card"></tm-skeleton>
|
||||
</view>
|
||||
<view v-else-if="loading == 'error'" class="flex flex-col flex-center" style="width:100%;height:60vh;">
|
||||
<tm-empty icon="icon-wind-cry" label="阿偶,似乎获取数据失败了~">
|
||||
<tm-button theme="light-blue" size="m" :shadow="0" @click="fnGetData(true)">刷新试试</tm-button>
|
||||
</tm-empty>
|
||||
</view>
|
||||
<!-- 内容区域 -->
|
||||
<view class="content" v-else>
|
||||
<view v-else class="content">
|
||||
<k-touch-listen class="touch-listen-content" @touchLeft="touchLeft" @touchRight="touchRight">
|
||||
<view v-if="dataList.length === 0" class="content-empty">
|
||||
<!-- 空布局 -->
|
||||
<tm-empty icon="icon-shiliangzhinengduixiang-" label="博主还没有分享图片~"></tm-empty>
|
||||
@@ -23,7 +32,8 @@
|
||||
<block v-else>
|
||||
<block v-if="galleryConfig.useWaterfall">
|
||||
<!--瀑布流-->
|
||||
<tm-flowLayout-custom ref="wafll" style="width: 100%;" @click="fnOnFlowClick"></tm-flowLayout-custom>
|
||||
<tm-flowLayout-custom ref="wafll" style="width: 100%;"
|
||||
@click="fnOnFlowClick"></tm-flowLayout-custom>
|
||||
</block>
|
||||
<!-- 列表 -->
|
||||
<block v-else>
|
||||
@@ -32,34 +42,45 @@
|
||||
animation-name="fadeUp" :wait="calcAniWait(index)">
|
||||
<view style="border-radius: 12rpx;overflow: hidden;width: 100%;height: 250rpx;">
|
||||
<image style="width: 100%;height: 100%;" mode="aspectFill" :src="item.spec.url"
|
||||
@click="fnPreview(item)"/>
|
||||
@click="fnPreview(item)" />
|
||||
</view>
|
||||
</tm-translate>
|
||||
</block>
|
||||
|
||||
<tm-flotbutton @click="fnToTopPage" color="light-blue" size="m" icon="icon-angle-up"></tm-flotbutton>
|
||||
<view class="load-text">{{ loadMoreText }}</view>
|
||||
</block>
|
||||
|
||||
</k-touch-listen>
|
||||
</view>
|
||||
|
||||
<view v-if="!calcAuditModeEnabled" class="flot-buttons">
|
||||
<tm-button v-if="loading == 'error'" @click="fnGetCategory" size="m" :fab="true" theme="light-blue"
|
||||
icon="icon-sync-alt"></tm-button>
|
||||
<tm-button @click="fnToTopPage" size="m" :fab="true" theme="light-blue"
|
||||
icon="icon-angle-up"></tm-button>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
|
||||
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
|
||||
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
|
||||
import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue';
|
||||
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
|
||||
import tmIcons from '@/tm-vuetify/components/tm-icons/tm-icons.vue';
|
||||
import tmImages from '@/tm-vuetify/components/tm-images/tm-images.vue';
|
||||
import tmFlowLayoutCustom from '@/tm-vuetify/components/tm-flowLayout-custom/tm-flowLayout-custom.vue';
|
||||
import tmTabs from '@/tm-vuetify/components/tm-tabs/tm-tabs.vue';
|
||||
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
|
||||
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
|
||||
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
|
||||
import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue';
|
||||
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
|
||||
import tmIcons from '@/tm-vuetify/components/tm-icons/tm-icons.vue';
|
||||
import tmImages from '@/tm-vuetify/components/tm-images/tm-images.vue';
|
||||
import tmFlowLayoutCustom from '@/tm-vuetify/components/tm-flowLayout-custom/tm-flowLayout-custom.vue';
|
||||
import tmTabs from '@/tm-vuetify/components/tm-tabs/tm-tabs.vue';
|
||||
import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
|
||||
|
||||
export default {
|
||||
import pluginAvailable from "@/common/mixins/pluginAvailable.js"
|
||||
import PluginUnavailable from '@/components/plugin-unavailable/plugin-unavailable.vue'
|
||||
export default {
|
||||
options: {
|
||||
multipleSlots: true
|
||||
},
|
||||
mixins: [pluginAvailable],
|
||||
components: {
|
||||
tmSkeleton,
|
||||
tmTranslate,
|
||||
@@ -69,7 +90,9 @@ export default {
|
||||
tmIcons,
|
||||
tmImages,
|
||||
tmFlowLayoutCustom,
|
||||
tmTabs
|
||||
tmTabs,
|
||||
tmButton,
|
||||
PluginUnavailable
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -88,7 +111,8 @@ export default {
|
||||
isLoadMore: false,
|
||||
loadMoreText: '',
|
||||
hasNext: false,
|
||||
dataList: []
|
||||
dataList: [],
|
||||
lock: false
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -100,11 +124,14 @@ export default {
|
||||
},
|
||||
mockJson() {
|
||||
return this.$tm.vx.getters().getMockJson;
|
||||
}
|
||||
},
|
||||
calcAuditModeEnabled() {
|
||||
return this.haloConfigs.auditConfig.auditModeEnabled
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
galleryConfig: {
|
||||
handler(newValue, oldValue) {
|
||||
async handler(newValue, oldValue) {
|
||||
if (!newValue) return;
|
||||
this.fnSetPageTitle(newValue.pageTitle);
|
||||
this.fnGetCategory();
|
||||
@@ -113,20 +140,33 @@ export default {
|
||||
immediate: true
|
||||
}
|
||||
},
|
||||
async onLoad() {
|
||||
// 检查插件
|
||||
this.setPluginId(this.NeedPluginIds.PluginPhotos)
|
||||
this.setPluginError("阿偶,检测到当前插件没有安装或者启用,无法使用图库功能哦,请联系管理员")
|
||||
await this.checkPluginAvailable()
|
||||
},
|
||||
onPullDownRefresh() {
|
||||
if (!this.uniHaloPluginAvailable) {
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
return
|
||||
}
|
||||
this.dataList = []
|
||||
this.isLoadMore = false;
|
||||
this.queryParams.page = 1;
|
||||
this.fnGetData(true);
|
||||
},
|
||||
onReachBottom(e) {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
if (!this.uniHaloPluginAvailable) return;
|
||||
if (this.calcAuditModeEnabled) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '没有更多数据了'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.hasNext) {
|
||||
this.queryParams.page += 1;
|
||||
this.isLoadMore = true;
|
||||
@@ -139,7 +179,7 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
fnOnCategoryChange(index) {
|
||||
fnGetDataByCategory(index) {
|
||||
this.fnResetSetAniWaitIndex();
|
||||
this.queryParams.group = this.category.list[index].name;
|
||||
this.queryParams.page = 1;
|
||||
@@ -147,8 +187,18 @@ export default {
|
||||
this.dataList = [];
|
||||
this.fnGetData(true);
|
||||
},
|
||||
fnOnCategoryChange(index) {
|
||||
if (this.lock) {
|
||||
// uni.showToast({
|
||||
// title: "上一个请求进行中...",
|
||||
// icon: "none"
|
||||
// })
|
||||
return;
|
||||
}
|
||||
this.fnGetDataByCategory(index)
|
||||
},
|
||||
fnGetCategory() {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
this.fnGetData(true);
|
||||
return
|
||||
}
|
||||
@@ -159,17 +209,24 @@ export default {
|
||||
this.category.list = res.items.map(item => {
|
||||
return {
|
||||
name: item.metadata.name,
|
||||
displayName: item.spec.displayName
|
||||
displayName: item.spec.displayName,
|
||||
priority: item.spec.priority
|
||||
}
|
||||
});
|
||||
}).sort((a, b) => a.priority - b.priority);
|
||||
|
||||
if (this.category.list.length !== 0) {
|
||||
this.queryParams.group = this.category.list[0].name;
|
||||
this.fnGetData(true);
|
||||
}
|
||||
}).catch(e => {
|
||||
this.loading = 'error'
|
||||
this.category.list = []
|
||||
this.category.activeIndex = 0
|
||||
this.category.activeValue = ""
|
||||
});
|
||||
},
|
||||
fnGetData(isClearWaterfall = false) {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
this.dataList = this.mockJson.gallery.list.map(item => {
|
||||
return {
|
||||
metadata: {
|
||||
@@ -196,6 +253,7 @@ export default {
|
||||
this.loadMoreText = '呜呜,没有更多数据啦~';
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
this.lock = false;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -239,10 +297,13 @@ export default {
|
||||
setTimeout(() => {
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
this.lock = false;
|
||||
}, 500);
|
||||
});
|
||||
},
|
||||
fnOnFlowClick({item}) {
|
||||
fnOnFlowClick({
|
||||
item
|
||||
}) {
|
||||
this.fnPreview(item)
|
||||
},
|
||||
// 预览
|
||||
@@ -253,27 +314,44 @@ export default {
|
||||
indicator: 'number',
|
||||
loop: true
|
||||
});
|
||||
},
|
||||
touchLeft() {
|
||||
if (this.loading != "success") return;
|
||||
this.category.activeIndex += 1
|
||||
if (this.category.activeIndex >= this.category.list.length) {
|
||||
this.category.activeIndex = 0
|
||||
}
|
||||
this.lock = true
|
||||
this.fnGetDataByCategory(this.category.activeIndex)
|
||||
},
|
||||
touchRight() {
|
||||
if (this.loading != "success") return;
|
||||
this.category.activeIndex -= 1
|
||||
if (this.category.activeIndex < 0) {
|
||||
this.category.activeIndex = 0
|
||||
}
|
||||
this.lock = true
|
||||
this.fnGetDataByCategory(this.category.activeIndex)
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.app-page {
|
||||
.app-page {
|
||||
width: 100vw;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding-bottom: 24rpx;
|
||||
background-color: #fafafa;
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
.content {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
box-sizing: border-box;
|
||||
padding: 24rpx 24rpx 0;
|
||||
gap: 12rpx 0;
|
||||
|
||||
.content-empty {
|
||||
width: 100%;
|
||||
@@ -282,15 +360,34 @@ export default {
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.loading-wrap {
|
||||
.touch-listen-content {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
box-sizing: border-box;
|
||||
padding: 24rpx 24rpx 0;
|
||||
gap: 12rpx 0;
|
||||
}
|
||||
|
||||
.loading-wrap {
|
||||
box-sizing: border-box;
|
||||
padding: 24rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.load-text {
|
||||
.load-text {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
.flot-buttons {
|
||||
position: fixed;
|
||||
bottom: 100rpx;
|
||||
right: 32rpx;
|
||||
flex-direction: column;
|
||||
display: flex;
|
||||
gap: 6rpx;
|
||||
z-index: 999;
|
||||
}
|
||||
</style>
|
||||
+260
-76
@@ -2,7 +2,7 @@
|
||||
<view class="app-page">
|
||||
<tm-menubars iconColor="white" color="white" :flat="true" :showback="false">
|
||||
<view slot="left">
|
||||
<image @click="fnOnLogoToPage" class="logo ml-24 round-24" :src="appInfo.logo" mode="scaleToFill"/>
|
||||
<image @click="fnOnLogoToPage" class="logo ml-24 round-24" :src="appInfo.logo" mode="scaleToFill" />
|
||||
</view>
|
||||
<view class="search-input round-12 pt-12 pb-12 flex pl-24" @click="fnToSearch">
|
||||
<text class="search-input_icon iconfont text-size-m icon-search text-grey"></text>
|
||||
@@ -21,22 +21,40 @@
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
</view>
|
||||
<block v-else>
|
||||
<view class="bg-white pb-24">
|
||||
<view v-if="bannerConfig.enabled" class="bg-white pb-24">
|
||||
<view class="banner bg-white ml-24 mr-24 mt-12 round-3" v-if="bannerList.length !== 0">
|
||||
<e-swiper
|
||||
height="400rpx"
|
||||
dotPosition="right"
|
||||
:autoplay="true"
|
||||
:useDot="false"
|
||||
:list="bannerList"
|
||||
@on-click="fnOnBannerClick"
|
||||
/>
|
||||
<e-swiper :height="bannerConfig.height" :dotPosition="bannerConfig.dotPosition" :autoplay="true"
|
||||
:useDot="bannerConfig.showIndicator" :showTitle="bannerConfig.showTitle"
|
||||
:type="bannerConfig.type" :list="bannerList" @on-click="fnOnBannerClick" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 金刚区 :v-if="navList.filter(x=>x.show).length>=4" -->
|
||||
<view :v-if="navList.filter(x=>x.show).length>=4" class="nav-box mt-16 mb-24 pl-24 pr-24 uh-py-12">
|
||||
<view class="page-item_title text-weight-b ">快捷导航</view>
|
||||
<view class="nav-list flex uh-mt-12">
|
||||
<template v-for="(item,index) in navList">
|
||||
<view v-if="item.show" class="nav-item" :key="index" @click="fnClickNav(item)">
|
||||
<!-- :class="[item.bgClass]" -->
|
||||
<view class="nav-item-icon" :style="{
|
||||
'--bgColor':item.bgColor,
|
||||
boxShadow: '0rpx 0rpx 6rpx ' + item.shadow,
|
||||
backgroundColor: item.bgColor
|
||||
}">
|
||||
<tm-icons :size="48" color="white" prefx="halocoloricon" :name="item.icon"></tm-icons>
|
||||
</view>
|
||||
<view class="nav-item-text">
|
||||
{{item.title}}
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 精品分类 -->
|
||||
<block v-if="calcIsShowCategory">
|
||||
<view class="flex flex-between mt-16 mb-24 pl-24 pr-24">
|
||||
<view class="page-item_title text-weight-b ">精品分类</view>
|
||||
<view class="page-item_title text-weight-b ">精选分类</view>
|
||||
<view class="show-more flex flex-center bg-white round-3" @click="fnToCategoryPage">
|
||||
<text class="iconfont icon-angle-right text-size-s text-grey-darken-1"></text>
|
||||
</view>
|
||||
@@ -82,25 +100,32 @@
|
||||
</tm-translate>
|
||||
</view>
|
||||
<view class="load-text mt-12">{{ loadMoreText }}</view>
|
||||
<tm-flotbutton v-if="articleList.length > 10" color="light-blue" @click="fnToTopPage" size="m"
|
||||
icon="icon-angle-up"></tm-flotbutton>
|
||||
<tm-flotbutton v-if="articleList.length > 10" :width="90" color="light-blue" @click="fnToTopPage"
|
||||
size="s" icon="icon-angle-up"></tm-flotbutton>
|
||||
</block>
|
||||
</block>
|
||||
|
||||
|
||||
<!-- 弹窗 -->
|
||||
<NotifyDialog v-if="notify.show" :show="notify.show" :title="notify.data.title" :content="notify.data.content"
|
||||
:url="notify.data.url" @on-change="fnOnNotifyChange"></NotifyDialog>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import tmMenubars from '@/tm-vuetify/components/tm-menubars/tm-menubars.vue';
|
||||
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
|
||||
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
|
||||
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
|
||||
import tmIcons from '@/tm-vuetify/components/tm-icons/tm-icons.vue';
|
||||
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
|
||||
import tmMenubars from '@/tm-vuetify/components/tm-menubars/tm-menubars.vue';
|
||||
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
|
||||
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
|
||||
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
|
||||
import tmIcons from '@/tm-vuetify/components/tm-icons/tm-icons.vue';
|
||||
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
|
||||
import tmGrid from '@/tm-vuetify/components/tm-grid/tm-grid.vue';
|
||||
|
||||
import eSwiper from '@/components/e-swiper/e-swiper.vue';
|
||||
import qs from 'qs'
|
||||
import eSwiper from '@/components/e-swiper/e-swiper.vue';
|
||||
import NotifyDialog from "@/components/notify-dialog/notify-dialog.vue";
|
||||
import qs from 'qs'
|
||||
|
||||
export default {
|
||||
export default {
|
||||
components: {
|
||||
tmMenubars,
|
||||
tmSkeleton,
|
||||
@@ -108,7 +133,9 @@ export default {
|
||||
tmFlotbutton,
|
||||
tmIcons,
|
||||
tmEmpty,
|
||||
eSwiper
|
||||
tmGrid,
|
||||
eSwiper,
|
||||
NotifyDialog
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -126,6 +153,11 @@ export default {
|
||||
noticeList: [],
|
||||
articleList: [],
|
||||
categoryList: [],
|
||||
notify: {
|
||||
show: false,
|
||||
data: {}
|
||||
},
|
||||
navList: []
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -145,14 +177,30 @@ export default {
|
||||
mockJson() {
|
||||
return this.$tm.vx.getters().getMockJson;
|
||||
},
|
||||
calcAuditModeEnabled() {
|
||||
return this.haloConfigs.auditConfig.auditModeEnabled
|
||||
},
|
||||
calcIsShowCategory() {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled && this.categoryList.length !== 0) {
|
||||
if (this.calcAuditModeEnabled && this.categoryList.length !== 0) {
|
||||
return false
|
||||
}
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
return false
|
||||
}
|
||||
return this.haloConfigs.pageConfig.homeConfig.useCategory
|
||||
},
|
||||
bannerConfig() {
|
||||
return this.haloConfigs.pageConfig.homeConfig.bannerConfig
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
haloConfigs: {
|
||||
handler(val) {
|
||||
if (!val) return;
|
||||
this.fnGetNavList();
|
||||
},
|
||||
deep: true,
|
||||
immediate: true,
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
@@ -167,7 +215,7 @@ export default {
|
||||
this.fnQuery();
|
||||
},
|
||||
onReachBottom(e) {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '没有更多数据了'
|
||||
@@ -187,13 +235,12 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
fnQuery() {
|
||||
console.log('this.mockJson', this.mockJson)
|
||||
this.fnGetBanner();
|
||||
this.fnGetArticleList();
|
||||
this.fnGetCategoryList();
|
||||
},
|
||||
fnGetCategoryList() {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
this.categoryList = this.mockJson.home.categoryList.map((item) => {
|
||||
return {
|
||||
metadata: {
|
||||
@@ -215,7 +262,7 @@ export default {
|
||||
|
||||
this.$httpApi.v2
|
||||
.getCategoryList({
|
||||
fieldSelector:['spec.hideFromList==false']
|
||||
fieldSelector: ['spec.hideFromList=false']
|
||||
})
|
||||
.then(res => {
|
||||
this.categoryList = res.items.sort((a, b) => {
|
||||
@@ -239,7 +286,7 @@ export default {
|
||||
},
|
||||
// 获取轮播图
|
||||
fnGetBanner() {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
this.bannerList = this.mockJson.home.bannerList.map((item) => {
|
||||
return {
|
||||
mp4: '',
|
||||
@@ -250,27 +297,37 @@ export default {
|
||||
createTime: item.time,
|
||||
title: item.title,
|
||||
src: this.$utils.checkThumbnailUrl(item.cover),
|
||||
image: this.$utils.checkThumbnailUrl(item.cover)
|
||||
image: this.$utils.checkThumbnailUrl(item.cover),
|
||||
type: "custom",
|
||||
content: "",
|
||||
url: ""
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
const _this = this;
|
||||
const _format = function (list) {
|
||||
return list.map((item, index) => {
|
||||
|
||||
|
||||
if (!this.bannerConfig.enabled) return;
|
||||
|
||||
if (this.bannerConfig.type === 'custom') {
|
||||
this.bannerList = this.bannerConfig.list.map((item) => {
|
||||
return {
|
||||
mp4: '',
|
||||
id: item.metadata.name,
|
||||
nickname: item.owner.displayName,
|
||||
avatar: _this.$utils.checkAvatarUrl(item.owner.avatar),
|
||||
id: Date.now() * Math.random(),
|
||||
nickname: this.haloConfigs.authorConfig.blogger.nickname,
|
||||
avatar: this.$utils.checkAvatarUrl(this.haloConfigs.authorConfig.blogger.avatar),
|
||||
address: '',
|
||||
createTime: uni.$tm.dayjs(item.spec.publishTime).fromNow(),
|
||||
title: item.spec.title,
|
||||
src: _this.$utils.checkThumbnailUrl(item.spec.cover),
|
||||
image: _this.$utils.checkThumbnailUrl(item.spec.cover)
|
||||
};
|
||||
});
|
||||
};
|
||||
createTime: "",
|
||||
title: item.title,
|
||||
src: this.$utils.checkThumbnailUrl(item.cover),
|
||||
image: this.$utils.checkThumbnailUrl(item.cover),
|
||||
type: "custom",
|
||||
content: item.content,
|
||||
url: item.url
|
||||
}
|
||||
})
|
||||
return;
|
||||
}
|
||||
|
||||
const paramsStr = qs.stringify(this.queryParams, {
|
||||
allowDots: true,
|
||||
@@ -283,20 +340,52 @@ export default {
|
||||
url: this.$baseApiUrl + '/apis/api.content.halo.run/v1alpha1/posts?' + paramsStr,
|
||||
method: 'GET',
|
||||
success: (res) => {
|
||||
this.bannerList = _format(res.data.items);
|
||||
this.bannerList = res.data.items.map((item, index) => {
|
||||
return {
|
||||
mp4: '',
|
||||
id: item.metadata.name,
|
||||
nickname: item.owner.displayName,
|
||||
avatar: this.$utils.checkAvatarUrl(item.owner.avatar),
|
||||
address: '',
|
||||
createTime: uni.$tm.dayjs(item.spec.publishTime).fromNow(),
|
||||
title: item.spec.title,
|
||||
src: this.$utils.checkThumbnailUrl(item.spec.cover),
|
||||
image: this.$utils.checkThumbnailUrl(item.spec.cover),
|
||||
type: "post",
|
||||
content: item.status.excerpt,
|
||||
url: ""
|
||||
};
|
||||
});
|
||||
},
|
||||
fail: (err) => {
|
||||
}
|
||||
fail: (err) => {}
|
||||
})
|
||||
|
||||
},
|
||||
fnOnBannerChange(e) {
|
||||
this.bannerCurrent = e.current;
|
||||
fnOnNotifyChange(e) {
|
||||
this.notify.show = e;
|
||||
},
|
||||
fnOnBannerClick(item) {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
return;
|
||||
}
|
||||
if (item.type === 'custom') {
|
||||
if (item.content) {
|
||||
this.notify.data = item
|
||||
this.notify.show = true
|
||||
return;
|
||||
}
|
||||
if (uni.$utils.checkIsUrl(item.url)) {
|
||||
uni.navigateTo({
|
||||
url: '/pagesC/website/website?data=' +
|
||||
JSON.stringify({
|
||||
title: item.title || "加载中...",
|
||||
url: encodeURIComponent(item.url)
|
||||
})
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.id === '') return;
|
||||
this.fnToArticleDetail({
|
||||
metadata: {
|
||||
@@ -306,7 +395,7 @@ export default {
|
||||
},
|
||||
// 文章列表
|
||||
fnGetArticleList() {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
this.articleList = this.mockJson.home.postList.map((item) => {
|
||||
return {
|
||||
metadata: {
|
||||
@@ -371,7 +460,7 @@ export default {
|
||||
},
|
||||
//跳转文章详情
|
||||
fnToArticleDetail(article) {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
return;
|
||||
}
|
||||
uni.navigateTo({
|
||||
@@ -409,7 +498,7 @@ export default {
|
||||
|
||||
// 根据slug查询分类下的文章
|
||||
fnToCategoryBy(category) {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
return;
|
||||
}
|
||||
uni.navigateTo({
|
||||
@@ -435,13 +524,77 @@ export default {
|
||||
uni.switchTab({
|
||||
url: '/pages/tabbar/about/about'
|
||||
})
|
||||
},
|
||||
fnClickNav(data) {
|
||||
uni.navigateTo({
|
||||
url: data.path
|
||||
});
|
||||
},
|
||||
fnGetNavList() {
|
||||
this.navList = [{
|
||||
key: 'archives',
|
||||
title: this.calcAuditModeEnabled ? '内容归档' : '文章归档',
|
||||
bgColor: "rgba(3, 169, 244, 0.95)",
|
||||
shadow: "rgba(3, 169, 244, 0.4)",
|
||||
bgClass: 'bg-gradient-blue-accent',
|
||||
icon: 'icon-news',
|
||||
iconColor: '',
|
||||
path: '/pagesA/archives/archives',
|
||||
type: 'page',
|
||||
show: true
|
||||
}, {
|
||||
key: 'vote',
|
||||
title: '投票中心',
|
||||
bgColor: "rgba(0, 188, 212,0.95)",
|
||||
shadow: "rgba(0, 188, 212, 0.4)",
|
||||
bgClass: 'bg-gradient-blue-accent',
|
||||
icon: 'icon-box',
|
||||
iconColor: '',
|
||||
path: '/pagesA/votes/votes',
|
||||
type: 'page',
|
||||
show: !this.calcAuditModeEnabled
|
||||
}, {
|
||||
key: 'disclaimers',
|
||||
title: '友情链接',
|
||||
bgColor: "rgba(0, 150, 136, 0.95)",
|
||||
shadow: "rgba(0, 150, 136, 0.4)",
|
||||
bgClass: 'bg-gradient-blue-accent',
|
||||
icon: 'icon-lianjie',
|
||||
iconColor: '',
|
||||
path: '/pagesA/friend-links/friend-links',
|
||||
type: 'page',
|
||||
show: true
|
||||
}, {
|
||||
key: 'love',
|
||||
title: '恋爱日记',
|
||||
bgColor: "rgba(255,76,103, 0.95)",
|
||||
shadow: "rgba(255,76,103, 0.4)",
|
||||
bgClass: 'bg-gradient-blue-accent',
|
||||
icon: 'icon-like',
|
||||
iconColor: '',
|
||||
path: '/pagesA/love/love',
|
||||
type: 'page',
|
||||
show: this.haloConfigs.loveConfig.loveEnabled
|
||||
}, {
|
||||
key: 'contact-blogger',
|
||||
title: '联系博主',
|
||||
bgColor: "rgba(255, 152, 0, 0.95)",
|
||||
shadow: "rgba(255, 152, 0, 0.4)",
|
||||
bgClass: 'bg-gradient-blue-accent',
|
||||
icon: 'icon-paper-plane',
|
||||
iconColor: '',
|
||||
rightText: '博主主常用常用联系方式',
|
||||
path: '/pagesA/contact/contact',
|
||||
type: 'page',
|
||||
show: this.haloConfigs.authorConfig.social.enabled
|
||||
}]
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.app-page {
|
||||
.app-page {
|
||||
width: 100vw;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
@@ -459,38 +612,36 @@ export default {
|
||||
min-width: initial;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.loading-wrap {
|
||||
.loading-wrap {
|
||||
padding: 24rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.search-input {
|
||||
.search-input {
|
||||
background-color: #f5f5f5;
|
||||
align-items: center;
|
||||
/* #ifdef MP-WEIXIN */
|
||||
margin-right: 24rpx;
|
||||
|
||||
/* #endif */
|
||||
&_icon {
|
||||
&_icon {}
|
||||
|
||||
&_text {}
|
||||
}
|
||||
|
||||
&_text {
|
||||
}
|
||||
}
|
||||
|
||||
.show-more {
|
||||
.show-more {
|
||||
width: 42rpx;
|
||||
height: 42rpx;
|
||||
box-sizing: border-box;
|
||||
box-shadow: 0rpx 0rpx 24rpx rgba(0, 0, 0, 0.03);
|
||||
}
|
||||
}
|
||||
|
||||
.banner {
|
||||
.banner {
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
|
||||
.quick-nav {
|
||||
.quick-nav {
|
||||
background-color: #fff;
|
||||
box-sizing: border-box;
|
||||
|
||||
@@ -498,9 +649,9 @@ export default {
|
||||
.name {
|
||||
color: var(--main-text-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.category {
|
||||
.category {
|
||||
width: 94vw;
|
||||
display: flex;
|
||||
height: 200rpx;
|
||||
@@ -519,9 +670,9 @@ export default {
|
||||
.cate-empty {
|
||||
height: inherit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.page-item {
|
||||
.page-item {
|
||||
&_title {
|
||||
position: relative;
|
||||
padding-left: 24rpx;
|
||||
@@ -541,9 +692,9 @@ export default {
|
||||
z-index: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.h_row_col2 {
|
||||
.h_row_col2 {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
box-sizing: border-box;
|
||||
@@ -552,5 +703,38 @@ export default {
|
||||
.ani-item {
|
||||
width: 50%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.nav-box {
|
||||
background-color: #ffff;
|
||||
overflow: hidden;
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
.nav-list {
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
// justify-content: space-between;
|
||||
justify-content: space-around;
|
||||
}
|
||||
|
||||
.nav-item {
|
||||
font-size: 26rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 12rpx;
|
||||
}
|
||||
|
||||
.nav-item-icon {
|
||||
padding: 24rpx;
|
||||
// border-radius: 24rpx 32rpx 24rpx 32rpx;
|
||||
border-radius: 24rpx;
|
||||
// border: 2rpx solid #fff;
|
||||
}
|
||||
|
||||
.nav-item-text {
|
||||
font-size: 24rpx;
|
||||
}
|
||||
</style>
|
||||
@@ -1,5 +1,8 @@
|
||||
<template>
|
||||
<view class="app-page">
|
||||
<view class="app-page" :class="[uniHaloPluginPageClass]">
|
||||
<PluginUnavailable v-if="!uniHaloPluginAvailable" :pluginId="uniHaloPluginId"
|
||||
:error-text="uniHaloPluginAvailableError" />
|
||||
<template v-else>
|
||||
<view v-if="loading !== 'success'" class="loading-wrap">
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
@@ -12,14 +15,14 @@
|
||||
<tm-empty icon="icon-shiliangzhinengduixiang-" label="暂无数据"></tm-empty>
|
||||
</view>
|
||||
<block v-else>
|
||||
<block v-for="(moment, index) in dataList" :key="index">
|
||||
<!-- 卡片 -->
|
||||
<tm-translate v-if="moment.spec.visible==='PUBLIC'" animation-name="fadeUp" :wait="calcAniWait()">
|
||||
<tm-translate v-for="(moment, index) in dataList" :key="moment.metadata.name"
|
||||
animation-name="fadeUp" :wait="calcAniWait(index)">
|
||||
<view class="moment-card">
|
||||
<view class="head" style="display: flex;align-items: center;">
|
||||
<view class="avatar" style="flex-shrink: 0;">
|
||||
<image style="width: 66rpx;height: 66rpx;border-radius: 50%;"
|
||||
:src="moment.spec.user.avatar"/>
|
||||
:src="moment.spec.user.avatar" />
|
||||
</view>
|
||||
<view class="nickname" style="margin-left: 12rpx;">
|
||||
<view style="font-size: 30rpx;font-weight: bold;color: #333333;">
|
||||
@@ -30,56 +33,84 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="content">
|
||||
<view class="content" @click.stop="handleToMomentDetail(moment)">
|
||||
<mp-html class="evan-markdown" lazy-load :domain="markdownConfig.domain"
|
||||
:loading-img="markdownConfig.loadingGif" :scroll-table="true" :selectable="true"
|
||||
:tag-style="markdownConfig.tagStyle" :container-style="markdownConfig.containStyle"
|
||||
:content="moment.spec.content.html" :markdown="true" :showLineNumber="true"
|
||||
:showLanguageName="true" :copyByLongPress="true"/>
|
||||
:content="moment.spec.newHtml" :markdown="true" :showLineNumber="true"
|
||||
:showLanguageName="true" :copyByLongPress="true" />
|
||||
</view>
|
||||
<view class="mb-12 mt--12" v-if="moment.videos.length!==0"
|
||||
style="display: flex; flex-direction: column; gap: 12rpx 0;padding: 0 24rpx; ">
|
||||
<video
|
||||
style="width:100%;height: 400rpx;border-radius: 12rpx;"
|
||||
v-for="(video,index) in moment.videos"
|
||||
:key="index" :src="video.url"></video>
|
||||
</view>
|
||||
<view v-if="moment.images.length!==0" class="images"
|
||||
<view v-if="moment.images && moment.images.length!==0" class="images"
|
||||
:class="['images-'+moment.images.length]">
|
||||
<view class="image-item"
|
||||
v-for="(image,mediumIndex) in moment.images"
|
||||
<view class="image-item" v-for="(image,mediumIndex) in moment.images"
|
||||
:key="mediumIndex">
|
||||
<image mode="aspectFill" style="width: 100%;height: 100%;border-radius: 6rpx;"
|
||||
:src="image.url"
|
||||
@click="handlePreview(mediumIndex,moment.images)"/>
|
||||
:src="image.url" @click="handlePreview(mediumIndex,moment.images)" />
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="moment.audios && moment.audios.length!==0" class="mb-12"
|
||||
style="display: flex; flex-direction: column; gap: 12rpx 0;padding: 0 24rpx;padding-right:28rpx;">
|
||||
<audio v-for="(audio,index) in moment.audios" :controls="true" :key="index"
|
||||
:id="audio.url" :poster="bloggerInfo.avatar"
|
||||
:name="'来自' + (startConfig.title||bloggerInfo.nickname) + '的声音'"
|
||||
:author="bloggerInfo.nickname" :src="audio.url"></audio>
|
||||
</view>
|
||||
<view v-if="moment.videos && moment.videos.length!==0" class="mb-12"
|
||||
style="display: flex; flex-direction: column; gap: 12rpx 0;padding: 0 24rpx; ">
|
||||
<video style="width:100%;height: 400rpx;border-radius: 12rpx;"
|
||||
v-for="(video,index) in moment.videos" :key="index" :src="video.url"
|
||||
:id="'video_' + video.id" :show-mute-btn="true" :controls="true"
|
||||
:show-center-play-btn="true" :enable-progress-gesture="true"
|
||||
@play="onVideoPlay(video.id)" @pause="onVideoPause(video.id)"
|
||||
@ended="onVideoEnded(video.id)"></video>
|
||||
</view>
|
||||
<view v-if="moment.spec.tags && moment.spec.tags.length!==0"
|
||||
class="mt-12 px-16 pb-24 flex flex-wrap">
|
||||
<tm-tags v-for="(tag,tagIndex) in moment.spec.tags" :key="tagIndex"
|
||||
:color="randomTagColor()" size="m" model="text">
|
||||
{{ tag }}
|
||||
</tm-tags>
|
||||
</view>
|
||||
</view>
|
||||
</tm-translate>
|
||||
</block>
|
||||
<tm-flotbutton @click="fnToTopPage" size="m" color="light-blue" icon="icon-angle-up"></tm-flotbutton>
|
||||
<tm-flotbutton @click="fnToTopPage" :width="90" size="xs" color="light-blue" :icon-size="24"
|
||||
icon="icon-angle-up"></tm-flotbutton>
|
||||
<view class="load-text">{{ loadMoreText }}</view>
|
||||
</block>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
|
||||
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
|
||||
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
|
||||
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
|
||||
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
|
||||
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
|
||||
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
|
||||
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
|
||||
import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue';
|
||||
|
||||
import MarkdownConfig from '@/common/markdown/markdown.config.js';
|
||||
import mpHtml from '@/components/mp-html/components/mp-html/mp-html.vue';
|
||||
import MarkdownConfig from '@/common/markdown/markdown.config.js';
|
||||
import mpHtml from '@/components/mp-html/components/mp-html/mp-html.vue';
|
||||
import {
|
||||
getRandomNumberByRange
|
||||
} from "@/utils/random.js";
|
||||
import {
|
||||
generateUUID
|
||||
} from '@/utils/uuid.js';
|
||||
|
||||
export default {
|
||||
import pluginAvailableMixin from "@/common/mixins/pluginAvailable.js"
|
||||
import PluginUnavailable from '@/components/plugin-unavailable/plugin-unavailable.vue'
|
||||
|
||||
export default {
|
||||
mixins: [pluginAvailableMixin],
|
||||
components: {
|
||||
tmSkeleton,
|
||||
tmFlotbutton,
|
||||
tmTranslate,
|
||||
tmEmpty,
|
||||
mpHtml
|
||||
tmTags,
|
||||
mpHtml,
|
||||
PluginUnavailable
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -92,7 +123,10 @@ export default {
|
||||
hasNext: false,
|
||||
dataList: [],
|
||||
isLoadMore: false,
|
||||
loadMoreText: '加载中...'
|
||||
loadMoreText: '加载中...',
|
||||
tagColors: ['orange', 'green', 'red', 'blue'],
|
||||
videoContexts: {},
|
||||
currentVideoId: null
|
||||
};
|
||||
},
|
||||
|
||||
@@ -107,20 +141,40 @@ export default {
|
||||
},
|
||||
mockJson() {
|
||||
return this.$tm.vx.getters().getMockJson;
|
||||
},
|
||||
calcAuditModeEnabled() {
|
||||
return this.haloConfigs.auditConfig.auditModeEnabled
|
||||
},
|
||||
calcUseTagRandomColor() {
|
||||
return this.haloConfigs.pageConfig.momentConfig.useTagRandomColor
|
||||
},
|
||||
startConfig() {
|
||||
return this.haloConfigs.appConfig.startConfig;
|
||||
}
|
||||
},
|
||||
async onLoad() {
|
||||
// 检查插件
|
||||
this.setPluginId(this.NeedPluginIds.PluginMoments)
|
||||
this.setPluginError("阿偶,检测到当前插件没有安装或者启用,无法使用瞬间功能哦,请联系管理员")
|
||||
if (!await this.checkPluginAvailable()) return
|
||||
|
||||
onLoad() {
|
||||
this.fnGetData();
|
||||
},
|
||||
onPullDownRefresh() {
|
||||
if (!this.uniHaloPluginAvailable) {
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
return
|
||||
}
|
||||
this.isLoadMore = false;
|
||||
this.queryParams.page = 0;
|
||||
this.videoContexts = {};
|
||||
this.currentVideoId = null;
|
||||
this.fnGetData();
|
||||
},
|
||||
|
||||
onReachBottom(e) {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
if (!this.uniHaloPluginAvailable) return;
|
||||
if (this.calcAuditModeEnabled) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '没有更多数据了'
|
||||
@@ -140,7 +194,7 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
fnGetData() {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
this.dataList = this.mockJson.moments.list.map((item) => {
|
||||
return {
|
||||
metadata: {
|
||||
@@ -188,7 +242,7 @@ export default {
|
||||
this.loadMoreText = res.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
|
||||
this.hasNext = res.hasNext;
|
||||
|
||||
const tempItems = res.items.map(item => {
|
||||
const tempItems = res.items.filter(x => x.spec.visible === 'PUBLIC').map(item => {
|
||||
item.spec.user = {
|
||||
displayName: this.bloggerInfo.nickname,
|
||||
avatar: this.$utils.checkAvatarUrl(this.bloggerInfo.avatar)
|
||||
@@ -197,11 +251,18 @@ export default {
|
||||
medium.url = this.$utils.checkThumbnailUrl(medium.url, true)
|
||||
})
|
||||
|
||||
item.spec.newHtml = this.removeTagLinksCompletely(item.spec.content.html, '')
|
||||
item['images'] = item.spec.content.medium
|
||||
.filter(x => x.type === 'PHOTO')
|
||||
|
||||
item['videos'] = item.spec.content.medium
|
||||
.filter(x => x.type === 'VIDEO')
|
||||
.filter(x => x.type === 'VIDEO').map(item => {
|
||||
item.id = generateUUID()
|
||||
return item;
|
||||
})
|
||||
|
||||
item['audios'] = item.spec.content.medium
|
||||
.filter(x => x.type === 'AUDIO')
|
||||
return item;
|
||||
})
|
||||
|
||||
@@ -210,6 +271,11 @@ export default {
|
||||
} else {
|
||||
this.dataList = tempItems;
|
||||
}
|
||||
|
||||
this.$nextTick(() => {
|
||||
this.createVideoContexts(tempItems);
|
||||
})
|
||||
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
@@ -228,24 +294,69 @@ export default {
|
||||
current: index,
|
||||
urls: list.map(item => item.url)
|
||||
})
|
||||
},
|
||||
removeTagLinksCompletely(htmlString) {
|
||||
const regex = /<a\s+(?:[^>]*?\s+)?class=(['"])[^'"]*?\btag\b[^'"]*?\1[^>]*?>.*?<\/a>/gi;
|
||||
const newHtml = htmlString.replace(regex, '');
|
||||
return newHtml
|
||||
},
|
||||
randomTagColor() {
|
||||
if (!this.calcUseTagRandomColor) return "blue";
|
||||
const randomIndex = getRandomNumberByRange(0, this.tagColors.length);
|
||||
return this.tagColors[randomIndex];
|
||||
},
|
||||
createVideoContexts(list) {
|
||||
this.stopAllVideos()
|
||||
list.map(item => item.videos).flat().forEach(item => {
|
||||
this.videoContexts[item.id] = uni.createVideoContext(`video_${item.id}`, this);
|
||||
})
|
||||
},
|
||||
onVideoPlay(videoId) {
|
||||
this.currentVideoId = videoId;
|
||||
this.stopAllVideos(videoId)
|
||||
},
|
||||
onVideoPause(videoId) {
|
||||
if (this.currentVideoId == videoId) {
|
||||
this.currentVideoId = null;
|
||||
}
|
||||
},
|
||||
onVideoEnded(videoId) {
|
||||
this.currentVideoId = null;
|
||||
},
|
||||
stopAllVideos(excludesVideoId = null) {
|
||||
Object.keys(this.videoContexts).forEach(videoId => {
|
||||
if (!excludesVideoId || excludesVideoId != videoId) {
|
||||
const videoContext = this.videoContexts[videoId]
|
||||
videoContext?.pause();
|
||||
}
|
||||
});
|
||||
},
|
||||
handleToMomentDetail(moment) {
|
||||
if (this.calcAuditModeEnabled) return;
|
||||
uni.navigateTo({
|
||||
url: '/pagesA/moment-detail/moment-detail?name=' + moment.metadata.name,
|
||||
animationType: 'slide-in-right'
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.app-page {
|
||||
.app-page {
|
||||
box-sizing: border-box;
|
||||
width: 100vw;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 24rpx 0;
|
||||
}
|
||||
}
|
||||
|
||||
.loading-wrap {
|
||||
.loading-wrap {
|
||||
padding: 24rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.moment-card {
|
||||
.moment-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
@@ -255,14 +366,14 @@ export default {
|
||||
box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.03);
|
||||
overflow: hidden;
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.head {
|
||||
.head {
|
||||
padding: 24rpx;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.images {
|
||||
.images {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-start;
|
||||
@@ -278,17 +389,22 @@ export default {
|
||||
}
|
||||
|
||||
&-1 {
|
||||
> .image-item {
|
||||
>.image-item {
|
||||
width: 100%;
|
||||
height: 350rpx
|
||||
}
|
||||
}
|
||||
|
||||
&-2 {
|
||||
> .image-item {
|
||||
>.image-item {
|
||||
width: 50%;
|
||||
height: 250rpx
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
::v-deep .uni-audio-default {
|
||||
width: 100%;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
</style>
|
||||
@@ -18,7 +18,7 @@
|
||||
<!-- 加载完成区域 -->
|
||||
<block v-else>
|
||||
<view v-if="dataList.length === 0" class="list-empty flex flex-center">
|
||||
<tm-empty v-if="haloConfigs.basicConfig.auditModeEnabled" icon="icon-shiliangzhinengduixiang-" label="暂无归档的内容"></tm-empty>
|
||||
<tm-empty v-if="calcAuditModeEnabled" icon="icon-shiliangzhinengduixiang-" label="暂无归档的内容"></tm-empty>
|
||||
<tm-empty v-else icon="icon-shiliangzhinengduixiang-" label="暂无归档的文章"></tm-empty>
|
||||
</view>
|
||||
<view v-else class="e-timeline tm-timeline mt-24">
|
||||
@@ -37,7 +37,7 @@
|
||||
<view class="flex time text-weight-b mb-24">
|
||||
<text>{{ item.year }}年</text>
|
||||
<text v-if="tab.activeIndex === 0">{{ item.month }}月</text>
|
||||
<view v-if="haloConfigs.basicConfig.auditModeEnabled" class="text-size-s text-grey-darken-1 ml-12">
|
||||
<view v-if="calcAuditModeEnabled" class="text-size-s text-grey-darken-1 ml-12">
|
||||
(共 {{ item.posts.length }} 篇内容)
|
||||
</view>
|
||||
<view v-else class="text-size-s text-grey-darken-1 ml-12">
|
||||
@@ -128,7 +128,10 @@ export default {
|
||||
},
|
||||
mockJson() {
|
||||
return this.$tm.vx.getters().getMockJson;
|
||||
}
|
||||
},
|
||||
calcAuditModeEnabled() {
|
||||
return this.haloConfigs.auditConfig.auditModeEnabled
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.fnGetData();
|
||||
@@ -139,7 +142,7 @@ export default {
|
||||
this.fnGetData();
|
||||
},
|
||||
onReachBottom(e) {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '没有更多数据了'
|
||||
@@ -165,7 +168,7 @@ export default {
|
||||
this.fnToTopPage();
|
||||
},
|
||||
fnGetData() {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
const dataList = this.mockJson.archives.list.map(item => {
|
||||
const date = new Date(item.time)
|
||||
const year = date.getFullYear()
|
||||
@@ -353,7 +356,7 @@ export default {
|
||||
});
|
||||
},
|
||||
fnToArticleDetail(article) {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
return;
|
||||
}
|
||||
uni.navigateTo({
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
</view>
|
||||
|
||||
<view class="cover" v-if="result.spec.cover">
|
||||
<image class="cover-img" mode="aspectFill" :src="calcUrl(result.spec.cover)"></image>
|
||||
<image class="cover-img" mode="aspectFill" :src="calcUrl(result.spec.cover)" @click="handlePreview(0,[{url:calcUrl(result.spec.cover)}])"></image>
|
||||
</view>
|
||||
<view class="count" :class="{ 'no-thumbnail': !result.spec.cover }">
|
||||
<view class="count-item">
|
||||
@@ -79,46 +79,65 @@
|
||||
<view class="markdown-wrap">
|
||||
<view v-if="checkPostRestrictRead(result)">
|
||||
<view v-if="showContentArr.length == 0">
|
||||
<restrict-read-skeleton
|
||||
:loading="true"
|
||||
:lines="3"
|
||||
:tip-text="`此处内容已隐藏,「${getRestrictReadTypeName(result)}可见」`"
|
||||
button-text="查看更多"
|
||||
button-color="#1890ff"
|
||||
skeleton-color="#f0f0f0"
|
||||
skeleton-highlight="#e0e0e0"
|
||||
animation-duration="2"
|
||||
@refresh="readMore"
|
||||
/>
|
||||
<restrict-read-skeleton :loading="true" :lines="3"
|
||||
:tip-text="`此处内容已隐藏,「${getRestrictReadTypeName(result)}可见」`" button-text="查看更多"
|
||||
button-color="#1890ff" skeleton-color="#f0f0f0" skeleton-highlight="#e0e0e0"
|
||||
animation-duration="2" @refresh="readMore" />
|
||||
</view>
|
||||
<view v-else v-for="showContent in showContentArr">
|
||||
<mp-html class="evan-markdown" lazy-load :domain="markdownConfig.domain"
|
||||
:loading-img="markdownConfig.loadingGif" :scroll-table="true" :selectable="true"
|
||||
:tag-style="markdownConfig.tagStyle" :container-style="markdownConfig.containStyle"
|
||||
:content="showContent" :markdown="true" :showLineNumber="true" :showLanguageName="true"
|
||||
:copyByLongPress="true"/>
|
||||
<restrict-read-skeleton
|
||||
:loading="true"
|
||||
:lines="3"
|
||||
:tip-text="`此处内容已隐藏,「${getRestrictReadTypeName(result)}可见」`"
|
||||
button-text="查看更多"
|
||||
button-color="#1890ff"
|
||||
skeleton-color="#f0f0f0"
|
||||
skeleton-highlight="#e0e0e0"
|
||||
animation-duration="2"
|
||||
@refresh="readMore"
|
||||
/>
|
||||
:copyByLongPress="true" />
|
||||
<restrict-read-skeleton :loading="true" :lines="3"
|
||||
:tip-text="`此处内容已隐藏,「${getRestrictReadTypeName(result)}可见」`" button-text="查看更多"
|
||||
button-color="#1890ff" skeleton-color="#f0f0f0" skeleton-highlight="#e0e0e0"
|
||||
animation-duration="2" @refresh="readMore" />
|
||||
</view>
|
||||
</view>
|
||||
<view v-else>
|
||||
<mp-html class="evan-markdown" lazy-load :domain="markdownConfig.domain"
|
||||
:loading-img="markdownConfig.loadingGif" :scroll-table="true" :selectable="true"
|
||||
:tag-style="markdownConfig.tagStyle" :container-style="markdownConfig.containStyle"
|
||||
:content="result.content.raw" :markdown="true" :showLineNumber="true" :showLanguageName="true"
|
||||
:copyByLongPress="true"/>
|
||||
:content="result.content.raw" :markdown="true" :showLineNumber="true"
|
||||
:showLanguageName="true" :copyByLongPress="true" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 投票 -->
|
||||
<view v-if="!calcAuditModeEnabled && result._voteIds.length!==0"
|
||||
class="vote-wrap copyright-wrap bg-white mt-24 pa-24 round-4">
|
||||
|
||||
<view class="copyright-title text-weight-b flex items-center justify-between">
|
||||
<text>相关投票</text>
|
||||
<text class="vote-opra" @click="voteIsOpen=!voteIsOpen">
|
||||
{{ voteIsOpen?'收起':'展开' }}
|
||||
</text>
|
||||
</view>
|
||||
<template v-if="reloadVote">
|
||||
<view v-show="voteIsOpen" class="flex flex-col uh-gap-8 uh-mt-8">
|
||||
<PluginUnavailable v-if="!uniHaloPluginAvailable" :pluginId="uniHaloPluginId"
|
||||
:error-text="uniHaloPluginAvailableError" :useDecoration="false" :customStyle="{
|
||||
width:'100%',borderRadius:'16rpx' }" />
|
||||
<template v-else>
|
||||
<ArticleVote v-for="(voteId,voteIdIndex) in result._voteIds" :key="voteId"
|
||||
:voteId="voteId" :article="result" :index="voteIdIndex">
|
||||
</ArticleVote>
|
||||
|
||||
</template>
|
||||
</view>
|
||||
<view v-show="uniHaloPluginAvailable && !voteIsOpen" class="vote-tip"
|
||||
@click="voteIsOpen=!voteIsOpen">
|
||||
投票已收起,点击展开 {{result._voteIds.length}} 个投票项
|
||||
</view>
|
||||
<view v-show="!uniHaloPluginAvailable && !voteIsOpen" class="vote-tip"
|
||||
@click="voteIsOpen=!voteIsOpen">
|
||||
提示区域已收起,点击显示
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
|
||||
<!-- 版权声明 -->
|
||||
<view v-if="postDetailConfig && postDetailConfig.copyrightEnabled"
|
||||
class="copyright-wrap bg-white mt-24 pa-24 round-4">
|
||||
@@ -152,9 +171,9 @@
|
||||
<!-- 弹幕效果 -->
|
||||
<barrage ref="barrage" :maxTop="240" :type="globalAppSettings.barrage.type"></barrage>
|
||||
<!-- 返回顶部 -->
|
||||
<tm-flotbutton :offset="[16, 80]" icon="icon-angle-up" color="bg-gradient-light-blue-accent"
|
||||
<tm-flotbutton :width="90" :offset="[16, 80]" icon="icon-angle-up" color="bg-gradient-light-blue-accent"
|
||||
@click="fnToTopPage()"></tm-flotbutton>
|
||||
<tm-flotbutton :actions="flotButtonActions" :click-actions-hiden="false" actions-pos="left"
|
||||
<tm-flotbutton :width="90" :actions="flotButtonActions" :click-actions-hiden="false" actions-pos="left"
|
||||
:show-text="true" color="bg-gradient-orange-accent" @change="fnOnFlotButtonChange"></tm-flotbutton>
|
||||
</block>
|
||||
|
||||
@@ -248,24 +267,18 @@
|
||||
|
||||
<!-- 验证码弹窗 -->
|
||||
<tm-dialog v-model="verificationCodeModal.show" :disabled="true" title="验证提示"
|
||||
:confirmText="verificationCodeModal.confirmText"
|
||||
:showCancel="true" model="verificationCodeModal.model" theme="split" confirmColor="blue shadow-blue-0"
|
||||
@cancel="verificationCodeModal.show = false"
|
||||
:confirmText="verificationCodeModal.confirmText" :showCancel="true" model="verificationCodeModal.model"
|
||||
theme="split" confirmColor="blue shadow-blue-0" @cancel="verificationCodeModal.show = false"
|
||||
@confirm="restrictReadCheckOrViewVideo">
|
||||
<template #default>
|
||||
<view class="pa-20">
|
||||
<!-- 扫码验证模式 -->
|
||||
<view v-if="verificationCodeModal.type === 'scan'" class="flex flex-col flex-center">
|
||||
<text class="mb-20">请扫描下方二维码获取验证码</text>
|
||||
<tm-images
|
||||
:width="180"
|
||||
:height="180"
|
||||
:src="verificationCodeModal.imgUrl"
|
||||
preview
|
||||
round="5"
|
||||
></tm-images>
|
||||
<tm-input bg-color="grey-lighten-5" required v-model="restrictReadInputCode" placeholder="请输入验证码"
|
||||
:border-bottom="false" :flat="true"></tm-input>
|
||||
<tm-images :width="180" :height="180" :src="verificationCodeModal.imgUrl" preview
|
||||
round="5"></tm-images>
|
||||
<tm-input bg-color="grey-lighten-5" required v-model="restrictReadInputCode"
|
||||
placeholder="请输入验证码" :border-bottom="false" :flat="true"></tm-input>
|
||||
</view>
|
||||
|
||||
<!-- 观看视频模式 -->
|
||||
@@ -278,8 +291,7 @@
|
||||
<!-- 密码弹窗 -->
|
||||
<tm-dialog v-model="passwordModal.show" :disabled="true" title="验证提示" confirmText="确定" content="请输入密码"
|
||||
:showCancel="true" model="confirm" theme="split" confirmColor="blue shadow-blue-0"
|
||||
:input-val.sync="restrictReadInputCode"
|
||||
@cancel="passwordModal.show = false"
|
||||
:input-val.sync="restrictReadInputCode" @cancel="passwordModal.show = false"
|
||||
@confirm="restrictReadCheck"></tm-dialog>
|
||||
|
||||
<!-- 评论弹窗 -->
|
||||
@@ -291,38 +303,46 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import MarkdownConfig from '@/common/markdown/markdown.config.js';
|
||||
import MarkdownConfig from '@/common/markdown/markdown.config.js';
|
||||
|
||||
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
|
||||
import tmPoup from '@/tm-vuetify/components/tm-poup/tm-poup.vue';
|
||||
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
|
||||
import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
|
||||
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
|
||||
import tmDialog from '@/tm-vuetify/components/tm-dialog/tm-dialog.vue';
|
||||
import tmMore from '@/tm-vuetify/components/tm-more/tm-more.vue';
|
||||
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
|
||||
import tmPoup from '@/tm-vuetify/components/tm-poup/tm-poup.vue';
|
||||
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
|
||||
import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
|
||||
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
|
||||
import tmDialog from '@/tm-vuetify/components/tm-dialog/tm-dialog.vue';
|
||||
import tmMore from '@/tm-vuetify/components/tm-more/tm-more.vue';
|
||||
|
||||
import mpHtml from '@/components/mp-html/components/mp-html/mp-html.vue';
|
||||
import commentList from '@/components/comment-list/comment-list.vue';
|
||||
import commentItem from '@/components/comment-item/comment-item.vue';
|
||||
import commentModal from '@/components/comment-modal/comment-modal.vue';
|
||||
import mpHtml from '@/components/mp-html/components/mp-html/mp-html.vue';
|
||||
import commentList from '@/components/comment-list/comment-list.vue';
|
||||
import commentItem from '@/components/comment-item/comment-item.vue';
|
||||
import commentModal from '@/components/comment-modal/comment-modal.vue';
|
||||
import ArticleVote from '@/components/article-vote/article-vote.vue';
|
||||
|
||||
import rCanvas from '@/components/r-canvas/r-canvas.vue';
|
||||
import barrage from '@/components/barrage/barrage.vue';
|
||||
import {getAppConfigs} from '@/config/index.js'
|
||||
import {upvote} from '@/utils/upvote.js'
|
||||
import {
|
||||
import rCanvas from '@/components/r-canvas/r-canvas.vue';
|
||||
import barrage from '@/components/barrage/barrage.vue';
|
||||
import {
|
||||
getAppConfigs
|
||||
} from '@/config/index.js'
|
||||
import {
|
||||
upvote
|
||||
} from '@/utils/upvote.js'
|
||||
import {
|
||||
checkPostRestrictRead,
|
||||
copyToClipboard,
|
||||
getRestrictReadTypeName,
|
||||
getShowableContent
|
||||
} from "@/utils/restrictRead";
|
||||
import HaloTokenConfig from "@/config/token.config";
|
||||
import RestrictReadSkeleton from "@/components/restrict-read-skeleton/restrict-read-skeleton.vue";
|
||||
import TmImages from "@/tm-vuetify/components/tm-images/tm-images.vue";
|
||||
import TmInput from "@/tm-vuetify/components/tm-input/tm-input.vue";
|
||||
} from "@/utils/restrictRead";
|
||||
import HaloTokenConfig from "@/config/uhalo.config";
|
||||
import RestrictReadSkeleton from "@/components/restrict-read-skeleton/restrict-read-skeleton.vue";
|
||||
import TmImages from "@/tm-vuetify/components/tm-images/tm-images.vue";
|
||||
import TmInput from "@/tm-vuetify/components/tm-input/tm-input.vue";
|
||||
import pluginAvailableMixin from "@/common/mixins/pluginAvailable.js"
|
||||
import PluginUnavailable from '@/components/plugin-unavailable/plugin-unavailable.vue'
|
||||
|
||||
let videoAd = null;
|
||||
export default {
|
||||
let videoAd = null;
|
||||
export default {
|
||||
mixins: [pluginAvailableMixin],
|
||||
components: {
|
||||
TmInput,
|
||||
TmImages,
|
||||
@@ -339,7 +359,9 @@ export default {
|
||||
commentItem,
|
||||
rCanvas,
|
||||
barrage,
|
||||
commentModal
|
||||
commentModal,
|
||||
ArticleVote,
|
||||
PluginUnavailable
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -389,7 +411,10 @@ export default {
|
||||
title: ""
|
||||
},
|
||||
|
||||
commentListScrollTop: 0
|
||||
commentListScrollTop: 0,
|
||||
|
||||
voteIsOpen: true,
|
||||
reloadVote: false
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -424,24 +449,39 @@ export default {
|
||||
},
|
||||
calcUpvoted() {
|
||||
return upvote.has("post", this.result?.metadata?.name)
|
||||
}
|
||||
},
|
||||
calcAuditModeEnabled() {
|
||||
return this.haloConfigs.auditConfig.auditModeEnabled
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
haloConfigs: {
|
||||
deep: true,
|
||||
immediate: true,
|
||||
handler: function (newVal) {
|
||||
handler: function(newVal) {
|
||||
if (!newVal) return;
|
||||
this.fnHandleSetFlotButtonItems(newVal);
|
||||
}
|
||||
}
|
||||
},
|
||||
onLoad(e) {
|
||||
async onLoad(e) {
|
||||
// 检查插件
|
||||
this.setPluginId(this.NeedPluginIds.PluginVote)
|
||||
this.setPluginError("阿偶,检测到当前插件没有安装或者启用,无法使用投票功能,请联系管理员")
|
||||
await this.checkPluginAvailable()
|
||||
|
||||
this.fnSetPageTitle('文章加载中...');
|
||||
this.queryParams.name = e.name;
|
||||
this.fnGetData();
|
||||
},
|
||||
|
||||
onShow() {
|
||||
if (this.reloadVote) {
|
||||
this.reloadVote = false
|
||||
setTimeout(() => {
|
||||
this.reloadVote = true
|
||||
}, 100);
|
||||
}
|
||||
},
|
||||
onPullDownRefresh() {
|
||||
this.fnGetData();
|
||||
},
|
||||
@@ -472,7 +512,8 @@ export default {
|
||||
.getPostByName(this.queryParams.name)
|
||||
.then(res => {
|
||||
console.log('详情', res);
|
||||
this.result = res;
|
||||
const tempResult = res;
|
||||
tempResult._voteIds = this.extractVoteBlockIds(res.content?.raw || res.content?.content || "")
|
||||
|
||||
const openid = uni.getStorageSync('openid');
|
||||
if (openid === '' || openid === null) {
|
||||
@@ -480,10 +521,14 @@ export default {
|
||||
}
|
||||
|
||||
const toolsPluginEnabled = getAppConfigs().pluginConfig.toolsPlugin?.enabled;
|
||||
const restrictRead = checkPostRestrictRead(this.result);
|
||||
const restrictRead = checkPostRestrictRead(tempResult);
|
||||
|
||||
if (restrictRead && toolsPluginEnabled) {
|
||||
const verifyCodeType = getAppConfigs().pluginConfig.toolsPlugin?.verifyCodeType;
|
||||
let verifyCodeType = getAppConfigs().pluginConfig.toolsPlugin?.verifyCodeType;
|
||||
const postVerifyCodeType = tempResult?.metadata?.annotations?.verifyCodeType;
|
||||
if (postVerifyCodeType) {
|
||||
verifyCodeType = postVerifyCodeType;
|
||||
}
|
||||
if (verifyCodeType === 'scan') {
|
||||
const scanCodeUrl = getAppConfigs().pluginConfig.toolsPlugin?.scanCodeUrl;
|
||||
this.verificationCodeModal.type = 'scan';
|
||||
@@ -501,12 +546,13 @@ export default {
|
||||
// #endif
|
||||
}
|
||||
|
||||
const showableContentArr = getShowableContent(this.result);
|
||||
const showableContentArr = getShowableContent(tempResult);
|
||||
this.showContentArr = showableContentArr;
|
||||
}
|
||||
|
||||
this.result = tempResult;
|
||||
this.fnSetPageTitle('文章详情');
|
||||
this.loading = 'success';
|
||||
this.reloadVote = true;
|
||||
this.fnHandleSetFlotButtonItems(this.haloConfigs);
|
||||
this.handleQueryCommentListScrollTop()
|
||||
})
|
||||
@@ -966,7 +1012,8 @@ export default {
|
||||
filePath: this.poster.url,
|
||||
success: () => {
|
||||
uni.$tm.toast('保存成功');
|
||||
}, fail: (e) => {
|
||||
},
|
||||
fail: (e) => {
|
||||
uni.$tm.toast('保存失败,请重试');
|
||||
}
|
||||
})
|
||||
@@ -1063,7 +1110,7 @@ export default {
|
||||
url: '/pagesC/website/website?data=' +
|
||||
JSON.stringify({
|
||||
title: data.title,
|
||||
url: data.url
|
||||
url: encodeURIComponent(data.url)
|
||||
})
|
||||
});
|
||||
},
|
||||
@@ -1108,7 +1155,7 @@ export default {
|
||||
// #ifdef MP-WEIXIN
|
||||
uni.login({
|
||||
provider: 'weixin',
|
||||
success: function (loginRes) {
|
||||
success: function(loginRes) {
|
||||
try {
|
||||
// todo 因为没有获取openid,所以先使用code代替
|
||||
uni.setStorageSync('openid', loginRes.code)
|
||||
@@ -1136,7 +1183,8 @@ export default {
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.$httpApi.v2.requestRestrictReadCheck(this.result?.metadata?.annotations?.restrictReadEnable, this.restrictReadInputCode, this.result?.metadata?.name)
|
||||
this.$httpApi.v2.requestRestrictReadCheck(this.result?.metadata?.annotations?.restrictReadEnable, this
|
||||
.restrictReadInputCode, this.result?.metadata?.name)
|
||||
.then(res => {
|
||||
if (res.code === 200) {
|
||||
this.passwordModal.show = false;
|
||||
@@ -1158,8 +1206,7 @@ export default {
|
||||
videoAd = wx.createRewardedVideoAd({
|
||||
adUnitId: this.verificationCodeModal.adId
|
||||
})
|
||||
videoAd.onError(err => {
|
||||
})
|
||||
videoAd.onError(err => {})
|
||||
videoAd.onClose((status) => {
|
||||
if (status && status.isEnded || status === undefined) {
|
||||
//这里写广告播放完成后的事件
|
||||
@@ -1170,7 +1217,7 @@ export default {
|
||||
})
|
||||
}
|
||||
},
|
||||
openVideoAd: function () {
|
||||
openVideoAd: function() {
|
||||
if (videoAd && this.verificationCodeModal.adId !== '') {
|
||||
videoAd.show().catch(err => {
|
||||
// 失败重试
|
||||
@@ -1219,14 +1266,40 @@ export default {
|
||||
}).exec();
|
||||
}, 2 * 1000)
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 从HTML字符串中提取所有vote-block的id
|
||||
* @param {string} html - 包含vote-block的HTML字符串
|
||||
* @returns {string[]} 提取到的id数组
|
||||
*/
|
||||
extractVoteBlockIds(html) {
|
||||
// 正则表达式匹配<vote-block id="xxx">格式
|
||||
// 捕获组提取id值
|
||||
const regex = /<vote-block\s+id="(vote-\w+)"\s*\/?>/g;
|
||||
const ids = [];
|
||||
let match;
|
||||
|
||||
// 循环匹配所有符合条件的id
|
||||
while ((match = regex.exec(html)) !== null) {
|
||||
// 第一个捕获组是id值
|
||||
ids.push(match[1]);
|
||||
}
|
||||
|
||||
return ids;
|
||||
},
|
||||
handlePreview(index, list) {
|
||||
uni.previewImage({
|
||||
current: index,
|
||||
urls: list.map(item => item.url)
|
||||
})
|
||||
},
|
||||
}
|
||||
};
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.app-page {
|
||||
.app-page {
|
||||
width: 100vw;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
@@ -1234,9 +1307,9 @@ export default {
|
||||
box-sizing: border-box;
|
||||
background-color: #fafafd;
|
||||
padding-bottom: 24rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.bg-image {
|
||||
.bg-image {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
@@ -1245,15 +1318,15 @@ export default {
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
z-index: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.loading-wrap {
|
||||
.loading-wrap {
|
||||
padding: 0 24rpx;
|
||||
height: inherit;
|
||||
background-color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
.head {
|
||||
.head {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
@@ -1280,8 +1353,7 @@ export default {
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
|
||||
&-name {
|
||||
}
|
||||
&-name {}
|
||||
|
||||
&-time {
|
||||
margin-left: 36rpx;
|
||||
@@ -1348,9 +1420,9 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.category {
|
||||
.category {
|
||||
margin: 0 24rpx;
|
||||
padding: 24rpx;
|
||||
background-color: #ffffff;
|
||||
@@ -1375,30 +1447,50 @@ export default {
|
||||
background-color: #607d8b;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.category-tag + .category-tag {
|
||||
.category-tag+.category-tag {
|
||||
margin-left: 12rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
.content {
|
||||
margin-top: 24rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.markdown-wrap,
|
||||
.evan-markdown,
|
||||
.ad-wrap,
|
||||
.copyright-wrap,
|
||||
.comment-wrap {
|
||||
.markdown-wrap,
|
||||
.evan-markdown,
|
||||
.ad-wrap,
|
||||
.copyright-wrap,
|
||||
.comment-wrap {
|
||||
box-shadow: 0rpx 0rpx 24rpx rgba(0, 0, 0, 0.03);
|
||||
}
|
||||
}
|
||||
|
||||
.markdown-wrap {
|
||||
.vote-wrap {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.vote-opra {
|
||||
font-size: 24rpx;
|
||||
font-weight: normal;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.vote-tip {
|
||||
margin-top: 12rpx;
|
||||
padding: 50rpx 24rpx;
|
||||
background: #F1F5F9;
|
||||
color: #666;
|
||||
font-size: 24rpx;
|
||||
border-radius: 12rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.markdown-wrap {
|
||||
overflow: hidden;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.copyright-title {
|
||||
.copyright-title {
|
||||
position: relative;
|
||||
box-sizing: border-box;
|
||||
padding-left: 24rpx;
|
||||
@@ -1414,41 +1506,41 @@ export default {
|
||||
background-color: rgb(3, 174, 252);
|
||||
border-radius: 6rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.poup-head {
|
||||
.poup-head {
|
||||
border-bottom: 2rpx solid #f5f5f5;
|
||||
}
|
||||
}
|
||||
|
||||
.poup-body {
|
||||
.poup-body {
|
||||
height: 50vh;
|
||||
}
|
||||
}
|
||||
|
||||
.poup-empty {
|
||||
.poup-empty {
|
||||
width: 100%;
|
||||
height: 40vh;
|
||||
}
|
||||
}
|
||||
|
||||
.poup-loading-wrap {
|
||||
.poup-loading-wrap {
|
||||
width: 100%;
|
||||
height: 40vh;
|
||||
|
||||
.e-loading-icon {
|
||||
font-size: 80rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.poster-content {
|
||||
.poster-content {
|
||||
width: 100%;
|
||||
min-height: 60vh;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
|
||||
.copyright-text {
|
||||
.copyright-text {
|
||||
line-height: 1.7;
|
||||
}
|
||||
}
|
||||
|
||||
.poster-loading {
|
||||
.poster-loading {
|
||||
width: 100%;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
@@ -1457,14 +1549,14 @@ export default {
|
||||
bottom: 0;
|
||||
// background-color: rgba(0, 0, 0, 0.1);
|
||||
z-index: 666;
|
||||
}
|
||||
}
|
||||
|
||||
.poster-save {
|
||||
.poster-save {
|
||||
box-sizing: border-box;
|
||||
border-top: 2rpx dashed #eee;
|
||||
}
|
||||
}
|
||||
|
||||
.original-url {
|
||||
.original-url {
|
||||
display: flex;
|
||||
|
||||
&_left {
|
||||
@@ -1492,5 +1584,5 @@ export default {
|
||||
text-align: right;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,7 +1,11 @@
|
||||
<template>
|
||||
<view class="app-page" :class="{ 'is-balck grey-darken-6': isBlackTheme }">
|
||||
<view class="app-page" :class="[uniHaloPluginPageClass]">
|
||||
<PluginUnavailable v-if="!uniHaloPluginAvailable" :pluginId="uniHaloPluginId"
|
||||
:error-text="uniHaloPluginAvailableError" />
|
||||
<template v-else>
|
||||
|
||||
<!-- 顶部切换 -->
|
||||
<view class="e-fixed shadow-2">
|
||||
<view class="e-fixed shadow-1">
|
||||
<tm-search v-model="queryParams.keyword" :round="24" :shadow="0" color="light-blue"
|
||||
insert-color="light-blue" :clear="true" @input="fnOnSearch" @confirm="fnOnSearch"></tm-search>
|
||||
<tm-tabs v-if="false" color="light-blue" :shadow="0" v-model="tab.activeIndex" :list="tab.list"
|
||||
@@ -10,62 +14,91 @@
|
||||
<!-- 占位区域 -->
|
||||
<view style="width: 100vw;height: 100rpx;"></view>
|
||||
<!-- 加载区域 -->
|
||||
<view v-if="loading != 'success'" class="loading-wrap pa-24">
|
||||
<view v-if="loading == 'loading'" class="loading-wrap pa-24">
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
</view>
|
||||
<view v-else-if="loading == 'error'" class="content-empty flex flex-center">
|
||||
<tm-empty icon="icon-wind-cry" label="搜索异常"></tm-empty>
|
||||
</view>
|
||||
<!-- 内容区域 -->
|
||||
<view v-else class="content">
|
||||
<view v-if="dataList.length == 0" class="content-empty flex flex-center">
|
||||
<!-- 空布局 -->
|
||||
<tm-empty v-if="!queryParams.keyword" icon="icon-shiliangzhinengduixiang-" label="请输入关键词搜索"></tm-empty>
|
||||
<tm-empty v-if="!queryParams.keyword" icon="icon-shiliangzhinengduixiang-"
|
||||
label="请输入关键词搜索"></tm-empty>
|
||||
<tm-empty v-else icon="icon-shiliangzhinengduixiang-"
|
||||
:label="`未搜到 ${queryParams.keyword} 相关内容`"></tm-empty>
|
||||
</view>
|
||||
<block v-else>
|
||||
<!-- 文章卡片 -->
|
||||
<tm-translate v-for="(article, index) in dataList" :key="article.metadataName" animation-name="fadeUp"
|
||||
<tm-translate v-for="(item, index) in dataList" :key="item.metadataName" animation-name="fadeUp"
|
||||
:wait="calcAniWait(index)">
|
||||
<view class="article-card" @click="fnToArticleDetail(article)">
|
||||
<rich-text style="font-size: 32rpx;font-weight: bold;color: #333;"
|
||||
:nodes="article.title"></rich-text>
|
||||
<rich-text style="font-size: 28rpx;margin-top: 16rpx;color: #555;"
|
||||
:nodes="article.content"></rich-text>
|
||||
<text style="font-size: 24rpx;margin-top: 24rpx;color:#888">
|
||||
最近更新:{{ {d: article.updateTimestamp, f: 'yyyy年MM月dd日 HH点mm分ss秒'} | formatTime }}
|
||||
<view class="article-card" @click="fnToDetail(item)">
|
||||
<view class="mb-12 flex flex-start">
|
||||
<view class="flex-shrink ml--12">
|
||||
<tm-tags v-if="isArticle(item)" color="blue" size="n" model="text">文章</tm-tags>
|
||||
<tm-tags v-else color="green" size="n" model="text">瞬间</tm-tags>
|
||||
</view>
|
||||
<text class="ml-2 text-overflow text-size-n text-weight-b"
|
||||
style="color: #333;">{{ item.title }}</text>
|
||||
</view>
|
||||
<mp-html class="evan-markdown" lazy-load :domain="markdownConfig.domain"
|
||||
:loading-img="markdownConfig.loadingGif" :scroll-table="true" :selectable="true"
|
||||
:tag-style="markdownConfig.tagStyle" :content="item.description || item.content"
|
||||
:markdown="true" :showLineNumber="true" :showLanguageName="true"
|
||||
:copyByLongPress="true" />
|
||||
<view class="mt-12 flex flex-center flex-between">
|
||||
<text style="font-size: 24rpx;color:#888">
|
||||
最近更新时间:{{ {d: item.updateTimestamp, f: 'yyyy年MM月dd日 HH点mm分ss秒'} | formatTime }}
|
||||
</text>
|
||||
<!-- <tm-tags v-if="isArticle(item)" color="blue" size="n" model="text">文章</tm-tags>
|
||||
<tm-tags v-else color="green" size="n" model="text">瞬间</tm-tags> -->
|
||||
</view>
|
||||
</view>
|
||||
</tm-translate>
|
||||
|
||||
<tm-flotbutton @click="fnToTopPage" size="m" color="light-blue" icon="icon-angle-up"></tm-flotbutton>
|
||||
<tm-flotbutton @click="fnToTopPage" size="m" color="light-blue"
|
||||
icon="icon-angle-up"></tm-flotbutton>
|
||||
|
||||
</block>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
|
||||
import tmSearch from '@/tm-vuetify/components/tm-search/tm-search.vue';
|
||||
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
|
||||
import tmTabs from '@/tm-vuetify/components/tm-tabs/tm-tabs.vue';
|
||||
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
|
||||
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
|
||||
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
|
||||
import tmSearch from '@/tm-vuetify/components/tm-search/tm-search.vue';
|
||||
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
|
||||
import tmTabs from '@/tm-vuetify/components/tm-tabs/tm-tabs.vue';
|
||||
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
|
||||
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
|
||||
import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue';
|
||||
|
||||
export default {
|
||||
import MarkdownConfig from '@/common/markdown/markdown.config.js';
|
||||
import mpHtml from '@/components/mp-html/components/mp-html/mp-html.vue';
|
||||
|
||||
import pluginAvailableMixin from "@/common/mixins/pluginAvailable.js"
|
||||
import PluginUnavailable from '@/components/plugin-unavailable/plugin-unavailable.vue'
|
||||
|
||||
export default {
|
||||
mixins: [pluginAvailableMixin],
|
||||
components: {
|
||||
tmSkeleton,
|
||||
tmSearch,
|
||||
tmTranslate,
|
||||
tmTabs,
|
||||
tmFlotbutton,
|
||||
tmEmpty
|
||||
tmEmpty,
|
||||
tmTags,
|
||||
mpHtml,
|
||||
PluginUnavailable
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
isBlackTheme: false,
|
||||
markdownConfig: MarkdownConfig,
|
||||
loading: 'loading',
|
||||
tab: {
|
||||
activeIndex: 0,
|
||||
@@ -73,9 +106,9 @@ export default {
|
||||
},
|
||||
queryParams: {
|
||||
keyword: "",
|
||||
limit: 5,
|
||||
highlightPreTag: "<text>",
|
||||
highlightPostTag: "</text>"
|
||||
limit: 50,
|
||||
highlightPreTag: "",
|
||||
highlightPostTag: ""
|
||||
},
|
||||
cache: {
|
||||
dataList: [],
|
||||
@@ -88,41 +121,41 @@ export default {
|
||||
haloConfigs() {
|
||||
return this.$tm.vx.getters().getConfigs;
|
||||
},
|
||||
calcAuditModeEnabled() {
|
||||
return this.haloConfigs.auditConfig.auditModeEnabled
|
||||
},
|
||||
onLoad() {
|
||||
},
|
||||
async onLoad() {
|
||||
this.fnSetPageTitle('内容搜索');
|
||||
},
|
||||
created() {
|
||||
// 检查插件
|
||||
this.setPluginId(this.NeedPluginIds.PluginSearchWidget)
|
||||
this.setPluginError("阿偶,检测到当前插件没有安装或者启用,无法使用搜索功能哦,请联系管理员")
|
||||
if (!await this.checkPluginAvailable()) return
|
||||
if (!this.queryParams.keyword) {
|
||||
this.loading = 'success'
|
||||
} else {
|
||||
this.fnGetData();
|
||||
}
|
||||
},
|
||||
|
||||
onPullDownRefresh() {
|
||||
this.fnResetSetAniWaitIndex();
|
||||
this.fnGetData();
|
||||
if (!this.uniHaloPluginAvailable) {
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
return
|
||||
}
|
||||
this.fnOnSearch()
|
||||
},
|
||||
|
||||
methods: {
|
||||
fnOnTabChange(index) {
|
||||
this.fnResetSetAniWaitIndex();
|
||||
this.dataList = [];
|
||||
const _sorts = {
|
||||
0: '',
|
||||
1: 'topPriority,createTime,desc',
|
||||
2: 'topPriority,visits,desc',
|
||||
3: 'topPriority,updateTime,desc',
|
||||
4: 'topPriority,likes,desc'
|
||||
};
|
||||
this.queryParams.sort = _sorts[index];
|
||||
this.dataList = [];
|
||||
this.fnToTopPage();
|
||||
this.fnGetData();
|
||||
},
|
||||
fnOnSearch() {
|
||||
this.fnResetSetAniWaitIndex();
|
||||
|
||||
if (!this.queryParams.keyword) {
|
||||
this.dataList = []
|
||||
} else {
|
||||
@@ -130,7 +163,7 @@ export default {
|
||||
}
|
||||
},
|
||||
fnGetData() {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
return;
|
||||
}
|
||||
// 设置状态为加载中
|
||||
@@ -152,20 +185,31 @@ export default {
|
||||
}, 800);
|
||||
});
|
||||
},
|
||||
|
||||
//跳转文章详情
|
||||
fnToArticleDetail(article) {
|
||||
isArticle(item) {
|
||||
return item.type == 'post.content.halo.run'
|
||||
},
|
||||
//跳转详情
|
||||
fnToDetail(item) {
|
||||
if (this.calcAuditModeEnabled) return;
|
||||
if (this.isArticle(item)) {
|
||||
uni.navigateTo({
|
||||
url: '/pagesA/article-detail/article-detail?name=' + article.metadataName,
|
||||
url: '/pagesA/article-detail/article-detail?name=' + item.metadataName,
|
||||
animationType: 'slide-in-right'
|
||||
});
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
url: '/pagesA/moment-detail/moment-detail?name=' + item.metadataName,
|
||||
animationType: 'slide-in-right'
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.app-page {
|
||||
.app-page {
|
||||
width: 100vw;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
@@ -176,17 +220,17 @@ export default {
|
||||
&.is-balck {
|
||||
background-color: #212121;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
.content {
|
||||
padding-top: 24rpx;
|
||||
}
|
||||
|
||||
.content-empty {
|
||||
height: 60vh;
|
||||
}
|
||||
}
|
||||
|
||||
.article-card {
|
||||
.article-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
@@ -197,5 +241,5 @@ export default {
|
||||
box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.03);
|
||||
overflow: hidden;
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -68,6 +68,18 @@ export default {
|
||||
this.queryParams.page = 0;
|
||||
this.fnGetData();
|
||||
},
|
||||
onShareAppMessage() {
|
||||
return {
|
||||
title: this.pageTitle,
|
||||
path: `/pagesA/category-detail/category-detail?name=${this.name}&title=${this.pageTitle}`
|
||||
}
|
||||
},
|
||||
onShareTimeline() {
|
||||
return {
|
||||
title: this.pageTitle,
|
||||
path: `/pagesA/category-detail/category-detail?name=${this.name}&title=${this.pageTitle}`
|
||||
}
|
||||
},
|
||||
onReachBottom(e) {
|
||||
if (this.hasNext) {
|
||||
this.queryParams.page += 1;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<template>
|
||||
<view class="app-page card-shadow">
|
||||
<view class="app-page card-shadow" :class="[uniHaloPluginPageClass]">
|
||||
<PluginUnavailable v-if="!uniHaloPluginAvailable" :pluginId="uniHaloPluginId"
|
||||
:error-text="uniHaloPluginAvailableError" />
|
||||
<template v-else>
|
||||
<view v-if="loading != 'success'" class="loading-wrap">
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
@@ -65,7 +68,7 @@
|
||||
|
||||
<!-- 返回顶部 -->
|
||||
<tm-flotbutton color="light-blue" @click="fnToTopPage" size="m" icon="icon-angle-up"></tm-flotbutton>
|
||||
<tm-flotbutton v-if="haloPluginConfigs.submitLink.enabled" :offset="[16,80]" label="申请"
|
||||
<tm-flotbutton v-if="haloPluginConfigs.linksSubmitPlugin.enabled" :offset="[16,80]" label="申请"
|
||||
actions-pos="left" :show-text="true" color="bg-gradient-orange-accent"
|
||||
@click="toSubmitLinkPage"></tm-flotbutton>
|
||||
<!-- 详情弹窗 -->
|
||||
@@ -73,10 +76,12 @@
|
||||
<view class="poup pa-36" v-if="detail.data">
|
||||
<view class="info flex">
|
||||
<view class="poup-logo bg-gradient-amber-accent pa-4 shadow-24">
|
||||
<image class="poup-logo_img" :src="$utils.checkImageUrl(detail.data.spec.logo)" mode="aspectFill"></image>
|
||||
<image class="poup-logo_img" :src="$utils.checkImageUrl(detail.data.spec.logo)"
|
||||
mode="aspectFill"></image>
|
||||
</view>
|
||||
<view class="pl-24 info-detail">
|
||||
<view class="poup-name text-size-lg text-weight-b">{{ detail.data.spec.displayName }}</view>
|
||||
<view class="poup-name text-size-lg text-weight-b">{{ detail.data.spec.displayName }}
|
||||
</view>
|
||||
<view class="poup-tag ml--10">
|
||||
<tm-tags color="bg-gradient-light-blue-lighten" size="n" model="fill">
|
||||
{{ detail.data.spec.groupName }}
|
||||
@@ -103,19 +108,24 @@
|
||||
|
||||
<view class="load-text">{{ loadMoreText }}</view>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
|
||||
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
|
||||
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
|
||||
import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue';
|
||||
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
|
||||
import tmImages from '@/tm-vuetify/components/tm-images/tm-images.vue';
|
||||
import tmPoup from '@/tm-vuetify/components/tm-poup/tm-poup.vue';
|
||||
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
|
||||
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
|
||||
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
|
||||
import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue';
|
||||
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
|
||||
import tmImages from '@/tm-vuetify/components/tm-images/tm-images.vue';
|
||||
import tmPoup from '@/tm-vuetify/components/tm-poup/tm-poup.vue';
|
||||
|
||||
export default {
|
||||
import pluginAvailableMixin from "@/common/mixins/pluginAvailable.js"
|
||||
import PluginUnavailable from '@/components/plugin-unavailable/plugin-unavailable.vue'
|
||||
|
||||
export default {
|
||||
mixins: [pluginAvailableMixin],
|
||||
components: {
|
||||
tmSkeleton,
|
||||
tmTranslate,
|
||||
@@ -123,7 +133,8 @@ export default {
|
||||
tmTags,
|
||||
tmEmpty,
|
||||
tmImages,
|
||||
tmPoup
|
||||
tmPoup,
|
||||
PluginUnavailable
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -166,19 +177,32 @@ export default {
|
||||
}
|
||||
return 'https://image.thum.io/get/width/1000/crop/800/' + val;
|
||||
};
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
calcAuditModeEnabled() {
|
||||
return this.haloConfigs.auditConfig.auditModeEnabled
|
||||
},
|
||||
},
|
||||
async onLoad() {
|
||||
this.fnSetPageTitle('友情链接');
|
||||
// 检查插件
|
||||
this.setPluginId(this.NeedPluginIds.PluginLinks)
|
||||
this.setPluginError("阿偶,检测到当前插件没有安装或者启用,无法使用友情链接功能哦,请联系管理员")
|
||||
if (!await this.checkPluginAvailable()) return
|
||||
this.fnGetLinkGroupData();
|
||||
},
|
||||
onPullDownRefresh() {
|
||||
if (!this.uniHaloPluginAvailable) {
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
return
|
||||
}
|
||||
this.isLoadMore = false;
|
||||
this.queryParams.page = 1;
|
||||
this.dataList = []
|
||||
this.fnGetData();
|
||||
},
|
||||
onReachBottom(e) {
|
||||
if (!this.uniHaloPluginAvailable) return;
|
||||
if (this.hasNext) {
|
||||
this.queryParams.page += 1;
|
||||
this.isLoadMore = true;
|
||||
@@ -207,10 +231,11 @@ export default {
|
||||
},
|
||||
findLinkGroupDisplayNameByGroupMetadataName(groupName) {
|
||||
if (this.linkGroupList.length === 0) return groupName || "未分组"
|
||||
return this.linkGroupList.find(item => item.metadata.name === groupName)?.spec?.displayName || groupName || "未分组"
|
||||
return this.linkGroupList.find(item => item.metadata.name === groupName)?.spec?.displayName || groupName ||
|
||||
"未分组"
|
||||
},
|
||||
fnGetData() {
|
||||
if (this.haloConfigs.basicConfig.auditModeEnabled) {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
return;
|
||||
}
|
||||
if (!this.isLoadMore) {
|
||||
@@ -225,7 +250,8 @@ export default {
|
||||
this.hasNext = res.hasNext;
|
||||
const list = res.items.map(item => {
|
||||
item.spec.logo = this.$utils.checkAvatarUrl(item.spec?.logo)
|
||||
item.spec.groupName = this.findLinkGroupDisplayNameByGroupMetadataName(item.spec?.groupName)
|
||||
item.spec.groupName = this.findLinkGroupDisplayNameByGroupMetadataName(item.spec
|
||||
?.groupName)
|
||||
return item;
|
||||
})
|
||||
this.dataList = this.dataList.concat(list);
|
||||
@@ -301,24 +327,24 @@ export default {
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.app-page {
|
||||
.app-page {
|
||||
width: 100vw;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background-color: #fafafd;
|
||||
}
|
||||
}
|
||||
|
||||
.loading-wrap {
|
||||
.loading-wrap {
|
||||
padding: 24rpx;
|
||||
min-height: 100vh;
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
.content {
|
||||
padding: 0 24rpx;
|
||||
padding-top: 24rpx;
|
||||
|
||||
@@ -328,9 +354,9 @@ export default {
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.link-card {
|
||||
.link-card {
|
||||
border-bottom: 2rpx solid #f5f5f5;
|
||||
background-color: #ffffff;
|
||||
|
||||
@@ -374,20 +400,20 @@ export default {
|
||||
font-size: 28rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.link-card_name {
|
||||
.link-card_name {
|
||||
// color: #303133;
|
||||
// color: #0080fe;
|
||||
}
|
||||
}
|
||||
|
||||
.link-card_desc {
|
||||
.link-card_desc {
|
||||
font-size: 24rpx;
|
||||
line-height: 1.6;
|
||||
color: #303133;
|
||||
}
|
||||
}
|
||||
|
||||
.link-logo {
|
||||
.link-logo {
|
||||
width: 140rpx;
|
||||
height: 140rpx;
|
||||
|
||||
@@ -395,9 +421,9 @@ export default {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.poup-logo {
|
||||
.poup-logo {
|
||||
width: 140rpx;
|
||||
height: 140rpx;
|
||||
border-radius: 50%;
|
||||
@@ -407,22 +433,22 @@ export default {
|
||||
height: 100%;
|
||||
border-radius: 50%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.info-detail {
|
||||
.info-detail {
|
||||
width: 0;
|
||||
flex-grow: 1;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
|
||||
.poup-desc {
|
||||
.poup-desc {
|
||||
font-size: 28rpx;
|
||||
line-height: 1.6;
|
||||
color: #555 !important;
|
||||
}
|
||||
}
|
||||
|
||||
.preview-site {
|
||||
.preview-site {
|
||||
width: 100%;
|
||||
height: 300rpx;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,357 @@
|
||||
<template>
|
||||
<view class="app-page">
|
||||
<view v-if="loading !== 'success'" class="loading-wrap">
|
||||
<tm-skeleton model="card"></tm-skeleton>
|
||||
<tm-skeleton model="card"></tm-skeleton>
|
||||
<tm-skeleton model="card"></tm-skeleton>
|
||||
</view>
|
||||
<block v-else>
|
||||
<view class="moment-card">
|
||||
<view class="card flex flex-start">
|
||||
<view class="avatar" style="flex-shrink: 0;">
|
||||
<image style="width: 80rpx;height: 80rpx;border-radius: 50%;" :src="moment.spec.user.avatar" />
|
||||
</view>
|
||||
<view class="nickname" style="margin-left: 12rpx;">
|
||||
<view style="font-size: 30rpx;font-weight: bold;color: #333333;">
|
||||
{{ moment.spec.user.displayName }}
|
||||
</view>
|
||||
<view style="margin-top: 6rpx;font-size: 24rpx;color: #666;">
|
||||
{{ {d: moment.spec.releaseTime, f: 'yyyy年MM月dd日 星期w'} | formatTime }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="moment.spec.tags && moment.spec.tags.length!==0" class="card flex flex-wrap flex-start"
|
||||
style="padding-top:12rpx;padding-bottom:12rpx;">
|
||||
<text class="text-size-m">标签列表:</text>
|
||||
<tm-tags v-for="(tag,tagIndex) in moment.spec.tags" :key="tagIndex" :color="randomTagColor()"
|
||||
size="m" model="text">
|
||||
{{ tag }}
|
||||
</tm-tags>
|
||||
</view>
|
||||
|
||||
<view class="card" style="padding:0">
|
||||
<mp-html class="evan-markdown" lazy-load :domain="markdownConfig.domain"
|
||||
:loading-img="markdownConfig.loadingGif" :scroll-table="true" :selectable="true"
|
||||
:tag-style="markdownConfig.tagStyle" :container-style="markdownConfig.containStyle"
|
||||
:content="moment.spec.newHtml" :markdown="true" :showLineNumber="true" :showLanguageName="true"
|
||||
:copyByLongPress="true" />
|
||||
</view>
|
||||
<view v-if="moment.images && moment.images.length!==0" class="card">
|
||||
<view class="card-head text-size-m">
|
||||
图片附件:
|
||||
</view>
|
||||
<view class="images" :class="['images-'+moment.images.length]">
|
||||
<view class="image-item" v-for="(image,mediumIndex) in moment.images" :key="mediumIndex">
|
||||
<image mode="aspectFill" style="width: 100%;height: 100%;border-radius: 6rpx;"
|
||||
:src="image.url" @click="handlePreview(mediumIndex,moment.images)" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="moment.audios && moment.audios.length!==0" class="card">
|
||||
<view class="card-head text-size-m">
|
||||
音频附件:
|
||||
</view>
|
||||
<view
|
||||
style="display: flex; flex-direction: column; gap: 12rpx 0;padding: 0 24rpx;padding-right:28rpx;">
|
||||
<audio v-for="(audio,index) in moment.audios" :controls="true" :key="index" :id="audio.url"
|
||||
:poster="bloggerInfo.avatar"
|
||||
:name="'来自' + (startConfig.title||bloggerInfo.nickname) + '的声音'"
|
||||
:author="bloggerInfo.nickname" :src="audio.url"></audio>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="moment.videos && moment.videos.length!==0" class="card">
|
||||
<view class="card-head text-size-m">
|
||||
视频附件:
|
||||
</view>
|
||||
<view style="margin-top:24rpx;width:100%;display: flex; flex-direction: column; gap: 12rpx 0;">
|
||||
<video style="width:100%;height: 400rpx;border-radius: 12rpx;"
|
||||
v-for="(video,index) in moment.videos" :key="index" :src="video.url"
|
||||
:id="'video_' + video.id" :show-mute-btn="true" :controls="true"
|
||||
:show-center-play-btn="true" :enable-progress-gesture="true" @play="onVideoPlay(video.id)"
|
||||
@pause="onVideoPause(video.id)" @ended="onVideoEnded(video.id)"></video>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
|
||||
<!-- 返回顶部 -->
|
||||
<tm-flotbutton :width="90" :offset="[16, 80]" icon="icon-angle-up" color="bg-gradient-light-blue-accent"
|
||||
@click="fnToTopPage()"></tm-flotbutton>
|
||||
</block>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import MarkdownConfig from '@/common/markdown/markdown.config.js';
|
||||
|
||||
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
|
||||
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
|
||||
import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
|
||||
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
|
||||
import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue';
|
||||
|
||||
import mpHtml from '@/components/mp-html/components/mp-html/mp-html.vue';
|
||||
import {
|
||||
getAppConfigs
|
||||
} from '@/config/index.js'
|
||||
import HaloTokenConfig from "@/config/uhalo.config";
|
||||
import {
|
||||
getRandomNumberByRange
|
||||
} from "@/utils/random.js";
|
||||
import {
|
||||
generateUUID
|
||||
} from '@/utils/uuid.js';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
tmSkeleton,
|
||||
tmFlotbutton,
|
||||
tmButton,
|
||||
tmEmpty,
|
||||
mpHtml,
|
||||
tmTags
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: 'loading',
|
||||
markdownConfig: MarkdownConfig,
|
||||
queryParams: {
|
||||
name: null
|
||||
},
|
||||
moment: null,
|
||||
tagColors: ['orange', 'green', 'red', 'blue'],
|
||||
videoContexts: {},
|
||||
currentVideoId: null
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
haloConfigs() {
|
||||
return this.$tm.vx.getters().getConfigs;
|
||||
},
|
||||
calcUrl() {
|
||||
return url => {
|
||||
if (this.$utils.checkIsUrl(url)) {
|
||||
return url;
|
||||
}
|
||||
return getApp().globalData.baseApiUrl + url;
|
||||
};
|
||||
},
|
||||
// 获取博主信息
|
||||
bloggerInfo() {
|
||||
const blogger = this.haloConfigs.authorConfig.blogger;
|
||||
blogger.avatar = this.$utils.checkAvatarUrl(blogger.avatar, true);
|
||||
return blogger;
|
||||
},
|
||||
calcUseTagRandomColor() {
|
||||
return this.haloConfigs.pageConfig.momentConfig.useTagRandomColor;
|
||||
},
|
||||
},
|
||||
onLoad(e) {
|
||||
this.fnSetPageTitle('瞬间加载中...');
|
||||
this.queryParams.name = e.name;
|
||||
this.fnGetData();
|
||||
},
|
||||
onPullDownRefresh() {
|
||||
this.videoContexts = {};
|
||||
this.currentVideoId = null;
|
||||
this.fnGetData();
|
||||
},
|
||||
onShareAppMessage() {
|
||||
return {
|
||||
path: '/pagesA/moment-detail/moment-detail?name=' + this.moment.metadata.name,
|
||||
title: this.moment.spec.title,
|
||||
}
|
||||
},
|
||||
onShareTimeline() {
|
||||
return {
|
||||
title: this.moment.spec.title,
|
||||
query: {
|
||||
name: this.moment.metadata.name
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
fnGetData() {
|
||||
this.loading = 'loading';
|
||||
this.$httpApi.v2
|
||||
.getMomentByName(this.queryParams.name)
|
||||
.then(res => {
|
||||
console.log('获取详情', res);
|
||||
let _tempResult = res;
|
||||
this.fnSetPageTitle('瞬间详情');
|
||||
|
||||
_tempResult.spec.user = {
|
||||
displayName: this.bloggerInfo.nickname,
|
||||
avatar: this.$utils.checkAvatarUrl(this.bloggerInfo.avatar)
|
||||
}
|
||||
_tempResult.spec.content.medium.map(medium => {
|
||||
medium.url = this.$utils.checkThumbnailUrl(medium.url, true)
|
||||
})
|
||||
|
||||
_tempResult.spec.newHtml = this.removeTagLinksCompletely(_tempResult.spec.content.html, '')
|
||||
_tempResult['images'] = _tempResult.spec.content.medium
|
||||
.filter(x => x.type === 'PHOTO')
|
||||
|
||||
_tempResult['videos'] = _tempResult.spec.content.medium
|
||||
.filter(x => x.type === 'VIDEO').map(_tempResult => {
|
||||
_tempResult.id = generateUUID()
|
||||
return _tempResult;
|
||||
})
|
||||
|
||||
_tempResult['audios'] = _tempResult.spec.content.medium
|
||||
.filter(x => x.type === 'AUDIO')
|
||||
|
||||
this.moment = _tempResult;
|
||||
this.loading = 'success';
|
||||
|
||||
this.$nextTick(() => {
|
||||
this.createVideoContexts(_tempResult.videos);
|
||||
})
|
||||
})
|
||||
.catch(err => {
|
||||
console.log("错误", err)
|
||||
this.loading = 'error';
|
||||
})
|
||||
.finally(() => {
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
});
|
||||
},
|
||||
handlePreview(index, list) {
|
||||
uni.previewImage({
|
||||
current: index,
|
||||
urls: list.map(item => item.url)
|
||||
})
|
||||
},
|
||||
removeTagLinksCompletely(htmlString) {
|
||||
const regex = /<a\s+(?:[^>]*?\s+)?class=(['"])[^'"]*?\btag\b[^'"]*?\1[^>]*?>.*?<\/a>/gi;
|
||||
const newHtml = htmlString.replace(regex, '');
|
||||
return newHtml
|
||||
},
|
||||
randomTagColor() {
|
||||
if (!this.calcUseTagRandomColor) return "blue";
|
||||
const randomIndex = getRandomNumberByRange(0, this.tagColors.length);
|
||||
return this.tagColors[randomIndex];
|
||||
},
|
||||
createVideoContexts(videos) {
|
||||
this.stopAllVideos()
|
||||
videos.forEach(item => {
|
||||
this.videoContexts[item.id] = uni.createVideoContext(`video_${item.id}`, this);
|
||||
})
|
||||
},
|
||||
onVideoPlay(videoId) {
|
||||
this.currentVideoId = videoId;
|
||||
this.stopAllVideos(videoId)
|
||||
},
|
||||
onVideoPause(videoId) {
|
||||
if (this.currentVideoId == videoId) {
|
||||
this.currentVideoId = null;
|
||||
}
|
||||
},
|
||||
onVideoEnded(videoId) {
|
||||
this.currentVideoId = null;
|
||||
},
|
||||
stopAllVideos(excludesVideoId = null) {
|
||||
Object.keys(this.videoContexts).forEach(videoId => {
|
||||
if (!excludesVideoId || excludesVideoId != videoId) {
|
||||
const videoContext = this.videoContexts[videoId]
|
||||
videoContext?.pause();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.app-page {
|
||||
width: 100vw;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
background-color: #fafafd;
|
||||
padding-bottom: 24rpx;
|
||||
}
|
||||
|
||||
.loading-wrap {
|
||||
padding: 0 24rpx;
|
||||
height: inherit;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.moment-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
gap: 24rpx;
|
||||
padding: 24rpx;
|
||||
}
|
||||
|
||||
.card {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
border-radius: 12rpx;
|
||||
background-color: #ffff;
|
||||
box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.03);
|
||||
overflow: hidden;
|
||||
padding: 24rpx;
|
||||
|
||||
&-head {
|
||||
position: relative;
|
||||
// padding-left: 24rpx;
|
||||
margin-bottom: 6rpx;
|
||||
|
||||
&:before {
|
||||
display: none;
|
||||
box-sizing: border-box;
|
||||
content: "";
|
||||
width: 6rpx;
|
||||
height: 24rpx;
|
||||
border-radius: 24rpx;
|
||||
background: #2196F3;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 6rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.images {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-start;
|
||||
padding: 24rpx;
|
||||
|
||||
.image-item {
|
||||
box-sizing: border-box;
|
||||
border-radius: 24rpx;
|
||||
padding: 6rpx;
|
||||
width: 33%;
|
||||
height: 200rpx
|
||||
}
|
||||
|
||||
&-1 {
|
||||
>.image-item {
|
||||
width: 100%;
|
||||
height: 350rpx
|
||||
}
|
||||
}
|
||||
|
||||
&-2 {
|
||||
>.image-item {
|
||||
width: 50%;
|
||||
height: 250rpx
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
::v-deep .uni-audio-default {
|
||||
width: 100%;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
</style>
|
||||
@@ -40,7 +40,7 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<video v-else class="video-bg" :object-fit="startConfig.bgVideoFit" :src="startConfig.bgVideo" :loop="true"
|
||||
<video v-else class="video-bg" :object-fit="startConfig.bgVideoFit" :src="$utils.checkUrl(startConfig.bgVideo)" :loop="true"
|
||||
:autoplay="true" :muted="true" :controls="false" :show-fullscreen-btn="false" :show-play-btn="false"
|
||||
:show-center-play-btn="false" :show-loading="false" :enable-progress-gesture="false"
|
||||
:show-progress="false"></video>
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
<view class="poup pa-36" scroll-y="auto">
|
||||
<view class="info flex">
|
||||
<view class="poup-logo pa-4 shadow-24">
|
||||
<image :src="blogDetail.blogLogo" class="poup-logo_img" mode="aspectFill"></image>
|
||||
<image :src="$utils.checkAvatarUrl(blogDetail.blogLogo)" class="poup-logo_img" mode="aspectFill"></image>
|
||||
</view>
|
||||
<view class="pl-24 info-detail">
|
||||
<view class="poup-name text-size-lg text-weight-b">{{ blogDetail.blogName }}</view>
|
||||
@@ -97,6 +97,7 @@ import tmPoup from '@/tm-vuetify/components/tm-poup/tm-poup.vue'
|
||||
import tmImages from '@/tm-vuetify/components/tm-images/tm-images.vue'
|
||||
import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue'
|
||||
import tmCoupon from '@/tm-vuetify/components/tm-coupon/tm-coupon.vue'
|
||||
import $utils from "@/utils";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@@ -128,11 +129,14 @@ export default {
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
$utils() {
|
||||
return $utils
|
||||
},
|
||||
haloPluginConfigs(){
|
||||
return this.$tm.vx.getters().getConfigs.pluginConfig;
|
||||
},
|
||||
blogDetail() {
|
||||
return this.haloPluginConfigs.submitLink;
|
||||
return this.haloPluginConfigs.linksSubmitPlugin;
|
||||
},
|
||||
calcSiteThumbnail(val) {
|
||||
return val => {
|
||||
@@ -147,13 +151,13 @@ export default {
|
||||
return `
|
||||
博客名称:${this.blogDetail.blogName}
|
||||
博客地址:${this.blogDetail.blogUrl}
|
||||
博客logo:${this.blogDetail.blogLogo}
|
||||
博客logo:${$utils.checkAvatarUrl(this.blogDetail.blogLogo)}
|
||||
博客简介:${this.blogDetail.blogDesc}
|
||||
`
|
||||
},
|
||||
calcBlogCoupon() {
|
||||
return {
|
||||
img: this.blogDetail.blogLogo,
|
||||
img: $utils.checkAvatarUrl(this.blogDetail.blogLogo),
|
||||
title: this.blogDetail.blogName,
|
||||
time: this.blogDetail.blogDesc,
|
||||
btnText: '友链详情'
|
||||
|
||||
@@ -0,0 +1,729 @@
|
||||
<template>
|
||||
<view class="app-page">
|
||||
<view v-if="loading != 'success'" class="loading-wrap">
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
</view>
|
||||
<block v-else>
|
||||
<view v-if="!detail" class="empty">
|
||||
<tm-empty icon="icon-shiliangzhinengduixiang-" label="未查询到数据"></tm-empty>
|
||||
</view>
|
||||
<block v-else>
|
||||
<view class="vote-card vote-info-card">
|
||||
<view class="sub-title"> 投票信息 </view>
|
||||
<view class="vote-card-body flex flex-col uh-mt-8">
|
||||
<view class="">
|
||||
投票类型:<tm-tags color="light-blue" :shadow="0" size="xs" model="fill">
|
||||
{{ vote.spec._uh_type }} </tm-tags>
|
||||
</view>
|
||||
<view class="">
|
||||
投票状态:<tm-tags :color="vote.spec._uh_state.color" size="xs" :shadow="0"
|
||||
model="fill">{{vote.spec._uh_state.state}}</tm-tags>
|
||||
</view>
|
||||
<view class="">
|
||||
投票方式:<tm-tags v-if="vote.spec.canAnonymously" color="light-blue" size="xs" :shadow="0"
|
||||
model="fill">匿名</tm-tags>
|
||||
<tm-tags v-else color="red" size="xs" :shadow="0" model="fill">不匿名</tm-tags>
|
||||
</view>
|
||||
<view class="">
|
||||
开始时间:{{ {d: vote.spec.startDate, f: 'yyyy-MM-dd HH:mm'} | formatTime }}
|
||||
</view>
|
||||
<view class="">
|
||||
<text v-if="vote.spec.timeLimit==='permanent'">
|
||||
结束时间:永久有效
|
||||
</text>
|
||||
<text v-else>
|
||||
结束时间:{{ {d: vote.spec.endDate, f: 'yyyy-MM-dd HH:mm'} | formatTime }}
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="vote-card">
|
||||
<view class="vote-card-head flex flex-col items-start mb-12">
|
||||
<view class="sub-title"> 投票内容 </view>
|
||||
<view class="sub-content">
|
||||
{{ vote.spec.title }}
|
||||
</view>
|
||||
<view v-if="vote.spec.remark" class="sub-remark">
|
||||
{{ vote.spec.remark }}
|
||||
</view>
|
||||
</view>
|
||||
<view class="vote-card-body uh-mt-8">
|
||||
<view class="sub-title"> 投票选项 <text v-if="vote.spec.type==='multiple'"
|
||||
class="sub-title-count">(最多选择 {{ vote.spec.maxVotes }} 项)</text> </view>
|
||||
<view v-if="vote.spec.type==='single'" class="single">
|
||||
<view class="w-full flex flex-col uh-gap-8">
|
||||
<template v-if="vote.spec.isVoted || vote.spec.hasEnded">
|
||||
<view v-for="(option,optionIndex) in vote.spec.options" :key="optionIndex"
|
||||
class="is-voted-item" :class="[option.checked?'selected':'']" :style="{
|
||||
'--percent':option._uh_percent + '%'
|
||||
}">
|
||||
<view class="is-voted-item-content flex w-full flex-between uh-gap-8">
|
||||
<view class="flex-1 text-align-left text-break">
|
||||
{{option.title }}
|
||||
</view>
|
||||
<view class="flex-shrink">
|
||||
{{option._uh_percent }}%
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view v-for="(option,optionIndex) in vote.spec.options" :key="optionIndex"
|
||||
class="vote-select-option flex-1 w-full text-break"
|
||||
:class="[option.checked?'light-blue':'grey-lighten-3']"
|
||||
@click="handleSelectSingleOption(option)">
|
||||
{{option.title }}
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-else-if="vote.spec.type==='multiple'" class="multiple">
|
||||
<view class="w-full flex flex-col uh-gap-8">
|
||||
<template v-if="vote.spec.isVoted || vote.spec.hasEnded">
|
||||
<view v-for="(option,optionIndex) in vote.spec.options" :key="optionIndex"
|
||||
class="is-voted-item" :class="[option.checked?'selected':'']" :style="{
|
||||
'--percent':option._uh_percent + '%'
|
||||
}">
|
||||
<view class="is-voted-item-content flex w-full flex-between uh-gap-8">
|
||||
<view class="flex-1 text-align-left text-break">
|
||||
{{option.title }}
|
||||
</view>
|
||||
<view class="flex-shrink">
|
||||
{{option._uh_percent }}%
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view v-for="(option,optionIndex) in vote.spec.options" :key="optionIndex"
|
||||
class="vote-select-option flex-1 w-full text-break"
|
||||
:class="[option.checked?'light-blue':'grey-lighten-3']"
|
||||
@click="handleSelectCheckboxOption(option)">
|
||||
{{option.title }}
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-else-if="vote.spec.type==='pk'" class="pk">
|
||||
<view class="pk-container">
|
||||
<view class="radio-item" v-for="(option,optionIndex) in vote.spec.options"
|
||||
:key="optionIndex" :class="[optionIndex==0?'radio-left':'radio-right']"
|
||||
:style="{width: option._uh_percent + '%'}">
|
||||
<view class="option-item"
|
||||
:class="[optionIndex==0?'option-item-left':'option-item-right']">
|
||||
{{option._uh_percent }}%
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="option-foot w-full flex flex-col uh-gap-8">
|
||||
<template v-if="vote.spec.isVoted || vote.spec.hasEnded">
|
||||
<view v-for="(option,optionIndex) in vote.spec.options" :key="optionIndex"
|
||||
class="is-voted-item" :class="[option.checked?'selected':'']" :style="{
|
||||
'--percent': option._uh_percent + '%'
|
||||
}">
|
||||
<view class="is-voted-item-content flex w-full flex-between uh-gap-8">
|
||||
<view class="flex-1 text-align-left text-break">
|
||||
选项{{ optionIndex+1}}:{{option.title }}
|
||||
</view>
|
||||
<view class="flex-shrink">
|
||||
{{option._uh_percent }}%
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<view v-for="(option,optionIndex) in vote.spec.options" :key="optionIndex"
|
||||
class="vote-select-option flex-1 w-full text-break"
|
||||
:class="[option.checked?'light-blue':'grey-lighten-3']"
|
||||
@click="handleSelectSingleOption(option)">
|
||||
选项{{ optionIndex+1}}:{{option.title }}
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="vote-card">
|
||||
<view class="vote-card-body">
|
||||
<view class="sub-title"> 投票统计 </view>
|
||||
<view class="">
|
||||
<tm-tags color="grey-darken-4" size="s" model="text">{{ vote.stats.voteCount }}
|
||||
人已参与</tm-tags>
|
||||
<!-- <tm-tags v-if="vote.spec.isVoted" color="blue" rounded size="s" model="text">已投票</tm-tags> -->
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 暂时不做,目前没有意义 -->
|
||||
<!-- <view v-if="vote.spec.canSeeVoters" class="vote-card">
|
||||
<view class="vote-card-body">
|
||||
<view class="sub-title"> 投票用户 </view>
|
||||
<view class="">
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</view> -->
|
||||
|
||||
<view class="vote-submit flex w-full flex-center" :style="{
|
||||
paddingBottom:safeAreaBottom + 'rpx'
|
||||
}">
|
||||
<tm-button v-if="fnCalcIsVoted()" theme="white" text :block="true" class="w-full">您已参与投票</tm-button>
|
||||
<tm-button v-else-if="vote.spec._uh_state.state==='未开始'" theme="orange" text class="w-full"
|
||||
:block="true" @click="handleSubmitTip('投票未开始')">投票未开始</tm-button>
|
||||
<tm-button v-else-if="vote.spec._uh_state.state==='已结束'" theme="red" text class="w-full"
|
||||
:block="true" @click="handleSubmitTip('投票已结束')">投票已结束</tm-button>
|
||||
<tm-button v-else-if="!vote.spec.canAnonymously" theme="red" :shadow="0" class="w-full" text
|
||||
:block="true" @click="handleSubmit()">不支持匿名投票</tm-button>
|
||||
<tm-button v-else-if="submitForm.voteData.length===0" theme="white" text class="w-full"
|
||||
:block="true" @click="handleSubmitTip('请选择选项')">提交投票(请选择选项)</tm-button>
|
||||
<tm-button v-else theme="light-blue" class="w-full" :block="true" :loading="submitLoading"
|
||||
:disabled="submitLoading" @click="handleSubmit()">提交投票</tm-button>
|
||||
</view>
|
||||
</block>
|
||||
</block>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
|
||||
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
|
||||
import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
|
||||
import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue';
|
||||
|
||||
import {
|
||||
VOTE_TYPES,
|
||||
calcVoteState,
|
||||
calcVotePercent,
|
||||
voteCacheUtil
|
||||
} from '@/utils/vote.js'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
tmSkeleton,
|
||||
tmEmpty,
|
||||
tmButton,
|
||||
tmTags,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
safeAreaBottom: 24,
|
||||
loading: 'loading',
|
||||
submitLoading: false,
|
||||
pageTitle: '加载中...',
|
||||
|
||||
name: '',
|
||||
detail: null,
|
||||
vote: null,
|
||||
submitForm: {
|
||||
voteData: []
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
onLoad(e) {
|
||||
this.name = e.name;
|
||||
this.fnGetData();
|
||||
// this.fnGetVoteUserList();
|
||||
// #ifndef H5
|
||||
const systemInfo = uni.getSystemInfoSync();
|
||||
this.safeAreaBottom = systemInfo.safeAreaInsets.bottom + 12;
|
||||
// #endif
|
||||
},
|
||||
onPullDownRefresh() {
|
||||
this.fnGetData();
|
||||
// this.fnGetVoteUserList();
|
||||
},
|
||||
onShareAppMessage() {
|
||||
return {
|
||||
path: '/pagesA/vote-detail/vote-detail?name=' + this.name,
|
||||
title: this.vote?.spec?.title ?? "来投个票吧",
|
||||
imageUrl: ""
|
||||
}
|
||||
},
|
||||
onShareTimeline() {
|
||||
return {
|
||||
title: this.vote?.spec?.title ?? "来投个票吧",
|
||||
query: {
|
||||
name: this.name
|
||||
},
|
||||
imageUrl: ""
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
fnGetData() {
|
||||
// 设置状态为加载中
|
||||
this.loading = 'loading';
|
||||
this.pageTitle = "加载中..."
|
||||
this.$httpApi.v2
|
||||
.getVoteDetail(this.name)
|
||||
.then(res => {
|
||||
this.pageTitle = "投票详情" + `(${VOTE_TYPES[res.vote.spec.type]})`
|
||||
|
||||
const tempVoteRes = res;
|
||||
|
||||
tempVoteRes.vote.spec.isVoted = this.fnCalcIsVoted()
|
||||
tempVoteRes.vote.spec.disabled = this.fnCalcIsVoted()
|
||||
tempVoteRes.vote.spec._uh_state = calcVoteState(tempVoteRes.vote)
|
||||
tempVoteRes.vote.spec._uh_type = VOTE_TYPES[tempVoteRes.vote.spec.type]
|
||||
|
||||
tempVoteRes.vote.spec.options.map((option, index) => {
|
||||
option.value = option.id
|
||||
option.label = option.title
|
||||
option.isVoted = this.fnCalcIsVoted()
|
||||
option.checked = this.fnCalcIsChecked(option)
|
||||
option._uh_percent = calcVotePercent(tempVoteRes.vote, option);
|
||||
|
||||
option.dataStr = JSON.stringify(option)
|
||||
|
||||
return option
|
||||
})
|
||||
|
||||
this.vote = tempVoteRes.vote
|
||||
this.detail = tempVoteRes;
|
||||
|
||||
setTimeout(() => {
|
||||
this.loading = 'success';
|
||||
}, 200);
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
this.loading = 'error';
|
||||
this.pageTitle = "加载失败,请重试..."
|
||||
})
|
||||
.finally(() => {
|
||||
setTimeout(() => {
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
this.fnSetPageTitle(this.pageTitle);
|
||||
}, 200);
|
||||
});
|
||||
},
|
||||
fnGetVoteUserList() {
|
||||
this.$httpApi.v2
|
||||
.getVoteUserList(this.name)
|
||||
.then(res => {
|
||||
console.log("查询投票用户列表")
|
||||
})
|
||||
.catch(err => {
|
||||
console.log("err")
|
||||
})
|
||||
},
|
||||
fnCalcIsVoted() {
|
||||
return voteCacheUtil.has(this.name)
|
||||
},
|
||||
|
||||
fnCalcIsChecked(option) {
|
||||
const data = voteCacheUtil.get(this.name)
|
||||
if (!data) return false;
|
||||
const checked = data.selected.includes(option.id)
|
||||
return checked
|
||||
},
|
||||
onOptionRadioChange(e) {
|
||||
this.submitForm.voteData = e.map(item => this.vote.spec.options[item.index]?.id);
|
||||
},
|
||||
onOptionCheckboxChange(e) {
|
||||
this.submitForm.voteData = e.map(item => this.vote.spec.options[item.index]?.id);
|
||||
},
|
||||
onOptionPkChange(e) {
|
||||
this.submitForm.voteData = e.map(item => this.vote.spec.options[item.index]?.id);
|
||||
},
|
||||
formatJsonStr(jsonStr) {
|
||||
return jsonStr ? JSON.parse(jsonStr) : {}
|
||||
},
|
||||
handleSubmitTip(text) {
|
||||
this.showToast(text)
|
||||
},
|
||||
handleSubmit() {
|
||||
if (!this.vote.spec.canAnonymously) {
|
||||
uni.showModal({
|
||||
icon: "none",
|
||||
title: "提示",
|
||||
content: "该投票不支持匿名,请到博主的 网站端 进行投票!",
|
||||
cancelColor: "#666666",
|
||||
cancelText: "关闭",
|
||||
confirmText: "复制地址",
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
this.$utils.copyText(this.$baseApiUrl, "复制成功")
|
||||
}
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
this.submitLoading = true
|
||||
uni.showLoading({
|
||||
title: "正在保存..."
|
||||
})
|
||||
|
||||
this.$httpApi.v2
|
||||
.submitVote(this.name, this.submitForm, this.vote.spec.canAnonymously)
|
||||
.then(res => {
|
||||
|
||||
this.showToast("提交成功")
|
||||
voteCacheUtil.set(this.name, {
|
||||
selected: [...this.submitForm.voteData],
|
||||
data: this.vote
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
uni.startPullDownRefresh()
|
||||
this.submitLoading = false
|
||||
}, 1500);
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
this.showToast("提交失败,请重试")
|
||||
this.submitLoading = false
|
||||
})
|
||||
},
|
||||
|
||||
handleSelectSingleOption(option) {
|
||||
if (this.vote.spec._uh_state.state == '未开始') {
|
||||
this.showToast(`投票未开始`)
|
||||
return
|
||||
}
|
||||
if (this.vote.spec.hasEnded) return
|
||||
if (this.vote.spec.disabled) return
|
||||
this.vote.spec.options.map(item => {
|
||||
if (option.id == item.id) {
|
||||
item.checked = true
|
||||
} else {
|
||||
item.checked = false
|
||||
}
|
||||
})
|
||||
|
||||
this.submitForm.voteData = this.vote.spec.options.filter(x => x.checked).map(item => item.id)
|
||||
},
|
||||
|
||||
handleSelectCheckboxOption(option) {
|
||||
if (this.vote.spec._uh_state.state == '未开始') {
|
||||
this.showToast(`投票未开始`)
|
||||
return
|
||||
}
|
||||
if (this.vote.spec.hasEnded) return
|
||||
if (this.vote.spec.disabled) return
|
||||
|
||||
const checkedList = this.vote.spec.options.filter(x => x.checked && x.id != option.id)
|
||||
|
||||
if (this.vote.spec.type === 'multiple' && checkedList.length >= this.vote.spec.maxVotes) {
|
||||
this.showToast(`最多选择 ${this.vote.spec.maxVotes} 项`)
|
||||
return
|
||||
}
|
||||
|
||||
this.vote.spec.options.map(item => {
|
||||
if (option.id == item.id) {
|
||||
item.checked = !item.checked
|
||||
}
|
||||
})
|
||||
|
||||
this.submitForm.voteData = this.vote.spec.options.filter(x => x.checked).map(item => item.id)
|
||||
},
|
||||
showToast(content) {
|
||||
uni.showToast({
|
||||
icon: "none",
|
||||
title: content,
|
||||
mask: true
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.app-page {
|
||||
box-sizing: border-box;
|
||||
width: 100vw;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 24rpx 0;
|
||||
padding-bottom: 160rpx;
|
||||
background-color: #fafafd;
|
||||
}
|
||||
|
||||
.loading-wrap {
|
||||
padding: 0 24rpx;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.empty {
|
||||
height: 60vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.w-full {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.wp-50 {
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.vote-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
margin: 0 24rpx;
|
||||
padding: 24rpx;
|
||||
border-radius: 12rpx;
|
||||
background-color: #ffff;
|
||||
box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.03);
|
||||
overflow: hidden;
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
.vote-info-card {
|
||||
.vote-card-body {
|
||||
font-size: 28rpx;
|
||||
gap: 12rpx 0;
|
||||
background: #F3F4F6;
|
||||
color: #3F3F3F;
|
||||
padding: 24rpx;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.vote-card-head {
|
||||
margin-bottom: 12rpx;
|
||||
display: flex;
|
||||
align-items: flex-satrt;
|
||||
justify-content: space-between;
|
||||
|
||||
.left {
|
||||
.title {
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.vote-card-body {
|
||||
|
||||
.remark {
|
||||
box-sizing: border-box;
|
||||
padding: 12rpx 6rpx;
|
||||
padding-top: 0;
|
||||
color: rgba(0, 0, 0, 0.75);
|
||||
}
|
||||
}
|
||||
|
||||
.vote-card-foot {
|
||||
box-sizing: border-box;
|
||||
margin-top: 12px;
|
||||
padding-top: 6px;
|
||||
border-top: 2rpx solid #eee;
|
||||
}
|
||||
|
||||
.is-voted-item {
|
||||
min-height: 72rpx;
|
||||
box-sizing: border-box;
|
||||
position: relative;
|
||||
border-radius: 12rpx;
|
||||
background-color: rgba(229, 229, 229, 0.75);
|
||||
font-size: 24rpx;
|
||||
overflow: hidden;
|
||||
|
||||
&::before {
|
||||
content: "";
|
||||
width: var(--percent);
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
background-color: rgba(208, 208, 208, 1);
|
||||
z-index: 0;
|
||||
border-radius: 6rpx;
|
||||
}
|
||||
|
||||
&.selected {
|
||||
background-color: rgba(3, 169, 244, 0.35);
|
||||
color: #ffffff;
|
||||
|
||||
&::before {
|
||||
background-color: rgba(3, 169, 244, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.is-voted-item-content {
|
||||
box-sizing: border-box;
|
||||
min-height: 72rpx;
|
||||
padding: 12rpx 24rpx;
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.vote-select-option {
|
||||
box-sizing: border-box;
|
||||
padding: 20rpx 24rpx;
|
||||
font-size: 24rpx;
|
||||
border-radius: 12rpx;
|
||||
transition: all 0.1s ease-in-out;
|
||||
}
|
||||
|
||||
|
||||
::v-deep {
|
||||
.tm-button-label {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.single {
|
||||
::v-deep {}
|
||||
}
|
||||
|
||||
.multiple {
|
||||
::v-deep {}
|
||||
}
|
||||
|
||||
.pk {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
|
||||
::v-deep {
|
||||
|
||||
.pk-container {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.radio-item {
|
||||
flex-grow: 1;
|
||||
min-width: 30% !important;
|
||||
max-width: 70% !important;
|
||||
}
|
||||
|
||||
.radio-left {}
|
||||
|
||||
.radio-right {}
|
||||
|
||||
.option-item {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
padding: 24rpx;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
|
||||
.option-item-left {
|
||||
background: linear-gradient(90deg, #3B82F6, #60A5FA);
|
||||
color: white;
|
||||
clip-path: polygon(0 0, calc(100% - 40rpx) 0, 100% 100%, 0 100%);
|
||||
}
|
||||
|
||||
.option-item-right {
|
||||
background: linear-gradient(90deg, #F87171, #EF4444);
|
||||
color: white;
|
||||
clip-path: polygon(0 0, 100% 0, 100% 100%, 40rpx 100%);
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.option-foot {
|
||||
margin-top: 24rpx;
|
||||
width: 100%;
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
|
||||
.tm-groupradio {
|
||||
display: flex;
|
||||
gap: 12rpx;
|
||||
}
|
||||
|
||||
.tm-checkbox {
|
||||
// width: 100%;
|
||||
max-width: initial !important;
|
||||
}
|
||||
|
||||
.tm-button {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.left {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.right {
|
||||
box-sizing: border-box;
|
||||
|
||||
.flex-start.fulled {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.sub-content {
|
||||
margin-bottom: 12rpx;
|
||||
padding: 12rpx 0;
|
||||
font-weight: bold;
|
||||
color: #2B2F33;
|
||||
font-size: 30rpx;
|
||||
}
|
||||
|
||||
.sub-remark {
|
||||
margin-bottom: 36rpx;
|
||||
padding-top: 12rpx;
|
||||
color: #3F3F3F;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.sub-title {
|
||||
box-sizing: border-box;
|
||||
position: relative;
|
||||
margin-bottom: 12rpx;
|
||||
padding-left: 24rpx;
|
||||
// font-weight: bold;
|
||||
font-size: 30rpx;
|
||||
|
||||
&:before {
|
||||
content: "";
|
||||
width: 8rpx;
|
||||
height: 28rpx;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 6rpx;
|
||||
background: #03A9F4;
|
||||
border-radius: 6rpx;
|
||||
}
|
||||
|
||||
.sub-title-count {
|
||||
font-size: 24rpx;
|
||||
font-weight: normal;
|
||||
}
|
||||
}
|
||||
|
||||
.vote-submit {
|
||||
box-sizing: border-box;
|
||||
padding: 24rpx 36rpx;
|
||||
position: fixed;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
bottom: 0;
|
||||
background-color: rgba(255, 255, 255, 0.98);
|
||||
box-shadow: 0rpx 2rpx 24rpx rgba(0, 0, 0, 0.03);
|
||||
border-top: 2rpx solid #eee;
|
||||
z-index: 99;
|
||||
|
||||
::v-deep {
|
||||
.tm-button {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.tm-button-btn {
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,409 @@
|
||||
<template>
|
||||
<view class="app-page" :class="[uniHaloPluginPageClass]">
|
||||
<PluginUnavailable v-if="!uniHaloPluginAvailable" :pluginId="uniHaloPluginId"
|
||||
:error-text="uniHaloPluginAvailableError" />
|
||||
<template v-else>
|
||||
<!-- 顶部切换 -->
|
||||
<view class="e-fixed filter-box">
|
||||
<tm-search v-model="queryParams.keyword" :round="24" :shadow="0" color="light-blue"
|
||||
insert-color="light-blue" :clear="true" @input="fnOnSearch" @confirm="fnOnSearch"></tm-search>
|
||||
<tm-dropDownMenu :shadow="0" color="light-blue" active-color="light-blue"
|
||||
:default-selected="filterOption.selected" :list="filterOption.list"
|
||||
@confirm="fnOnFilterConfirm"></tm-dropDownMenu>
|
||||
</view>
|
||||
<!-- 占位区域 -->
|
||||
<view style="width: 100vw;height: 180rpx;"></view>
|
||||
<!-- 加载区域 -->
|
||||
<view v-if="loading == 'loading'" class="loading-wrap pa-24">
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
<tm-skeleton model="listAvatr"></tm-skeleton>
|
||||
</view>
|
||||
<view v-else-if="loading == 'error'" class="content-empty flex flex-center">
|
||||
<tm-empty icon="icon-wind-cry" label="加载异常"></tm-empty>
|
||||
</view>
|
||||
<!-- 内容区域 -->
|
||||
<view v-else class="content">
|
||||
<view v-if="dataList.length == 0" class="content-empty flex flex-center">
|
||||
<tm-empty icon="icon-shiliangzhinengduixiang-" label="暂无数据"></tm-empty>
|
||||
</view>
|
||||
<block v-else>
|
||||
<tm-translate v-for="(item, index) in dataList" :key="item.metadata.name" animation-name="fadeUp"
|
||||
:wait="calcAniWait(index)">
|
||||
<VoteCard :vote="item" :index="index" @on-click="fnToDetail"></VoteCard>
|
||||
</tm-translate>
|
||||
<view class="load-text">{{ loadMoreText }}</view>
|
||||
<tm-flotbutton @click="fnToTopPage" size="m" color="light-blue"
|
||||
icon="icon-angle-up"></tm-flotbutton>
|
||||
|
||||
</block>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import tmSkeleton from '@/tm-vuetify/components/tm-skeleton/tm-skeleton.vue';
|
||||
import tmSearch from '@/tm-vuetify/components/tm-search/tm-search.vue';
|
||||
import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
|
||||
import tmTabs from '@/tm-vuetify/components/tm-tabs/tm-tabs.vue';
|
||||
import tmFlotbutton from '@/tm-vuetify/components/tm-flotbutton/tm-flotbutton.vue';
|
||||
import tmEmpty from '@/tm-vuetify/components/tm-empty/tm-empty.vue';
|
||||
import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue';
|
||||
import tmDropDownMenu from '@/tm-vuetify/components/tm-dropDownMenu/tm-dropDownMenu.vue';
|
||||
|
||||
import VoteCard from '@/components/vote-card/vote-card.vue'
|
||||
|
||||
import {
|
||||
VOTE_TYPES,
|
||||
calcVoteState,
|
||||
voteCacheUtil
|
||||
} from '@/utils/vote.js'
|
||||
import pluginAvailableMixin from "@/common/mixins/pluginAvailable.js"
|
||||
import PluginUnavailable from '@/components/plugin-unavailable/plugin-unavailable.vue'
|
||||
|
||||
export default {
|
||||
options: {
|
||||
styleIsolation: 'shared'
|
||||
},
|
||||
mixins: [pluginAvailableMixin],
|
||||
components: {
|
||||
tmSkeleton,
|
||||
tmSearch,
|
||||
tmTranslate,
|
||||
tmTabs,
|
||||
tmFlotbutton,
|
||||
tmEmpty,
|
||||
tmTags,
|
||||
tmDropDownMenu,
|
||||
VoteCard,
|
||||
PluginUnavailable
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: 'loading',
|
||||
hasNext: false,
|
||||
isLoadMore: false,
|
||||
loadMoreText: '加载中...',
|
||||
filterOption: {
|
||||
selected: [],
|
||||
list: [{
|
||||
title: '类型',
|
||||
children: [{
|
||||
title: "",
|
||||
model: "list",
|
||||
name: "type",
|
||||
children: [{
|
||||
title: "全部",
|
||||
id: undefined
|
||||
},
|
||||
{
|
||||
title: "单选",
|
||||
id: 'single'
|
||||
},
|
||||
{
|
||||
title: "多选",
|
||||
id: 'multiple'
|
||||
},
|
||||
{
|
||||
title: "双选PK",
|
||||
id: 'pk'
|
||||
}
|
||||
]
|
||||
}]
|
||||
}, {
|
||||
title: '状态',
|
||||
children: [{
|
||||
title: "",
|
||||
model: "list",
|
||||
name: "hasEnded",
|
||||
children: [{
|
||||
title: "全部",
|
||||
id: undefined
|
||||
},
|
||||
{
|
||||
title: "进行中",
|
||||
id: false
|
||||
},
|
||||
{
|
||||
title: "已结束",
|
||||
id: true
|
||||
}
|
||||
]
|
||||
}]
|
||||
}, {
|
||||
title: '排序',
|
||||
children: [{
|
||||
title: "",
|
||||
model: "list",
|
||||
name: "sort",
|
||||
children: [{
|
||||
title: "默认排序",
|
||||
id: undefined
|
||||
},
|
||||
{
|
||||
title: "较近创建",
|
||||
id: 'metadata.creationTimestamp,desc'
|
||||
},
|
||||
{
|
||||
title: "较早创建",
|
||||
id: 'metadata.creationTimestamp,asc'
|
||||
}
|
||||
]
|
||||
}]
|
||||
}, {
|
||||
title: '是否已投',
|
||||
children: [{
|
||||
title: "",
|
||||
model: "list",
|
||||
name: "isVoted",
|
||||
children: [{
|
||||
title: "全部",
|
||||
id: undefined
|
||||
},
|
||||
{
|
||||
title: "未投票",
|
||||
id: false
|
||||
},
|
||||
{
|
||||
title: "已投票",
|
||||
id: true
|
||||
}
|
||||
]
|
||||
}]
|
||||
}]
|
||||
},
|
||||
filterIsVoted: undefined,
|
||||
queryParams: {
|
||||
keyword: "",
|
||||
page: 1,
|
||||
size: 10,
|
||||
sort: undefined,
|
||||
type: undefined,
|
||||
hasEnded: undefined
|
||||
},
|
||||
dataList: []
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
haloConfigs() {
|
||||
return this.$tm.vx.getters().getConfigs;
|
||||
},
|
||||
calcAuditModeEnabled() {
|
||||
return this.haloConfigs.auditConfig.auditModeEnabled
|
||||
},
|
||||
},
|
||||
async onLoad() {
|
||||
this.fnSetPageTitle('投票列表');
|
||||
// 检查插件
|
||||
this.setPluginId(this.NeedPluginIds.PluginVote)
|
||||
this.setPluginError("阿偶,检测到当前插件没有安装或者启用,无法使用投票功能哦,请联系管理员")
|
||||
if (!await this.checkPluginAvailable()) return
|
||||
this.fnGetData();
|
||||
},
|
||||
onPullDownRefresh() {
|
||||
if (!this.uniHaloPluginAvailable) {
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
return
|
||||
}
|
||||
this.fnResetSetAniWaitIndex();
|
||||
this.isLoadMore = false;
|
||||
this.queryParams.page = 0;
|
||||
this.fnGetData();
|
||||
},
|
||||
onReachBottom(e) {
|
||||
if (!this.uniHaloPluginAvailable) return;
|
||||
if (this.calcAuditModeEnabled) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '没有更多数据了'
|
||||
});
|
||||
return
|
||||
}
|
||||
if (this.hasNext) {
|
||||
this.queryParams.page += 1;
|
||||
this.isLoadMore = true;
|
||||
this.fnGetData();
|
||||
} else {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '没有更多数据了'
|
||||
});
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
fnOnSearch() {
|
||||
this.fnResetSetAniWaitIndex();
|
||||
this.fnToTopPage();
|
||||
this.fnGetData();
|
||||
},
|
||||
fnGetData() {
|
||||
if (this.calcAuditModeEnabled) {
|
||||
return;
|
||||
}
|
||||
uni.showLoading({
|
||||
mask: true,
|
||||
title: '加载中...'
|
||||
});
|
||||
// 设置状态为加载中
|
||||
if (!this.isLoadMore) {
|
||||
this.loading = 'loading';
|
||||
}
|
||||
this.loadMoreText = '加载中...';
|
||||
this.$httpApi.v2
|
||||
.getVoteList(this.queryParams)
|
||||
.then(res => {
|
||||
this.loading = 'success';
|
||||
this.loadMoreText = res.hasNext ? '上拉加载更多' : '呜呜,没有更多数据啦~';
|
||||
this.hasNext = res.hasNext;
|
||||
|
||||
const tempItems = res.items.map(item => {
|
||||
item.spec.disabled = true
|
||||
item.spec.isVoted = this.fnCalcIsVoted(item.metadata.name)
|
||||
item.spec._uh_state = calcVoteState(item)
|
||||
item.spec._uh_type = VOTE_TYPES[item.spec.type]
|
||||
item.spec.options.map((option, index) => {
|
||||
|
||||
option.checked = this.fnCalcIsChecked(item.metadata.name, option)
|
||||
option.value = option.id
|
||||
option.label = option.title
|
||||
|
||||
// 计算当前的选择占比
|
||||
if (item.spec.type === 'single') {
|
||||
option.percent = this.fnCalcPercent(option, item.stats);
|
||||
} else if (item.spec.type === 'multiple') {
|
||||
option.percent = this.fnCalcPercent(option, item.stats);
|
||||
} else if (item.spec.type === 'pk') {
|
||||
option.percent = this.fnCalcPercent(option, item.stats);
|
||||
}
|
||||
|
||||
return option
|
||||
})
|
||||
|
||||
return item;
|
||||
})
|
||||
|
||||
if (this.isLoadMore) {
|
||||
this.dataList = this.dataList.concat(tempItems);
|
||||
} else {
|
||||
this.dataList = tempItems;
|
||||
}
|
||||
|
||||
this.dataList = this.dataList.sort((a, b) => {
|
||||
return a.spec.isVoted - b.spec.isVoted
|
||||
})
|
||||
|
||||
if (this.filterIsVoted != undefined) {
|
||||
this.dataList = this.dataList.filter(x => x.spec.isVoted == this.filterIsVoted)
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
this.loading = 'error';
|
||||
this.loadMoreText = '加载失败,请下拉刷新!';
|
||||
})
|
||||
.finally(() => {
|
||||
setTimeout(() => {
|
||||
uni.hideLoading();
|
||||
uni.stopPullDownRefresh();
|
||||
}, 100);
|
||||
});
|
||||
},
|
||||
|
||||
fnCalcPercent(voteOption, stats) {
|
||||
if (!stats?.voteDataList) return 0;
|
||||
const option = stats.voteDataList.find(x => x.id == voteOption.id)
|
||||
if (!option) return 0;
|
||||
const percent = (option.voteCount / stats.voteCount) * 100
|
||||
return Math.round(percent)
|
||||
},
|
||||
|
||||
fnCalcIsVoted(name) {
|
||||
return voteCacheUtil.has(name)
|
||||
},
|
||||
fnCalcIsChecked(name, option) {
|
||||
const data = voteCacheUtil.get(name)
|
||||
if (!data) return false;
|
||||
const checked = data.selected.includes(option.id)
|
||||
return checked
|
||||
},
|
||||
|
||||
//跳转详情
|
||||
fnToDetail(item) {
|
||||
if (this.calcAuditModeEnabled) return;
|
||||
uni.navigateTo({
|
||||
url: '/pagesA/vote-detail/vote-detail?name=' + item.metadata.name,
|
||||
animationType: 'slide-in-right'
|
||||
});
|
||||
},
|
||||
fnOnFilterConfirm(e) {
|
||||
// 类型
|
||||
const type = e.find(x => x.name == 'type')
|
||||
if (type.children.length == 0) {
|
||||
this.queryParams.type = undefined
|
||||
} else {
|
||||
this.queryParams.type = type.children[0]?.id
|
||||
}
|
||||
|
||||
// 状态
|
||||
const hasEnded = e.find(x => x.name == 'hasEnded')
|
||||
if (hasEnded.children.length == 0) {
|
||||
this.queryParams.hasEnded = undefined
|
||||
} else {
|
||||
this.queryParams.hasEnded = hasEnded.children[0]?.id
|
||||
}
|
||||
|
||||
// 排序
|
||||
const sort = e.find(x => x.name == 'sort')
|
||||
if (sort.children.length == 0) {
|
||||
this.queryParams.sort = undefined
|
||||
} else {
|
||||
this.queryParams.sort = sort.children[0]?.id
|
||||
}
|
||||
|
||||
// 是否已经投
|
||||
const isVoted = e.find(x => x.name == 'isVoted')
|
||||
if (isVoted.children.length == 0) {
|
||||
this.filterIsVoted = undefined
|
||||
} else {
|
||||
this.filterIsVoted = isVoted.children[0]?.id
|
||||
}
|
||||
|
||||
this.queryParams.page = 0;
|
||||
this.isLoadMore = false;
|
||||
this.fnResetSetAniWaitIndex();
|
||||
this.fnToTopPage();
|
||||
this.fnGetData();
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.app-page {
|
||||
width: 100vw;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding-bottom: 24rpx;
|
||||
background-color: #fafafd;
|
||||
|
||||
&.is-balck {
|
||||
background-color: #212121;
|
||||
}
|
||||
}
|
||||
|
||||
.filter-box {
|
||||
box-shadow: 0rpx 0rpx 12rpx rgba(0, 0, 0, 0.035);
|
||||
}
|
||||
|
||||
.content {
|
||||
padding-top: 24rpx;
|
||||
}
|
||||
|
||||
.content-empty {
|
||||
height: 60vh;
|
||||
}
|
||||
</style>
|
||||
@@ -13,10 +13,13 @@ export default {
|
||||
};
|
||||
},
|
||||
onLoad(e) {
|
||||
const {title, url} = JSON.parse(e.query.data);
|
||||
this.webUrl = url;
|
||||
const {title, url} = JSON.parse(e.data);
|
||||
this.webUrl = decodeURIComponent(url);
|
||||
console.log("webUrl" + this.webUrl)
|
||||
if (title) {
|
||||
this.fnSetPageTitle(title);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
+10
-5
@@ -5,9 +5,10 @@
|
||||
* 时间:2024年06月22日 12:00:44
|
||||
* 版本:v0.1.0
|
||||
*/
|
||||
import {DefaultAppConfigs, getAppConfigs, setAppConfigs,setAppMockJson,getAppMockJson} from '@/config/index.js'
|
||||
import {DefaultAppConfigs, getAppConfigs, getAppMockJson, setAppConfigs, setAppMockJson} from '@/config/index.js'
|
||||
import v2Config from '@/api/v2/all.config.js'
|
||||
import utils from '@/utils/index.js'
|
||||
import {setTokens} from "@/utils/token";
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
@@ -21,7 +22,7 @@ export default {
|
||||
return getAppConfigs()
|
||||
},
|
||||
getMockJson(state) {
|
||||
if(state.mockJson) return state.mockJson;
|
||||
if (state.mockJson) return state.mockJson;
|
||||
return getAppMockJson()
|
||||
}
|
||||
},
|
||||
@@ -36,12 +37,17 @@ export default {
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
fetchConfigs({commit, dispatch}) {
|
||||
fetchConfigs({state, commit, dispatch}) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
const res = await v2Config.getAppConfigs()
|
||||
if (res) {
|
||||
commit('setConfigs', res)
|
||||
commit('setConfigs', utils.deepMerge(DefaultAppConfigs, res))
|
||||
|
||||
// 存储token
|
||||
if (res?.basicConfig?.tokenConfig) {
|
||||
setTokens(res.basicConfig.tokenConfig)
|
||||
}
|
||||
resolve(res)
|
||||
} else {
|
||||
dispatch("setDefaultAppSettings");
|
||||
@@ -65,7 +71,6 @@ export default {
|
||||
url: mockJsonUrl,
|
||||
method: "GET",
|
||||
success: (res) => {
|
||||
console.log("mockJson", res.data)
|
||||
commit('setMockJson', res.data)
|
||||
resolve({
|
||||
ok: true,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<view @click="onclick" class=" tm-checkbox " :class="[dense?'':'pa-20',inline?'d-inline-block':'']">
|
||||
<view class=" flex-start">
|
||||
|
||||
<slot name="default" :checkData="{label:label,checked:changValue}" :on="onclick">
|
||||
<slot name="default" :checkData="{label:label,checked:changValue,extendData}" :on="onclick">
|
||||
<view :style="{width: sizes.wk,height: sizes.wk}" class="tm-checkbox-boey relative d-inline-block"
|
||||
:class="[black?'bk':'','flex-shrink mr-10',
|
||||
changValue?'ani':'',
|
||||
@@ -51,6 +51,10 @@
|
||||
*/
|
||||
import tmIcons from "@/tm-vuetify/components/tm-icons/tm-icons.vue"
|
||||
export default {
|
||||
options: {
|
||||
virtualHost: true,
|
||||
styleIsolation: 'shared'
|
||||
},
|
||||
components:{tmIcons},
|
||||
name: 'tm-checkbox',
|
||||
model: {
|
||||
@@ -117,6 +121,10 @@
|
||||
fllowTheme:{
|
||||
type:Boolean|String,
|
||||
default:true
|
||||
},
|
||||
extendData:{
|
||||
type:Object,
|
||||
default:()=>({})
|
||||
}
|
||||
},
|
||||
data() {
|
||||
|
||||
@@ -100,8 +100,6 @@ export default {
|
||||
},
|
||||
//向列表添加数据
|
||||
pushData(list) {
|
||||
console.log('添加图片数据----------',list)
|
||||
|
||||
let prIdx_i = this.list2.length;
|
||||
if (!Array.isArray(list) || typeof list == 'undefined') {
|
||||
return false;
|
||||
@@ -122,8 +120,6 @@ export default {
|
||||
return this.dataList;
|
||||
},
|
||||
async loadimg(event, isLoad, index) {
|
||||
console.log('图片加载事件----------',event)
|
||||
|
||||
this.isLoading = true;
|
||||
let ps = this.list2[index];
|
||||
ps.isLoad = true;
|
||||
|
||||
@@ -17,6 +17,10 @@
|
||||
*
|
||||
*/
|
||||
export default {
|
||||
options: {
|
||||
virtualHost: true,
|
||||
styleIsolation: 'shared'
|
||||
},
|
||||
name:'tm-groupcheckbox',
|
||||
props:{
|
||||
// 最大选择数量
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<view @click="onclick" class=" tm-checkbox " :class="[dense?'':'pa-20',inline?'d-inline-block ':'fulled']">
|
||||
<view class="flex-start fulled">
|
||||
|
||||
<slot name="default" :checkData="{label:label,checked:changValue}" :on="onclick">
|
||||
<slot name="default" :checkData="{label:label,checked:changValue,extendData}" :on="onclick">
|
||||
<view :style="{width: sizes.wk,height: sizes.wk}" class="tm-checkbox-boey relative d-inline-block"
|
||||
:class="[black?'bk':'','flex-shrink mr-10 ',
|
||||
changValue?'ani':'',
|
||||
@@ -119,8 +119,11 @@
|
||||
fllowTheme:{
|
||||
type:Boolean|String,
|
||||
default:true
|
||||
}
|
||||
|
||||
},
|
||||
extendData:{
|
||||
type:Object,
|
||||
default:()=>({})
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
## 1.0.2(2023-09-14)
|
||||
更新使用文档:
|
||||
引入本插件 然后使用,手动滑稽,教程简单吗?
|
||||
<k-touch-listen @touchUp="touchUp" @touchDown="touchDown" @touchLeft="touchLeft" @touchRight="touchRight">
|
||||
<view>
|
||||
//您需要监听的区域的代码
|
||||
</view>
|
||||
</k-touch-listen>
|
||||
## 1.0.1(2023-09-14)
|
||||
更新使用文档:
|
||||
引入本插件 然后使用,手动滑稽,教程简单吗?
|
||||
<k-touch-listen @touchUp="touchUp" @touchDown="touchDown" @touchLeft="touchLeft" @touchRight="touchRight">
|
||||
<view>
|
||||
//您需要监听的区域的代码
|
||||
</view>
|
||||
</k-touch-listen>
|
||||
## 1.0.0(2023-09-14)
|
||||
首次提交
|
||||
@@ -0,0 +1,113 @@
|
||||
<template>
|
||||
<view class="touch-box" @touchstart="touchStart" @touchmove="touchMove" @touchend="touchEnd">
|
||||
<slot></slot>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'k-touch-listen',
|
||||
data() {
|
||||
return {
|
||||
touchStartX: 0, // 触摸时的原点
|
||||
touchStartY: 0, // 触摸时的原点
|
||||
time: 0, // 时间记录,用于滑动时且时间小于1s则执行左右滑动
|
||||
interval: '', // 记录/清理时间记录
|
||||
touchMoveX: 0, // x轴方向移动的距离
|
||||
touchMoveY: 0, // y轴方向移动的距离
|
||||
touchMoveTag: false // 定义滑动状态
|
||||
}
|
||||
},
|
||||
props: {
|
||||
direction: {
|
||||
type: String,
|
||||
default: 'all'
|
||||
},
|
||||
distance: {
|
||||
type: [String, Number],
|
||||
default: 30
|
||||
}
|
||||
},
|
||||
emits: ['touchUp', 'touchDown', 'touchLeft', 'touchRight'],
|
||||
methods: {
|
||||
// 触摸开始事件
|
||||
touchStart(e) {
|
||||
this.touchStartX = e.touches[0].pageX // 获取触摸时的原点
|
||||
this.touchStartY = e.touches[0].pageY // 获取触摸时的原点
|
||||
// 使用js计时器记录时间
|
||||
this.interval = setInterval(() => {
|
||||
this.time++
|
||||
}, 100)
|
||||
},
|
||||
// 触摸移动事件
|
||||
touchMove(e) {
|
||||
this.touchMoveTag = true
|
||||
this.touchMoveX = e.touches[0].pageX
|
||||
this.touchMoveY = e.touches[0].pageY
|
||||
},
|
||||
ressetData() {
|
||||
this.touchStartX = 0 // 触摸时的原点
|
||||
this.touchStartY = 0 // 触摸时的原点
|
||||
this.time = 0 // 时间记录,用于滑动时且时间小于1s则执行左右滑动
|
||||
this.interval = '' // 记录/清理时间记录
|
||||
this.touchMoveX = 0 // x轴方向移动的距离
|
||||
this.touchMoveY = 0 // y轴方向移动的距离
|
||||
this.touchMoveTag = false // 定义滑动状态
|
||||
},
|
||||
// 触摸结束事件
|
||||
touchEnd(e) {
|
||||
let moveX = this.touchMoveX - this.touchStartX
|
||||
let moveY = this.touchMoveY - this.touchStartY
|
||||
if (Math.sign(moveX) == -1) {
|
||||
moveX *= -1
|
||||
}
|
||||
if (Math.sign(moveY) == -1) {
|
||||
moveY *= -1
|
||||
}
|
||||
if (2 * moveX <= moveY && this.touchMoveTag) {
|
||||
// 上下
|
||||
if (this.direction != 'all' && this.direction != 'vertical') return
|
||||
// 向上滑动
|
||||
if (
|
||||
this.touchMoveY - this.touchStartY <= -this.distance &&
|
||||
this.time < 10
|
||||
) {
|
||||
this.$emit('touchUp')
|
||||
}
|
||||
// 向下滑动
|
||||
if (
|
||||
this.touchMoveY - this.touchStartY >= this.distance &&
|
||||
this.time < 10
|
||||
) {
|
||||
this.$emit('touchDown')
|
||||
}
|
||||
} else if (moveX > 2 * moveY && this.touchMoveTag) {
|
||||
// 左右
|
||||
if (this.direction != 'all' && this.direction != 'horizontal') return
|
||||
// 向左滑动
|
||||
if (
|
||||
this.touchMoveX - this.touchStartX <= -this.distance &&
|
||||
this.time < 10
|
||||
) {
|
||||
this.$emit('touchLeft')
|
||||
}
|
||||
// 向右滑动
|
||||
if (
|
||||
this.touchMoveX - this.touchStartX >= this.distance &&
|
||||
this.time < 10
|
||||
) {
|
||||
this.$emit('touchRight')
|
||||
}
|
||||
}
|
||||
clearInterval(this.interval) // 清除setInterval
|
||||
this.ressetData()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
.touch-box {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,85 @@
|
||||
{
|
||||
"id": "k-touch-listen",
|
||||
"displayName": "k-touch-listen 手势监听 全面兼容小程序、vue2、vue3等多端",
|
||||
"version": "1.0.2",
|
||||
"description": "用于监听用户滑动手势,左滑右滑,上滑下滑等一系列手势监听",
|
||||
"keywords": [
|
||||
"touch",
|
||||
"手势",
|
||||
"手势监听",
|
||||
"手势监听",
|
||||
"vue3"
|
||||
],
|
||||
"repository": "",
|
||||
"engines": {
|
||||
"HBuilderX": "^3.7.6"
|
||||
},
|
||||
"dcloudext": {
|
||||
"type": "component-vue",
|
||||
"sale": {
|
||||
"regular": {
|
||||
"price": "0.00"
|
||||
},
|
||||
"sourcecode": {
|
||||
"price": "0.00"
|
||||
}
|
||||
},
|
||||
"contact": {
|
||||
"qq": ""
|
||||
},
|
||||
"declaration": {
|
||||
"ads": "无",
|
||||
"data": "插件不采集任何数据",
|
||||
"permissions": "无"
|
||||
},
|
||||
"npmurl": ""
|
||||
},
|
||||
"uni_modules": {
|
||||
"dependencies": [],
|
||||
"encrypt": [],
|
||||
"platforms": {
|
||||
"cloud": {
|
||||
"tcb": "y",
|
||||
"aliyun": "y"
|
||||
},
|
||||
"client": {
|
||||
"Vue": {
|
||||
"vue2": "y",
|
||||
"vue3": "y"
|
||||
},
|
||||
"App": {
|
||||
"app-vue": "y",
|
||||
"app-nvue": "y"
|
||||
},
|
||||
"H5-mobile": {
|
||||
"Safari": "y",
|
||||
"Android Browser": "y",
|
||||
"微信浏览器(Android)": "y",
|
||||
"QQ浏览器(Android)": "y"
|
||||
},
|
||||
"H5-pc": {
|
||||
"Chrome": "y",
|
||||
"IE": "y",
|
||||
"Edge": "y",
|
||||
"Firefox": "y",
|
||||
"Safari": "y"
|
||||
},
|
||||
"小程序": {
|
||||
"微信": "y",
|
||||
"阿里": "y",
|
||||
"百度": "y",
|
||||
"字节跳动": "y",
|
||||
"QQ": "y",
|
||||
"钉钉": "u",
|
||||
"快手": "u",
|
||||
"飞书": "u",
|
||||
"京东": "u"
|
||||
},
|
||||
"快应用": {
|
||||
"华为": "u",
|
||||
"联盟": "u"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+42
-1
@@ -10,7 +10,7 @@
|
||||
* 修改时间:
|
||||
*/
|
||||
|
||||
import HaloTokenConfig from '@/config/token.config.js'
|
||||
import HaloTokenConfig from '@/config/uhalo.config.js'
|
||||
import {getAppConfigs} from '@/config/index.js'
|
||||
|
||||
const utils = {
|
||||
@@ -160,7 +160,48 @@ const utils = {
|
||||
urls: list,
|
||||
loop: true
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 检查是否为json字符串
|
||||
* @param {Object} jsonStr 数据源
|
||||
*/
|
||||
checkJsonAndParse(jsonStr) {
|
||||
try {
|
||||
const jsonResult = JSON.parse(jsonStr);
|
||||
return {
|
||||
ok: true,
|
||||
jsonData: jsonResult,
|
||||
}
|
||||
} catch (e) {
|
||||
return {
|
||||
ok: false,
|
||||
jsonData: {},
|
||||
}
|
||||
}
|
||||
},
|
||||
isObject(obj) {
|
||||
return obj && typeof obj === 'object' && !Array.isArray(obj);
|
||||
},
|
||||
deepMerge(target, source) {
|
||||
let output = Object.assign({}, target);
|
||||
|
||||
if (this.isObject(target) && this.isObject(source)) {
|
||||
Object.keys(source).forEach(key => {
|
||||
const targetValue = target[key];
|
||||
const sourceValue = source[key];
|
||||
|
||||
if (Array.isArray(targetValue) && Array.isArray(sourceValue)) {
|
||||
output[key] = targetValue.concat(sourceValue);
|
||||
} else if (this.isObject(targetValue) && this.isObject(sourceValue)) {
|
||||
output[key] = this.deepMerge(targetValue, sourceValue);
|
||||
} else {
|
||||
output[key] = sourceValue;
|
||||
}
|
||||
});
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
import utils from '@/utils/index.js'
|
||||
import v2Apis from "@/api/v2/all.api.js"
|
||||
|
||||
export const NeedPluginIds = Object.freeze({
|
||||
PluginUniHalo: "plugin-uni-halo",
|
||||
PluginPhotos: "PluginPhotos",
|
||||
PluginLinks: "PluginLinks",
|
||||
PluginMoments: "PluginMoments",
|
||||
PluginSearchWidget: "PluginSearchWidget",
|
||||
PluginCommentWidget: "PluginCommentWidget",
|
||||
PluginVote: "vote",
|
||||
})
|
||||
|
||||
export const NeedPlugins = new Map([
|
||||
[
|
||||
NeedPluginIds.PluginUniHalo, {
|
||||
id: "plugin-uni-halo",
|
||||
name: "UniHalo配置",
|
||||
desc: "uni-halo 核心插件,未安装和启用的情况下,将无法使用 uni-halo,请检查是否已安装和启用",
|
||||
logo: utils.checkUrl("/plugins/plugin-uni-halo/assets/logo.png"),
|
||||
url: "https://www.halo.run/store/apps/app-ryemX"
|
||||
}
|
||||
],
|
||||
[
|
||||
NeedPluginIds.PluginPhotos, {
|
||||
id: "PluginPhotos",
|
||||
name: "图库管理",
|
||||
desc: "图库功能模块所需要的插件",
|
||||
logo: utils.checkUrl("/plugins/PluginPhotos/assets/logo.svg"),
|
||||
url: "https://www.halo.run/store/apps/app-BmQJW"
|
||||
}
|
||||
],
|
||||
[
|
||||
NeedPluginIds.PluginLinks, {
|
||||
id: "PluginLinks",
|
||||
name: "链接管理",
|
||||
desc: "链接管理模块,用于网站友情链接功能模块",
|
||||
logo: utils.checkUrl("/plugins/PluginLinks/assets/logo.svg"),
|
||||
url: "https://www.halo.run/store/apps/app-hfbQg"
|
||||
}
|
||||
],
|
||||
[
|
||||
NeedPluginIds.PluginMoments, {
|
||||
id: "PluginMoments",
|
||||
name: "瞬间",
|
||||
desc: "提供一个轻量级的内容图文、视频、音频等内容展示",
|
||||
logo: utils.checkUrl("/plugins/PluginMoments/assets/logo.svg"),
|
||||
url: "https://www.halo.run/store/apps/app-SnwWD"
|
||||
}
|
||||
],
|
||||
[
|
||||
NeedPluginIds.PluginSearchWidget, {
|
||||
id: "PluginSearchWidget",
|
||||
name: "搜索组件",
|
||||
desc: "为应用提供统一的搜索组件",
|
||||
logo: utils.checkUrl("/plugins/PluginSearchWidget/assets/logo.svg"),
|
||||
url: "https://www.halo.run/store/apps/app-DlacW"
|
||||
}
|
||||
],
|
||||
[
|
||||
NeedPluginIds.PluginCommentWidget, {
|
||||
id: "PluginCommentWidget",
|
||||
name: "评论组件",
|
||||
desc: "为用户前台提供完整的评论解决方案",
|
||||
logo: utils.checkUrl("/plugins/PluginCommentWidget/assets/logo.svg"),
|
||||
url: "https://www.halo.run/store/apps/app-YXyaD"
|
||||
}
|
||||
],
|
||||
[
|
||||
NeedPluginIds.PluginVote, {
|
||||
id: "vote",
|
||||
name: "投票管理",
|
||||
desc: "投票模块所需要的插件,用于展示投票和提交投票",
|
||||
logo: utils.checkUrl("/plugins/vote/assets/logo.png"),
|
||||
url: "https://www.halo.run/store/apps/app-veyvzyhv"
|
||||
}
|
||||
]
|
||||
])
|
||||
|
||||
/**
|
||||
* 检查插件是否启用、安装
|
||||
* @param {String} pluginId 插件id
|
||||
* @return {Boolean} true = 安装、启用 false= 未安装启用
|
||||
*/
|
||||
export const checkNeedPluginAvailable = (pluginId) => {
|
||||
return new Promise(async (resolve) => {
|
||||
try {
|
||||
const available = await v2Apis.checkPluginAvailable(pluginId)
|
||||
resolve(available)
|
||||
} catch (err) {
|
||||
resolve(false)
|
||||
}
|
||||
})
|
||||
}
|
||||
+6
-6
@@ -12,11 +12,11 @@
|
||||
|
||||
/**
|
||||
* 指定范围生成随机数
|
||||
* @param {Number} m
|
||||
* @param {Number} n
|
||||
* @return {Number}
|
||||
* @param {Number} m 最小值(包含)
|
||||
* @param {Number} n 最大(不包含)
|
||||
* @return {Number} 随机值
|
||||
*/
|
||||
export function GetRandomNumberByRange(m, n) {
|
||||
export function getRandomNumberByRange(m, n) {
|
||||
return Math.floor(Math.random() * (m - n) + n);
|
||||
}
|
||||
|
||||
@@ -26,10 +26,10 @@ export function GetRandomNumberByRange(m, n) {
|
||||
* @param {*} min 最小值
|
||||
* @param {*} max 最大值
|
||||
*/
|
||||
export function GetRandomNumberArray(len, min, max) {
|
||||
export function getRandomNumberArray(len, min, max) {
|
||||
let arr = [];
|
||||
for (let index = 0; index < len; index++) {
|
||||
arr.push(GetRandomNumberByRange(min, max));
|
||||
arr.push(getRandomNumberByRange(min, max));
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
+5
-5
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* 设置缓存
|
||||
* @param {缓存key} key
|
||||
* @param {需要存储的缓存值} value
|
||||
* @param {过期时间,默认0表示永久有效} expire
|
||||
* @param {string} key 缓存key
|
||||
* @param {Object} value 需要存储的缓存值
|
||||
* @param {number} expire 过期时间,默认0表示永久有效
|
||||
*/
|
||||
export const setCache = (key, value, expire = 0) => {
|
||||
let obj = {
|
||||
@@ -15,7 +15,7 @@ export const setCache = (key, value, expire = 0) => {
|
||||
|
||||
/**
|
||||
* 获取缓存
|
||||
* @param {缓存key} key
|
||||
* @param {string} key
|
||||
*/
|
||||
export const getCache = (key) => {
|
||||
let val = uni.getStorageSync(key)
|
||||
@@ -32,7 +32,7 @@ export const getCache = (key) => {
|
||||
|
||||
/**
|
||||
* 删除缓存
|
||||
* @param {缓存key} key
|
||||
* @param { string } key 缓存key
|
||||
*/
|
||||
export const delCache = (key) => {
|
||||
uni.removeStorageSync(key)
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
import {getCache, setCache} from "./storage";
|
||||
import utils from "./index"
|
||||
|
||||
export const APP_TOKENS_KEY = "APP_TOKENS";
|
||||
|
||||
|
||||
/**
|
||||
* 获取 tokens
|
||||
*/
|
||||
export function getTokens() {
|
||||
const tokens = getCache(APP_TOKENS_KEY);
|
||||
return tokens ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 tokens
|
||||
*/
|
||||
export function setTokens(value) {
|
||||
setCache(APP_TOKENS_KEY, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 tokens
|
||||
*/
|
||||
export function updateTokens(value) {
|
||||
if (!value) return false
|
||||
const tokens = getTokens(APP_TOKENS_KEY);
|
||||
if (!tokens) return false
|
||||
setTokens(utils.deepMerge(tokens, value))
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 系统token
|
||||
*/
|
||||
export function getPersonalToken() {
|
||||
const tokens = getTokens(APP_TOKENS_KEY);
|
||||
console.log("tokens", tokens)
|
||||
return tokens?.personalToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 系统token
|
||||
*/
|
||||
export function setPersonalToken(personalToken) {
|
||||
const tokens = getCache(APP_TOKENS_KEY);
|
||||
if (!tokens) return false
|
||||
tokens.personalToken = personalToken
|
||||
updateTokens(tokens)
|
||||
return true
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
/**
|
||||
* 生成指定长度的uuid
|
||||
* @param {number} = 长度
|
||||
*/
|
||||
export function generateUUID(length = 36) {
|
||||
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
let result = '';
|
||||
|
||||
const validLength = Math.max(1, Math.floor(Number(length)) || 36);
|
||||
for (let i = 0; i < validLength; i++) {
|
||||
result += characters.charAt(Math.floor(Math.random() * characters.length));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
const UnihaloVoteUid = "unihalo_vote_uid"
|
||||
|
||||
export const voteCacheUtil = {
|
||||
getAll() {
|
||||
const data = uni.getStorageSync(UnihaloVoteUid)
|
||||
if (!data) {
|
||||
return null
|
||||
}
|
||||
return JSON.parse(data)
|
||||
},
|
||||
get(name) {
|
||||
const data = this.getAll()
|
||||
if (!data) {
|
||||
return null
|
||||
}
|
||||
return data[name]
|
||||
},
|
||||
has(name) {
|
||||
const data = this.getAll()
|
||||
if (!data) return false
|
||||
return data[name] != undefined
|
||||
},
|
||||
set(name, value) {
|
||||
let data = this.getAll()
|
||||
if (!data) {
|
||||
data = {
|
||||
[name]: value
|
||||
}
|
||||
} else {
|
||||
data[name] = value
|
||||
}
|
||||
uni.setStorageSync(UnihaloVoteUid, JSON.stringify(data))
|
||||
}
|
||||
}
|
||||
|
||||
export const VOTE_TYPES = {
|
||||
"pk": "双选PK",
|
||||
"multiple": "多选",
|
||||
"single": "单选"
|
||||
}
|
||||
|
||||
export const VOTE_STATES = {
|
||||
"未开始": {
|
||||
state: "未开始",
|
||||
color: "orange"
|
||||
},
|
||||
"进行中": {
|
||||
state: "进行中",
|
||||
color: "green"
|
||||
},
|
||||
"已结束": {
|
||||
state: "已结束",
|
||||
color: "red"
|
||||
},
|
||||
}
|
||||
|
||||
export const calcVoteState = (vote) => {
|
||||
if (vote.spec.timeLimit !== 'custom') {
|
||||
return vote.spec.hasEnded ? VOTE_STATES["已结束"] : VOTE_STATES["进行中"]
|
||||
}
|
||||
|
||||
const nowTime = new Date().getTime()
|
||||
const startTime = new Date(vote.spec.startDate).getTime()
|
||||
const endTime = new Date(vote.spec.endDate).getTime()
|
||||
|
||||
if (nowTime < startTime) {
|
||||
return VOTE_STATES["未开始"]
|
||||
}
|
||||
if (nowTime < endTime) {
|
||||
return VOTE_STATES["进行中"]
|
||||
}
|
||||
return vote.spec.hasEnded ? VOTE_STATES["已结束"] : VOTE_STATES["进行中"]
|
||||
}
|
||||
|
||||
export const calcVotePercent = (vote, voteOption) => {
|
||||
if (!vote || !voteOption) return 0
|
||||
const votedDataList = vote?.stats?.voteDataList || []
|
||||
if (votedDataList.length == 0) return 0
|
||||
const voteCount = vote?.stats?.voteCount || 0
|
||||
if (voteCount == 0) return 0
|
||||
|
||||
const _voteOption = votedDataList.find(x => x.id == voteOption.id)
|
||||
if (!_voteOption) return 0;
|
||||
const percent = (_voteOption.voteCount / voteCount) * 100
|
||||
return Math.round(percent)
|
||||
}
|
||||
Reference in New Issue
Block a user