Code Monkey home page Code Monkey logo

Comments (19)

HenryQW avatar HenryQW commented on July 23, 2024 1

才看见你上面说的web安全域名,应该就是这个问题导致了只允许由安全域名发起的修改数据请求?可是你可以创建新纪录,这就奇怪了😂

from jekyll-text-theme.

kitian616 avatar kitian616 commented on July 23, 2024

配置看起来没有什么问题。浏览器控制台有报错吗,有的话能提供截图吗?电脑不在身边,没法去调试。

from jekyll-text-theme.

willguxy avatar willguxy commented on July 23, 2024

@kitian616 谢谢. chrome console只有这样一句话

The SSL certificate used to load resources from https://app-router.leancloud.cn will be distrusted in M70. Once distrusted, users will be prevented from loading these resources. See https://g.co/chrome/symantecpkicerts for more information.

[edit] 上面那句貌似是chrome相关的. 我在其他浏览器里尝试, view也都显示为0

from jekyll-text-theme.

kitian616 avatar kitian616 commented on July 23, 2024

看起来是 SSL 证书的问题,白天不方便,晚上我看看。你也可以搜索下看看有什么线索。

from jekyll-text-theme.

willguxy avatar willguxy commented on July 23, 2024

@kitian616 又研究了一下, 大概知道怎么看error了. 开着console的时候打开网页, 有如下错误

AV.Object#fetchWhenSave is deprecated, use AV.Object#save with options.fetchWhenSave instead.

PUT https://pase2hy7.api.lncld.net/1.1/classes/counter/5a309896128fe10044550a12?new=true 403 (Forbidden)

The resource https://c.disquscdn.com/next/embed/common.bundle.8edffe1405dcc2d5eb5ee9d96a2866d1.js was preloaded using link preload but not used within a few seconds from the window's load event. Please make sure it wasn't preloaded for nothing

看来前两个跟Lean Cloud有关, 最后一个跟disqus有关. 我不太懂啊, 貌似是访问权限的关系? 我再研究一下Lean Cloud的设置

from jekyll-text-theme.

willguxy avatar willguxy commented on July 23, 2024

检查了一下. 首页的显示没有问题 -- 我手动在LeanCloud上改数据, 首页的view数就改变了.

上面的错误是在打开单篇文章的时候出现的. 也就是说更新class里key对应的数值失败. 所以一直显示为零.

from jekyll-text-theme.

kitian616 avatar kitian616 commented on July 23, 2024

多谢反馈,看起来是代码的 BUG。

from jekyll-text-theme.

HenryQW avatar HenryQW commented on July 23, 2024

@willguxy 你的lean cloud写入权限有问题

from jekyll-text-theme.

willguxy avatar willguxy commented on July 23, 2024

@WangQiru
app权限是默认全开的。难道是LeanCloudWeb 安全域名的问题?我就加入一个url地址

screen shot 2017-12-17 at 2 32 21 pm

from jekyll-text-theme.

willguxy avatar willguxy commented on July 23, 2024

@WangQiru 如果是写入权限的问题,应该连Key的创建不了吧。 我看LeanCloud上已经创建了很多key了,现在应该是更新的时候出错。上面说的那个错误PUT https://pase2hy7.api.lncld.net/1.1/classes/counter/5a309896128fe10044550a12?new=true 403 (Forbidden)
看来像是重复创建新的key失败。因为这个key 5a309896128fe10044550a12已经存在了

from jekyll-text-theme.

HenryQW avatar HenryQW commented on July 23, 2024

@willguxy 检查下你counter的update权限?以及_layout/post.html下的lean cloud相关js代码。我看了下更新计数器的逻辑没看出错误来。我的网站也没遇到这个问题。

$(function() {
 // 初始化
 AV.init({
  appId: '{{ site.leancloud.app_id }}',
  appKey: '{{ site.leancloud.app_key }}'
 });
 // 查询
 var query = new AV.Query('{{ site.leancloud.app_class }}');
 query.equalTo('key', '{{ page.key }}');
 query.first().then(function(result) {
  if (result) {
   addOne(result)
  } else {
   //新建
   var Blog = AV.Object.extend('{{ site.leancloud.app_class }}');
   var blog = new Blog();
   blog.set('title', '{{ page.title }}');
   blog.set('key', '{{ page.key }}');
   blog.set('views', 0);
   blog.save().then(function(page) {
    addOne(page)
   }, function(error) {
    if (error) {
     throw error;
    }
   });
  }

  function addOne(page) {
   page.increment('views', 1);
   page.fetchWhenSave(true);
   page.save().then(function(page) {
    $("#post-key-{{ page.key }}").text(page.attributes.views);
   }, function(error) {
    if (error) {
     throw error;
    }
   });
  }
 }, function(error) {
  if (error) {
   throw error;
  }
 });
});

from jekyll-text-theme.

willguxy avatar willguxy commented on July 23, 2024

@WangQiru 代码是一样的. 我是pull了最新的代码. 权限问题跟上面图显示的一样, update没有限制

from jekyll-text-theme.

HenryQW avatar HenryQW commented on July 23, 2024

@willguxy 403八成就是写入权限有问题,或者lean cloud屏蔽了来自你服务器IP地址的PUT(貌似不可能)?你有没有fork新项目或者换个leancloud appid试试?

https://leancloud.cn/docs/error_code.html#hash1392106

from jekyll-text-theme.

willguxy avatar willguxy commented on July 23, 2024

@WangQiru 我也是觉得能创建不能修改hin奇怪。。。我的两个博客设置一样,不同的app id,都有这个问题。

from jekyll-text-theme.

HenryQW avatar HenryQW commented on July 23, 2024

@willguxy 我两个博客两个appid都没问题。你重新建一个repo跑一个fresh demo看看。也可以试试重新申请一个lean cloud账号,我怀疑是那边的问题。

from jekyll-text-theme.

willguxy avatar willguxy commented on July 23, 2024

发现了一个LeanCloud的设置问题。就是创建class的时候需要选择无限制。可能是我的理解有问题,选择限制写入的话,默认的ACL权限为
{"*":{"write":false,"read":true}}

无限制的话岂不是任何人都可以修改了?

总之使用无限制之后,数据更新就没问题了。默认的ACL权限也变成
{"*":{"write":true,"read":true}}

from jekyll-text-theme.

kitian616 avatar kitian616 commented on July 23, 2024

对,确实是这样,如果 LeanCloud 应用有 url 白名单机制就非常好了。

from jekyll-text-theme.

willguxy avatar willguxy commented on July 23, 2024

thank you. please feel free to close this issue

from jekyll-text-theme.

HenryQW avatar HenryQW commented on July 23, 2024

@kitian616 应用设置下有一个 web 安全域名,就是白名单设置

from jekyll-text-theme.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.