Skip to content

Commit d0703bf

Browse files
authored
Merge branch 'BIT101-dev:dev' into dev
2 parents a7ef225 + 4989e7c commit d0703bf

File tree

5 files changed

+55
-28
lines changed

5 files changed

+55
-28
lines changed

components.d.ts

+11
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,16 @@ declare module 'vue' {
1616
ImageViewer: typeof import('./src/components/ImageViewer/ImageViewer.vue')['default']
1717
MessageContent: typeof import('./src/components/MessageContent.vue')['default']
1818
NA: typeof import('naive-ui')['NA']
19+
NAlert: typeof import('naive-ui')['NAlert']
20+
NAvatar: typeof import('naive-ui')['NAvatar']
1921
NBadge: typeof import('naive-ui')['NBadge']
2022
NButton: typeof import('naive-ui')['NButton']
2123
NCard: typeof import('naive-ui')['NCard']
2224
NCarousel: typeof import('naive-ui')['NCarousel']
25+
NCollapse: typeof import('naive-ui')['NCollapse']
26+
NCollapseItem: typeof import('naive-ui')['NCollapseItem']
2327
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
28+
NDataTable: typeof import('naive-ui')['NDataTable']
2429
NDivider: typeof import('naive-ui')['NDivider']
2530
NDrawer: typeof import('naive-ui')['NDrawer']
2631
NDrawerContent: typeof import('naive-ui')['NDrawerContent']
@@ -29,6 +34,9 @@ declare module 'vue' {
2934
NElement: typeof import('naive-ui')['NElement']
3035
NEllipsis: typeof import('naive-ui')['NEllipsis']
3136
NEmpty: typeof import('naive-ui')['NEmpty']
37+
NForm: typeof import('naive-ui')['NForm']
38+
NFormItem: typeof import('naive-ui')['NFormItem']
39+
NFormItemGi: typeof import('naive-ui')['NFormItemGi']
3240
NGi: typeof import('naive-ui')['NGi']
3341
NGlobalStyle: typeof import('naive-ui')['NGlobalStyle']
3442
NGrid: typeof import('naive-ui')['NGrid']
@@ -46,11 +54,14 @@ declare module 'vue' {
4654
NModal: typeof import('naive-ui')['NModal']
4755
NPopconfirm: typeof import('naive-ui')['NPopconfirm']
4856
NRadio: typeof import('naive-ui')['NRadio']
57+
NRadioButton: typeof import('naive-ui')['NRadioButton']
4958
NRadioGroup: typeof import('naive-ui')['NRadioGroup']
5059
NRate: typeof import('naive-ui')['NRate']
5160
NScrollbar: typeof import('naive-ui')['NScrollbar']
61+
NSelect: typeof import('naive-ui')['NSelect']
5262
NSpace: typeof import('naive-ui')['NSpace']
5363
NSpin: typeof import('naive-ui')['NSpin']
64+
NTable: typeof import('naive-ui')['NTable']
5465
NTabPane: typeof import('naive-ui')['NTabPane']
5566
NTabs: typeof import('naive-ui')['NTabs']
5667
NTag: typeof import('naive-ui')['NTag']

index.html

+29-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!--
22
* @Author: flwfdd
33
* @Date: 2022-05-28 00:01:07
4-
* @LastEditTime: 2023-11-02 03:02:40
4+
* @LastEditTime: 2024-12-16 02:38:10
55
* @Description:
66
* _(:з」∠)_
77
-->
@@ -15,24 +15,40 @@
1515
<meta name="description" content="BIT101校园社区">
1616
<link rel="apple-touch-icon" href="/pwa-512x512.png" />
1717
<meta name="theme-color" content="#FF9A57">
18-
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
18+
<meta name="viewport"
19+
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
1920
<!--引入思源字体-->
20-
<link rel="preload" href="https://fonts.googleapis.com/css?family=Noto+Serif+SC:300,500,700,900&display=swap" crossorigin as="style" onload="this.onload=null;this.rel='stylesheet'">
21+
<link rel="preload" href="https://fonts.googleapis.com/css?family=Noto+Serif+SC:300,500,700,900&display=swap"
22+
crossorigin as="style" onload="this.onload=null;this.rel='stylesheet'">
2123
</head>
2224

25+
<!-- Google tag (gtag.js) -->
26+
<script async src="https://www.googletagmanager.com/gtag/js?id=G-1X4GFL2WXR"></script>
27+
<script>
28+
window.dataLayer = window.dataLayer || [];
29+
function gtag() {dataLayer.push(arguments);}
30+
gtag('js', new Date());
31+
32+
// User ID
33+
let id = '';
34+
let store = window.localStorage.getItem('store');
35+
if (store && JSON.parse(store).fake_cookie) {
36+
let fakeCookie = JSON.parse(store).fake_cookie;
37+
let base64Url = fakeCookie.split('.')[1];
38+
let base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
39+
let jsonPayload = decodeURIComponent(atob(base64).split('').map(function (c) {
40+
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
41+
}).join(''));
42+
let payload = JSON.parse(jsonPayload);
43+
id = payload.id;
44+
}
45+
gtag('config', 'G-1X4GFL2WXR', {'user_id': id});
46+
47+
</script>
48+
2349
<body>
2450
<div id="app"></div>
2551
<script type="module" src="/src/main.ts"></script>
2652
</body>
2753

28-
<script>
29-
var _hmt = _hmt || [];
30-
(function () {
31-
var hm = document.createElement("script");
32-
hm.src = "https://hm.baidu.com/hm.js?de1af35c78c09fec38632742181a9808";
33-
var s = document.getElementsByTagName("script")[0];
34-
s.parentNode.insertBefore(hm, s);
35-
})();
36-
</script>
37-
3854
</html>

src/main.ts

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* @Author: flwfdd
33
* @Date: 2022-05-28 00:01:07
4-
* @LastEditTime: 2023-02-16 23:39:02
4+
* @LastEditTime: 2024-12-15 14:45:43
55
* @Description:
66
* _(:з」∠)_
77
*/
@@ -12,12 +12,3 @@ import router from './router/index'
1212
const app = createApp(App);
1313
app.use(router)
1414
app.mount('#app')
15-
16-
router.afterEach((to, from) => {
17-
/* 告诉增加一个PV */
18-
try {
19-
const window_=window as any;
20-
window_._hmt = window_._hmt || [];
21-
window_._hmt.push(['_trackPageview', '/#'+to.fullPath]);
22-
} catch (e) { console.log(e); }
23-
});

src/router/index.ts

+13-4
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,18 @@ const router = createRouter({
139139
},
140140
});
141141

142-
router.beforeEach(({ path }) => {
143-
// 此处只是尽快响应,设置大类标题。
144-
// 之后各组件可以再覆盖。
142+
router.beforeEach((to) => {
143+
// 兼容旧hash模式的链接
144+
// 例:/#/paper/show/15 👉 /paper/15
145+
if (to.path === '/' && to.hash.startsWith('#/')) {
146+
let path = to.hash.slice('#'.length)
147+
path = path.replace(/^\/(paper|course)\/show\//, '/$1/')
148+
return path
149+
}
150+
151+
152+
// 设置大类标题
153+
// 此处只是尽快响应,之后各组件可以再覆盖。
145154

146155
const titleMap: Record<string, string> = {
147156
home: '主页',
@@ -157,7 +166,7 @@ router.beforeEach(({ path }) => {
157166
gallery: '话廊',
158167
report: '举报',
159168
}
160-
const top = path.split('/').filter(piece => piece.length > 0)[0] ?? ''
169+
const top = to.path.split('/').filter(piece => piece.length > 0)[0] ?? ''
161170
const title = titleMap[top] ?? top
162171
if (title) setTitle(title)
163172
})

src/utils/store.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* @Author: flwfdd
33
* @Date: 2022-05-28 09:18:09
4-
* @LastEditTime: 2024-02-26 15:11:41
4+
* @LastEditTime: 2024-12-15 14:44:39
55
* @Description: 全局状态管理
66
* _(:з」∠)_
77
*/

0 commit comments

Comments
 (0)