Skip to content

Commit

Permalink
Merge pull request #24 from TeamGrabit/develop
Browse files Browse the repository at this point in the history
Release v1.0.1
  • Loading branch information
MOBUMIN authored Feb 13, 2022
2 parents ea8ed13 + 5dc35a7 commit 457dd6d
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
# /public/build/

.DS_Store
.env
40 changes: 40 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
"build": "rollup -c",
"dev": "rollup -c -w",
"start": "sirv public --no-clear",
"release": "git push origin `git subtree split --prefix public/ main`:gh-pages --force"
"release": "git push origin `git subtree split --prefix public/ main`:gh-pages --force"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-node-resolve": "^11.0.0",
"@rollup/plugin-replace": "^3.1.0",
"autoprefixer": "^10.4.2",
"dotenv": "^16.0.0",
"node-sass": "^7.0.1",
"postcss": "^8.4.6",
"rollup": "^2.67.0",
Expand Down
8 changes: 8 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import livereload from 'rollup-plugin-livereload';
import { terser } from 'rollup-plugin-terser';
import css from 'rollup-plugin-css-only';
import sveltePreprocess from 'svelte-preprocess';
import replace from '@rollup/plugin-replace';
import dotenv from 'dotenv';

dotenv.config();
const production = !process.env.ROLLUP_WATCH;

function serve() {
Expand Down Expand Up @@ -38,6 +41,11 @@ export default {
file: 'public/build/bundle.js'
},
plugins: [
replace({
ENV_API_URL: JSON.stringify(process.env.API_URL),
ENV_CALLBACK_URL: production? JSON.stringify(process.env.CALLBACK_URL) : JSON.stringify(process.env.CALLBACK_URL_LOCAL),
ENV_GIT_URL: JSON.stringify(process.env.GIT_URL)
}),
svelte({
compilerOptions: {
// enable run-time checks when not in production
Expand Down
5 changes: 3 additions & 2 deletions src/common/Variable.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const GIT_URL = 'https://github.com';
export const API_URL = 'https://grabit.duckdns.org/api';
export const GIT_URL = ENV_GIT_URL;
export const API_URL = ENV_API_URL;
export const CALLBACK_URL = ENV_CALLBACK_URL;
export const ACCESS_TOKEN = 'accessToken';
3 changes: 2 additions & 1 deletion src/pages/Home.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { user, getUser } from '../store/user.js';
import { changeTab } from '../store/page';
import { challengeList } from '../store/challenge.js';
import { ACCESS_TOKEN } from '../common/Variable';
let grass_list = new Array(365);
Expand All @@ -17,7 +18,7 @@
// TODO: 유저별로 home을 만들지 자기 home만 보이게 할 것인지 회의 필요
beforeUpdate(() => {
if (!$user){
if(localStorage.getItem('accessToken')) getUser();
if(localStorage.getItem(ACCESS_TOKEN)) getUser();
else push('/login');
}
});
Expand Down
1 change: 0 additions & 1 deletion src/pages/Setting.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
let activeItem = -1;
function onClickItem(i) {
activeItem = i;
console.log(activeItem)
}
function setActive(i) {
if(i === activeItem) return true;
Expand Down
4 changes: 2 additions & 2 deletions src/store/user.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { writable } from 'svelte/store';
import { ACCESS_TOKEN } from '../common/Variable';
import { ACCESS_TOKEN, CALLBACK_URL } from '../common/Variable';
import { fetchGet, fetchGetRedirectUrl, getQueryUri } from '../common/fetch';

export const user = writable(null);

export async function login() {
await fetchGetRedirectUrl(`oauth2/authorization/github?${getQueryUri({ 'redirect_uri' : 'http://localhost:5000/#/redirect'})}`, {redirect: 'manual'})
await fetchGetRedirectUrl(`oauth2/authorization/github?${getQueryUri({ 'redirect_uri' : CALLBACK_URL+'#/redirect'})}`, {redirect: 'manual'})
}

export function logout() {
Expand Down

0 comments on commit 457dd6d

Please sign in to comment.