diff --git a/app/controllers/option-controller.php b/app/controllers/option-controller.php index 1cf9374..876de9b 100644 --- a/app/controllers/option-controller.php +++ b/app/controllers/option-controller.php @@ -100,7 +100,7 @@ class OptionController extends BaseController if ($hasNoDiff) { return [ 'code' => 'save_config_succeed', - 'message' => __('Configurations already up to date.', self::$text_domain), + 'message' => __('Configuration is already up to date.', self::$text_domain), ]; } @@ -108,13 +108,13 @@ class OptionController extends BaseController if (!$config) { return new WP_Error( 'save_config_failure', - __('Unable to save configuration.', self::$text_domain), + __('Unable to save the configuration.', self::$text_domain), array('status' => 500) ); } else { return [ 'code' => 'save_config_succeed', - 'message' => __('Configurations saved successfully.', self::$text_domain), + 'message' => __('Configuration saved successfully.', self::$text_domain), ]; } } diff --git a/app/functions.php b/app/functions.php index 6167c2f..8500532 100644 --- a/app/functions.php +++ b/app/functions.php @@ -5,7 +5,7 @@ define('SAKURA_VERSION', wp_get_theme()->get('Version')); define('SAKURA_TEXT_DOMAIN', wp_get_theme()->get('TextDomain')); -define('SAKURA_DEVEPLOMENT', true); +define('SAKURA_DEVEPLOMENT', false); define('SAKURA_DEVEPLOMENT_HOST', 'http://127.0.0.1:9000'); // PHP loaders diff --git a/src/@types/declarations.d.ts b/src/@types/declarations.d.ts index 74cb512..1e91008 100644 --- a/src/@types/declarations.d.ts +++ b/src/@types/declarations.d.ts @@ -53,7 +53,20 @@ interface WPPostAbstract { categories: [number?] categoriesMeta: { [key: string]: any } tags: [number?] - tagsMeta: { [key: string]: any } + tagsMeta: { + [key: string]: { + count: number + description: string + filter: string + name: string + parent: number + slug: string + taxonomy: string + termGroup: number + termId: number + termTaxonomyId: number + } + } commentCount: number viewCount: number wordsCount: number @@ -117,3 +130,5 @@ interface CommentStore { pagination: Pagination } } + +declare type FetchingStatus = 'inite' | 'cached' | 'pending' | 'success' | 'error' | 'empty' diff --git a/src/App.vue b/src/App.vue index 5b57c08..fbda8c1 100644 --- a/src/App.vue +++ b/src/App.vue @@ -4,15 +4,19 @@ +
+ +
diff --git a/src/admin/Core.vue b/src/admin/Core.vue index 32e0779..fb51546 100644 --- a/src/admin/Core.vue +++ b/src/admin/Core.vue @@ -47,10 +47,10 @@ @@ -96,6 +113,19 @@ export default defineComponent({ flex: 0 0 auto; width: 200px; padding-top: 15px; + @media screen and (max-width: variables.$mobile-max-width) { + margin-block-start: 0; + margin-block-end: 0; + padding-top: 0; + } + > .restore { + padding-left: 6px; + font-size: 0.8em; + color: var(--mdc-theme-secondary, #1d2327); + :hover { + color: var(--mdc-theme-primary, #6200ee); + } + } } &--main { width: 100%; @@ -112,6 +142,7 @@ export default defineComponent({ &--desc { font-size: 14px; color: #646970; + // margin-block-end: 0; } } } diff --git a/src/admin/components/MediaPicker.vue b/src/admin/components/MediaPicker.vue index 8cd678d..11b63e4 100644 --- a/src/admin/components/MediaPicker.vue +++ b/src/admin/components/MediaPicker.vue @@ -139,14 +139,21 @@ export default defineComponent({ (value) => { if (!props.multiple && value.length > 1) { selection.value = selection.value.slice(-1) - console.log(selection.value.length) + // console.log(selection.value.length) } - console.log(selection.value) + // console.log(selection.value) emit('update:selection', selection.value) }, { deep: true } ) + watch( + () => props.selection as { id: number; url: string }[], + (selectionProp) => { + selection.value = selectionProp + } + ) + return { open, add, del, userInput, selection } }, }) @@ -183,9 +190,6 @@ export default defineComponent({ flex-flow: row wrap; justify-content: flex-start; @include polyfills.flex-gap(12px, 'row wrap'); - > .input__wrapper { - flex: 0 0 auto; - } } } &--preview { diff --git a/src/admin/store.ts b/src/admin/store.ts index 2c71e98..e1afdb5 100644 --- a/src/admin/store.ts +++ b/src/admin/store.ts @@ -1,9 +1,9 @@ import { Ref } from 'vue' import { useState } from '@/hooks' -import API from '@/api' -import camelcaseKeys from 'camelcase-keys' -import intl from '@/locales' -import options, { Options } from './options' +// import API from '@/api' +// import camelcaseKeys from 'camelcase-keys' +// import intl from '@/locales' +// import options, { Options } from './options' import { cloneDeep } from 'lodash' export interface OptionStore { diff --git a/src/components/cards/postThumbCards/PostThumbCardClassic.vue b/src/components/cards/postThumbCards/PostThumbCardClassic.vue index 615866a..918bda8 100644 --- a/src/components/cards/postThumbCards/PostThumbCardClassic.vue +++ b/src/components/cards/postThumbCards/PostThumbCardClassic.vue @@ -2,21 +2,25 @@
-
- +
+ + +
{{ $props.data.publistTime }}
-
- {{ $props.data.title }} +
+ + {{ $props.data.title }} +
@@ -32,19 +36,20 @@
{{ $props.data.excerpt }}
- - -
+
+
- + + +
@@ -55,11 +60,11 @@ diff --git a/src/components/link/types.ts b/src/components/link/types.ts new file mode 100644 index 0000000..bac53cf --- /dev/null +++ b/src/components/link/types.ts @@ -0,0 +1,6 @@ +export interface RouterLinkTo { + path?: string + name?: string + params?: { [key: string]: any } + query?: { [key: string]: any } +} diff --git a/src/components/lists/postThumbList/PostThumbList.vue b/src/components/lists/postThumbList/PostThumbList.vue index c8eaa35..9ae351d 100644 --- a/src/components/lists/postThumbList/PostThumbList.vue +++ b/src/components/lists/postThumbList/PostThumbList.vue @@ -7,7 +7,7 @@ :type="index % 2 ? 'normal' : 'reverse'" >
-
+
no more
@@ -17,7 +17,14 @@ diff --git a/src/hooks/index.ts b/src/hooks/index.ts index 0569143..f1ef2d9 100644 --- a/src/hooks/index.ts +++ b/src/hooks/index.ts @@ -8,8 +8,11 @@ import useReachElementSide from './useReachElementSide' import { useElementRef, useElementRefs } from './useElementRef' import useOffsetDistance from './useOffsetDistance' import useMDCRipple from './mdc/useMDCRipple' -import useMessage from './useMessage' +import useMessage, { useCommonMessages } from './useMessage' import useTypewriterEffect from './useTypewriterEffect' +import useIntervalWatcher from './useIntervalWatcher' +import useKeepAliveWindowScrollTop from './useKeepAliveWindowScrollTop' +import useWindowScrollLock from './useWindowScrollLock' export { useState, @@ -29,5 +32,9 @@ export { useElementRefs, useOffsetDistance, useMessage, + useCommonMessages, useTypewriterEffect, + useIntervalWatcher, + useKeepAliveWindowScrollTop, + useWindowScrollLock, } diff --git a/src/hooks/useIntervalWatcher.ts b/src/hooks/useIntervalWatcher.ts new file mode 100644 index 0000000..5536e80 --- /dev/null +++ b/src/hooks/useIntervalWatcher.ts @@ -0,0 +1,18 @@ +import { onMounted, onUnmounted, onActivated, onDeactivated } from 'vue' +export default function useIntervalWatcher(func: () => void, interval = 100): void { + let timer = NaN + const addWatcher = () => { + if (timer) return + timer = window.setInterval(func, interval) + } + const removeWatcher = () => { + if (!timer) return + window.clearInterval(timer) + timer = NaN + } + + onMounted(() => addWatcher()) + onActivated(() => addWatcher()) + onUnmounted(() => removeWatcher()) + onDeactivated(() => removeWatcher()) +} diff --git a/src/hooks/useKeepAliveWindowScrollTop.ts b/src/hooks/useKeepAliveWindowScrollTop.ts new file mode 100644 index 0000000..3e4807a --- /dev/null +++ b/src/hooks/useKeepAliveWindowScrollTop.ts @@ -0,0 +1,27 @@ +import { onDeactivated, watch, onActivated } from 'vue' +import { useWindowScroll } from '@vueuse/core' +import { useState } from '@/hooks' + +export default function () { + const { scrollTop, scrollLeft } = (function () { + const { x, y } = useWindowScroll() + return { scrollTop: y, scrollLeft: x } + })() + + const [scrollTopCache, setScrollTopCache] = useState(0) + const [isScrollTopSet, setIsScrollTopSet] = useState(false) + + watch(scrollTop, (value) => { + if (!isScrollTopSet.value) return + setScrollTopCache(value) + }) + + onActivated(() => { + window.scrollTo(scrollLeft.value ?? 0, scrollTopCache.value) + setIsScrollTopSet(true) + }) + + onDeactivated(() => { + setIsScrollTopSet(false) + }) +} diff --git a/src/hooks/useMessage.ts b/src/hooks/useMessage.ts index aea6174..dd59fc5 100644 --- a/src/hooks/useMessage.ts +++ b/src/hooks/useMessage.ts @@ -1,16 +1,24 @@ import type { Ref } from 'vue' -import { useInjector } from '@/hooks' +import { useInjector, useIntl } from '@/hooks' import { messages } from '@/store' import type { Message, MessageOptions } from '@/store/messages' -export default function useMessage() { - const { - messageList, - addMessage, - }: { - messageList: Ref - addMessage: (state: Ref, options: MessageOptions) => void - } = useInjector(messages) +/** + * deprecated + */ +export interface UseMessageInjecter { + messageList: Ref + addMessage: (state: Ref, options: MessageOptions) => void +} + +/** + * @param useMessageInjecter (deprecated) + * @returns + */ +export default function useMessage(useMessageInjecter?: UseMessageInjecter) { + const { messageList, addMessage }: UseMessageInjecter = useMessageInjecter + ? useMessageInjecter + : useInjector(messages) const _addMessage = (options: MessageOptions) => { addMessage(messageList, options) @@ -18,3 +26,13 @@ export default function useMessage() { return _addMessage } + +export const useCommonMessages = () => { + const intl = useIntl() + return { + javascriptErrorTitle: intl.formatMessage({ + id: 'messages.commonMessages.javascriptErrorTitle', + defaultMessage: 'Opps, something when wrong!', + }), + } +} diff --git a/src/hooks/useWindowScrollLock.ts b/src/hooks/useWindowScrollLock.ts new file mode 100644 index 0000000..48f2a03 --- /dev/null +++ b/src/hooks/useWindowScrollLock.ts @@ -0,0 +1,29 @@ +import { onUnmounted, onDeactivated } from 'vue' +import getScrollbarWidth from '@/utils/getScrollbarWidth' +export default function () { + const removeScrollLock = () => { + const body = document.querySelector('body') + // TODO: add a fake scroll bar element + if (body instanceof HTMLElement) { + body.style.overflow = 'auto' + body.style.width = '100%' + } + } + const addScrollLock = () => { + const body = document.querySelector('body') + if (body instanceof HTMLElement) { + body.style.overflow = 'hidden' + body.style.width = `calc(100% - ${String(getScrollbarWidth())}px)` + } + } + + onUnmounted(() => { + removeScrollLock() + }) + + onDeactivated(() => { + removeScrollLock() + }) + + return [removeScrollLock, addScrollLock] +} diff --git a/src/layouts/Base.vue b/src/layouts/Base.vue index f5f474c..2022860 100644 --- a/src/layouts/Base.vue +++ b/src/layouts/Base.vue @@ -36,9 +36,13 @@