diff --git a/.vitepress/config.ts b/.vitepress/config.ts index d3354540f..57bd913c5 100644 --- a/.vitepress/config.ts +++ b/.vitepress/config.ts @@ -49,6 +49,7 @@ export default defineConfig({ srcExclude: [], scrollOffset: 'header', cleanUrls: true, + lastUpdated: true, sitemap: { hostname: 'https://yuanshen.site', }, diff --git a/.vitepress/locales/en.ts b/.vitepress/locales/en.ts index 4a09e468d..007487a7b 100644 --- a/.vitepress/locales/en.ts +++ b/.vitepress/locales/en.ts @@ -27,6 +27,37 @@ export const enConfig: LocaleSpecificConfig< siteTitle: 'Genshin Interactive Map', outlineTitle: 'On This Page', logo: '/imgs/logo_256.png', + ui: { + button: { + submit: 'Submit', + cancel: 'Cancel', + }, + }, + docsFeedback: { + feedbackMsg: 'Was this document helpful?', + good: 'Yes', + bad: 'No', + feedbackFailMsg: + 'Feedback failed, please retry or contact admin (QQ: 1961266616)!', + feedbackSuccessMsg: 'Feedback submitted successfully, thank you!', + badFeedbackSuccessMsg: 'Please specify any issues below~', + form: { + chooseIssues: 'Did you encounter these issues?', + translationIssue: 'Translation', + typosIssue: 'Typos/Punctuation', + ContentImgLinkIssue: 'Inaccurate Content, Image or Link', + feedbackDetail: 'Details/Suggestions', + feedbackTip: 'Describe issues or suggestions here', + otherIssue: 'Other (specify below)', + contactWay: 'Contact (optional)', + issueOptions: [ + { label: 'Page Display Error', value: 'pagedisplay-issue' }, + { label: 'Typos, Punctuation', value: 'typos-issue' }, + { label: 'Content, Image, Link Error', value: 'content-issue' }, + { label: 'Other Issues', value: 'other-issue' }, + ], + }, + }, notFound: { title: 'PAGE NOT FOUND', quote: diff --git a/.vitepress/locales/fr.ts b/.vitepress/locales/fr.ts index a162aea2a..820a652c8 100644 --- a/.vitepress/locales/fr.ts +++ b/.vitepress/locales/fr.ts @@ -32,6 +32,38 @@ export const frConfig: LocaleSpecificConfig< "But if you don't change your direction, and if you keep looking, you may end up where you are heading.", linkLabel: 'Take me home', }, + ui: { + button: { + submit: 'Soumettre', + cancel: 'Annuler', + }, + }, + docsFeedback: { + feedbackMsg: 'Ce document vous a-t-il été utile ?', + good: 'Utile', + bad: 'Pas utile', + feedbackFailMsg: + "Échec de la rétroaction, veuillez réessayer ou contacter l'administrateur (QQ : 1961266616) !", + feedbackSuccessMsg: 'Rétroaction soumise avec succès, merci !', + badFeedbackSuccessMsg: 'Veuillez spécifier les problèmes ci-dessous~', + form: { + chooseIssues: "Avez-vous rencontré l'un de ces problèmes ?", + translationIssue: 'Problème de traduction', + typosIssue: 'Erreurs de frappe/ponctuation', + ContentImgLinkIssue: + "Contenu inexact, problème de chargement d'image ou de lien", + feedbackDetail: 'Détails/Suggestions', + feedbackTip: 'Décrivez les problèmes rencontrés ou les suggestions ici', + otherIssue: 'Autres problèmes (spécifiez ci-dessous)', + contactWay: 'Coordonnées (facultatif)', + issueOptions: [ + { label: "Erreur d'affichage de page", value: 'pagedisplay-issue' }, + { label: 'Erreurs de frappe, ponctuation', value: 'typos-issue' }, + { label: 'Contenu, image, erreur de lien', value: 'content-issue' }, + { label: 'Autres problèmes', value: 'other-issue' }, + ], + }, + }, team: { title: '关于团队', desc: '地图的背后是一个基本来自中国的团队,以下是部分成员的个人信息。', diff --git a/.vitepress/locales/ja.ts b/.vitepress/locales/ja.ts index 20a0c0acb..2e62dc936 100644 --- a/.vitepress/locales/ja.ts +++ b/.vitepress/locales/ja.ts @@ -32,6 +32,39 @@ export const jaConfig: LocaleSpecificConfig< "But if you don't change your direction, and if you keep looking, you may end up where you are heading.", linkLabel: 'Take me home', }, + ui: { + button: { + submit: '提出する', + cancel: 'キャンセル', + }, + }, + docsFeedback: { + feedbackMsg: 'このドキュメントは役立ちましたか?', + good: '役立つ', + bad: '役に立たない', + feedbackFailMsg: + 'フィードバックが失敗しました。再試行するか、管理者に連絡してください(QQ:1961266616)!', + feedbackSuccessMsg: + 'フィードバックが正常に送信されました。ありがとうございます!', + badFeedbackSuccessMsg: '以下の問題を具体的にお知らせください~', + form: { + chooseIssues: '以下の問題に遭遇しましたか?', + translationIssue: '翻訳の問題', + typosIssue: '誤字/句読点のエラー', + ContentImgLinkIssue: + '不正確なコンテンツ表現、画像読み込みエラー、またはリンクエラー', + feedbackDetail: '詳細/提案', + feedbackTip: 'ここに遭遇した問題や提案を説明してください', + otherIssue: 'その他の問題(以下で具体的に指定してください)', + contactWay: '連絡先(任意)', + issueOptions: [ + { label: 'ページ表示エラー', value: 'pagedisplay-issue' }, + { label: '誤字、句読点のエラー', value: 'typos-issue' }, + { label: 'コンテンツ、画像、リンクのエラー', value: 'content-issue' }, + { label: 'その他の問題', value: 'other-issue' }, + ], + }, + }, team: { title: '关于团队', desc: '地图的背后是一个基本来自中国的团队,以下是部分成员的个人信息。', diff --git a/.vitepress/locales/types.ts b/.vitepress/locales/types.ts index 0b8f7b07b..ba9de3c32 100644 --- a/.vitepress/locales/types.ts +++ b/.vitepress/locales/types.ts @@ -50,4 +50,32 @@ export interface CustomConfig { address: string } > + ui: { + button: { + submit: string + cancel: string + } + } + docsFeedback: { + feedbackMsg: string + good: string + bad: string + badFeedbackSuccessMsg: string + feedbackFailMsg: string + feedbackSuccessMsg: string + form: { + chooseIssues: string + translationIssue: string + typosIssue: string + ContentImgLinkIssue: string + feedbackDetail: string + feedbackTip: string + otherIssue: string + contactWay: string + issueOptions: { + label: string + value: string + }[] + } + } } diff --git a/.vitepress/locales/zh.ts b/.vitepress/locales/zh.ts index b61f0a842..778e516da 100644 --- a/.vitepress/locales/zh.ts +++ b/.vitepress/locales/zh.ts @@ -83,7 +83,6 @@ export const zhConfig: LocaleSpecificConfig< ariaLabel: 'bilibili', }, ], - docFooter: { prev: '上一页', next: '下一页', @@ -96,6 +95,36 @@ export const zhConfig: LocaleSpecificConfig< sponsor: '支持我们', editLink: '报告页面错误', }, + ui: { + button: { + submit: '提交', + cancel: '取消', + }, + }, + docsFeedback: { + feedbackMsg: '这篇文档是否对你有帮助?', + good: '有帮助', + bad: '无帮助', + feedbackFailMsg: '反馈失败,请重试或联系管理员(QQ:1961266616)!', + feedbackSuccessMsg: '提交成功,感谢你的反馈!', + badFeedbackSuccessMsg: '希望你能在下方告知我们具体问题~', + form: { + chooseIssues: '是否遇到以下问题?', + translationIssue: '翻译问题', + typosIssue: '错别字/标点符号', + ContentImgLinkIssue: '文案表达不准确、图片加载失败或链接错误', + feedbackDetail: '反馈内容/更多建议', + feedbackTip: '请详细描述你在使用文档过程中遇到的问题或优化建议', + otherIssue: '其他问题(请在反馈内容中具体描述)', + contactWay: '联系方式(可选)', + issueOptions: [ + { label: '页面显示错误', value: 'pagedisplay-issue' }, + { label: '错别字、标点符号错误', value: 'typos-issue' }, + { label: '内容表达有误、图片/文字链接错误', value: 'content-issue' }, + { label: '其他问题', value: 'other-issue' }, + ], + }, + }, payment: { wechatpay: { name: '微信支付', diff --git a/.vitepress/theme/apis/getPageInfo.ts b/.vitepress/theme/apis/getPageInfo.ts new file mode 100644 index 000000000..8bb686ed2 --- /dev/null +++ b/.vitepress/theme/apis/getPageInfo.ts @@ -0,0 +1,23 @@ +import { fetcher } from '.' + +export type PageInfoResponse = { + code: number + message?: string + data: { + good: number + bad: number + pageview: number + lastupdate: number + id: string + record_id: string + } +} + +export const getPageInfo = async (page): Promise => + await fetcher + .get('docs/pageinfo', { + searchParams: { + path: String(page.value.filePath).replace('.md', ''), + }, + }) + .json() diff --git a/.vitepress/theme/apis/index.ts b/.vitepress/theme/apis/index.ts new file mode 100644 index 000000000..77be1d3f5 --- /dev/null +++ b/.vitepress/theme/apis/index.ts @@ -0,0 +1,29 @@ +import ky from 'ky' +import sha256 from 'crypto-js/sha256' +import hmacSHA512 from 'crypto-js/hmac-sha512' +import Base64 from 'crypto-js/enc-base64' + +const hmacDigest = (date) => + Base64.stringify(hmacSHA512(sha256(parseInt(date)), 'site.yuanshen')) + +export const fetcher = ky.create({ + prefixUrl: 'https://kongying-tavern-pin-feedback-api.vercel.app/apis/v1', + timeout: 5000, + retry: 0, + hooks: { + beforeRequest: [ + (request) => { + const currently = Date.now() + request.headers.set( + 'authorization', + `${currently}:${hmacDigest(currently)}`, + ) + }, + ], + afterResponse: [ + (_request, _options, response) => { + console.log(response) + }, + ], + }, +}) diff --git a/.vitepress/theme/apis/newDocFeedback.ts b/.vitepress/theme/apis/newDocFeedback.ts new file mode 100644 index 000000000..3686ffc55 --- /dev/null +++ b/.vitepress/theme/apis/newDocFeedback.ts @@ -0,0 +1,55 @@ +import { Content } from 'vitepress' +import { UAParser } from 'ua-parser-js' +import { fetcher } from '.' + +const parser = new UAParser(window.navigator.userAgent) +const result = parser.getResult() + +export type NewDocFeedbackResponse = { + code: number + message?: string + data?: { + id: string + feedback_id: string + record_id: string + } +} + +export const newDocFeedback = async (data: { + path: string + feedback_type?: Array + feedback_content?: string + user_id?: string + nickname?: string + file?: Array + user_contact?: string +}): Promise => { + try { + return await fetcher + .post('docs/feedback/new', { + json: { + path: data.path, + feedback_type: data.feedback_type, + feedback_content: data.feedback_content, + user_id: data.user_id, + file: data.file, + nickname: data.nickname, + user_contract: data.user_contact, + user_platform: `${result.os.name}-${result.browser.name}`, + user_env_info: JSON.stringify({ + userAgent: navigator.userAgent, + screen: { + availWidth: window.screen.availWidth, + availHeight: window.screen.availHeight, + width: window.screen.width, + height: window.screen.height, + }, + }), + }, + }) + .json() + } catch (error) { + console.log(error) + return await error.response + } +} diff --git a/.vitepress/theme/apis/pageview.ts b/.vitepress/theme/apis/pageview.ts new file mode 100644 index 000000000..a7593e850 --- /dev/null +++ b/.vitepress/theme/apis/pageview.ts @@ -0,0 +1,15 @@ +import { fetcher } from '.' + +export type PageviewResponse = { + code: number + message?: string +} + +export const pageview = async (record_id): Promise => + await fetcher + .get('docs/pageview', { + searchParams: { + record_id, + }, + }) + .json() diff --git a/.vitepress/theme/apis/sendDocFeedback.ts b/.vitepress/theme/apis/sendDocFeedback.ts new file mode 100644 index 000000000..da84dcd8e --- /dev/null +++ b/.vitepress/theme/apis/sendDocFeedback.ts @@ -0,0 +1,21 @@ +import { fetcher } from '.' + +export type DocFeedbackResponse = { + code: number + message?: string +} + +export const sendDocFeedback = async ( + record_id: string, + type: 'good' | 'bad', + cancel?: boolean, +): Promise => + await fetcher + .post('docs/feedback', { + json: { + record_id: record_id, + type: type, + cancel: cancel, + }, + }) + .json() diff --git a/.vitepress/theme/components/Banner.vue b/.vitepress/theme/components/Banner.vue index 5dd15e419..b28f03c86 100644 --- a/.vitepress/theme/components/Banner.vue +++ b/.vitepress/theme/components/Banner.vue @@ -4,11 +4,11 @@ import { ref, onMounted, watchEffect } from 'vue' import { useData } from 'vitepress' import { hash } from '../utils' import dayjs from 'dayjs' -const el = ref() -const { height } = useElementSize(el) +const banner = ref() +const { height } = useElementSize(banner) const { frontmatter, page } = useData() const storeKey = `banner-${page.value.relativePath}` -const isShow = ref(typeof frontmatter.value.banner === 'string') +const isBannerVisible = ref(typeof frontmatter.value.banner === 'string') const deal = () => (Date.now() + 8.64e7 * 1).toString() // current time + 1 day const inExpiryDate = () => { if (!frontmatter.value.bannerExpiryDate) return false @@ -54,14 +54,14 @@ const dismiss = () => { } const hideBanner = () => { - isShow.value = false + isBannerVisible.value = false document.documentElement.style.setProperty('--vp-layout-top-height', '0.1px') }