Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: 其他页面 pageview 异常 || [Bug]: Pageview exception on other pages #2207

Closed
BeiyanYunyi opened this issue Dec 19, 2023 · 8 comments · Fixed by #2343
Closed

[Bug]: 其他页面 pageview 异常 || [Bug]: Pageview exception on other pages #2207

BeiyanYunyi opened this issue Dec 19, 2023 · 8 comments · Fixed by #2343
Assignees
Labels
bug Something isn't working Inactive

Comments

@BeiyanYunyi
Copy link
Contributor

BeiyanYunyi commented Dec 19, 2023

问题描述 | Describe the bug

复现版本为 master 分支 6c9f4f6 。后端与 https://waline.js.org/ 相同。

复现方法为,将 pnpm client:devhttp://localhost:5173/pageview.html 改为如下所示:

<!doctype html>
<html>
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Waline pageview test</title>
  </head>
  <body>
    阅读量: <span id="/" class="waline-pageview-count"></span>
    页面阅读量 1:
    <span
      class="waline-pageview-count"
      data-path="/guide/features/pageview.html"
    ></span
    >页面阅读量 2:<span
      class="waline-pageview-count"
      data-path="/guide/features/i18n.html"
    ></span>
    <script type="module">
      import { pageviewCount } from '../src/entries/pageview.ts';

      pageviewCount({
        serverURL:
          import.meta.env.SERVERURL || 'https://walinejs.comment.lithub.cc',
        path: '/',
      });
    </script>
  </body>
</html>

即可见“页面阅读量 1”与“页面阅读量 2”处出现异常。出现异常的原因是在查询其他页面的访问量时,服务端返回值与客户端预期不同。

BeiyanYunyi/sodesu@8208fae 在前端给出了一个可能的缓解或修复措施。然而,我认为服务端的接口同样需要统一。

问题网站 | Website URL

https://waline.js.org/

服务部署在哪里? | Where your waline deploy?

Vercel (Default)

数据存储在哪里?| Where your comment data store?

LeanCloud(https://leancloud.app)


Problem description | Describe the bug

The reproducible version is master branch 6c9f4f6. The backend is the same as https://waline.js.org/.

The method to reproduce is to change http://localhost:5173/pageview.html of pnpm client:dev to the following:

<!doctype html>
<html>
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Waline pageview test</title>
  </head>
  <body>
    Reading volume: <span id="/" class="waline-pageview-count"></span>
    Page views 1:
    <span
      class="waline-pageview-count"
      data-path="/guide/features/pageview.html"
    ></span
    >Page views 2:<span
      class="waline-pageview-count"
      data-path="/guide/features/i18n.html"
    ></span>
    <script type="module">
      import { pageviewCount } from '../src/entries/pageview.ts';

      pageviewCount({
        serverURL:
          import.meta.env.SERVERURL || 'https://walinejs.comment.lithub.cc',
        path: '/',
      });
    </script>
  </body>
</html>

It can be seen that there are exceptions at "Page Views 1" and "Page Views 2". The reason for the exception is that when querying the visits of other pages, the server return value is different from the client's expectation.

BeiyanYunyi/sodesu@8208fae gives a possible mitigation or fix on the front end. However, I think the server-side interface also needs to be unified.

Question Website | Website URL

https://waline.js.org/

Where is the service deployed? | Where your waline deploy?

Vercel (Default)

Where is the data stored? | Where your comment data store?

LeanCloud(https://leancloud.app)

@BeiyanYunyi BeiyanYunyi added the bug Something isn't working label Dec 19, 2023
@github-actions github-actions bot changed the title [Bug]: 其他页面 pageview 异常 [Bug]: 其他页面 pageview 异常 || [Bug]: Pageview exception on other pages Dec 19, 2023
@lizheming lizheming removed the bug Something isn't working label Dec 20, 2023
@lizheming
Copy link
Collaborator

lizheming commented Dec 20, 2023

  1. pageview 接口之前是有一个返回数据问题,是当请求一条的时候返回的是 1,而多条的时候返回的是 [1,1] 数组格式。这块在新的版本中已经都统一成了 {errmsg: '', errno: '', data: [1]} 结构体了。前提是需要使用 <serverURL>/api 新的接口来请求。
  2. 我看了下你的 MR BeiyanYunyi/sodesu@8208fae 没有看太明白,我们应该是不会返回{time: 1} 这种结构的。这块建议你直接发下请求地址我一块看看。

  1. The pageview interface had a problem with returning data before. When one request was made, it returned 1, and when multiple requests were made, it returned the [1,1] array format. This has been unified into the {errmsg: '', errno: '', data: [1]} structure in the new version. The premise is that you need to use the <serverURL>/api new interface to request.
  2. I took a look at your MR BeiyanYunyi/sodesu@8208fae. I didn’t understand it very well. We should not return a structure like {time: 1}. It is recommended that you directly send the request address and I will take a look.

@lizheming lizheming added the Needs more info Further information is needed label Dec 20, 2023
@BeiyanYunyi
Copy link
Contributor Author

BeiyanYunyi commented Dec 20, 2023

对于“其他页面 pageview”的情况:

GET https://walinejs.comment.lithub.cc/api/article?path=/guide/features/pageview.html,/guide/features/i18n.html&type=time&lang=zh-CN

返回值:

{"errno":0,"errmsg":"","data":[{"time":5995},{"time":4844}]}

对于“本页面 pageview”的情况:

POST https://walinejs.comment.lithub.cc/api/article?lang=zh-CN

返回值:

{"errno":0,"errmsg":"","data":[125849]}

两个返回值的 data 格式很显然是不同的。


For the case of "other page pageview":

GET https://walinejs.comment.lithub.cc/api/article?path=/guide/features/pageview.html,/guide/features/i18n.html&type=time&lang=zh-CN

return value:

{"errno":0,"errmsg":"","data":[{"time":5995},{"time":4844}]}

For the case of "this page pageview":

POST https://walinejs.comment.lithub.cc/api/article?lang=zh-CN

return value:

{"errno":0,"errmsg":"","data":[125849]}

The data format of the two return values ​​is obviously different.

@lizheming lizheming added bug Something isn't working and removed Needs more info Further information is needed labels Dec 20, 2023
@lizheming lizheming self-assigned this Dec 20, 2023
@Mister-Hope
Copy link
Member

Any update with this @lizheming, dpes client side code need any changes?

@Mister-Hope
Copy link
Member

Mister-Hope commented Feb 16, 2024

@lizheming 我这两天又羊了,正难受,你看一下这个问题是 @waline/api 写的有问题还是的确需要 refine 一下服务端的 api 吧。


@lizheming I've been having trouble these past two days and I'm feeling uncomfortable. Please check if this question is written by @waline/api, or if the server-side API really needs to be refined.

@lizheming
Copy link
Collaborator

lizheming commented Feb 16, 2024

@Mister-Hope 是服务端 API 改造的问题,这个我正在纠结预期的返回格式是什么样子的,确认完之后再统一修改一下。


@Mister-Hope It’s a question of server-side API transformation. I’m struggling with what the expected return format should be. I’ll make unified changes after confirmation.

@lizheming
Copy link
Collaborator

lizheming commented Feb 17, 2024

为了统一 pageview 和 reaction 的返回格式,思考了下,最终统一按照如下结构体进行统一返回。@waline/client@v3 也需要进行下适配,这块我来同步修改一下。

type ResponseData = Counter[];

interface Counter {
  time?: number;
  reaction0: number;
  reaction1: number;
}

In order to unify the return format of pageview and reaction, I thought about it and finally unified the return according to the following structure. @waline/client@v3 also needs to be adapted. I will modify this synchronously.

type ResponseData = Counter[];

interface Counter {
  time?: number;
  reaction0: number;
  reaction1: number;
}

@FidStyle
Copy link
Contributor

image
按照文档配置发生error,仍然无法显示
服务端客户端均为latest
@lizheming

@lizheming
Copy link
Collaborator

lizheming commented Feb 20, 2024

@FidStyle 修了,更新到 @waline/[email protected]


@FidStyle fixed it and updated it to @waline/[email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Inactive
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants