update preview

This commit is contained in:
AceDataCloud committed 2022-04-03 09:13:04 +08:00
1 parent 1eb713aaf4
commit 304201ef80
10 files changed
+83 -17

No files matched your search

+26 -6
View File
@@ -1,11 +1,31 @@
# Vue 3 + Typescript + Vite
# Adademy
This template should help get you started developing with Vue 3 and Typescript in Vite.
## Setup domain
## Recommended IDE Setup
Modify the host file, like `/etc/hosts`, add this line:
- [VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.volar)
```
127.0.0.1 academy.local.zhishuyun.com
```
## Type Support For `.vue` Imports in TS
Then save it.
Since TypeScript cannot handle type information for `.vue` imports, they are shimmed to be a generic Vue component type by default. In most cases this is fine if you don't really care about component prop types outside of templates. However, if you wish to get actual prop types in `.vue` imports (for example to get props validation when using manual `h(...)` calls), you can enable Volar's `.vue` type support plugin by running `Volar: Switch TS Plugin on/off` from VSCode command palette.
### Generate certs
Run below command to generate certs:
```
yarn run init:https
```
Then install the `.crt` file and trust it.
### Start server
Run below command to start local server:
```
sudo yarn start
```
Then open `https://academy.local.zhishuyun.com` to view the content.
+2
View File
@@ -0,0 +1,2 @@
*
!.gitignore
+6 -2
View File
@@ -2,9 +2,12 @@
"name": "zhishuyun-auth",
"version": "0.1.0",
"scripts": {
"start": "vite --host",
"start": "vite",
"build": "vue-tsc --noEmit && vite build",
"serve": "vite preview"
"serve": "vite preview",
"init:https": "yarn run init:ca && yarn run init:cert",
"init:ca": "npx mkcert create-ca --validity 36500 --key certs/academy.local.zhishuyun.com.ca.key --cert certs/academy.local.zhishuyun.com.ca.crt",
"init:cert": "npx mkcert create-cert --ca-key certs/academy.local.zhishuyun.com.ca.key --ca-cert certs/academy.local.zhishuyun.com.ca.crt --validity 36500 --key certs/academy.local.zhishuyun.com.cert.key --cert certs/academy.local.zhishuyun.com.cert.crt --domains academy.local.zhishuyun.com"
},
"dependencies": {
"@element-plus/icons-vue": "^0.2.7",
@@ -33,6 +36,7 @@
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-vue": "^7.17.0",
"husky": "^7.0.2",
"mkcert": "^1.5.0",
"postcss": "^8.3.6",
"prettier": "^2.3.2",
"rollup-plugin-string": "^3.0.0",
+12 -1
View File
@@ -1,6 +1,16 @@
<template>
<div class="card">
<div class="left">
<div
class="left"
@click="
$router.push({
name: 'course-detail',
params: {
id: $route.params.courseId
}
})
"
>
<img :src="course.thumbnail" class="thumbnail" />
</div>
<div class="right">
@@ -37,6 +47,7 @@ export default defineComponent({
text-align: center;
width: 64px;
height: 64px;
cursor: pointer;
}
}
.right {
+5 -2
View File
@@ -30,8 +30,11 @@ export default defineComponent({
this.$router.push(this.redirect);
}
} else {
const currentUrl = window.location.href;
const targetUrl = `https://auth.zhishuyun.com?redirect=${currentUrl}`;
const host = window.location.host;
const subDomain = import.meta.env.DEV ? 'test.zhishuyun.com' : host.substring(host.indexOf('.') + 1);
// callback url used to init access token and then redirect back of `redirect`
const callbackUrl = `https://${host}/auth/callback?redirect=${this.redirect}`;
const targetUrl = `https://auth.${subDomain}?redirect=${callbackUrl}`;
window.location.href = targetUrl;
}
},
+1 -1
View File
@@ -17,7 +17,7 @@ export default defineComponent({
},
async mounted() {
const host = window.location.host;
const subDomain = host.substring(host.indexOf('.') + 1);
const subDomain = import.meta.env.DEV ? 'test.zhishuyun.com' : host.substring(host.indexOf('.') + 1);
// callback url used to init access token and then redirect back of `redirect`
const callbackUrl = `https://${host}/auth/callback?redirect=${this.redirect}`;
// redirect to auth service to get access token then redirect back
+2 -2
View File
@@ -16,8 +16,8 @@ const routes = [
];
const router = createRouter({
// history: createWebHistory(),
history: createWebHashHistory(),
history: createWebHistory(),
// history: createWebHashHistory(),
routes
});
+1 -2
View File
@@ -11,8 +11,7 @@ export interface IState {
const store = createStore({
state(): IState {
return {
accessToken:
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNjQ4ODUxMDc2LCJqdGkiOiI0ZGZkMjEzMzNmODY0MTEzYTRjZWZmMzI5NzAyMWFiZiIsInVzZXJfaWQiOjMsInBlcm1pc3Npb25zIjpbInZpZXdfYWNhZGVteV9jb3Vyc2UiXSwiaXNfc3VwZXJ1c2VyIjpmYWxzZX0.ZVEeeU-vZBGSQf4s-RJhnNItZHUmSw0MnsDp4Bgh9RI',
accessToken: undefined,
refreshToken: undefined,
user: undefined
};
+8
View File
@@ -4,9 +4,17 @@ import replace from '@rollup/plugin-replace';
import pkg from './package.json';
import { string } from 'rollup-plugin-string';
import path from 'path';
import fs from 'fs';
export default defineConfig({
server: {
open: true,
host: 'academy.local.zhishuyun.com',
port: 443,
https: {
key: fs.readFileSync('certs/academy.local.zhishuyun.com.cert.key'),
cert: fs.readFileSync('certs/academy.local.zhishuyun.com.cert.crt')
},
proxy: {
'/api': {
target: 'http://localhost:8000',
+20 -1
View File
@@ -676,7 +676,7 @@ color@^4.0.1:
color-convert "^2.0.1"
color-string "^1.9.0"
commander@^8.0.0:
commander@^8.0.0, commander@^8.3.0:
version "8.3.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-8.3.0.tgz#4837ea1b2da67b9c616a67afbb0fafee567bca66"
integrity sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==
@@ -1413,6 +1413,11 @@ inherits@2:
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c"
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==
ip-regex@^4.3.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/ip-regex/-/ip-regex-4.3.0.tgz#687275ab0f57fa76978ff8f4dddc8a23d5990db5"
integrity sha512-B9ZWJxHHOHUhUjCPrMpLD4xEq35bUTClHM1S6CBU5ixQnkZmwipwgc96vAd7AAGM9TGHvJR+Uss+/Ak6UphK+Q==
is-arrayish@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d"
@@ -1659,6 +1664,15 @@ minimist@^1.1.1:
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==
mkcert@^1.5.0:
version "1.5.0"
resolved "https://registry.yarnpkg.com/mkcert/-/mkcert-1.5.0.tgz#5395427b2f86fbf9b3b707a81dc1dc1e680feba8"
integrity sha512-Jc5tW6XGpRZR/GXimztRtvv0Q46Qkv0/iqy06sBOldb1I5FfkeD7/LDPOMV9fnV6Nkx8YbNv+Z/8AmmQGfPtgg==
dependencies:
commander "^8.3.0"
ip-regex "^4.3.0"
node-forge "^1.2.1"
modern-normalize@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/modern-normalize/-/modern-normalize-1.1.0.tgz#da8e80140d9221426bd4f725c6e11283d34f90b7"
@@ -1686,6 +1700,11 @@ node-emoji@^1.11.0:
dependencies:
lodash "^4.17.21"
node-forge@^1.2.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-1.3.1.tgz#be8da2af243b2417d5f646a770663a92b7e9ded3"
integrity sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA==
node-releases@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.1.tgz#3d1d395f204f1f2f29a54358b9fb678765ad2fc5"