Skip to content

Commit

Permalink
Merge branch 'main' of github.com:wmui/essay into main
Browse files Browse the repository at this point in the history
  • Loading branch information
wmui committed Jun 30, 2023
2 parents cd1c5f6 + 0120215 commit 686b139
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 5 deletions.
16 changes: 16 additions & 0 deletions app/public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "Essay",
"short_name": "Essay",
"icons": [
{
"src": "/public/favicon.png",
"type": "image/png",
"sizes": "400x400"
}
],
"start_url": "/",
"scope": "/",
"display": "standalone",
"background_color": "#fff",
"theme_color": "#fff"
}
3 changes: 3 additions & 0 deletions app/public/sw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
self.addEventListener('fetch', function (e) {
console.log('正在请求:' + e.request.url);
});
2 changes: 1 addition & 1 deletion app/service/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class UserService extends Service {
return jwt.verify(token, key, (err, decoded) => {
if (err) {
// JWT验证失败,可能是过期或无效
this.logger.error('token 验证失败', err);
this.logger.warn('token 验证失败', err);
return {
status: -1,
data: 'token解析失败',
Expand Down
20 changes: 19 additions & 1 deletion app/view/theme/layout.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<meta name="description" content="<%= seo.description %>">
<%}%>
<link rel="shortcut icon" href="/public/favicon.png" type="image/x-icon">
<link rel="manifest" href="/public/manifest.json">
<%- include('./style.ejs') -%>
</head>
<body>
Expand Down Expand Up @@ -151,7 +152,7 @@
<footer class="footer">
<span class="icp"
><%= site.icp %> Powered by
<a href="https://github.wmui/essay" target="_blank">Essay</a></span
<a href="https://github.com/wmui/essay" target="_blank">Essay</a></span
>
</footer>
<script>
Expand All @@ -162,6 +163,23 @@
window.location.href = '/search?keywords=' + encodeURIComponent(search.value)
}
})
// https://www.imooc.com/article/289875
if('serviceWorker' in navigator) {
navigator.serviceWorker
.register('/public/sw.js', { scope: '/' })
.then(function (registration) {
// 注册成功
console.log(
'ServiceWorker registration successful with scope: ',
registration.scope
);
})
.catch(function (err) {
// 注册失败:(
console.log('ServiceWorker registration failed: ', err);
});
}
})
</script>
<%- include('./script.ejs') -%>
Expand Down
2 changes: 0 additions & 2 deletions app/view/theme/script.ejs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


<!-- <script src="/public/lib/lulu/polyfill.min.js" defer></script> -->
<script src="/public/lib/lulu/all.min.js" defer></script>
<script src="/public/lib/axios/axios.min.js" defer></script>
Expand Down
3 changes: 2 additions & 1 deletion config/config.default.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
* @param {Egg.EggAppInfo} appInfo app info
*/
module.exports = appInfo => {
console.log(appInfo.root);
// console.log(appInfo.root);

/**
* built-in config
* @type {Egg.EggAppConfig}
Expand Down

0 comments on commit 686b139

Please sign in to comment.