Tistory Blog

๐Ÿธ Haguri & Peng's Blog ๐Ÿง

Vue3 + Typescript + Vite์„ ํ†ตํ•ด ํ™˜๊ฒฝ์„ ๊ตฌ์„ฑํ•˜์˜€์œผ๋ฉฐ, Ex-Repository ์˜ ์†Œ์Šค๋ฅผ ๋ฆฌํŒฉํ† ๋ง ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

Changelog

  • 2024/5/27 Add spinner store. Router์˜ Navigation Guard์™€ ๋ฉ”์ธ(App.vue)์—์„œ LoadingSpinner๋ฅผ ์ปจํŠธ๋กค.
  • 2024/5/25 Vue 3.4์—์„œ ์•ˆ์ •ํ™”๋œ defineModel ์ ์šฉ. defineEmits ๋ฌธ๋ฒ• ์ตœ์‹ ํ™”. Aside ์˜์—ญ ์„ธํŒ…ํ•˜๋Š” ๋ถ€๋ถ„ ๊ฐœ์„ .
  • 2024/5/12 404 Page ์ˆ˜์ •.
  • 2024/3/18 ์˜คํ›„๋ถ€๋กœ ์ด์ „ theme๋กœ ์›๋ณตํ•˜์˜€์Šต๋‹ˆ๋‹ค. ์ œ๊ฐ€ ์ข€ ๊ฒŒ์„๋Ÿฌ์ง„ ํƒ“๋„ ์žˆ๊ฒ ์ง€๋งŒ ์ƒ๊ฐ๋ณด๋‹ค ๊ณต์‚ฌ๊ฐ€ ๊ฝค ์ปธ์Šต๋‹ˆ๋‹ค. ๊ธฐ์กด ๊ธฐ๋Šฅ๋“ค์€ ๋ชจ๋‘ ์žˆ์œผ๋‚˜ ์ตœ๊ทผ ๊ฒŒ์‹œ๊ธ€์˜ ํƒœ๊ทธ ์ •๋ณด๋ฅผ ๊ฐ€์ ธ์˜ค๋Š” ๋ถ€๋ถ„์€ ํ˜„์žฌ ์ž‘์—…์ค‘์ž…๋‹ˆ๋‹ค.
  • 2024/3/5 ์ƒˆ๋ฒฝ๋ถ€ํ„ฐ ํ‹ฐ์Šคํ† ๋ฆฌ Open API ์„œ๋น„์Šค๊ฐ€ ์ข…๋ฃŒ๋จ์— ๋”ฐ๋ผ ํ˜„์žฌ ๊ตฌํ˜„ํ•ด๋†“์€ ๋ถ€๋ถ„์ด ์›ํ™œํžˆ ๋™์ž‘ํ•˜์ง€ ์•Š์•„ ์ˆ˜์ • ์ž‘์—…์ค‘์ž…๋‹ˆ๋‹ค. ์ƒ๊ฐ๋ณด๋‹ค ๊ณ ์น  ๋ถ€๋ถ„์ด ๋งŽ์Šต๋‹ˆ๋‹ค. ๐Ÿ˜ฑ ๊ธฐ์กด ํŽ˜์ด์ง€๋“ค์ด ์ •์ƒ์ ์œผ๋กœ ๋™์ž‘ํ•˜๊ฒŒ ๋˜๋ฉด ๋‹ค์‹œ ๊ณต์ง€ํ•  ์˜ˆ์ •์ด๋ฉฐ, ๊ทธ ์ „๊นŒ์ง€ ๊ณ„์† ์†Œ์Šค๋ฅผ commit ํ•˜์—ฌ ๋ฐ˜์˜ํ•  ์˜ˆ์ •์ž…๋‹ˆ๋‹ค. ํ˜„์žฌ ๋ธ”๋กœ๊ทธ๋Š” ๊ธฐ๋ณธ ์Šคํ‚จ์„ ์ ์šฉํ•œ ์ƒํƒœ.

Vue

Pinia (Vuex -> Pinia)

๊ฒŒ์‹œ๊ธ€(post)์—์„œ ์ด์ „ ํŽ˜์ด์ง€๋กœ ์ด๋™ ์‹œ ํŽ˜์ด์ง€ ์ •๋ณด์™€ ๊ฒ€์ƒ‰์–ด๋ฅผ ์ €์žฅํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ

// category.ts
import { reactive, computed } from 'vue';
import { defineStore } from 'pinia';

import { CategoryInfo } from '@/types';

const setValue = <T>(obj: T, key: keyof T, value: T[keyof T]) => {
  obj[key] = value;
};

export const useCategoryStore = defineStore('category', () => {
  const categoryInfo = reactive(<CategoryInfo>{});

  const getCategoryInfo = computed(() => categoryInfo);

  function setCategoryInfo(pCategoryInfo: CategoryInfo) {
    for (const key of Object.keys(pCategoryInfo)) {
      const categoryKey = key as keyof CategoryInfo;
      setValue<CategoryInfo>(
        categoryInfo,
        categoryKey,
        pCategoryInfo[categoryKey],
      );
    }
  }

  function clearCategoryInfo() {
    const initData = <CategoryInfo>{};
    for (const key of Object.keys(categoryInfo)) {
      const categoryKey = key as keyof CategoryInfo;
      setValue<CategoryInfo>(categoryInfo, categoryKey, initData[categoryKey]);
    }
  }

  return { categoryInfo, getCategoryInfo, setCategoryInfo, clearCategoryInfo };
});

Icon

Modal

  • Gitart Vue Dialog
    (๋Œ“๊ธ€/๋ฐฉ๋ช…๋ก ๋“ฑ๋ก, RecentTag)

Libraries

Color

Color Hunt

Tistory

2024/3/5 ์ดํ›„๋กœ Tistory Open API๋Š” ์„œ๋น„์Šค ์ข…๋ฃŒ!!

Tistory ์—์„œ ์ œ๊ณตํ•˜๋Š” Open API ๋ฅผ ํ™œ์šฉ (Tistory Open API).
์ œ๊ณตํ•ด์ฃผ๋Š” Open API ์— ํ•œ๊ณ„๊ฐ€ ์žˆ์–ด ์ด๋ฅผ ๊ฐ์•ˆํ•˜๊ณ  ๊ฐœ๋ฐœํ•˜์˜€์œผ๋‹ˆ ์ฐธ๊ณ  ๋ฐ”๋ž๋‹ˆ๋‹ค.

๋ชจ๋ฐ”์ผ ํŽ˜์ด์ง€๋Š” Tistory์—์„œ ์ž๋™์œผ๋กœ ์ œ๊ณตํ•˜๋ฉฐ,
๋ชจ๋ฐ”์ผ๋กœ ์ ‘์†ํ•˜๋Š” ๊ฒฝ์šฐ์— ๋ชจ๋ฐ”์ผ ํŽ˜์ด์ง€(/m)๋กœ redirect ์ฒ˜๋ฆฌํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

Open API๋Š” 2024๋…„ 2์›”๊นŒ์ง€ ์ˆœ์ฐจ์ ์œผ๋กœ ์„œ๋น„์Šค๊ฐ€ ์ข…๋ฃŒ๋ฉ๋‹ˆ๋‹ค.
์„œ๋น„์Šค ์ข…๋ฃŒ ์•ˆ๋‚ด ๋งํฌ

๊ณต์ง€์‚ฌํ•ญ

  • Header์— ๊ณต์ง€์‚ฌํ•ญ(Notice) ๋ฉ”๋‰ด ์ ์šฉ

์นดํ…Œ๊ณ ๋ฆฌ

  • ์นดํ…Œ๊ณ ๋ฆฌ Level(1, 2)๋ณ„ ์ด๋™ ์ฒ˜๋ฆฌ
  • ์นดํ…Œ๊ณ ๋ฆฌ ํด๋ฆญ ์‹œ, ํ•˜์œ„ ์นดํ…Œ๊ณ ๋ฆฌ๊ฐ€ ์žˆ๋Š” ๊ฒฝ์šฐ ํ•˜์œ„ ์นดํ…Œ๊ณ ๋ฆฌ๋ฅผ ๋ณด์—ฌ์คŒ
  • ํ•ด๋‹น ์นดํ…Œ๊ณ ๋ฆฌ๊ฐ€ ๋น„์–ด(์ž‘์„ฑ๊ธ€ 0๊ฐœ) ์žˆ๋Š” ๊ฒฝ์šฐ ๋…ธ์ถœํ•˜์ง€ ์•Š์Œ

๊ธฐ๋Šฅ๊ตฌํ˜„ ๋ชฉ๋ก

  • ๊ธ€ ๋ชฉ๋ก ํŽ˜์ด์ง• ์ฒ˜๋ฆฌ
  • ๊ฒ€์ƒ‰ ๋ฐ ๊ฒ€์ƒ‰ ํŽ˜์ด์ง€ ์ด๋™
  • ๋Œ“๊ธ€ ๋“ฑ๋ก
  • ๋Œ“๊ธ€ ์ˆ˜์ •/์‚ญ์ œ
  • ๋ฐฉ๋ช…๋ก ๋“ฑ๋ก
  • ๋ฐฉ๋ช…๋ก ์ˆ˜์ •/์‚ญ์ œ
  • ์ข‹์•„์š” ์„ค์ •/ํ•ด์ œ
  • ๊ด‘๊ณ 

๊ด‘๊ณ 

  • Google Adsense: ๋ธ”๋กœ๊ทธ ์ „๋ฐ˜์— ์ ์šฉ
  • Kakao Adfit: Side ์˜์—ญ ๋ฐ ํฌ์ŠคํŒ…์— ํ•œ ๊ฐœ์”ฉ ์ ์šฉ
  • Tenping: ํฌ์ŠคํŒ…์— ํ•œ ๊ฐœ์”ฉ ์ ์šฉ

๊ฐ ๊ฒŒ์‹œ๊ธ€์— ์ ์šฉ๋˜๋Š” ๋ถ€๋ถ„์€ ์ž‘์„ฑ ์‹œ์— ์—๋””ํ„ฐ์—์„œ ์ˆ˜๋™์œผ๋กœ ์ถ”๊ฐ€ํ•˜๋Š” ๋ถ€๋ถ„์ž…๋‹ˆ๋‹ค.

โš™๏ธ Configuration

Vue 3 + TypeScript + Vite

This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 <script setup> SFCs, check out the script setup docs to learn more.

Recommended IDE Setup

Type Support For .vue Imports in TS

TypeScript cannot handle type information for .vue imports by default, so we replace the tsc CLI with vue-tsc for type checking. In editors, we need TypeScript Vue Plugin (Volar) to make the TypeScript language service aware of .vue types.

If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a Take Over Mode that is more performant. You can enable it by the following steps:

  1. Disable the built-in TypeScript Extension
    1. Run Extensions: Show Built-in Extensions from VSCode's command palette
    2. Find TypeScript and JavaScript Language Features, right click and select Disable (Workspace)
  2. Reload the VSCode window by running Developer: Reload Window from the command palette.

Build & Deploy

npm run build

์ •์ƒ์ ์œผ๋กœ ๋นŒ๋“œ๋˜๋ฉด, dist ํด๋”์˜ index.html, index-[name].js ํŒŒ์ผ ๋‚ด์—์„œ /images/ ๋กœ ์‹œ์ž‘ํ•˜๋Š” ๊ฒฝ๋กœ ๊ฐ’์„ ์ˆ˜๋™์œผ๋กœ ๋ณ€๊ฒฝํ•ด์„œ ์ตœ์ข… ์Šคํ‚จ์— ์—…๋กœ๋“œํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

https://tistory4.daumcdn.net/tistory/2876097/skin/
/tistory/ ๊ฒฝ๋กœ ๋‹ค์Œ์— ๋‚˜์˜ค๋Š” ์ˆซ์ž ๊ฐ’์ด Tistory ๋ธ”๋กœ๊ทธ๋งˆ๋‹ค ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ๊ณ ์œ  ID ๊ฐ’์ธ ๊ฒƒ ๊ฐ™์€๋ฐ, ์ด ๊ฐ’์€ ์‹ค์ œ ๋ฐฐํฌํ•œ ๋‹ค์Œ์— console ์ฐฝ์— error ๋กœ ๋‚˜ํƒ€๋‚˜๋Š” ๊ฐ’์„ ํ™•์ธํ•ด์•ผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์‹ค์ œ ์„ค์ •๋˜๋Š” ๊ฐ’์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.
https://tistory4.daumcdn.net/tistory/2876097/skin/images/index-OYSrlsaS.js