Compare commits

..
6 Commits
Author SHA1 Message Date
539943419 82d9531c25 ... 2024-07-29 15:20:30 +08:00
539943419 ad8260b87e app上路径直接写死 2024-07-29 15:06:07 +08:00
539943419 4b9599ef8a fix 2024-07-29 15:00:05 +08:00
539943419 5ad3f87323 fix 2024-07-29 14:58:13 +08:00
539943419 5b5849744b ignore visualizer.html 2024-07-29 14:43:06 +08:00
539943419 44f3d57884 统一在store.js中管理baseUrl 2024-07-29 14:41:50 +08:00
9 changed files with 131 additions and 115 deletions

No files matched your search

+3 -1
View File
@@ -36,4 +36,6 @@ miaoShare.db
# removeUser.js
# JWT SK
*.key
*.key
visualizer.html
+1 -3
View File
@@ -26,8 +26,7 @@ import config from "../miaoShareConfig.json"
const settingData = useSettingStore();
const serverPort = settingData.serverPort;
const baseUrl =
location.protocol + "//" + location.hostname + ":" + serverPort + "/";
const baseUrl = settingData.baseUrl
const tokenExpiresIn = config.tokenExpiresIn
@@ -46,7 +45,6 @@ const menuOptions = ref([
key: 'upload',
icon: renderIcon(uploadIcon),
disabled: computed(() => {
// console.log(settingData)
return settingData.token === null
})
},
+1 -1
View File
@@ -70,7 +70,7 @@ const _toClipboard = async (text) => {
}
const setting = useSettingStore();
const serverPort = setting.serverPort;
const baseUrl = location.protocol + "//" + location.hostname + ":" + serverPort + "/";
const baseUrl = setting.baseUrl
const props = defineProps({
messages: {
type: Array,
+66 -54
View File
@@ -1,72 +1,84 @@
import { defineStore } from "pinia";
import config from "../../miaoShareConfig.json"
import { defineStore } from 'pinia'
import config from '../../miaoShareConfig.json'
const userID = localStorage.getItem('userID');
const userGroup = localStorage.getItem('userGroup');
console.log(location)
const userID = localStorage.getItem('userID')
const userGroup = localStorage.getItem('userGroup')
const tokenExpiresIn = config.tokenExpiresIn
if(localStorage.getItem('tokenExpiredTime') == null ||
parseInt(localStorage.getItem('tokenExpiredTime')) < parseInt(Date.now())){
localStorage.removeItem('token')
}
if (
localStorage.getItem('tokenExpiredTime') == null ||
parseInt(localStorage.getItem('tokenExpiredTime')) < parseInt(Date.now())
) {
localStorage.removeItem('token')
}
const token = localStorage.getItem('token');
// console.log(token)
const token = localStorage.getItem('token')
var activeFuctionLocal = localStorage.getItem('activeFuction')
if (activeFuctionLocal == null){
if (activeFuctionLocal == null) {
activeFuctionLocal = 'AES128'
localStorage.setItem('activeFuction',activeFuctionLocal)
localStorage.setItem('activeFuction', activeFuctionLocal)
}
// localStorage.removeItem('activeKeyMap')
var activeKeyMap = localStorage.getItem('activeKeyMap')
if (activeKeyMap == null ){
activeKeyMap = JSON.stringify(['A-Z','0-9'])
localStorage.setItem('activeKeyMap',activeKeyMap)
if (activeKeyMap == null) {
activeKeyMap = JSON.stringify(['A-Z', '0-9'])
localStorage.setItem('activeKeyMap', activeKeyMap)
}
// 开发环境下服务器端口使用设置的端口,否则使用与页面相同的端口
const serverPort = process.env.NODE_ENV === 'development' ? config.PORT : location.port
const serverPort =
process.env.NODE_ENV === 'development' ? config.PORT : location.port
const baseUrl = 'http://110.238.117.95:17057/'
// location.protocol + '//' + location.hostname + ':' + serverPort + '/'
// const wsBaseUrl = 'ws' + '://' + location.hostname + ':' + serverPort
const wsBaseUrl = 'ws://110.238.117.95:17057/'
// console.log(process.env.NODE_ENV,config.DEVPORT,location.port,serverPort)
export const useSettingStore = defineStore("setting", {
state: () => ({
export const useSettingStore = defineStore('setting', {
state: () => ({
activeFuction: activeFuctionLocal,
activeKeyMap:JSON.parse(activeKeyMap),
enableGuest:config.enableGuest,
serverPort,
token,
userID,
userGroup
activeKeyMap: JSON.parse(activeKeyMap),
enableGuest: config.enableGuest,
serverPort,
token,
userID,
userGroup,
baseUrl,
wsBaseUrl
}),
getters: {
// double: state => state.count * 2
},
actions: {
setJWT( token,keepTokenLocal ){
this.token = token
if(keepTokenLocal){
localStorage.setItem('token',token)
localStorage.setItem('tokenExpiredTime',parseInt(Date.now())+parseInt(tokenExpiresIn)*3600000)
}
},
setUserID( id,keepTokenLocal ){
this.userID = id
if(keepTokenLocal)
localStorage.setItem('userID',id)
},
setUserGroup( g,keepTokenLocal ){
this.userGroup = g
if(keepTokenLocal)
localStorage.setItem('userGroup',g)
},
getToken(){
return localStorage.getItem('token')
}
// increment() {
// this.count++;
// }
}
});
getters: {
// double: state => state.count * 2
},
actions: {
setJWT(token, keepTokenLocal) {
this.token = token
if (keepTokenLocal) {
localStorage.setItem('token', token)
localStorage.setItem(
'tokenExpiredTime',
parseInt(Date.now()) + parseInt(tokenExpiresIn) * 3600000
)
}
},
setUserID(id, keepTokenLocal) {
this.userID = id
if (keepTokenLocal) localStorage.setItem('userID', id)
},
setUserGroup(g, keepTokenLocal) {
this.userGroup = g
if (keepTokenLocal) localStorage.setItem('userGroup', g)
},
getToken() {
return localStorage.getItem('token')
}
// increment() {
// this.count++;
// }
}
})
+12 -10
View File
@@ -37,7 +37,7 @@
<div style="flex:1; position: relative;min-height: none;">
<chatui style="margin-bottom: 10px; height: 65vh"
:messages="activeGID ? Messages[activeGID].map(v => { v.timestampString = new Date(v.timestamp).toLocaleString(); return v }).reverse() : []"/>
<n-input v-model:value="msgInput" type="textarea" placeholder="发送信息" :autosize="{
minRows: 1,
maxRows: 2
@@ -48,7 +48,7 @@
<n-icon :component="SendOutline" style="cursor: pointer;" @click='sendMsg(activeGID, msgInput)'/>
</template>
</n-input>
<!-- <n-button @click="sendMsg(activeGID, msg)" :disabled="msg === '' || activeGID === null"
:type="msg === '' || activeGID === null ? 'default' : 'primary'">
发送消息
@@ -58,7 +58,7 @@
<!-- {{ dataTest }} -->
<!-- {{ Messages }} -->
<n-modal v-model:show="showModal">
<n-card
style="width: fit-content;"
@@ -68,8 +68,8 @@
role="dialog"
aria-modal="true"
>
<n-qr-code :value="QRCodeData" style="padding: 0;" :size="256" error-correction-level="Q" :v-if="showModal"
:icon-src='0?QRIconUrl:null'
<n-qr-code :value="QRCodeData" style="padding: 0;" :size="256" error-correction-level="Q" :v-if="showModal"
:icon-src='0?QRIconUrl:null'
:icon-size="128"/>
</n-card>
</n-modal>
@@ -105,9 +105,11 @@ const _toClipboard = async (text) => {
const setting = useSettingStore();
const serverPort = setting.serverPort;
const wsBaseUrl = 'ws' + "://" + location.hostname + ":" + serverPort;
const baseUrl = location.protocol + "//" + location.hostname + ":" + serverPort + "/";
const QRIconUrl = ref(location.protocol + "//" + location.hostname + ":" + serverPort + "/favicon.ico")
// const wsBaseUrl = 'ws' + "://" + location.hostname + ":" + serverPort;
const wsBaseUrl = setting.wsBaseUrl
// const baseUrl = location.protocol + "//" + location.hostname + ":" + serverPort + "/";
const baseUrl = setting.baseUrl
const QRIconUrl = ref(baseUrl + "favicon.ico")
const columns = [
{
@@ -290,7 +292,7 @@ function joinGroup_Verify(gID) {
}
function sendMsg(gID, msg) {
if(msg === '' || msg === null || activeGID.value === null)return
if(msg === '' || msg === null || activeGID.value === null)return
let key = gID2key[gID].key
msg = encryptString(key, msg, setting)
socket.send(JSON.stringify({ type: 'message',type1:'text', msg, gID }))
@@ -306,7 +308,7 @@ function sendMsg(gID, msg) {
// }
async function uploadFile(file){
if(activeGID.value === null)return
if(activeGID.value === null)return
var fileName = file.name;
let key = gID2key[activeGID.value].key
const encryptedFileName = encryptString(key, fileName, setting);
+2 -2
View File
@@ -40,8 +40,8 @@ const setting = useSettingStore();
// 服务端端口
const serverPort = setting.serverPort;
var baseUrl =
location.protocol + "//" + location.hostname + ":" + serverPort + "/";
// const baseUrl = location.protocol + "//" + location.hostname + ":" + serverPort + "/";
const baseUrl = setting.baseUrl
// console.log(baseUrl);
// const blob2Uint8Array = function(blob) {
+2 -2
View File
@@ -43,8 +43,8 @@ const serverPort = settingData.serverPort;
const userIDInput = ref('')
const userPasswordInput = ref('')
const isLogining = ref(false)
const baseUrl =
location.protocol + "//" + location.hostname + ":" + serverPort + "/";
// const baseUrl = location.protocol + "//" + location.hostname + ":" + serverPort + "/";
const baseUrl = settingData.baseUrl
const Token = computed(() => settingData.token)
const keepTokenLocal = ref(true)
+4 -3
View File
@@ -19,7 +19,7 @@
</n-p>
</n-upload-dragger>
</n-upload>
<n-flex justify="end" style="margin: 10px 0;position:relative">
<n-input-number v-model:value="downloadCredit" placeholder="可下载次数,默认无限" clearable :min="1" :max="2147483647" style="width:max-content"/>
<n-button type="primary" @click="clickUpload">开始上传</n-button>
@@ -94,8 +94,9 @@ var file_Code_Map = ref([]);
var uploadProcess = ref(0);
const baseUrl =
location.protocol + "//" + location.hostname + ":" + serverPort + "/";
// const baseUrl = location.protocol + "//" + location.hostname + ":" + serverPort + "/";
const baseUrl = setting.baseUrl
console.log(baseUrl)
// const blob2Uint8Array = function(blob) {
+40 -39
View File
@@ -6,42 +6,43 @@ import vue from "@vitejs/plugin-vue";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
visualizer({
open: true,
filename: "visualizer.html" //分析图生成的文件名
})
],
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url))
}
},
server: {
// host:'0.0.0.0',
port: "17058",
open: true
},
esbuild: {
drop: ["console", "debugger"]
},
build: {
minify: true,
rollupOptions: {
output: {
// 打包输出的配置
manualChunks: id => {
// 这个ID,就是所有文件的绝对路径
if (id.includes("node_modules")) {
// 因为 node_modules 中的依赖通常是不会改变的
// 所以直接单独打包出去
// 这个return 的值就是打包的名称
// return id.split('node_modules')[1]
return "modules";
}
}
}
}
}
});
plugins: [
vue(),
visualizer({
open: true,
filename: 'visualizer.html' //分析图生成的文件名
})
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
server: {
// host:'0.0.0.0',
port: '17058',
open: true
},
esbuild: {
drop: ['console', 'debugger']
},
build: {
minify: true,
rollupOptions: {
output: {
// 打包输出的配置
manualChunks: (id) => {
// 这个ID,就是所有文件的绝对路径
if (id.includes('node_modules')) {
// 因为 node_modules 中的依赖通常是不会改变的
// 所以直接单独打包出去
// 这个return 的值就是打包的名称
// return id.split('node_modules')[1]
return 'modules'
}
}
}
}
},
base: './'
})