flat: 暂存
This commit is contained in:
@@ -250,6 +250,46 @@ class IndexedDBHelper {
|
||||
request.onerror = (event) => reject(`Delete Error: ${event.target.error}`);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 根据条件删除所有匹配的数据
|
||||
* @param {string} storeName - 数据仓库名
|
||||
* @param {function} conditionFn - 判断是否删除 (record) => boolean
|
||||
* @returns {Promise}
|
||||
*/
|
||||
deleteByCondition(storeName, conditionFn) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!this.db) {
|
||||
reject('Database not initialized');
|
||||
return;
|
||||
}
|
||||
|
||||
const transaction = this.db.transaction([storeName], 'readwrite');
|
||||
const store = transaction.objectStore(storeName);
|
||||
const request = store.openCursor();
|
||||
|
||||
request.onsuccess = (event) => {
|
||||
const cursor = event.target.result;
|
||||
if (cursor && cursor.value) {
|
||||
try {
|
||||
// console.log(cursor.value)
|
||||
const shouldDelete = conditionFn(cursor.value);
|
||||
if (shouldDelete) {
|
||||
cursor.delete();
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Condition function error:', err);
|
||||
}
|
||||
cursor.continue();
|
||||
} else {
|
||||
resolve('All matching records deleted successfully');
|
||||
}
|
||||
};
|
||||
|
||||
request.onerror = (event) => {
|
||||
reject(`Delete by condition failed: ${event.target.error}`);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过索引查询数据
|
||||
|
@@ -13,7 +13,6 @@ body,
|
||||
page {
|
||||
overscroll-behavior: none;
|
||||
overflow: hidden;
|
||||
height: 100%;
|
||||
} */
|
||||
|
||||
image {
|
||||
@@ -23,6 +22,8 @@ image {
|
||||
|
||||
.page-body {
|
||||
height: calc(100vh - var(--window-top) - var(--status-bar-height) - var(--window-bottom));
|
||||
/* width: 100%; */
|
||||
/* height: 100%; */
|
||||
}
|
||||
|
||||
body,
|
||||
@@ -52,7 +53,77 @@ html {
|
||||
}
|
||||
|
||||
.btn-light:active {
|
||||
background-color: #2980b9;
|
||||
background-color: rgba(189, 197, 254, 0.15);
|
||||
}
|
||||
|
||||
.btn-incline {
|
||||
transition: transform 0.2s ease;
|
||||
transform-style: preserve-3d;
|
||||
}
|
||||
|
||||
.btn-incline:active {
|
||||
transform: perspective(600px) rotateY(6deg) rotateX(3deg);
|
||||
}
|
||||
|
||||
.btn-feel {
|
||||
transition: transform 0.2s ease;
|
||||
transform-style: preserve-3d;
|
||||
}
|
||||
|
||||
.btn-feel:active {
|
||||
transform: perspective(600px) rotateX(6deg) scale(0.98);
|
||||
}
|
||||
|
||||
|
||||
/* 动画效果 */
|
||||
.btn-shaky:active {
|
||||
animation: shakeScale 0.6s;
|
||||
}
|
||||
|
||||
@keyframes shakeScale {
|
||||
0% {
|
||||
transform: scale(1);
|
||||
}
|
||||
|
||||
10% {
|
||||
transform: scale(0.9) rotate(-3deg);
|
||||
}
|
||||
|
||||
20% {
|
||||
transform: scale(1.05) rotate(3deg);
|
||||
}
|
||||
|
||||
30% {
|
||||
transform: scale(0.95) rotate(-3deg);
|
||||
}
|
||||
|
||||
40% {
|
||||
transform: scale(1.02) rotate(3deg);
|
||||
}
|
||||
|
||||
50% {
|
||||
transform: scale(0.98) rotate(-2deg);
|
||||
}
|
||||
|
||||
60% {
|
||||
transform: scale(1.01) rotate(2deg);
|
||||
}
|
||||
|
||||
70% {
|
||||
transform: scale(0.99) rotate(-1deg);
|
||||
}
|
||||
|
||||
80% {
|
||||
transform: scale(1.005) rotate(1deg);
|
||||
}
|
||||
|
||||
90% {
|
||||
transform: scale(1) rotate(0deg);
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: scale(1) rotate(0deg);
|
||||
}
|
||||
}
|
||||
|
||||
/* 控制hover */
|
||||
@@ -191,8 +262,8 @@ html {
|
||||
color: #FB7307 !important;
|
||||
}
|
||||
|
||||
.color_4873D9 {
|
||||
color: #4873D9 !important;
|
||||
.color_256BFA {
|
||||
color: #256BFA !important;
|
||||
}
|
||||
|
||||
.color_4E8ADE {
|
||||
@@ -343,6 +414,14 @@ html {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.fl_warp {
|
||||
flex-wrap: wrap
|
||||
}
|
||||
|
||||
.fl_nowarp {
|
||||
flex-wrap: nowrap
|
||||
}
|
||||
|
||||
.line_2 {
|
||||
display: -webkit-box;
|
||||
/* 让文本内容成为弹性盒 */
|
||||
@@ -354,4 +433,17 @@ html {
|
||||
/* 隐藏超出的文本 */
|
||||
text-overflow: ellipsis;
|
||||
/* 使用省略号 */
|
||||
}
|
||||
|
||||
.line_1 {
|
||||
display: -webkit-box;
|
||||
/* 让文本内容成为弹性盒 */
|
||||
-webkit-box-orient: vertical;
|
||||
/* 设置盒子的方向为垂直 */
|
||||
-webkit-line-clamp: 1;
|
||||
/* 限制最多显示两行 */
|
||||
overflow: hidden;
|
||||
/* 隐藏超出的文本 */
|
||||
text-overflow: ellipsis;
|
||||
/* 使用省略号 */
|
||||
}
|
@@ -51,18 +51,77 @@ const prePage = () => {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 页面跳转封装,支持 query 参数传递和返回回调
|
||||
* @param {string} url - 跳转路径
|
||||
* @param {object} options
|
||||
* @param {boolean} options.needLogin - 是否需要登录
|
||||
* @param {object} options.query - 携带参数
|
||||
* @param {function} options.onBack - 页面返回时的回调(目标页调用 uni.navigateBack 时传递数据)
|
||||
*/
|
||||
export const navTo = function(url, {
|
||||
needLogin = false,
|
||||
query = {},
|
||||
onBack = null
|
||||
} = {}) {
|
||||
const userStore = useUserStore();
|
||||
|
||||
const navTo = function(url, needLogin) {
|
||||
if (needLogin && useUserStore().hasLogin) {
|
||||
if (needLogin && !userStore.hasLogin) {
|
||||
uni.navigateTo({
|
||||
url: '/pages/login/login'
|
||||
});
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
const queryStr = Object.entries(query)
|
||||
.map(([key, val]) => `${key}=${encodeURIComponent(val)}`)
|
||||
.join('&');
|
||||
const finalUrl = queryStr ? `${url}?${queryStr}` : url;
|
||||
|
||||
if (onBack) {
|
||||
const pages = getCurrentPages();
|
||||
const currentPage = pages[pages.length - 1];
|
||||
currentPage.__onBackCallback__ = onBack;
|
||||
}
|
||||
|
||||
uni.navigateTo({
|
||||
url
|
||||
url: finalUrl
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const navBack = function({
|
||||
delta = 1,
|
||||
data = null,
|
||||
fallbackUrl = '/pages/index/index'
|
||||
} = {}) {
|
||||
const pages = getCurrentPages();
|
||||
|
||||
if (pages.length > 1) {
|
||||
const prevPage = pages[pages.length - 1 - delta];
|
||||
|
||||
// 如果上一页存在回调函数,调用
|
||||
if (data && prevPage?.__onBackCallback__) {
|
||||
prevPage.__onBackCallback__(data);
|
||||
}
|
||||
|
||||
uni.navigateBack({
|
||||
delta
|
||||
});
|
||||
} else {
|
||||
// 没有可返回的页面,直接跳转 fallback 页面
|
||||
uni.reLaunch({
|
||||
url: fallbackUrl
|
||||
});
|
||||
}
|
||||
};
|
||||
// // 默认返回上一页
|
||||
// navBack();
|
||||
|
||||
// // 返回上两层
|
||||
// navBack(2);
|
||||
|
||||
// // 没有历史页面时跳转首页
|
||||
// navBack(1, '/pages/home/home');
|
||||
|
||||
function getdeviceInfo() {
|
||||
const globalData = {
|
||||
@@ -247,33 +306,33 @@ class CustomSystem {
|
||||
const customSystem = new CustomSystem()
|
||||
|
||||
function setCheckedNodes(nodes, ids) {
|
||||
// 处理每个第一层节点
|
||||
const isClear = ids.length === 0;
|
||||
|
||||
nodes.forEach((firstLayer) => {
|
||||
// 初始化或重置计数器
|
||||
// 每次处理都先重置
|
||||
firstLayer.checkednumber = 0;
|
||||
|
||||
// 递归处理子树
|
||||
const traverse = (node) => {
|
||||
// 设置当前节点选中状态
|
||||
const shouldCheck = ids.includes(node.id);
|
||||
if (shouldCheck) node.checked = true;
|
||||
if (isClear) {
|
||||
node.checked = false;
|
||||
} else {
|
||||
node.checked = ids.includes(node.id);
|
||||
}
|
||||
|
||||
// 统计后代节点(排除首层自身)
|
||||
if (node !== firstLayer && node.checked) {
|
||||
firstLayer.checkednumber++;
|
||||
}
|
||||
|
||||
// 递归子节点
|
||||
if (node.children) {
|
||||
node.children.forEach((child) => traverse(child));
|
||||
if (node.children && node.children.length) {
|
||||
node.children.forEach(child => traverse(child));
|
||||
}
|
||||
};
|
||||
|
||||
// 启动当前首层节点的遍历
|
||||
traverse(firstLayer);
|
||||
});
|
||||
}
|
||||
|
||||
return nodes;
|
||||
}
|
||||
const formatTotal = (total) => {
|
||||
if (total < 10) return total.toString(); // 直接返回小于 10 的数
|
||||
|
||||
@@ -496,6 +555,7 @@ export const $api = {
|
||||
export default {
|
||||
$api,
|
||||
navTo,
|
||||
navBack,
|
||||
cloneDeep,
|
||||
formatDate,
|
||||
getdeviceInfo,
|
||||
@@ -513,5 +573,6 @@ export default {
|
||||
getWeeksOfMonth,
|
||||
isFutureDate,
|
||||
parseQueryParams,
|
||||
appendScriptTagElement
|
||||
appendScriptTagElement,
|
||||
insertSortData
|
||||
}
|
Reference in New Issue
Block a user