Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
Zing22 committed Jul 6, 2022
2 parents 4f52396 + 98a23e7 commit a44d710
Show file tree
Hide file tree
Showing 33 changed files with 1,229 additions and 1,105 deletions.
2 changes: 0 additions & 2 deletions cloudfunctions/imProcess/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ const _ = db.command;
const sharp = require('sharp');
const { registerFont } = require('canvas');
const text2png = require('text2png');
// const sizeOf = require("buffer-image-size");
// const { async } = require('../../miniprogram/packages/regenerator-runtime/runtime');
var assert = require('assert');

registerFont('./方正黑体-GBK.TTF', {family: 'FZHei'});
Expand Down
6 changes: 6 additions & 0 deletions cloudfunctions/relationOp/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"permissions": {
"openapi": [
]
}
}
54 changes: 54 additions & 0 deletions cloudfunctions/relationOp/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// 云函数入口文件
const cloud = require('wx-server-sdk');

cloud.init({
env: cloud.DYNAMIC_CURRENT_ENV
});
const db = cloud.database();
const _ = db.command;

// 权限检查
async function check_manager(level) {
const wxContext = cloud.getWXContext()
const openid = wxContext.OPENID;
const isManager = (await cloud.callFunction({
name: 'isManager',
data: {
openid: openid,
req: level
}
}));
return isManager;
}

// 云函数入口函数
exports.main = async (event, context) => {
if (event.deploy_test === true) {
// 进行部署检查
return;
}
const type = event.type;

if (type == "saveRelationTypes") {
// 新建关系类型
if (!event.relationTypes) {
return false;
}
return await db.collection("setting").doc("relation").update({
data: {
types: event.relationTypes
}
});
}
if (type == "saveRelation") {
var cat_id = event.cat_id;
var relations = event.relations;
return await db.collection("cat").doc(cat_id).update({
data: {
relations: relations
}
});
}

return `unk type ${type}`;
}
14 changes: 14 additions & 0 deletions cloudfunctions/relationOp/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "relationOp",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"wx-server-sdk": "~2.6.3"
}
}
2 changes: 1 addition & 1 deletion miniprogram/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ App({
checkUpdateVersion();

this.globalData = {
version: "v1.8.1"
version: "v1.8.3"
}
}
})
140 changes: 71 additions & 69 deletions miniprogram/app.json
Original file line number Diff line number Diff line change
@@ -1,71 +1,73 @@
{
"pages": [
"pages/genealogy/genealogy",
"pages/genealogy/addPhoto/addPhoto",
"pages/genealogy/detailCat/detailCat",
"pages/info/info",
"pages/info/photoRank/photoRank",
"pages/info/reward/reward",
"pages/info/feedback/feedback",
"pages/info/feedback/myFeedback/myFeedback",
"pages/info/devTeam/devTeam",
"pages/manage/addCat/addCat",
"pages/manage/imProcess/imProcess",
"pages/manage/checkPhotos/checkPhotos",
"pages/manage/filters/filters",
"pages/debug/debug",
"pages/manage/managers/managers",
"pages/genealogy/feedbackDetail/feedbackDetail",
"pages/manage/checkFeedbacks/checkFeedbacks",
"pages/manage/replyFeedback/replyFeedback",
"pages/manage/rewards/rewards",
"pages/recognize/recognize",
"pages/genealogy/commentBoard/commentBoard",
"pages/debug/deployTip/deployTip",
"pages/news/news",
"pages/news/detailNews/detailNews",
"pages/news/modifyNews/modifyNews",
"pages/news/createNews/createNews",
"pages/news/sciDetail/sciDetail"
],
"tabBar": {
"selectedColor": "#000",
"borderStyle": "white",
"list": [
{
"pagePath": "pages/genealogy/genealogy",
"iconPath": "./images/tabs/default/cat.png",
"selectedIconPath": "./images/tabs/active/cat.png",
"text": "猫谱"
},
{
"pagePath": "pages/news/news",
"iconPath": "./images/tabs/default/sci.png",
"selectedIconPath": "./images/tabs/active/sci.png",
"text": "公告"
},
{
"pagePath": "pages/info/info",
"iconPath": "./images/tabs/default/info.png",
"selectedIconPath": "./images/tabs/active/info.png",
"text": "关于"
}
]
},
"window": {
"backgroundColor": "#fff",
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#ffd101",
"navigationBarTitleText": "中大猫谱",
"navigationBarTextStyle": "black"
},
"supportedMaterials": [
{
"materialType": "image/*",
"name": "用${nickname}识别",
"desc": "根据图片识别校园中相似的猫咪",
"path": "pages/recognize/recognize"
}
],
"sitemapLocation": "sitemap.json"
"pages": [
"pages/genealogy/genealogy",
"pages/genealogy/addPhoto/addPhoto",
"pages/genealogy/detailCat/detailCat",
"pages/info/info",
"pages/info/photoRank/photoRank",
"pages/info/reward/reward",
"pages/info/feedback/feedback",
"pages/info/feedback/myFeedback/myFeedback",
"pages/info/devTeam/devTeam",
"pages/manage/addCat/addCat",
"pages/manage/imProcess/imProcess",
"pages/manage/checkPhotos/checkPhotos",
"pages/manage/filters/filters",
"pages/debug/debug",
"pages/manage/managers/managers",
"pages/genealogy/feedbackDetail/feedbackDetail",
"pages/manage/checkFeedbacks/checkFeedbacks",
"pages/manage/replyFeedback/replyFeedback",
"pages/manage/rewards/rewards",
"pages/recognize/recognize",
"pages/genealogy/commentBoard/commentBoard",
"pages/debug/deployTip/deployTip",
"pages/news/news",
"pages/news/detailNews/detailNews",
"pages/news/modifyNews/modifyNews",
"pages/news/createNews/createNews",
"pages/news/sciDetail/sciDetail",
"pages/manage/addRelations/addRelations"
],
"tabBar": {
"selectedColor": "#000",
"borderStyle": "white",
"list": [
{
"pagePath": "pages/genealogy/genealogy",
"iconPath": "./images/tabs/default/cat.png",
"selectedIconPath": "./images/tabs/active/cat.png",
"text": "猫谱"
},
{
"pagePath": "pages/news/news",
"iconPath": "./images/tabs/default/sci.png",
"selectedIconPath": "./images/tabs/active/sci.png",
"text": "公告"
},
{
"pagePath": "pages/info/info",
"iconPath": "./images/tabs/default/info.png",
"selectedIconPath": "./images/tabs/active/info.png",
"text": "关于"
}
]
},
"window": {
"backgroundColor": "#fff",
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#ffd101",
"navigationBarTitleText": "中大猫谱",
"navigationBarTextStyle": "black"
},
"supportedMaterials": [
{
"materialType": "image/*",
"name": "用${nickname}识别",
"desc": "根据图片识别校园中相似的猫咪",
"path": "pages/recognize/recognize"
}
],
"sitemapLocation": "sitemap.json",
"lazyCodeLoading" : "requiredComponents"
}
3 changes: 2 additions & 1 deletion miniprogram/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ function getCacheItem(key) {
}

// 过期了
if (new Date() < new Date(data.expire_date)) {
if (new Date() > new Date(data.expire_date)) {
console.log(`${key} expired.`);
return undefined;
}

Expand Down
31 changes: 29 additions & 2 deletions miniprogram/cat.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@ const cache = require('./cache.js');
// 常用的一些对象
const db = wx.cloud.database();
const coll_photo = db.collection('photo');
const coll_cat = db.collection('cat');

// 获取猫猫的封面图
// TODO(zing): 可以搞个缓存
async function getAvatar(cat_id, total) {
if (!total || total === 0) {
return undefined;
}

var cacheKey = `cat-avatar-${cat_id}`;
var cacheItem = cache.getCacheItem(cacheKey);
console.log(cacheKey, cacheItem);
if (cacheItem) {
return cacheItem;
}

// photo_id : 不以 HEIC 为文件后缀的字符串
const qf = {
Expand All @@ -24,7 +31,10 @@ async function getAvatar(cat_id, total) {
// TODO: 这里对于API调用的次数较多,需要修改
var index = utils.randomInt(0, total);
var pho_src = (await coll_photo.where(qf).skip(index).limit(1).get()).data;
return pho_src[0];
cacheItem = pho_src[0];

cache.setCacheItem(cacheKey, cacheItem, 24);
return cacheItem;
}

// 消除“有新相片”提示
Expand All @@ -38,8 +48,25 @@ function setVisitedDate(cat_id) {
return;
}

// 获取猫猫信息
async function getCatItem(cat_id) {
if (!cat_id) {
return undefined;
}
var cacheKey = `cat-item-${cat_id}`;
var cacheItem = cache.getCacheItem(cacheKey);
if (cacheItem) {
return cacheItem;
}

cacheItem = (await coll_cat.doc(cat_id).get()).data;
cache.setCacheItem(cacheKey, cacheItem, 24);
return cacheItem;
}

export {
getAvatar,
getVisitedDate,
setVisitedDate,
getCatItem,
}
Binary file modified miniprogram/images/recognize/share_cover.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 0 additions & 31 deletions miniprogram/packages/regenerator-runtime/README.md

This file was deleted.

18 changes: 0 additions & 18 deletions miniprogram/packages/regenerator-runtime/package.json

This file was deleted.

11 changes: 0 additions & 11 deletions miniprogram/packages/regenerator-runtime/path.js

This file was deleted.

Loading

0 comments on commit a44d710

Please sign in to comment.